mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
refactoring(drawer): drawer component.
This commit is contained in:
@@ -1,27 +1,29 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
|
||||||
import { Position, Drawer } from '@blueprintjs/core';
|
import { Position, Drawer } from '@blueprintjs/core';
|
||||||
|
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||||
|
|
||||||
export default function ({
|
import { compose } from 'utils';
|
||||||
title = <T id={'view_paper'} />,
|
|
||||||
children,
|
function DrawerComponent(props) {
|
||||||
isOpen,
|
const { name, children, onClose, closeDrawer } = props;
|
||||||
isClose,
|
|
||||||
drawerProps,
|
const handleClose = (event) => {
|
||||||
}) {
|
closeDrawer(name);
|
||||||
|
onClose && onClose(event);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Drawer
|
<Drawer
|
||||||
isOpen={isOpen}
|
size={'700px'}
|
||||||
title={title}
|
|
||||||
position={Position.RIGHT}
|
|
||||||
canOutsideClickClose={true}
|
canOutsideClickClose={true}
|
||||||
canEscapeKeyClose={true}
|
canEscapeKeyClose={true}
|
||||||
size={'700px'}
|
position={Position.RIGHT}
|
||||||
onClose={isClose}
|
onClose={handleClose}
|
||||||
{...drawerProps}
|
{...props}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Drawer>
|
</Drawer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default compose(withDrawerActions)(DrawerComponent);
|
||||||
|
|||||||
46
client/src/components/Drawer/DrawerHeaderContent.js
Normal file
46
client/src/components/Drawer/DrawerHeaderContent.js
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { FormattedMessage as T } from 'react-intl';
|
||||||
|
import { Classes, Icon, H4, Button } from '@blueprintjs/core';
|
||||||
|
|
||||||
|
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||||
|
|
||||||
|
import { compose } from 'utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drawer header content.
|
||||||
|
*/
|
||||||
|
function DrawerHeaderContent(props) {
|
||||||
|
const {
|
||||||
|
icon,
|
||||||
|
title = <T id={'view_paper'} />,
|
||||||
|
onClose,
|
||||||
|
name,
|
||||||
|
closeDrawer,
|
||||||
|
} = props;
|
||||||
|
|
||||||
|
if (title == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleClose = (event) => {
|
||||||
|
closeDrawer(name);
|
||||||
|
onClose && onClose(event);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={Classes.DRAWER_HEADER}>
|
||||||
|
<Icon icon={icon} iconSize={Icon.SIZE_LARGE} />
|
||||||
|
<H4>{title}</H4>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
aria-label="Close"
|
||||||
|
className={Classes.DIALOG_CLOSE_BUTTON}
|
||||||
|
icon={<Icon icon="small-cross" iconSize={Icon.SIZE_LARGE} />}
|
||||||
|
minimal={true}
|
||||||
|
onClick={handleClose}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default compose(withDrawerActions)(DrawerHeaderContent);
|
||||||
@@ -51,6 +51,7 @@ import DashboardPageContent from './Dashboard/DashboardPageContent';
|
|||||||
import DashboardInsider from './Dashboard/DashboardInsider';
|
import DashboardInsider from './Dashboard/DashboardInsider';
|
||||||
import Drawer from './Drawer/Drawer';
|
import Drawer from './Drawer/Drawer';
|
||||||
import DrawerSuspense from './Drawer/DrawerSuspense';
|
import DrawerSuspense from './Drawer/DrawerSuspense';
|
||||||
|
import DrawerHeaderContent from './Drawer/DrawerHeaderContent';
|
||||||
import Postbox from './Postbox';
|
import Postbox from './Postbox';
|
||||||
import AccountsSuggestField from './AccountsSuggestField';
|
import AccountsSuggestField from './AccountsSuggestField';
|
||||||
import MaterialProgressBar from './MaterialProgressBar';
|
import MaterialProgressBar from './MaterialProgressBar';
|
||||||
@@ -112,7 +113,8 @@ export {
|
|||||||
DashboardInsider,
|
DashboardInsider,
|
||||||
Drawer,
|
Drawer,
|
||||||
DrawerSuspense,
|
DrawerSuspense,
|
||||||
|
DrawerHeaderContent,
|
||||||
Postbox,
|
Postbox,
|
||||||
AccountsSuggestField,
|
AccountsSuggestField,
|
||||||
MaterialProgressBar
|
MaterialProgressBar,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user