Skip to content

Commit

Permalink
Merge pull request #1624 from adevinta/drawer-final-spec-sync
Browse files Browse the repository at this point in the history
feat(drawer): final spec sync
  • Loading branch information
Powerplex authored Nov 10, 2023
2 parents a0567ed + 900bf2a commit 2eaab6a
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 44 deletions.
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/components/drawer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spark-ui/drawer",
"version": "0.3.5",
"version": "1.0.0",
"description": "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.",
"publishConfig": {
"access": "public"
Expand Down
78 changes: 42 additions & 36 deletions packages/components/drawer/src/Drawer.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Button } from '@spark-ui/button'
import { RadioGroup } from '@spark-ui/radio-group'
import { Meta, StoryFn } from '@storybook/react'
import { useState } from 'react'

import { Drawer, type DrawerContentProps } from '.'

const meta: Meta<typeof Drawer> = {
title: 'Experimental/Drawer',
title: 'Components/Drawer',
component: Drawer,
}

Expand Down Expand Up @@ -43,11 +44,17 @@ export const Usage: StoryFn = () => {
))}
</Drawer.Body>

<Drawer.Footer className="flex justify-end gap-md">
<Button intent="neutral" design="outlined" onClick={() => setOpen(false)}>
<Drawer.Footer className="flex justify-between gap-md">
<Button intent="basic" design="ghost" onClick={() => setOpen(false)}>
Cancel
</Button>
<Button>Submit</Button>

<div className="flex gap-md">
<Button intent="basic" design="outlined" onClick={() => setOpen(false)}>
Disagree
</Button>
<Button>Submit</Button>
</div>
</Drawer.Footer>

<Drawer.CloseButton aria-label="Close edit profile" />
Expand All @@ -62,21 +69,23 @@ export const Sizes = () => {
const [open, setOpen] = useState(false)

return (
<>
<Drawer open={open} onOpenChange={setOpen}>
<div className="flex gap-md">
<Drawer.Trigger asChild>
<Button onClick={() => setSize('sm')}>Small</Button>
</Drawer.Trigger>

<Drawer.Trigger asChild>
<Button onClick={() => setSize('md')}>Medium</Button>
</Drawer.Trigger>
<div>
<RadioGroup
className="mb-lg flex gap-md"
value={size}
orientation="horizontal"
onValueChange={value => setSize(value as ExcludeNull<DrawerContentProps>['size'])}
>
<RadioGroup.Radio value="sm">Small</RadioGroup.Radio>
<RadioGroup.Radio value="md">Medium</RadioGroup.Radio>
<RadioGroup.Radio value="lg">Large</RadioGroup.Radio>
<RadioGroup.Radio value="fullscreen">Fullscreen</RadioGroup.Radio>
</RadioGroup>

<Drawer.Trigger asChild>
<Button onClick={() => setSize('lg')}>Large</Button>
</Drawer.Trigger>
</div>
<Drawer open={open} onOpenChange={setOpen}>
<Drawer.Trigger asChild>
<Button>Open drawer</Button>
</Drawer.Trigger>

<Drawer.Portal>
<Drawer.Overlay />
Expand Down Expand Up @@ -112,7 +121,7 @@ export const Sizes = () => {
</Drawer.Content>
</Drawer.Portal>
</Drawer>
</>
</div>
)
}

Expand All @@ -122,24 +131,21 @@ export const Side = () => {

return (
<>
<RadioGroup
className="mb-lg flex gap-md"
value={side}
orientation="horizontal"
onValueChange={value => setSide(value as ExcludeNull<DrawerContentProps>['side'])}
>
<RadioGroup.Radio value="right">Right</RadioGroup.Radio>
<RadioGroup.Radio value="left">Left</RadioGroup.Radio>
<RadioGroup.Radio value="top">Top</RadioGroup.Radio>
<RadioGroup.Radio value="bottom">Bottom</RadioGroup.Radio>
</RadioGroup>
<Drawer open={open} onOpenChange={setOpen}>
<div className="flex gap-md">
<Drawer.Trigger asChild>
<Button onClick={() => setSide('right')}>Right</Button>
</Drawer.Trigger>

<Drawer.Trigger asChild>
<Button onClick={() => setSide('left')}>Left</Button>
</Drawer.Trigger>

<Drawer.Trigger asChild>
<Button onClick={() => setSide('top')}>Top</Button>
</Drawer.Trigger>

<Drawer.Trigger asChild>
<Button onClick={() => setSide('bottom')}>Bottom</Button>
</Drawer.Trigger>
</div>
<Drawer.Trigger asChild>
<Button>Open drawer</Button>
</Drawer.Trigger>

<Drawer.Portal>
<Drawer.Overlay />
Expand Down
2 changes: 1 addition & 1 deletion packages/components/drawer/src/DrawerBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const DrawerBody = forwardRef(
<div
ref={ref}
className={cx(
['px-xl', 'py-md', 'flex-grow', 'overflow-y-auto'],
['px-xl', 'py-lg', 'flex-grow', 'overflow-y-auto'],
['outline-none', 'focus-visible:u-ring'],
className
)}
Expand Down
2 changes: 1 addition & 1 deletion packages/components/drawer/src/DrawerCloseButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const DrawerCloseButton = forwardRef<CloseButtonElement, DrawerCloseButto
) => (
<DrawerClose
ref={ref}
className={cx(['absolute', 'top-sm', 'right-sm'], className)}
className={cx(['absolute', 'top-sm', 'right-xl'], className)}
asChild
{...rest}
>
Expand Down
9 changes: 5 additions & 4 deletions packages/components/drawer/src/DrawerContent.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const drawerContentStyles = cva(
sm: '',
md: '',
lg: '',
fullscreen: 'h-screen w-screen',
},
side: {
right: [
Expand Down Expand Up @@ -52,12 +53,12 @@ export const drawerContentStyles = cva(
{
side: ['right', 'left'],
size: 'md',
class: ['w-sz-640', 'max-w-full'],
class: ['w-sz-672', 'max-w-full'],
},
{
side: ['right', 'left'],
size: 'lg',
class: ['w-sz-768', 'max-w-full'],
class: ['w-sz-864', 'max-w-full'],
},
{
side: ['top', 'bottom'],
Expand All @@ -67,12 +68,12 @@ export const drawerContentStyles = cva(
{
side: ['top', 'bottom'],
size: 'md',
class: ['h-sz-640', 'max-h-full'],
class: ['h-sz-672', 'max-h-full'],
},
{
side: ['top', 'bottom'],
size: 'lg',
class: ['h-sz-768', 'max-h-full'],
class: ['h-sz-864', 'max-h-full'],
},
],
defaultVariants: {
Expand Down

0 comments on commit 2eaab6a

Please sign in to comment.