-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pedro Ladaria
committed
Dec 17, 2024
1 parent
46da8a7
commit 89fee12
Showing
3 changed files
with
228 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import * as React from 'react'; | ||
import Drawer from '../drawer'; | ||
import {Placeholder} from '../placeholder'; | ||
import Stack from '../stack'; | ||
import {ButtonPrimary} from '../button'; | ||
|
||
export default { | ||
title: 'Components/Modals/Drawer', | ||
}; | ||
|
||
type Args = { | ||
title: string; | ||
subtitle: string; | ||
description: string; | ||
contentLength: number; | ||
}; | ||
|
||
export const Default = ({title, subtitle, description, contentLength}: Args): JSX.Element => { | ||
const [isOpen, setIsOpen] = React.useState(false); | ||
const content = ( | ||
<Stack space={16}> | ||
{Array.from({length: contentLength}).map((_, index) => ( | ||
<Placeholder key={index} height={200} /> | ||
))} | ||
</Stack> | ||
); | ||
|
||
return ( | ||
<> | ||
<ButtonPrimary onPress={() => setIsOpen(true)}>Open Drawer</ButtonPrimary> | ||
{isOpen && ( | ||
<Drawer | ||
title={title} | ||
subtitle={subtitle} | ||
description={description} | ||
onClose={() => { | ||
setIsOpen(false); | ||
}} | ||
> | ||
{content} | ||
</Drawer> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
Default.storyName = 'Drawer'; | ||
|
||
Default.args = { | ||
title: 'Title', | ||
subtitle: 'Subtitle', | ||
description: 'Description', | ||
contentLength: 2, | ||
}; |
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,69 @@ | ||
import {style} from '@vanilla-extract/css'; | ||
import * as mq from './media-queries.css'; | ||
import {vars} from './skins/skin-contract.css'; | ||
import {sprinkles} from './sprinkles.css'; | ||
|
||
export const ANIMATION_DURATION_MS = 400; // review | ||
|
||
export const container = style({ | ||
background: vars.colors.background, | ||
position: 'fixed', | ||
top: 0, | ||
right: 0, | ||
bottom: 0, | ||
'@media': { | ||
[mq.tabletOrSmaller]: { | ||
left: 0, | ||
transition: `transform ${ANIMATION_DURATION_MS}ms cubic-bezier(0.32, 0.72, 0, 1)`, | ||
}, | ||
[mq.desktopOrBigger]: { | ||
borderTopLeftRadius: vars.borderRadii.container, | ||
borderBottomLeftRadius: vars.borderRadii.container, | ||
transition: `transform ${ANIMATION_DURATION_MS}ms cubic-bezier(0.65, 0, 0.35, 1)`, | ||
}, | ||
}, | ||
}); | ||
|
||
export const open = style({ | ||
transform: '', | ||
}); | ||
|
||
export const closed = style({ | ||
'@media': { | ||
[mq.desktopOrBigger]: { | ||
transform: 'translateX(100%)', | ||
}, | ||
[mq.tabletOrSmaller]: { | ||
transform: 'translateY(100%)', | ||
}, | ||
}, | ||
}); | ||
|
||
export const overlay = style([ | ||
sprinkles({ | ||
position: 'fixed', | ||
top: 0, | ||
left: 0, | ||
right: 0, | ||
bottom: 0, | ||
background: vars.colors.backgroundOverlay, | ||
}), | ||
{ | ||
transition: `opacity ${ANIMATION_DURATION_MS}ms`, | ||
touchAction: 'none', | ||
}, | ||
]); | ||
|
||
export const overlayClosed = style({ | ||
opacity: 0, | ||
}); | ||
|
||
export const overlayOpen = style({ | ||
opacity: 1, | ||
}); | ||
|
||
export const closeButton = style({ | ||
position: 'absolute', | ||
top: 8, | ||
right: 8, | ||
}); |
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