@bitrise/bitkit 9.26.3 → 9.27.0

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit",
3
3
  "description": "Bitrise React component library",
4
- "version": "9.26.3",
4
+ "version": "9.27.0",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -0,0 +1,56 @@
1
+ import { Story, ComponentMeta } from '@storybook/react';
2
+ import Button from '../Button/Button';
3
+ import Dialog, { DialogProps, useDialog } from './Dialog';
4
+ import DialogBody from './DialogBody';
5
+ import DialogFooter from './DialogFooter';
6
+
7
+ export default {
8
+ title: 'Components/Dialog',
9
+ component: Dialog,
10
+ } as ComponentMeta<typeof Dialog>;
11
+
12
+ const TextContent = () => (
13
+ <p>
14
+ Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley
15
+ of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap
16
+ into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of
17
+ Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus
18
+ PageMaker including versions of Lorem Ipsum.
19
+ </p>
20
+ );
21
+
22
+ interface StoryType extends DialogProps {
23
+ lotsOfContent: boolean;
24
+ }
25
+
26
+ export const WithProps: Story<StoryType> = ({ lotsOfContent, ...props }: StoryType) => {
27
+ const state = useDialog();
28
+
29
+ return (
30
+ <>
31
+ <Button onClick={state.onOpen}>Open Dialog</Button>
32
+
33
+ <Dialog {...props} state={state}>
34
+ <DialogBody>
35
+ {[...Array(lotsOfContent ? 10 : 1)].map((_key, index) => (
36
+ // eslint-disable-next-line react/no-array-index-key
37
+ <TextContent key={index} />
38
+ ))}
39
+ </DialogBody>
40
+ <DialogFooter>
41
+ <Button marginRight="auto" variant="tertiary">
42
+ Tertiary
43
+ </Button>
44
+ <Button variant="secondary">Secondary</Button>
45
+ <Button>Primary</Button>
46
+ </DialogFooter>
47
+ </Dialog>
48
+ </>
49
+ );
50
+ };
51
+
52
+ WithProps.args = {
53
+ ...Dialog.defaultProps,
54
+ title: 'Title',
55
+ lotsOfContent: false,
56
+ };
@@ -0,0 +1,74 @@
1
+ import type { SystemStyleObject } from '@chakra-ui/theme-tools';
2
+
3
+ const DialogTheme: SystemStyleObject = {
4
+ baseStyle: {
5
+ overlay: {
6
+ backgroundColor: 'rgba(0, 0, 0, .5)',
7
+ },
8
+ dialogContainer: {
9
+ display: 'flex',
10
+ justifyContent: 'center',
11
+ alignItems: 'flex-start',
12
+ overflow: 'auto',
13
+ },
14
+ dialog: {
15
+ borderRadius: '8',
16
+ backgroundColor: 'neutral.100',
17
+ boxShadow: 'large',
18
+ marginY: '128',
19
+ },
20
+ header: {
21
+ padding: '24',
22
+ paddingLeft: '30',
23
+ },
24
+ closeButton: {
25
+ position: 'absolute',
26
+ top: '22',
27
+ right: '22',
28
+ width: '40',
29
+ height: '40',
30
+ padding: '8',
31
+ borderRadius: '8',
32
+ },
33
+ body: {
34
+ flex: 1,
35
+ paddingX: '32',
36
+ },
37
+ footer: {
38
+ display: 'flex',
39
+ justifyContent: 'end',
40
+ gap: '16',
41
+ padding: '32',
42
+ paddingTop: '48',
43
+ },
44
+ },
45
+ sizes: {
46
+ small: {
47
+ dialog: {
48
+ maxWidth: '30rem',
49
+ },
50
+ },
51
+ medium: {
52
+ dialog: {
53
+ maxWidth: '40rem',
54
+ },
55
+ },
56
+ large: {
57
+ dialog: {
58
+ maxWidth: '50rem',
59
+ },
60
+ },
61
+ full: {
62
+ dialog: {
63
+ maxW: '100vw',
64
+ minH: '100vh',
65
+ '@supports(min-height: -webkit-fill-available)': {
66
+ minH: '-webkit-fill-available',
67
+ },
68
+ borderRadius: 0,
69
+ },
70
+ },
71
+ },
72
+ };
73
+
74
+ export default DialogTheme;
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ import {
3
+ Modal,
4
+ ModalOverlay,
5
+ ModalContent,
6
+ ModalCloseButton,
7
+ ModalHeader,
8
+ useBreakpointValue,
9
+ useDisclosure,
10
+ } from '@chakra-ui/react';
11
+ import Icon from '../Icon/Icon';
12
+ import Text from '../Text/Text';
13
+
14
+ type DialogState = {
15
+ isOpen: boolean;
16
+ onClose(): void;
17
+ onOpen(): void;
18
+ };
19
+
20
+ export const useDialog = (): DialogState => {
21
+ const { isOpen, onOpen, onClose } = useDisclosure();
22
+ return {
23
+ isOpen,
24
+ onClose,
25
+ onOpen,
26
+ };
27
+ };
28
+ export interface DialogProps {
29
+ children: React.ReactNode;
30
+ size?: 'small' | 'medium' | 'large';
31
+ state: DialogState;
32
+ title: string;
33
+ }
34
+
35
+ const Dialog = ({ children, state, size, title }: DialogProps) => {
36
+ const dialogSize = useBreakpointValue({ mobile: 'full', desktop: size });
37
+ return (
38
+ <Modal closeOnOverlayClick={false} isOpen={state.isOpen} onClose={state.onClose} size={dialogSize}>
39
+ <ModalOverlay />
40
+ <ModalContent>
41
+ <ModalHeader>
42
+ <Text as="h1" size="5">
43
+ {title}
44
+ </Text>
45
+ </ModalHeader>
46
+ <ModalCloseButton>
47
+ <Icon name="CloseSmall" />
48
+ </ModalCloseButton>
49
+ {children}
50
+ </ModalContent>
51
+ </Modal>
52
+ );
53
+ };
54
+
55
+ Dialog.defaultProps = {
56
+ size: 'medium',
57
+ } as DialogProps;
58
+
59
+ export default Dialog;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { ModalBody, ModalBodyProps } from '@chakra-ui/react';
3
+
4
+ export type DialogBodyProps = ModalBodyProps;
5
+
6
+ const DialogBody = (props: DialogBodyProps) => {
7
+ return <ModalBody {...props} />;
8
+ };
9
+
10
+ export default DialogBody;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { ModalFooter, ModalFooterProps } from '@chakra-ui/react';
3
+
4
+ export type DialogFooterProps = ModalFooterProps;
5
+
6
+ const DialogFooter = (props: DialogFooterProps) => {
7
+ return <ModalFooter {...props} />;
8
+ };
9
+
10
+ export default DialogFooter;
package/src/index.ts CHANGED
@@ -85,3 +85,13 @@ export { default as useToast } from './Components/Toast/Toast';
85
85
 
