-
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-web/b2c): add Overlay component
- Loading branch information
1 parent
e2e8027
commit f7dcdd9
Showing
6 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
packages/plasma-b2c/src/components/Overlay/Overlay.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,76 @@ | ||
import React, { useState } from 'react'; | ||
import styled from 'styled-components'; | ||
import type { ComponentProps } from 'react'; | ||
import type { StoryObj, Meta } from '@storybook/react'; | ||
import { action } from '@storybook/addon-actions'; | ||
import { disableProps, InSpacingDecorator } from '@salutejs/plasma-sb-utils'; | ||
|
||
import { Button } from '../Button/Button'; | ||
|
||
import { Overlay } from '.'; | ||
|
||
const onOverlayClick = action('onOverlayClick'); | ||
|
||
export default { | ||
title: 'Controls/Overlay', | ||
decorators: [InSpacingDecorator], | ||
argTypes: { | ||
isClickable: { | ||
control: { | ||
type: 'boolean', | ||
}, | ||
table: { defaultValue: { summary: true } }, | ||
}, | ||
withBlur: { | ||
control: { | ||
type: 'boolean', | ||
}, | ||
table: { defaultValue: { summary: false } }, | ||
}, | ||
...disableProps(['onOverlayClick', 'zIndex']), | ||
}, | ||
} as Meta; | ||
|
||
type StoryOverlayProps = ComponentProps<typeof Overlay>; | ||
|
||
const StyledButton = styled(Button)` | ||
margin: 1rem; | ||
width: 15rem; | ||
`; | ||
|
||
const StyledCloseButton = styled(Button)` | ||
position: fixed; | ||
top: 50%; | ||
left: 50%; | ||
z-index: 101; | ||
transform: translate(-50%, -50%); | ||
width: 15rem; | ||
`; | ||
|
||
const StoryDefault = (props: StoryOverlayProps) => { | ||
const [isVisible, setIsVisible] = useState(false); | ||
|
||
return ( | ||
<> | ||
<StyledButton text="Показать overlay" onClick={() => setIsVisible(true)} /> | ||
{isVisible && ( | ||
<> | ||
<Overlay {...props} /> | ||
<StyledCloseButton text=" Скрыть overlay" onClick={() => setIsVisible(false)} /> | ||
</> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export const Default: StoryObj<StoryOverlayProps> = { | ||
args: { | ||
zIndex: '100', | ||
backgroundColorProperty: 'var(--plasma-colors-overlay-soft)', | ||
withBlur: false, | ||
transparent: false, | ||
isClickable: true, | ||
onOverlayClick, | ||
}, | ||
render: (args) => <StoryDefault {...args} />, | ||
}; |
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 { Overlay } from '@salutejs/plasma-new-hope/styled-components'; | ||
export type { OverlayProps } 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
76 changes: 76 additions & 0 deletions
76
packages/plasma-web/src/components/Overlay/Overlay.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,76 @@ | ||
import React, { useState } from 'react'; | ||
import styled from 'styled-components'; | ||
import type { ComponentProps } from 'react'; | ||
import type { StoryObj, Meta } from '@storybook/react'; | ||
import { action } from '@storybook/addon-actions'; | ||
import { disableProps, InSpacingDecorator } from '@salutejs/plasma-sb-utils'; | ||
|
||
import { Button } from '../Button/Button'; | ||
|
||
import { Overlay } from '.'; | ||
|
||
const onOverlayClick = action('onOverlayClick'); | ||
|
||
export default { | ||
title: 'Controls/Overlay', | ||
decorators: [InSpacingDecorator], | ||
argTypes: { | ||
isClickable: { | ||
control: { | ||
type: 'boolean', | ||
}, | ||
table: { defaultValue: { summary: true } }, | ||
}, | ||
withBlur: { | ||
control: { | ||
type: 'boolean', | ||
}, | ||
table: { defaultValue: { summary: false } }, | ||
}, | ||
...disableProps(['onOverlayClick', 'zIndex']), | ||
}, | ||
} as Meta; | ||
|
||
type StoryOverlayProps = ComponentProps<typeof Overlay>; | ||
|
||
const StyledButton = styled(Button)` | ||
margin: 1rem; | ||
width: 15rem; | ||
`; | ||
|
||
const StyledCloseButton = styled(Button)` | ||
position: fixed; | ||
top: 50%; | ||
left: 50%; | ||
z-index: 101; | ||
transform: translate(-50%, -50%); | ||
width: 15rem; | ||
`; | ||
|
||
const StoryDefault = (props: StoryOverlayProps) => { | ||
const [isVisible, setIsVisible] = useState(false); | ||
|
||
return ( | ||
<> | ||
<StyledButton text="Показать overlay" onClick={() => setIsVisible(true)} /> | ||
{isVisible && ( | ||
<> | ||
<Overlay {...props} /> | ||
<StyledCloseButton view="primary" text=" Скрыть overlay" onClick={() => setIsVisible(false)} /> | ||
</> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export const Default: StoryObj<StoryOverlayProps> = { | ||
args: { | ||
zIndex: '100', | ||
backgroundColorProperty: 'var(--plasma-colors-overlay-soft)', | ||
withBlur: false, | ||
transparent: false, | ||
isClickable: true, | ||
onOverlayClick, | ||
}, | ||
render: (args) => <StoryDefault {...args} />, | ||
}; |
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 { Overlay } from '@salutejs/plasma-new-hope/styled-components'; | ||
export type { OverlayProps } 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