Skip to content

Commit

Permalink
style: Fix sheet style (#292)
Browse files Browse the repository at this point in the history
* style: Fix sheet style

Signed-off-by: yazhou <[email protected]>

* ci: Add changeset

Signed-off-by: yazhou <[email protected]>

---------

Signed-off-by: yazhou <[email protected]>
  • Loading branch information
yazhouio authored Aug 6, 2024
1 parent e878027 commit ccb568f
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 22 deletions.
13 changes: 13 additions & 0 deletions .changeset/wicked-beans-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@kubed/code-editor': patch
'@kubed/diff-viewer': patch
'@kubed/components': patch
'@kubed/log-viewer': patch
'@kubed/charts': patch
'@kubed/hooks': patch
'@kubed/icons': patch
'@kubed/tests': patch
'kubed-documents': patch
---

style: Update sheet style
7 changes: 7 additions & 0 deletions packages/components/src/Sheet/Sheet.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import * as SheetPrimitive from '@radix-ui/react-dialog';
import classNames from 'classnames';

import { addColorAlpha } from '../utils/color';
import { Field } from '../index';

export const FieldWrapper = styled(Field).attrs({
className: 'kubed-sheet-header-field',
})`
min-height: 40px;
`;

const fadeIn = keyframes`
from { opacity: 0; }
Expand Down
70 changes: 48 additions & 22 deletions packages/components/src/Sheet/Sheets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import {
StyledHeaderClose,
HeaderWrapper,
HiddenTitle,
FieldWrapper as Field,
} from './Sheet.styles';
import { Button, Field } from '../index';
import { Button } from '../index';

const Sheet = SheetPrimitive.Root;
const SheetTrigger = SheetPrimitive.Trigger;
Expand Down Expand Up @@ -65,32 +66,56 @@ export interface SheetContentProps
title?: string;
/** The accessible description of the SheetContent. */
description?: string;
/** Whether the SheetContent has overlay. */
hasOverlay?: boolean;
}

const SheetBaseContent = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Content>,
SheetContentProps
>(
(
{ side = 'right', hasOverlay = true, className, children, title, description, ...props },
ref
) => (
<SheetPortal>
{hasOverlay && <SheetOverlay />}
<StyledSheetContent ref={ref} side={side} className={className} {...props}>
{children}
</StyledSheetContent>
</SheetPortal>
)
);

const SheetContent = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Content>,
SheetContentProps
>(({ side = 'right', className, children, title, description, ...props }, ref) => (
<SheetPortal>
<SheetOverlay />
<StyledSheetContent ref={ref} side={side} className={className} {...props}>
<HiddenTitle>
<SheetPrimitive.Title>{title ?? 'sheet'}</SheetPrimitive.Title>
</HiddenTitle>
<HiddenTitle>
<SheetPrimitive.Description>
{description ?? 'sheet description'}
</SheetPrimitive.Description>
</HiddenTitle>
<SheetHeaderClose asChild>
<Button variant="filled" color="secondary" radius="sm" size="sm">
<CloseDuotone size={24} variant="light" />
</Button>
</SheetHeaderClose>
{children}
</StyledSheetContent>
</SheetPortal>
));
>(
(
{ side = 'right', hasOverlay = true, className, children, title, description, ...props },
ref
) => (
<SheetPortal>
{hasOverlay && <SheetOverlay />}
<StyledSheetContent ref={ref} side={side} className={className} {...props}>
<HiddenTitle>
<SheetPrimitive.Title>{title ?? 'sheet'}</SheetPrimitive.Title>
</HiddenTitle>
<HiddenTitle>
<SheetPrimitive.Description>
{description ?? 'sheet description'}
</SheetPrimitive.Description>
</HiddenTitle>
<SheetHeaderClose asChild>
<Button variant="filled" color="secondary" radius="sm" size="sm">
<CloseDuotone size={24} variant="light" />
</Button>
</SheetHeaderClose>
{children}
</StyledSheetContent>
</SheetPortal>
)
);

const SheetHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
<StyledSheetHeader {...props} className={className} />
Expand Down Expand Up @@ -136,4 +161,5 @@ export {
SheetDescription,
SheetHeaderClose,
SheetFieldTitle,
SheetBaseContent,
};

0 comments on commit ccb568f

Please sign in to comment.