-
Notifications
You must be signed in to change notification settings - Fork 456
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
1 parent
c52858a
commit cc9a974
Showing
50 changed files
with
868 additions
and
1,222 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,85 @@ | ||
--- | ||
layout: AtomLayout | ||
hideBreadcrumbs: true | ||
description: VsfDrawer is surface containing supplementary content that is anchored to the left, right, top or bottom edge of the screen. | ||
--- | ||
# Drawer | ||
|
||
::: slot usage | ||
|
||
{{ $frontmatter.description }} | ||
|
||
## Examples | ||
|
||
### Drawer placement | ||
|
||
Drawer supports 4 different placements that can be set via `placement` prop: `top`, `right`, `bottom`, `left`. | ||
<Showcase showcase-name="Drawer/Placement" style="min-height: 400px;"> | ||
<!-- vue --> | ||
<<<../../preview/nuxt/pages/showcases/Drawer/Placement.vue | ||
<!-- end vue --> | ||
<!-- react --> | ||
<<<../../preview/next/pages/showcases/Drawer/Placement.tsx | ||
<!-- end react --> | ||
</Showcase> | ||
|
||
### Drawer transition and trap focus | ||
|
||
Component can be wrapped in <!-- vue -->[`<transition>`](https://vuejs.org/guide/built-ins/transition.html#the-transition-component)<!-- end vue --><!-- react -->[`<CSSTransition>`](https://reactcommunity.org/react-transition-group/css-transition)<!-- end react --> component for animated showing and hiding. Drawer as well can use `useTrapFocus` <!-- vue -->`composable`<!-- end vue --><!-- react -->`hook`<!-- end react --> for better control of focusable elements inside. | ||
<Showcase showcase-name="Drawer/TransitionAndCloseButton" style="min-height: 400px;"> | ||
<!-- vue --> | ||
<<<../../preview/nuxt/pages/showcases/Drawer/TransitionAndCloseButton.vue | ||
<!-- end vue --> | ||
<!-- react --> | ||
<<<../../preview/next/pages/showcases/Drawer/TransitionAndCloseButton.tsx | ||
<!-- end react --> | ||
</Showcase> | ||
|
||
## Playground | ||
|
||
<Generate style="height: 600px"/> | ||
::: | ||
|
||
::: slot api | ||
|
||
| Prop name | Type | Default value | Possible values | | ||
|-----------------------|----------------------------|---------------|----------------------------------------| | ||
<!-- vue --> | ||
| modelValue | boolean | false | | | ||
| tag | string | aside | | | ||
<!-- end vue --> | ||
<!-- react --> | ||
| open | boolean | false | | | ||
| as | ReactElement | aside | | | ||
<!-- end react --> | ||
| placement | VsfDrawerPlacement | VsfDrawerPlacement.left | | | ||
| disableClickAway | boolean | false | | | ||
| disableEsc | boolean | false | | | ||
<!-- react --> | ||
| children | ReactNode | | | | ||
| onClose | Function | | | | ||
<!-- end react --> | ||
<!-- vue --> | ||
|
||
## Slots | ||
|
||
| Slot name | Description | | ||
| --------- | :-------------------------------: | | ||
| default | place content of drawer | | ||
|
||
## Events | ||
|
||
| Event name | Trigger | | ||
| ---------- | :----------------------------: | | ||
| update:modelValue | emits on clicking close button | | ||
<!-- end vue --> | ||
::: | ||
|
||
::: slot source | ||
<!-- vue --> | ||
<<<../../../packages/sfui/frameworks/vue/components/VsfDrawer/VsfDrawer.vue | ||
<!-- end vue --> | ||
<!-- react --> | ||
<<<../../../packages/sfui/frameworks/react/components/VsfDrawer/VsfDrawer.tsx | ||
<!-- end react --> | ||
::: |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,94 @@ | ||
import { VsfDrawer, VsfDrawerPlacement } from '@storefront-ui/react/components/VsfDrawer'; | ||
import { VsfButton } from '@storefront-ui/react/components/VsfButton'; | ||
import { prepareControls } from '../../components/utils/Controls'; | ||
import ComponentExample from '../../components/utils/ComponentExample'; | ||
import { ExamplePageLayout } from '../examples'; | ||
|
||
function Example() { | ||
const { state, controls } = prepareControls( | ||
[ | ||
{ | ||
type: 'text', | ||
modelName: 'children', | ||
description: 'Only for demonstration purposes. Default slot, replaces example drawer content', | ||
}, | ||
{ | ||
type: 'boolean', | ||
modelName: 'open', | ||
propType: 'boolean', | ||
propDefaultValue: false, | ||
description: 'If true drawer is visible', | ||
}, | ||
{ | ||
type: 'select', | ||
modelName: 'placement', | ||
options: Object.keys(VsfDrawerPlacement), | ||
propType: 'enum', | ||
propDefaultValue: VsfDrawerPlacement.left, | ||
description: 'Placement of drawer', | ||
}, | ||
{ | ||
type: 'text', | ||
modelName: 'as', | ||
propType: 'string', | ||
propDefaultValue: 'aside', | ||
description: 'Tag of drawer HTML element', | ||
}, | ||
{ | ||
type: 'boolean', | ||
modelName: 'disableClickAway', | ||
propType: 'boolean', | ||
propDefaultValue: false, | ||
description: "If true can't close drawer when clicking outside drawer", | ||
}, | ||
{ | ||
type: 'boolean', | ||
modelName: 'disableEsc', | ||
propType: 'boolean', | ||
propDefaultValue: false, | ||
description: "If true can't close drawer when using ESC keyboard button", | ||
}, | ||
], | ||
{ | ||
children: undefined, | ||
open: false, | ||
placement: VsfDrawerPlacement.left, | ||
as: undefined, | ||
disableClickAway: undefined, | ||
disableEsc: undefined, | ||
}, | ||
); | ||
|
||
return ( | ||
<ComponentExample controls={{ state, controls }}> | ||
<VsfButton onClick={() => state.set({ ...state.get, open: !state.get.open })} type="button"> | ||
Open Drawer | ||
</VsfButton> | ||
|
||
<VsfDrawer | ||
{...state.get} | ||
onClose={(isOpen: boolean) => state.set({ ...state.get, open: isOpen })} | ||
className="bg-neutral-50 p-3" | ||
style={{ | ||
...(state.get.placement === VsfDrawerPlacement.left || state.get.placement === VsfDrawerPlacement.right | ||
? { maxWidth: '300px' } | ||
: {}), | ||
}} | ||
> | ||
{state.get.children || ( | ||
<div> | ||
<p className="mb-2"> | ||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Laboriosam consequatur repellat, odit | ||
voluptatibus deserunt eligendi nemo perspiciatis tenetur vero repellendus facere? Dolores sit maiores ut | ||
labore facilis minima debitis dolore. | ||
</p> | ||
<strong>You can close Drawer by clicking outside or focus and use ESC button</strong> | ||
</div> | ||
)} | ||
</VsfDrawer> | ||
</ComponentExample> | ||
); | ||
} | ||
|
||
Example.getLayout = ExamplePageLayout; | ||
export default Example; |
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.