2025-01-29 20:42:01 -05:00
|
|
|
import React from 'react';
|
2025-04-16 16:55:38 -07:00
|
|
|
|
|
|
|
|
import { Button } from '@components/components/Button';
|
|
|
|
|
import { StyledDrawer, TitleContainer, TitleLeftContainer } from '@components/components/Drawer/components';
|
|
|
|
|
import { maskTransparentStyle } from '@components/components/Drawer/constants';
|
|
|
|
|
import { drawerDefault } from '@components/components/Drawer/defaults';
|
|
|
|
|
import { DrawerProps } from '@components/components/Drawer/types';
|
|
|
|
|
import { Text } from '@components/components/Text';
|
2025-01-29 20:42:01 -05:00
|
|
|
|
|
|
|
|
export const Drawer = ({
|
|
|
|
|
title,
|
|
|
|
|
children,
|
|
|
|
|
open,
|
|
|
|
|
onClose,
|
2025-02-19 10:50:13 -08:00
|
|
|
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>
|
2025-02-19 10:50:13 -08:00
|
|
|
<TitleLeftContainer>
|
|
|
|
|
{onBack && (
|
|
|
|
|
<Button
|
|
|
|
|
color="gray"
|
2025-04-02 12:16:50 -07:00
|
|
|
icon={{ icon: 'ArrowBack', source: 'material' }}
|
2025-02-19 10:50:13 -08:00
|
|
|
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"
|
2025-04-02 12:16:50 -07:00
|
|
|
icon={{ icon: 'Close', source: 'material' }}
|
2025-01-29 20:42:01 -05:00
|
|
|
iconPosition="left"
|
|
|
|
|
isCircle
|
|
|
|
|
onClick={() => onClose?.()}
|
|
|
|
|
size="xl"
|
|
|
|
|
variant="text"
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</TitleContainer>
|
|
|
|
|
}
|
|
|
|
|
open={open}
|
|
|
|
|
width={width}
|
|
|
|
|
closable={false}
|
|
|
|
|
maskStyle={maskTransparent ? maskTransparentStyle : undefined}
|
|
|
|
|
>
|
|
|
|
|
{children}
|
|
|
|
|
</StyledDrawer>
|
|
|
|
|
);
|
|
|
|
|
};
|