-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(drawer): Add docs on the site (#1956)
- Loading branch information
Showing
22 changed files
with
368 additions
and
47 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,64 @@ | ||
import { | ||
DrawerProvider, | ||
Button, | ||
DrawerPopover, | ||
DrawerHeader, | ||
DrawerHeading, | ||
DrawerDismiss, | ||
DrawerContent, | ||
DrawerFooter, | ||
} from '@vtex/shoreline' | ||
import { DecorativeBox } from '../components/decorative-box' | ||
import { useState } from 'react' | ||
|
||
export default function Example() { | ||
const [open, setOpen] = useState(false) | ||
const [loading, setLoading] = useState(false) | ||
|
||
async function someServerAction() { | ||
if (open) { | ||
setOpen(false) | ||
|
||
return | ||
} | ||
|
||
setLoading(true) | ||
|
||
// This promise simulates a call to an API. | ||
// Using the controlled apporach of the Drawer | ||
// is particullary useful in programmatic dispatch scenarios. | ||
await new Promise((resolve) => { | ||
setTimeout(resolve, 3000) | ||
}) | ||
|
||
setLoading(false) | ||
setOpen(true) | ||
} | ||
|
||
return ( | ||
<> | ||
<Button loading={loading} onClick={someServerAction}> | ||
Some action | ||
</Button> | ||
<DrawerProvider open={open} onOpenChange={setOpen}> | ||
<DrawerPopover> | ||
<DrawerHeader> | ||
<DrawerHeading>Controlled Drawer</DrawerHeading> | ||
<DrawerDismiss /> | ||
</DrawerHeader> | ||
<DrawerContent> | ||
<DecorativeBox height="32rem" color="blue" /> | ||
</DrawerContent> | ||
<DrawerFooter> | ||
<Button onClick={() => null} size="large"> | ||
Label | ||
</Button> | ||
<Button variant="primary" onClick={() => null} size="large"> | ||
Label | ||
</Button> | ||
</DrawerFooter> | ||
</DrawerPopover> | ||
</DrawerProvider> | ||
</> | ||
) | ||
} |
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,39 @@ | ||
import { | ||
DrawerProvider, | ||
DrawerTrigger, | ||
Button, | ||
DrawerPopover, | ||
DrawerHeader, | ||
DrawerHeading, | ||
DrawerDismiss, | ||
DrawerContent, | ||
DrawerFooter, | ||
} from '@vtex/shoreline' | ||
import { DecorativeBox } from '../components/decorative-box' | ||
|
||
export default function Example() { | ||
return ( | ||
<DrawerProvider> | ||
<DrawerTrigger asChild> | ||
<Button>Open</Button> | ||
</DrawerTrigger> | ||
<DrawerPopover> | ||
<DrawerHeader> | ||
<DrawerHeading>Drawer Heading</DrawerHeading> | ||
<DrawerDismiss /> | ||
</DrawerHeader> | ||
<DrawerContent> | ||
<DecorativeBox height="100rem" color="blue" /> | ||
</DrawerContent> | ||
<DrawerFooter> | ||
<Button onClick={() => null} size="large"> | ||
Label | ||
</Button> | ||
<Button variant="primary" onClick={() => null} size="large"> | ||
Label | ||
</Button> | ||
</DrawerFooter> | ||
</DrawerPopover> | ||
</DrawerProvider> | ||
) | ||
} |
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,39 @@ | ||
import { | ||
DrawerProvider, | ||
DrawerTrigger, | ||
Button, | ||
DrawerPopover, | ||
DrawerHeader, | ||
DrawerHeading, | ||
DrawerDismiss, | ||
DrawerContent, | ||
DrawerFooter, | ||
} from '@vtex/shoreline' | ||
import { DecorativeBox } from '../components/decorative-box' | ||
|
||
export default function Example() { | ||
return ( | ||
<DrawerProvider> | ||
<DrawerTrigger asChild> | ||
<Button>Open small drawer</Button> | ||
</DrawerTrigger> | ||
<DrawerPopover size="small"> | ||
<DrawerHeader> | ||
<DrawerHeading>Small Drawer</DrawerHeading> | ||
<DrawerDismiss /> | ||
</DrawerHeader> | ||
<DrawerContent> | ||
<DecorativeBox height="20rem" color="blue" /> | ||
</DrawerContent> | ||
<DrawerFooter> | ||
<Button onClick={() => null} size="large"> | ||
Label | ||
</Button> | ||
<Button variant="primary" onClick={() => null} size="large"> | ||
Label | ||
</Button> | ||
</DrawerFooter> | ||
</DrawerPopover> | ||
</DrawerProvider> | ||
) | ||
} |
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,20 +1,82 @@ | ||
# Drawer | ||
|
||
Comming soon | ||
|
||
{/* <ComponentDescription name="drawer-provider" /> | ||
<ComponentDescription>Drawer displays content related to a minor job within a page's main job. It does not block interactions outside the overlay, allowing users to interact with content.</ComponentDescription> | ||
|
||
<Preview name="drawer" /> | ||
|
||
## Optional props | ||
## Anatomy | ||
|
||
![Drawer anatomy](/assets/drawer-anatomy.png) | ||
|
||
The Drawer is a composition of several components: | ||
|
||
| Component | Description | | ||
| --- | --- | | ||
| [DrawerProvider](/components/drawer/drawer-provider) | Provides the state to all Drawer components | | ||
| [DrawerTrigger](/components/drawer/drawer-trigger) | A composition-first component that toggles the [DrawerPopover](/components/drawer/drawer-popover) | | ||
| [DrawerPopover](/components/drawer/drawer-popover) | Popover box of the Drawer | | ||
| [DrawerHeader](/components/drawer/drawer-header) | The fixed Header | | ||
| [DrawerHeading](/components/drawer/drawer-heading) | The title of the Drawer | | ||
| [DrawerDismiss](/components/drawer/drawer-dismiss) | Dismisses the [DrawerPopover](/components/drawer/drawer-popover) | | ||
| [DrawerContent](/components/drawer/drawer-content) | Main content inside of the [DrawerPopover](/components/drawer/drawer-popover) | | ||
| [DrawerFooter](/components/drawer/drawer-footer) | The fixed Footer mainly used for actions | | ||
|
||
|
||
The example code below, illustrates how these components interact with each other: | ||
|
||
```jsx | ||
function Anatomy() { | ||
return ( | ||
<DrawerProvider> | ||
<DrawerTrigger asChild> | ||
<Button>Open</Button> | ||
</DrawerTrigger> | ||
<DrawerPopover> | ||
<DrawerHeader> | ||
<DrawerHeading>Drawer Heading</DrawerHeading> | ||
<DrawerDismiss /> | ||
</DrawerHeader> | ||
<DrawerContent> | ||
Content goes here | ||
</DrawerContent> | ||
<DrawerFooter> | ||
<Button size="large"> | ||
Label | ||
</Button> | ||
<Button variant="primary" size="large"> | ||
Label | ||
</Button> | ||
</DrawerFooter> | ||
</DrawerPopover> | ||
</DrawerProvider> | ||
) | ||
} | ||
``` | ||
|
||
## Examples | ||
|
||
### Controlled | ||
|
||
The `open` and `onChangeOpen` props of [DrawerProvider](/components/drawer/drawer-provider) are used to control the [DrawerPopover](/components/drawer/drawer-popover) open state. | ||
|
||
<Preview name="drawer-controlled" /> | ||
|
||
### Long content | ||
|
||
The [DrawerContent](/components/drawer/drawer-content) adds a scrollbar for long content. | ||
|
||
<Preview name="drawer-long-content" /> | ||
|
||
### Small size | ||
|
||
The [DrawerPopover](/components/drawer/drawer-popover) has either a `small` or `medium`(default) size. | ||
|
||
<PropsDocs name="drawer-provider" /> | ||
<Preview name="drawer-small" /> | ||
|
||
## Related components | ||
|
||
<ComponentSummaryGrid> | ||
<ComponentSummary name="modal" /> | ||
<ComponentSummary name="toast" /> | ||
<ComponentSummary name="alert" /> | ||
<ComponentSummary name="contextual-help" /> | ||
</ComponentSummaryGrid> */} | ||
</ComponentSummaryGrid> |
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,9 @@ | ||
# DrawerContent | ||
|
||
<ComponentDescription name="drawer-content" /> | ||
|
||
<Preview name="drawer" /> | ||
|
||
## Optional props | ||
|
||
<PropsDocs name="drawer-content" /> |
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,9 @@ | ||
# DrawerDismiss | ||
|
||
<ComponentDescription name="drawer-dismiss" /> | ||
|
||
<Preview name="drawer" /> | ||
|
||
## Optional props | ||
|
||
<PropsDocs name="drawer-dismiss" /> |
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,9 @@ | ||
# DrawerFooter | ||
|
||
<ComponentDescription name="drawer-footer" /> | ||
|
||
<Preview name="drawer" /> | ||
|
||
## Optional props | ||
|
||
All props of `<footer />` JSX element. |
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,9 @@ | ||
# DrawerHeader | ||
|
||
<ComponentDescription name="drawer-header" /> | ||
|
||
<Preview name="drawer" /> | ||
|
||
## Optional props | ||
|
||
All props of `<header />` JSX element. |
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,9 @@ | ||
# DrawerHeading | ||
|
||
<ComponentDescription name="drawer-heading" /> | ||
|
||
<Preview name="drawer" /> | ||
|
||
## Optional props | ||
|
||
<PropsDocs name="drawer-heading" /> |
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,13 @@ | ||
# DrawerPopover | ||
|
||
<ComponentDescription name="drawer-popover" /> | ||
|
||
<Preview name="drawer" /> | ||
|
||
## Required props | ||
|
||
<PropsDocs name="drawer-popover" required /> | ||
|
||
## Optional props | ||
|
||
<PropsDocs name="drawer-popover" /> |
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,13 @@ | ||
# DrawerProvider | ||
|
||
<ComponentDescription name="drawer-provider" /> | ||
|
||
<Preview name="drawer" /> | ||
|
||
## Required props | ||
|
||
<PropsDocs name="drawer-provider" required /> | ||
|
||
## Optional props | ||
|
||
<PropsDocs name="drawer-provider" /> |
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,13 @@ | ||
# DrawerTrigger | ||
|
||
<ComponentDescription name="drawer-trigger" /> | ||
|
||
<Preview name="drawer" /> | ||
|
||
## Required props | ||
|
||
<PropsDocs name="drawer-trigger" required /> | ||
|
||
## Optional props | ||
|
||
<PropsDocs name="drawer-trigger" /> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.