63 lines
2.0 KiB
TypeScript
Raw Normal View History

2025-01-29 20:42:01 -05:00
import React from 'react';
import { Button } from '../Button';
import { Text } from '../Text';
import { StyledDrawer, TitleContainer, TitleLeftContainer } from './components';
2025-01-29 20:42:01 -05:00
import { maskTransparentStyle } from './constants';
import { DrawerProps } from './types';
import { drawerDefault } from './defaults';
2025-01-29 20:42:01 -05:00
export const Drawer = ({
title,
children,
open,
onClose,
onBack,
2025-01-29 20:42:01 -05:00
width = drawerDefault.width,
closable = drawerDefault.closable,
maskTransparent = drawerDefault.maskTransparent,
}: React.PropsWithChildren<DrawerProps>) => {
return (
<StyledDrawer
onClose={onClose}
destroyOnClose
title={
<TitleContainer>
<TitleLeftContainer>
{onBack && (
<Button
color="gray"
icon="ArrowBack"
iconPosition="left"
isCircle
onClick={() => onBack?.()}
size="xl"
variant="text"
/>
)}
<Text weight="bold" size="xl">
{title}
</Text>
</TitleLeftContainer>
2025-01-29 20:42:01 -05:00
{closable && (
<Button
color="gray"
icon="Close"
iconPosition="left"
isCircle
onClick={() => onClose?.()}
size="xl"
variant="text"
/>
)}
</TitleContainer>
}
open={open}
width={width}
closable={false}
maskStyle={maskTransparent ? maskTransparentStyle : undefined}
>
{children}
</StyledDrawer>
);
};