-
Notifications
You must be signed in to change notification settings - Fork 13
feat: migrate sheet to drawer #654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,49 @@ | ||
| 'use client'; | ||
|
|
||
| import { Button, Drawer, Flex } from '@raystack/apsara'; | ||
| import PlaygroundLayout from './playground-layout'; | ||
|
|
||
| export function DrawerExamples() { | ||
| return ( | ||
| <PlaygroundLayout title='Drawer'> | ||
| <Flex gap='medium' wrap='wrap'> | ||
| <Drawer side='top'> | ||
| <Drawer.Trigger asChild> | ||
| <Button>Top Drawer</Button> | ||
| </Drawer.Trigger> | ||
| <Drawer.Content side='top'> | ||
| <Drawer.Title>Top Drawer</Drawer.Title> | ||
| <Drawer.Description>Slides in from the Top</Drawer.Description> | ||
| </Drawer.Content> | ||
| </Drawer> | ||
| <Drawer side='right'> | ||
| <Drawer.Trigger asChild> | ||
| <Button>Right Drawer</Button> | ||
| </Drawer.Trigger> | ||
| <Drawer.Content side='right'> | ||
| <Drawer.Title>Right Drawer</Drawer.Title> | ||
| <Drawer.Description>Slides in from the Right</Drawer.Description> | ||
| </Drawer.Content> | ||
| </Drawer> | ||
| <Drawer side='left'> | ||
| <Drawer.Trigger asChild> | ||
| <Button>Left Drawer</Button> | ||
| </Drawer.Trigger> | ||
| <Drawer.Content side='left'> | ||
| <Drawer.Title>Left Drawer</Drawer.Title> | ||
| <Drawer.Description>Slides in from the Left</Drawer.Description> | ||
| </Drawer.Content> | ||
| </Drawer> | ||
| <Drawer side='bottom'> | ||
| <Drawer.Trigger asChild> | ||
| <Button>Bottom Drawer</Button> | ||
| </Drawer.Trigger> | ||
| <Drawer.Content side='bottom'> | ||
| <Drawer.Title>Bottom Drawer</Drawer.Title> | ||
| <Drawer.Description>Slides in from the Bottom</Drawer.Description> | ||
| </Drawer.Content> | ||
| </Drawer> | ||
| </Flex> | ||
| </PlaygroundLayout> | ||
| ); | ||
| } |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,109 @@ | ||
| 'use client'; | ||
|
|
||
| import { getPropsString } from '@/lib/utils'; | ||
|
|
||
| export const getCode = (props: Record<string, unknown>) => { | ||
| return ` | ||
| <Drawer${getPropsString(props)}> | ||
| <Drawer.Trigger> | ||
| <Button>Drawer</Button> | ||
| </Drawer.Trigger> | ||
| <Drawer.Content${getPropsString(props)}> | ||
| <Drawer.Header> | ||
| <Drawer.Title>Drawer</Drawer.Title> | ||
| <Drawer.Description>A simple drawer</Drawer.Description> | ||
| </Drawer.Header> | ||
| <Drawer.Body>Content goes here</Drawer.Body> | ||
| </Drawer.Content> | ||
| </Drawer>`; | ||
| }; | ||
|
|
||
| export const playground = { | ||
| type: 'playground', | ||
| controls: { | ||
| side: { | ||
| type: 'select', | ||
| options: ['top', 'right', 'bottom', 'left'], | ||
| defaultValue: 'right' | ||
| }, | ||
| showCloseButton: { | ||
| type: 'checkbox', | ||
| defaultValue: true | ||
| } | ||
| }, | ||
| getCode | ||
| }; | ||
|
|
||
| export const basicDemo = { | ||
| type: 'code', | ||
| code: ` | ||
| <Drawer side="right"> | ||
| <Drawer.Trigger> | ||
| <Button>Open Drawer</Button> | ||
| </Drawer.Trigger> | ||
| <Drawer.Content> | ||
| <Drawer.Header> | ||
| <Drawer.Title>Drawer Title</Drawer.Title> | ||
| <Drawer.Description>Drawer description goes here</Drawer.Description> | ||
| </Drawer.Header> | ||
| <Drawer.Body> | ||
| <span>Main content of the drawer</span> | ||
| </Drawer.Body> | ||
| </Drawer.Content> | ||
| </Drawer>` | ||
| }; | ||
|
|
||
| export const positionDemo = { | ||
| type: 'code', | ||
| code: ` | ||
| <Flex gap="medium"> | ||
| <Drawer side="top"> | ||
| <Drawer.Trigger> | ||
| <Button>Top Drawer</Button> | ||
| </Drawer.Trigger> | ||
| <Drawer.Content side="top"> | ||
| <Drawer.Header> | ||
| <Drawer.Title>Top Drawer</Drawer.Title> | ||
| <Drawer.Description>Slides in from the Top</Drawer.Description> | ||
| </Drawer.Header> | ||
| <Drawer.Body>Content here</Drawer.Body> | ||
| </Drawer.Content> | ||
| </Drawer> | ||
| <Drawer side="right"> | ||
| <Drawer.Trigger> | ||
| <Button>Right Drawer</Button> | ||
| </Drawer.Trigger> | ||
| <Drawer.Content side="right"> | ||
| <Drawer.Header> | ||
| <Drawer.Title>Right Drawer</Drawer.Title> | ||
| <Drawer.Description>Slides in from the Right</Drawer.Description> | ||
| </Drawer.Header> | ||
| <Drawer.Body>Content here</Drawer.Body> | ||
| </Drawer.Content> | ||
| </Drawer> | ||
| <Drawer side="left"> | ||
| <Drawer.Trigger> | ||
| <Button>Left Drawer</Button> | ||
| </Drawer.Trigger> | ||
| <Drawer.Content side="left"> | ||
| <Drawer.Header> | ||
| <Drawer.Title>Left Drawer</Drawer.Title> | ||
| <Drawer.Description>Slides in from the Left</Drawer.Description> | ||
| </Drawer.Header> | ||
| <Drawer.Body>Content here</Drawer.Body> | ||
| </Drawer.Content> | ||
| </Drawer> | ||
| <Drawer side="bottom"> | ||
| <Drawer.Trigger> | ||
| <Button>Bottom Drawer</Button> | ||
| </Drawer.Trigger> | ||
| <Drawer.Content side="bottom"> | ||
| <Drawer.Header> | ||
| <Drawer.Title>Bottom Drawer</Drawer.Title> | ||
| <Drawer.Description>Slides in from the Bottom</Drawer.Description> | ||
| </Drawer.Header> | ||
| <Drawer.Body>Content here</Drawer.Body> | ||
| </Drawer.Content> | ||
| </Drawer> | ||
| </Flex>` | ||
| }; | ||
This file contains hidden or 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,83 @@ | ||
| --- | ||
| title: Drawer | ||
| description: A panel that slides in from the edge of the screen with swipe-to-dismiss gestures. | ||
| source: packages/raystack/components/drawer | ||
| --- | ||
|
|
||
| import { playground, basicDemo, positionDemo } from "./demo.ts"; | ||
|
|
||
| <Demo data={playground} /> | ||
|
|
||
| ## Anatomy | ||
|
|
||
| Import and assemble the component: | ||
|
|
||
| ```tsx | ||
| import { Drawer } from "@raystack/apsara"; | ||
|
|
||
| <Drawer side="right"> | ||
| <Drawer.Content> | ||
| <Drawer.Header> | ||
| <Drawer.Title /> | ||
| <Drawer.Description /> | ||
| </Drawer.Header> | ||
| <Drawer.Body /> | ||
| <Drawer.Footer /> | ||
| </Drawer.Content> | ||
| </Drawer> | ||
| ``` | ||
|
|
||
| ## API Reference | ||
|
|
||
| ### Root | ||
|
|
||
| Groups all parts of the drawer. The `side` prop determines both the slide direction and the swipe-to-dismiss direction. | ||
|
|
||
| <auto-type-table path="./props.ts" name="DrawerProps" /> | ||
|
|
||
| ### Content | ||
|
|
||
| Renders the drawer panel that slides in from a screen edge. | ||
|
|
||
| <auto-type-table path="./props.ts" name="DrawerContentProps" /> | ||
|
|
||
| ### Header | ||
|
|
||
| - `children`: React.ReactNode - Content to render inside the header | ||
| - `className`: string - Additional CSS class name | ||
|
|
||
| ### Title | ||
|
|
||
| - Inherits all Base UI Drawer.Title props | ||
|
|
||
| ### Description | ||
|
|
||
| - Inherits all Base UI Drawer.Description props | ||
|
|
||
| ### Body | ||
|
|
||
| - Inherits all HTML div element props | ||
|
|
||
| ### Footer | ||
|
|
||
| - Inherits all HTML div element props | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Basic | ||
|
|
||
| <Demo data={basicDemo} /> | ||
|
|
||
| ### Positioning | ||
|
|
||
| The Drawer can slide in from different sides of the screen. Swipe-to-dismiss is automatically configured based on the `side` prop. | ||
|
|
||
| <Demo data={positionDemo} /> | ||
|
|
||
| ## Accessibility | ||
|
|
||
| - Uses `role="dialog"` with `aria-modal="true"` | ||
| - Focus is trapped within the drawer and restored on close | ||
| - Supports dismissal with Escape key and swipe gestures | ||
| - Title is announced via `aria-labelledby` | ||
|
|
||
rohanchkrabrty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.