♻️ refactor: WavyBorder component and update CreateProjectLayout

This commit is contained in:
Wahyu Kurniawan 2024-02-28 14:46:17 +07:00
parent 392377d6ae
commit 7dbfe03555
No known key found for this signature in database
GPG Key ID: 040A1549143A8E33
2 changed files with 9 additions and 12 deletions

View File

@ -1,20 +1,19 @@
import React, { ComponentPropsWithoutRef, useMemo } from 'react';
import { cn } from 'utils/classnames';
type WavyBorderType = 'card' | 'layout';
type WaveBorderVariant = 'card' | 'layout';
export interface WavyBorderProps extends ComponentPropsWithoutRef<'div'> {
type?: WavyBorderType;
variant?: WaveBorderVariant;
}
export const WavyBorder = ({
className,
children,
type = 'card',
variant = 'card',
...props
}: WavyBorderProps) => {
const imageSrc = useMemo(() => {
switch (type) {
switch (variant) {
case 'card':
return '/wave-border-card.svg';
case 'layout':
@ -22,17 +21,15 @@ export const WavyBorder = ({
default:
return '/wave-border-card.svg';
}
}, [type]);
}, [variant]);
return (
<div
{...props}
className={cn('w-full h-1 bg-repeat-x bg-top bg-cover', className)}
className={cn('w-full bg-repeat-x h-1 bg-top bg-cover', className)}
style={{
backgroundImage: `url(${imageSrc})`,
}}
>
{children}
</div>
/>
);
};

View File

@ -25,11 +25,11 @@ export const CreateProjectLayout = ({
</Heading>
<Link to={`/${orgSlug}`}>
<Button iconOnly variant="tertiary">
<CrossIcon />
<CrossIcon size={18} />
</Button>
</Link>
</div>
<WavyBorder type="layout" />
<WavyBorder variant="layout" />
</div>
<section className="px-6 h-full flex-1 py-6 overflow-y-auto">
<Outlet />