Skip to content

Commit

Permalink
feat: revise drawer component
Browse files Browse the repository at this point in the history
  • Loading branch information
cschroeter committed Jun 30, 2023
1 parent 9598320 commit a1771e1
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## Added

- Revise `Drawer` to have a more consistent spacing with the rest of the components.

## Fixed

- Fixed an issue with the `Button` component where the `text` variant had the wrong line height.
Expand Down
29 changes: 29 additions & 0 deletions src/components/drawer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { modalAnatomy as parts } from '@chakra-ui/anatomy'
import { createMultiStyleConfigHelpers } from '@chakra-ui/styled-system'

const { defineMultiStyleConfig, definePartsStyle } = createMultiStyleConfigHelpers(parts.keys)

const baseStyle = definePartsStyle({
header: {
px: { base: 4, md: 6 },
pt: 6,
pb: 0,
fontSize: 'md',
fontWeight: 'normal',
},
body: {
px: { base: 4, md: 6 },
py: 6,
},
footer: {
px: { base: 4, md: 6 },
py: 4,
display: 'block',
},
dialog: {
bg: 'bg.surface',
boxShadow: 'lg',
},
})

export default defineMultiStyleConfig({ baseStyle })
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export { default as CloseButton } from './close-button'
export { default as Container } from './container'
export { default as CustomSelect } from './custom-select'
export { default as Divider } from './divider'
export { default as Drawer } from './drawer'
export { default as FormLabel } from './form-label'
export { default as Heading } from './heading'
export { default as Input } from './input'
Expand Down
35 changes: 35 additions & 0 deletions src/stories/drawer.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
Box,
Drawer,
DrawerBody,
DrawerContent,
DrawerFooter,
DrawerHeader,
DrawerOverlay,
} from '@chakra-ui/react'
import type { Meta } from '@storybook/react'

const meta: Meta = {
title: 'Components / Drawer',
}

export default meta

export const Basic = () => {
return (
<Drawer isOpen={true} placement="right" onClose={() => void 0}>
<DrawerOverlay />
<DrawerContent>
<DrawerHeader bg="red.100">
<Box bg="red.500">Header</Box>
</DrawerHeader>
<DrawerBody bg="green.100">
<Box bg="green.500">Body</Box>
</DrawerBody>
<DrawerFooter bg="blue.100">
<Box bg="blue.500">Footer</Box>
</DrawerFooter>
</DrawerContent>
</Drawer>
)
}

1 comment on commit a1771e1

@vercel
Copy link

@vercel vercel bot commented on a1771e1 Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.