-
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.
feat(plasma-core, plasma-web, plasma-b2c): ModalBase component
- Loading branch information
Showing
23 changed files
with
697 additions
and
120 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
139 changes: 139 additions & 0 deletions
139
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import React from 'react'; | ||
import styled, { createGlobalStyle } from 'styled-components'; | ||
import { Story, Meta } from '@storybook/react'; | ||
import { surfaceSolid02, darkOverlayBlur, overlaySoft } from '@salutejs/plasma-tokens-web'; | ||
import { InSpacingDecorator } from '@salutejs/plasma-sb-utils'; | ||
|
||
import { SSRProvider } from '../SSRProvider'; | ||
import { Button } from '../Button'; | ||
import { PopupBaseProvider } from '../PopupBase'; | ||
|
||
import { ModalBase } from '.'; | ||
|
||
export default { | ||
title: 'Controls/ModalBase', | ||
decorators: [InSpacingDecorator], | ||
argTypes: { | ||
position: { | ||
options: [ | ||
'center', | ||
'top', | ||
'bottom', | ||
'right', | ||
'left', | ||
'top-right', | ||
'top-left', | ||
'bottom-right', | ||
'bottom-left', | ||
], | ||
control: { | ||
type: 'select', | ||
}, | ||
}, | ||
}, | ||
} as Meta; | ||
|
||
type ModalBaseStoryProps = { | ||
position: string; | ||
offsetX: number; | ||
offsetY: number; | ||
closeOnEsc: boolean; | ||
closeOnOverlayClick: boolean; | ||
withBlur: boolean; | ||
}; | ||
|
||
const StyledButton = styled(Button)` | ||
margin-top: 1rem; | ||
width: 15rem; | ||
`; | ||
|
||
const StyledWrapper = styled.div` | ||
height: 1200px; | ||
`; | ||
|
||
const ModalOverlayVariables = createGlobalStyle` | ||
body { | ||
--plasma-modal-blur-overlay-color: ${darkOverlayBlur}; | ||
--plasma-modal-overlay-color: ${overlaySoft}; | ||
} | ||
`; | ||
|
||
const Content = styled.div` | ||
background: ${surfaceSolid02}; | ||
padding: 1rem; | ||
`; | ||
|
||
export const ModalBaseDemo: Story<ModalBaseStoryProps> = ({ position, offsetX, offsetY, ...rest }) => { | ||
const [isOpenA, setIsOpenA] = React.useState(false); | ||
const [isOpenB, setIsOpenB] = React.useState(false); | ||
const [isOpenC, setIsOpenC] = React.useState(false); | ||
|
||
return ( | ||
<SSRProvider> | ||
<StyledWrapper> | ||
<ModalOverlayVariables /> | ||
<PopupBaseProvider> | ||
<div style={{ display: 'flex', flexDirection: 'column' }}> | ||
<StyledButton text="Открыть A" onClick={() => setIsOpenA(true)} /> | ||
</div> | ||
<ModalBase | ||
id="modalA" | ||
onClose={() => setIsOpenA(false)} | ||
isOpen={isOpenA} | ||
position={position} | ||
offset={[offsetX, offsetY]} | ||
{...rest} | ||
> | ||
<Content> | ||
<Button onClick={() => setIsOpenA(false)}>Close</Button> | ||
<div style={{ display: 'flex', flexDirection: 'column' }}> | ||
<StyledButton text="Открыть B" onClick={() => setIsOpenB(true)} /> | ||
</div> | ||
<ModalBase | ||
id="modalB" | ||
onClose={() => setIsOpenB(false)} | ||
isOpen={isOpenB} | ||
position="left" | ||
offset={[offsetX, offsetY]} | ||
{...rest} | ||
> | ||
<Content> | ||
<Button style={{ marginRight: '1rem' }} onClick={() => setIsOpenB(false)}> | ||
Close | ||
</Button> | ||
<div style={{ display: 'flex', flexDirection: 'column' }}> | ||
<StyledButton text="Открыть C" onClick={() => setIsOpenC(true)} /> | ||
</div> | ||
<ModalBase | ||
id="modalC" | ||
onClose={() => setIsOpenC(false)} | ||
isOpen={isOpenC} | ||
position="top" | ||
offset={[offsetX, offsetY]} | ||
{...rest} | ||
> | ||
<Content> | ||
<Button style={{ marginRight: '1rem' }} onClick={() => setIsOpenC(false)}> | ||
Close | ||
</Button> | ||
<>Content</> | ||
</Content> | ||
</ModalBase> | ||
</Content> | ||
</ModalBase> | ||
</Content> | ||
</ModalBase> | ||
</PopupBaseProvider> | ||
</StyledWrapper> | ||
</SSRProvider> | ||
); | ||
}; | ||
|
||
ModalBaseDemo.args = { | ||
position: 'center', | ||
withBlur: false, | ||
closeOnEsc: true, | ||
closeOnOverlayClick: true, | ||
offsetX: 0, | ||
offsetY: 0, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { ModalBase } from '@salutejs/plasma-hope'; | ||
export type { ModalBaseProps } from '@salutejs/plasma-hope'; |
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,4 @@ | ||
export { PopupBaseProvider } from '@salutejs/plasma-hope'; | ||
|
||
export { PopupBase } from '@salutejs/plasma-hope'; | ||
export type { PopupBaseProps, PopupBasePlacement } from '@salutejs/plasma-hope'; |
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
Oops, something went wrong.