From d45ed8841b761297d1cc47043aa5f65ef6766839 Mon Sep 17 00:00:00 2001 From: Nishchit Dhanani Date: Sat, 22 Jul 2023 14:55:59 +0530 Subject: [PATCH] feat: component added in ui-kit --- .vscode/settings.json | 1 + .../src/components/drawer/Drawer.tsx | 98 ++++++++++++++++--- platform/firecamp-ui/src/ui-kit.ts | 4 + 3 files changed, 90 insertions(+), 13 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 89725ab4..829c596c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,6 +3,7 @@ "Auths", "firecamp", "initialise", + "Mantine", "plgs", "resizer", "testid" diff --git a/platform/firecamp-ui/src/components/drawer/Drawer.tsx b/platform/firecamp-ui/src/components/drawer/Drawer.tsx index 890ceedf..960fa918 100644 --- a/platform/firecamp-ui/src/components/drawer/Drawer.tsx +++ b/platform/firecamp-ui/src/components/drawer/Drawer.tsx @@ -1,18 +1,90 @@ +import { FC } from 'react'; +import { Drawer as MantineDrawer, DrawerProps, ScrollArea, createStyles } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; -import { Drawer, Button, Group } from '@mantine/core'; -function Demo() { - const [opened, { open, close }] = useDisclosure(false); +export interface IDrawer extends DrawerProps { } + +const useStyles = createStyles((theme, { title }: IDrawer) => ({ + content: { + borderRadius: '0px', + backgroundColor: + theme.colorScheme === 'light' + ? theme.colors.gray[1] + : theme.colors.dark[6], + color: + theme.colorScheme === 'light' + ? theme.colors.dark[5] + : theme.colors.gray[4], + maxWidth: '48rem', + minHeight: '400px', + }, + header: { + backgroundColor: 'transparent', + color: + theme.colorScheme === 'light' + ? theme.colors.dark[5] + : theme.colors.gray[4], + paddingRight: '1rem', + paddingTop: '1rem', + paddingBottom: !!title ? '1rem' : '0px', + ...(!!title + ? { + borderBottom: `1px solid ${theme.colorScheme === 'light' + ? theme.colors.gray[4] + : theme.colors.dark[4] + }`, + backgroundColor: + theme.colorScheme === 'light' + ? theme.colors.gray[1] + : theme.colors.dark[6], + } + : {}), + }, + body: { + paddingLeft: '2rem', + paddingRight: '2rem', + paddingBottom: '2rem', + position: 'relative', + }, +})); + +const Drawer: FC = ({ + id = '', + opened = false, + classNames = {}, + onClose = () => { }, + children = <>, + ...props +}) => { + const { classes, cx, theme } = useStyles({ + title: props.title, + opened, + onClose: () => { }, + }); return ( - <> - - {/* Drawer content */} - - - - - - + onClose()} + id={id} + classNames={{ + ...classNames, + content: cx('invisible-scrollbar', classes.content, classNames.content), + header: cx(classes.header, classNames.header), + body: cx(classes.body, classNames.body), + }} + scrollAreaComponent={ScrollArea.Autosize} + closeButtonProps={{ + bg: + theme.colorScheme === 'light' + ? theme.colors.gray[1] + : theme.colors.dark[6], + }} + {...props} + > + {children} + ); -} \ No newline at end of file +}; + +export default Drawer; \ No newline at end of file diff --git a/platform/firecamp-ui/src/ui-kit.ts b/platform/firecamp-ui/src/ui-kit.ts index dc34dca0..e7655208 100644 --- a/platform/firecamp-ui/src/ui-kit.ts +++ b/platform/firecamp-ui/src/ui-kit.ts @@ -32,6 +32,10 @@ export { default as FileInput } from './components/input/FileInput'; export { default as Modal } from './components/modal/Modal'; export type { IModal } from './components/modal/Modal'; +// Drawer +export { default as Drawer } from './components/drawer/Drawer'; +export type { IDrawer } from './components/drawer/Drawer'; + export { default as SplitView } from './components/split-view/SplitView'; export { default as Tabs } from './components/tabs/Tabs';