86
86
  export type { EmptyStateProps } from './Components/EmptyState/EmptyState';
87
87
  export { default as EmptyState } from './Components/EmptyState/EmptyState';
88
+
89
+ export type { DialogProps } from './Components/Dialog/Dialog';
90
+ export { default as Dialog } from './Components/Dialog/Dialog';
91
+ export { useDialog } from './Components/Dialog/Dialog';
92
+
93
+ export type { DialogBodyProps } from './Components/Dialog/DialogBody';
94
+ export { default as DialogBody } from './Components/Dialog/DialogBody';
95
+
96
+ export type { DialogFooterProps } from './Components/Dialog/DialogFooter';
97
+ export { default as DialogFooter } from './Components/Dialog/DialogFooter';
package/src/theme.ts CHANGED
@@ -2,6 +2,7 @@ import Badge from './Components/Badge/Badge.theme';
2
2
  import Button from './Components/Button/Button.theme';
3
3
  import Card from './Components/Card/Card.theme';
4
4
  import ColorButton from './Components/ColorButton/ColorButton.theme';
5
+ import Dialog from './Components/Dialog/Dialog.theme';
5
6
  import Divider from './Components/Divider/Divider.theme';
6
7
  import EmptyState from './Components/EmptyState/EmptyState.theme';
7
8
  import Link from './Components/Link/Link.theme';
@@ -63,6 +64,7 @@ const theme = {
63
64
  EmptyState,
64
65
  Link,
65
66
  Menu,
67
+ Modal: Dialog,
66
68
  Select,
67
69
  Tabs,
68
70
  Text,