Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: Fix sheet style #292

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
};