Skip to content

Commit

Permalink
Merge pull request #24 from ikon-integration/devm/122
Browse files Browse the repository at this point in the history
feat: add version to new drawer position
  • Loading branch information
rescio authored Aug 8, 2024
2 parents 5fb4b47 + f515a70 commit 308573d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
4 changes: 2 additions & 2 deletions 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 package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ikonintegration/ui",
"version": "1.0.96-alpha-1",
"version": "1.0.99",
"type": "module",
"license": "MIT",
"publishConfig": {
Expand Down
43 changes: 26 additions & 17 deletions src/components/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@ import { cn } from '@/lib/utils';

const { Trigger, Portal, Close } = DrawerPrimitive;

function Root({
shouldScaleBackground = true,
...props
}: React.ComponentProps<typeof DrawerPrimitive.Root> & {
type DrawerRootProps = React.ComponentProps<typeof DrawerPrimitive.Root> & {
shouldScaleBackground?: boolean;
}) {
return (
<DrawerPrimitive.Root
shouldScaleBackground={shouldScaleBackground}
{...props}
/>
);
}
Root.displayName = 'Drawer';
direction?: 'bottom' | 'right';
};

const Root = React.forwardRef<
React.ElementRef<typeof DrawerPrimitive.Root>,
DrawerRootProps
>(({ shouldScaleBackground = true, direction = 'bottom', ...props }) => (
<DrawerPrimitive.Root
shouldScaleBackground={shouldScaleBackground}
{...props}
data-direction={direction}
/>
));
Root.displayName = 'DrawerRoot';

const Overlay = React.forwardRef<
React.ElementRef<typeof DrawerPrimitive.Overlay>,
Expand All @@ -37,19 +39,26 @@ Overlay.displayName = DrawerPrimitive.Overlay.displayName;

const Content = React.forwardRef<
React.ElementRef<typeof DrawerPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
>(({ className, children, ...props }, ref) => (
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content> & {
direction?: 'bottom' | 'right';
}
>(({ className, children, direction = 'bottom', ...props }, ref) => (
<Portal>
<Overlay />
<DrawerPrimitive.Content
ref={ref}
className={cn(
'ikui-fixed ikui-inset-x-0 ikui-bottom-0 ikui-z-50 ikui-mt-24 ikui-flex ikui-h-auto ikui-flex-col ikui-rounded-t-[10px] ikui-border ikui-bg-background',
'ikui-fixed ikui-z-50 ikui-mt-24 ikui-flex ikui-h-auto ikui-flex-col ikui-rounded-t-[10px] ikui-border ikui-bg-background',
direction === 'right'
? 'ikui-bottom-0 ikui-right-0 ikui-h-full ikui-w-[400px]'
: 'ikui-inset-x-0 ikui-bottom-0',
className,
)}
{...props}
>
<div className="ikui-mx-auto ikui-mt-4 ikui-h-2 ikui-w-[100px] ikui-rounded-full ikui-bg-muted" />
{direction === 'bottom' && (
<div className="ikui-mx-auto ikui-mt-4 ikui-h-2 ikui-w-[100px] ikui-rounded-full ikui-bg-muted" />
)}
{children}
</DrawerPrimitive.Content>
</Portal>
Expand Down
4 changes: 2 additions & 2 deletions src/stories/components/Drawer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ function Template() {
}

return (
<Drawer.Root>
<Drawer.Root direction="right">
<Drawer.Trigger asChild>
<Button variant="outline">Open Drawer</Button>
</Drawer.Trigger>
<Drawer.Content>
<Drawer.Content direction="right">
<div className="ikui-mx-auto ikui-w-full ikui-max-w-sm">
<Drawer.Header>
<Drawer.Title>Move Goal</Drawer.Title>
Expand Down

0 comments on commit 308573d

Please sign in to comment.