@bitrise/bitkit 12.17.2 → 12.18.0-alpha-drawer.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createMultiStyleConfigHelpers } from '@chakra-ui/styled-system';
|
|
2
|
+
|
|
3
|
+
const { defineMultiStyleConfig } = createMultiStyleConfigHelpers([
|
|
4
|
+
'overlay',
|
|
5
|
+
'dialogContainer',
|
|
6
|
+
'dialog',
|
|
7
|
+
'closeButton',
|
|
8
|
+
'header',
|
|
9
|
+
'footer',
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const DrawerTheme = defineMultiStyleConfig({
|
|
13
|
+
baseStyle: {
|
|
14
|
+
overlay: {
|
|
15
|
+
backgroundColor: 'rgba(0, 0, 0, 0.2)',
|
|
16
|
+
zIndex: 'dialogOverlay',
|
|
17
|
+
top: '3rem',
|
|
18
|
+
},
|
|
19
|
+
dialogContainer: {
|
|
20
|
+
zIndex: 'dialog',
|
|
21
|
+
top: '3rem',
|
|
22
|
+
},
|
|
23
|
+
dialog: {
|
|
24
|
+
top: '3rem !important',
|
|
25
|
+
background: 'neutral.100',
|
|
26
|
+
maxWidth: '20rem',
|
|
27
|
+
padding: '24',
|
|
28
|
+
display: 'flex',
|
|
29
|
+
flexDirection: 'column',
|
|
30
|
+
gap: '9',
|
|
31
|
+
},
|
|
32
|
+
closeButton: {
|
|
33
|
+
position: 'absolute',
|
|
34
|
+
top: '24',
|
|
35
|
+
right: '24',
|
|
36
|
+
},
|
|
37
|
+
header: {
|
|
38
|
+
color: 'neutral.40',
|
|
39
|
+
fontSize: '1',
|
|
40
|
+
lineHeight: '1rem',
|
|
41
|
+
textTransform: 'uppercase',
|
|
42
|
+
},
|
|
43
|
+
footer: {
|
|
44
|
+
marginTop: 'auto',
|
|
45
|
+
justifyContent: 'flex-start',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export default DrawerTheme;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Drawer as ChakraDrawer,
|
|
4
|
+
DrawerBody,
|
|
5
|
+
DrawerFooter,
|
|
6
|
+
DrawerHeader,
|
|
7
|
+
DrawerProps as ChakraDrawerProps,
|
|
8
|
+
DrawerOverlay,
|
|
9
|
+
DrawerContent,
|
|
10
|
+
DrawerCloseButton,
|
|
11
|
+
DrawerContentProps,
|
|
12
|
+
} from '@chakra-ui/react';
|
|
13
|
+
|
|
14
|
+
export interface DrawerProps
|
|
15
|
+
extends Pick<ChakraDrawerProps, 'finalFocusRef' | 'initialFocusRef' | 'isOpen' | 'onClose'> {
|
|
16
|
+
children: DrawerContentProps['children'];
|
|
17
|
+
footer?: ReactNode;
|
|
18
|
+
title: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const Drawer = (props: DrawerProps) => {
|
|
22
|
+
const { children, footer, title, ...drawerProps } = props;
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<ChakraDrawer {...drawerProps}>
|
|
26
|
+
<DrawerOverlay />
|
|
27
|
+
<DrawerContent>
|
|
28
|
+
<DrawerCloseButton />
|
|
29
|
+
<DrawerHeader as="h3">{title}</DrawerHeader>
|
|
30
|
+
<DrawerBody>{children}</DrawerBody>
|
|
31
|
+
{footer && <DrawerFooter>{footer}</DrawerFooter>}
|
|
32
|
+
</DrawerContent>
|
|
33
|
+
</ChakraDrawer>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default Drawer;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ReactNode, useState } from 'react';
|
|
2
|
+
import { DrawerProps as ChakraDrawerProps, useDisclosure } from '@chakra-ui/react';
|
|
3
|
+
import Drawer from './Drawer';
|
|
4
|
+
|
|
5
|
+
export type UseDrawerProps = {
|
|
6
|
+
content: Record<
|
|
7
|
+
string,
|
|
8
|
+
{
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
footer?: ReactNode;
|
|
11
|
+
title: string;
|
|
12
|
+
}
|
|
13
|
+
>;
|
|
14
|
+
drawerProps?: Pick<ChakraDrawerProps, 'finalFocusRef' | 'initialFocusRef'>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const useDrawer = (props: UseDrawerProps) => {
|
|
18
|
+
const { content, drawerProps } = props;
|
|
19
|
+
const [activeDrawer, setActiveDrawer] = useState<string>('');
|
|
20
|
+
|
|
21
|
+
const { isOpen, onClose, onOpen } = useDisclosure();
|
|
22
|
+
|
|
23
|
+
const closeDrawer = () => {
|
|
24
|
+
onClose();
|
|
25
|
+
setActiveDrawer('');
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const toggleDrawer = (contentKey: string) => {
|
|
29
|
+
if (!isOpen) {
|
|
30
|
+
onOpen();
|
|
31
|
+
} else if (activeDrawer === contentKey) {
|
|
32
|
+
closeDrawer();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
setActiveDrawer(contentKey);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const drawerComponent = <Drawer {...content[activeDrawer]} {...drawerProps} isOpen={isOpen} onClose={closeDrawer} />;
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
activeDrawer,
|
|
43
|
+
drawerComponent,
|
|
44
|
+
isDrawerOpen: isOpen,
|
|
45
|
+
toggleDrawer,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default useDrawer;
|
package/src/index.ts
CHANGED
|
@@ -272,3 +272,7 @@ export { default as ContentSwitcher } from './Components/ContentSwitcher/Content
|
|
|
272
272
|
|
|
273
273
|
export type { ContentSwitcherItemProps } from './Components/ContentSwitcher/ContentSwitcherItem';
|
|
274
274
|
export { default as ContentSwitcherItem } from './Components/ContentSwitcher/ContentSwitcherItem';
|
|
275
|
+
|
|
276
|
+
export type { DrawerProps } from './Components/Drawer/Drawer';
|
|
277
|
+
export { default as Drawer } from './Components/Drawer/Drawer';
|
|
278
|
+
export { default as useDrawer } from './Components/Drawer/useDrawer';
|
package/src/theme.ts
CHANGED
|
@@ -8,6 +8,7 @@ import Checkbox from './Components/Form/Checkbox/Checkbox.theme';
|
|
|
8
8
|
import ColorButton from './Components/ColorButton/ColorButton.theme';
|
|
9
9
|
import Dialog from './Components/Dialog/Dialog.theme';
|
|
10
10
|
import Divider from './Components/Divider/Divider.theme';
|
|
11
|
+
import Drawer from './Components/Drawer/Drawer.theme';
|
|
11
12
|
import EmptyState from './Components/EmptyState/EmptyState.theme';
|
|
12
13
|
import Link from './Components/Link/Link.theme';
|
|
13
14
|
import List from './Components/List/List.theme';
|
|
@@ -88,6 +89,7 @@ const theme = {
|
|
|
88
89
|
Checkbox,
|
|
89
90
|
ColorButton,
|
|
90
91
|
Divider,
|
|
92
|
+
Drawer,
|
|
91
93
|
Dropdown,
|
|
92
94
|
EmptyState,
|
|
93
95
|
...Form,
|