Skip to content

Commit

Permalink
Merge pull request chakra-ui#3427 from TheAsda/docs/drawer
Browse files Browse the repository at this point in the history
Update drawer docs
  • Loading branch information
segunadebayo committed Feb 26, 2021
2 parents db01b34 + e73e6be commit c51f3ae
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .changeset/chatty-deers-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@chakra-ui/modal": patch
"@chakra-ui/docs": patch
---

- Add drawer example to modal readme
- Fix github references in drawer and alert-dialog docs
75 changes: 75 additions & 0 deletions packages/modal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,78 @@ function AlertDialogExample() {
)
}
```

# Drawer

The Drawer component is a panel that slides out from the edge of the screen.
It can be useful when you need users to complete a task or view some details
without leaving the current page.

## Installation

```sh
yarn add @chakra-ui/modal

# or

npm i @chakra-ui/modal
```

## Import components

```jsx
import {
Drawer,
DrawerOverlay,
DrawerContent,
DrawerHeader,
DrawerFooter,
DrawerBody,
DrawerCloseButton,
} from "@chakra-ui/react"
```

## Basic usage

## Usage

By default focus is placed on `DrawerCloseButton` when the drawer opens.

```jsx
function DrawerExample() {
const { isOpen, onOpen, onClose } = useDisclosure()
const btnRef = React.useRef()

return (
<>
<Button ref={btnRef} colorScheme="teal" onClick={onOpen}>
Open
</Button>
<Drawer
isOpen={isOpen}
placement="right"
onClose={onClose}
finalFocusRef={btnRef}
>
<DrawerOverlay>
<DrawerContent>
<DrawerCloseButton />
<DrawerHeader>Create your account</DrawerHeader>

<DrawerBody>
<Input placeholder="Type here..." />
</DrawerBody>

<DrawerFooter>
<Button variant="outline" mr={3} onClick={onClose}>
Cancel
</Button>
<Button color="blue">Save</Button>
</DrawerFooter>
</DrawerContent>
</DrawerOverlay>
</Drawer>
</>
)
}
```
4 changes: 2 additions & 2 deletions website/pages/docs/overlay/alert-dialog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ description:
confirmation or action.

<ComponentLinks
github={{ package: "dialog" }}
npm={{ package: "@chakra-ui/dialog" }}
github={{ package: "modal" }}
npm={{ package: "@chakra-ui/modal" }}
/>

<carbon-ad></carbon-ad>
Expand Down
4 changes: 2 additions & 2 deletions website/pages/docs/overlay/drawer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ without leaving the current page.

<ComponentLinks
theme={{ componentName: "drawer" }}
github={{ package: "drawer" }}
npm={{ package: "@chakra-ui/drawer" }}
github={{ package: "modal" }}
npm={{ package: "@chakra-ui/modal" }}
/>

<carbon-ad></carbon-ad>
Expand Down

0 comments on commit c51f3ae

Please sign in to comment.