@bitrise/bitkit 10.2.3 → 10.3.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,9 @@
|
|
|
1
|
+
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
1
2
|
import { Story, ComponentMeta } from '@storybook/react';
|
|
2
3
|
import { useDisclosure } from '@chakra-ui/react';
|
|
3
4
|
import { sortObjectByKey } from '../../utils/storyUtils';
|
|
4
5
|
import Button from '../Button/Button';
|
|
6
|
+
import Link from '../Link/Link';
|
|
5
7
|
import Dialog, { DialogProps } from './Dialog';
|
|
6
8
|
import DialogBody from './DialogBody';
|
|
7
9
|
import DialogFooter from './DialogFooter';
|
|
@@ -11,14 +13,19 @@ export default {
|
|
|
11
13
|
component: Dialog,
|
|
12
14
|
} as ComponentMeta<typeof Dialog>;
|
|
13
15
|
|
|
14
|
-
const TextContent = () => (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
const TextContent = ({ lotsOfContent = false }: { lotsOfContent?: boolean }) => (
|
|
17
|
+
<>
|
|
18
|
+
{[...Array(lotsOfContent ? 10 : 1)].map((_key, index) => (
|
|
19
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
20
|
+
<p key={index}>
|
|
21
|
+
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a
|
|
22
|
+
galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also
|
|
23
|
+
the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the
|
|
24
|
+
release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software
|
|
25
|
+
like Aldus PageMaker including versions of Lorem Ipsum.
|
|
26
|
+
</p>
|
|
27
|
+
))}
|
|
28
|
+
</>
|
|
22
29
|
);
|
|
23
30
|
|
|
24
31
|
interface StoryType extends DialogProps {
|
|
@@ -26,18 +33,24 @@ interface StoryType extends DialogProps {
|
|
|
26
33
|
}
|
|
27
34
|
|
|
28
35
|
export const WithProps: Story<StoryType> = ({ lotsOfContent, ...props }: StoryType) => {
|
|
36
|
+
const { variant } = props;
|
|
29
37
|
const { isOpen, onClose, onOpen } = useDisclosure();
|
|
30
38
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
const getContent = () => {
|
|
40
|
+
if (variant === 'empty') {
|
|
41
|
+
return (
|
|
42
|
+
<DialogBody padding="0">
|
|
43
|
+
<TextContent lotsOfContent={lotsOfContent} />
|
|
44
|
+
<Link as="button" colorScheme="purple" onClick={onClose} marginTop="16">
|
|
45
|
+
Link or button or anything to close this Dialog with onClick
|
|
46
|
+
</Link>
|
|
47
|
+
</DialogBody>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
36
52
|
<DialogBody>
|
|
37
|
-
{
|
|
38
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
39
|
-
<TextContent key={index} />
|
|
40
|
-
))}
|
|
53
|
+
<TextContent lotsOfContent={lotsOfContent} />
|
|
41
54
|
</DialogBody>
|
|
42
55
|
<DialogFooter>
|
|
43
56
|
<Button marginRight="auto" variant="tertiary">
|
|
@@ -46,6 +59,15 @@ export const WithProps: Story<StoryType> = ({ lotsOfContent, ...props }: StoryTy
|
|
|
46
59
|
<Button variant="secondary">Secondary</Button>
|
|
47
60
|
<Button>Primary</Button>
|
|
48
61
|
</DialogFooter>
|
|
62
|
+
</>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<>
|
|
68
|
+
<Button onClick={onOpen}>Open Dialog</Button>
|
|
69
|
+
<Dialog padding={variant === 'empty' ? '16' : '0'} {...props} isOpen={isOpen} onClose={onClose}>
|
|
70
|
+
{getContent()}
|
|
49
71
|
</Dialog>
|
|
50
72
|
</>
|
|
51
73
|
);
|
|
@@ -21,6 +21,7 @@ export interface DialogProps extends Omit<HTMLChakraProps<'section'>, 'scrollBeh
|
|
|
21
21
|
scrollBehavior?: 'inside' | 'outside';
|
|
22
22
|
title: string;
|
|
23
23
|
trapFocus?: boolean;
|
|
24
|
+
variant?: 'default' | 'empty';
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
const Dialog = ({
|
|
@@ -33,6 +34,7 @@ const Dialog = ({
|
|
|
33
34
|
size,
|
|
34
35
|
title,
|
|
35
36
|
trapFocus,
|
|
37
|
+
variant,
|
|
36
38
|
...rest
|
|
37
39
|
}: DialogProps) => {
|
|
38
40
|
const dialogSize = useBreakpointValue({ [BREAKPOINTS.MOBILE]: 'mobile', [BREAKPOINTS.DESKTOP]: size });
|
|
@@ -51,14 +53,18 @@ const Dialog = ({
|
|
|
51
53
|
>
|
|
52
54
|
<ModalOverlay />
|
|
53
55
|
<ModalContent data-testid={dataTestid} {...rest}>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
{variant !== 'empty' && (
|
|
57
|
+
<>
|
|
58
|
+
<ModalHeader>
|
|
59
|
+
<Text as="h1" size="5">
|
|
60
|
+
{title}
|
|
61
|
+
</Text>
|
|
62
|
+
</ModalHeader>
|
|
63
|
+
<ModalCloseButton isDisabled={!isClosable}>
|
|
64
|
+
<Icon name="CloseSmall" />
|
|
65
|
+
</ModalCloseButton>
|
|
66
|
+
</>
|
|
67
|
+
)}
|
|
62
68
|
{children}
|
|
63
69
|
</ModalContent>
|
|
64
70
|
</Modal>
|
|
@@ -70,6 +76,7 @@ Dialog.defaultProps = {
|
|
|
70
76
|
scrollBehavior: 'outside',
|
|
71
77
|
size: 'medium',
|
|
72
78
|
trapFocus: true,
|
|
79
|
+
variant: 'default',
|
|
73
80
|
} as DialogProps;
|
|
74
81
|
|
|
75
82
|
export default Dialog;
|