-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(plasma-web, plasma-b2c): fix NoScroll behavior in ModalBase
- Loading branch information
Showing
15 changed files
with
83 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/plasma-b2c/src/components/ModalBase/ModalBase.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 19 additions & 3 deletions
22
packages/plasma-b2c/src/components/ModalBase/ModalBase.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
import React, { ForwardRefExoticComponent, RefAttributes, forwardRef } from 'react'; | ||
import { modalConfig, component, mergeConfig } from '@salutejs/plasma-new-hope/styled-components'; | ||
import type { ModalProps } from '@salutejs/plasma-new-hope/styled-components'; | ||
import { createGlobalStyle } from 'styled-components'; | ||
|
||
import { config } from './Modal.config'; | ||
|
||
// linaria не поддерживает динамический global style | ||
const NoScroll = createGlobalStyle` | ||
body { | ||
overflow-y: hidden; | ||
} | ||
`; | ||
|
||
const mergedConfig = mergeConfig(modalConfig, config); | ||
const ModalBaseComponent = component(mergedConfig) as React.ForwardRefExoticComponent< | ||
ModalProps & React.RefAttributes<HTMLDivElement> | ||
const ModalBaseComponent = component(mergedConfig) as ForwardRefExoticComponent< | ||
ModalProps & RefAttributes<HTMLDivElement> | ||
>; | ||
|
||
/** | ||
* Модальное окно. | ||
*/ | ||
export const ModalBase = ModalBaseComponent; | ||
export const ModalBase = forwardRef<HTMLDivElement, ModalProps>(({ children, ...rest }) => { | ||
return ( | ||
<ModalBaseComponent {...rest}> | ||
<NoScroll /> | ||
{children} | ||
</ModalBaseComponent> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
export { ModalBase } from './ModalBase'; | ||
export { modalClasses as modalBaseClasses } from '@salutejs/plasma-new-hope/styled-components'; | ||
export { | ||
modalClasses as modalBaseClasses, | ||
modalTokens as modalBaseTokens, | ||
} from '@salutejs/plasma-new-hope/styled-components'; | ||
|
||
export type { ModalProps as ModalBaseProps } from '@salutejs/plasma-new-hope/styled-components'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { modalConfig, modalRoot } from './Modal/Modal'; | ||
export { classes as modalClasses } from './Modal/Modal.tokens'; | ||
export { classes as modalClasses, tokens as modalTokens } from './Modal/Modal.tokens'; |
6 changes: 4 additions & 2 deletions
6
packages/plasma-new-hope/src/examples/plasma_b2c/components/Modal/Modal.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
packages/plasma-new-hope/src/examples/plasma_web/components/Modal/Modal.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
packages/plasma-new-hope/src/examples/sds_engineer/components/Modal/Modal.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 19 additions & 3 deletions
22
packages/plasma-web/src/components/ModalBase/ModalBase.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
import React, { ForwardRefExoticComponent, RefAttributes, forwardRef } from 'react'; | ||
import { modalConfig, component, mergeConfig } from '@salutejs/plasma-new-hope/styled-components'; | ||
import type { ModalProps } from '@salutejs/plasma-new-hope/styled-components'; | ||
import { createGlobalStyle } from 'styled-components'; | ||
|
||
import { config } from './Modal.config'; | ||
|
||
// linaria не поддерживает динамический global style | ||
const NoScroll = createGlobalStyle` | ||
body { | ||
overflow-y: hidden; | ||
} | ||
`; | ||
|
||
const mergedConfig = mergeConfig(modalConfig, config); | ||
const ModalBaseComponent = component(mergedConfig) as React.ForwardRefExoticComponent< | ||
ModalProps & React.RefAttributes<HTMLDivElement> | ||
const ModalBaseComponent = component(mergedConfig) as ForwardRefExoticComponent< | ||
ModalProps & RefAttributes<HTMLDivElement> | ||
>; | ||
|
||
/** | ||
* Модальное окно. | ||
*/ | ||
export const ModalBase = ModalBaseComponent; | ||
export const ModalBase = forwardRef<HTMLDivElement, ModalProps>(({ children, ...rest }) => { | ||
return ( | ||
<ModalBaseComponent {...rest}> | ||
<NoScroll /> | ||
{children} | ||
</ModalBaseComponent> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
export { ModalBase } from './ModalBase'; | ||
export { modalClasses as modalBaseClasses } from '@salutejs/plasma-new-hope/styled-components'; | ||
export { | ||
modalClasses as modalBaseClasses, | ||
modalTokens as modalBaseTokens, | ||
} from '@salutejs/plasma-new-hope/styled-components'; | ||
|
||
export type { ModalProps as ModalBaseProps } from '@salutejs/plasma-new-hope/styled-components'; |