@bitrise/bitkit 9.22.1 → 9.23.0-alpha-chakra.1
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 +1 -1
- package/src/Components/Badge/Badge.theme.ts +0 -1
- package/src/Components/IconButton/IconButton.stories.tsx +1 -0
- package/src/Components/IconButton/IconButton.tsx +8 -2
- package/src/Components/Menu/Menu.stories.tsx +50 -34
- package/src/Components/Menu/Menu.theme.ts +11 -0
- package/src/Components/Menu/Menu.tsx +1 -1
- package/src/Components/Menu/MenuButton.tsx +10 -0
- package/src/Components/Menu/MenuItem.tsx +20 -14
- package/src/Components/Menu/MenuList.tsx +10 -0
- package/src/Components/OverflowMenu/OverflowMenu.stories.tsx +9 -14
- package/src/Components/OverflowMenu/OverflowMenu.tsx +12 -4
- package/src/Components/OverflowMenu/OverflowMenuItem.tsx +5 -4
- package/src/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ export interface IconButtonProps extends ChakraIconButtonProps {
|
|
|
7
7
|
as?: 'a' | 'button';
|
|
8
8
|
iconName: TypeIconName;
|
|
9
9
|
isDanger?: boolean;
|
|
10
|
+
isTooltipDisabled?: boolean;
|
|
10
11
|
label?: string;
|
|
11
12
|
size?: 'small' | 'medium';
|
|
12
13
|
tooltipCloseDelay?: number;
|
|
@@ -17,7 +18,7 @@ export interface IconButtonProps extends ChakraIconButtonProps {
|
|
|
17
18
|
* IconButton composes the `Button` component except that it renders only an icon.
|
|
18
19
|
*/
|
|
19
20
|
const IconButton = forwardRef<IconButtonProps, 'button'>((props, ref) => {
|
|
20
|
-
const { as, iconName, isDanger, isDisabled, label, tooltipCloseDelay, variant, ...rest } = props;
|
|
21
|
+
const { as, iconName, isDanger, isDisabled, isTooltipDisabled, label, tooltipCloseDelay, variant, ...rest } = props;
|
|
21
22
|
const properties: ChakraIconButtonProps = {
|
|
22
23
|
as: isDisabled ? 'button' : as,
|
|
23
24
|
icon: <Icon name={iconName} />,
|
|
@@ -26,7 +27,12 @@ const IconButton = forwardRef<IconButtonProps, 'button'>((props, ref) => {
|
|
|
26
27
|
...rest,
|
|
27
28
|
};
|
|
28
29
|
return (
|
|
29
|
-
<Tooltip
|
|
30
|
+
<Tooltip
|
|
31
|
+
closeDelay={tooltipCloseDelay}
|
|
32
|
+
isDisabled={isTooltipDisabled}
|
|
33
|
+
label={label || rest['aria-label']}
|
|
34
|
+
shouldWrapChildren={isDisabled}
|
|
35
|
+
>
|
|
30
36
|
<ChakraIconButton {...properties} ref={ref} />
|
|
31
37
|
</Tooltip>
|
|
32
38
|
);
|
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { forwardRef } from '@chakra-ui/react';
|
|
3
|
+
import Badge from '../Badge/Badge';
|
|
4
|
+
import Box from '../Box/Box';
|
|
5
|
+
import Button, { ButtonProps } from '../Button/Button';
|
|
6
|
+
import ButtonGroup from '../ButtonGroup/ButtonGroup';
|
|
4
7
|
import IconButton from '../IconButton/IconButton';
|
|
8
|
+
import Link from '../Link/Link';
|
|
9
|
+
import Icon from '../Icon/Icon';
|
|
5
10
|
import Menu from './Menu';
|
|
11
|
+
import MenuButton from './MenuButton';
|
|
12
|
+
import MenuList from './MenuList';
|
|
6
13
|
import MenuItem from './MenuItem';
|
|
7
14
|
|
|
8
15
|
export default {
|
|
9
|
-
title: 'Components/Menu
|
|
16
|
+
title: 'Components/Menu',
|
|
10
17
|
component: Menu,
|
|
11
18
|
subcomponents: { MenuButton, MenuList, MenuItem },
|
|
12
19
|
} as ComponentMeta<typeof Menu>;
|
|
13
20
|
|
|
14
21
|
const List = () => (
|
|
15
22
|
<MenuList>
|
|
16
|
-
<MenuItem iconName="
|
|
17
|
-
<MenuItem
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<MenuItem iconName="
|
|
23
|
+
<MenuItem iconName="Download">Download</MenuItem>
|
|
24
|
+
<MenuItem as="a" href="#" iconName="Link">
|
|
25
|
+
As a link
|
|
26
|
+
</MenuItem>
|
|
27
|
+
<MenuItem iconName="Pencil" isDisabled>
|
|
28
|
+
Disabled
|
|
29
|
+
</MenuItem>
|
|
30
|
+
<MenuItem iconName="DeleteNope" isDanger>
|
|
31
|
+
Danger version
|
|
32
|
+
</MenuItem>
|
|
21
33
|
</MenuList>
|
|
22
34
|
);
|
|
23
35
|
|
|
@@ -28,47 +40,51 @@ export const WithButton: ComponentStory<typeof Menu> = () => (
|
|
|
28
40
|
</Menu>
|
|
29
41
|
);
|
|
30
42
|
|
|
31
|
-
export const
|
|
43
|
+
export const WithLink: ComponentStory<typeof Menu> = () => (
|
|
32
44
|
<Menu>
|
|
33
|
-
<MenuButton as={
|
|
45
|
+
<MenuButton as={Link}>Open menu</MenuButton>
|
|
34
46
|
<List />
|
|
35
47
|
</Menu>
|
|
36
48
|
);
|
|
37
49
|
|
|
38
50
|
export const WithButtonGroup: ComponentStory<typeof Menu> = () => (
|
|
39
|
-
<
|
|
51
|
+
<Box display="flex" justifyContent="flex-end">
|
|
40
52
|
<ButtonGroup isAttached>
|
|
41
53
|
<Button>Button</Button>
|
|
42
54
|
<Menu>
|
|
43
|
-
<MenuButton as={IconButton} iconName="
|
|
55
|
+
<MenuButton as={IconButton} iconName="AddonsTuorqouise" aria-label="Open menu" isTooltipDisabled />
|
|
44
56
|
<List />
|
|
45
57
|
</Menu>
|
|
46
58
|
</ButtonGroup>
|
|
47
|
-
</
|
|
59
|
+
</Box>
|
|
48
60
|
);
|
|
49
61
|
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
const TriggerButton = forwardRef<ButtonProps, 'button'>((props, ref) => (
|
|
63
|
+
<Button gap="12" ref={ref} rightIconName="DropdownArrows" variant="secondary" {...props}>
|
|
64
|
+
<span>Attempt #3</span>
|
|
65
|
+
<Badge>Latest</Badge>
|
|
66
|
+
</Button>
|
|
67
|
+
));
|
|
53
68
|
|
|
69
|
+
export const WithCustomItems: ComponentStory<typeof Menu> = () => {
|
|
54
70
|
return (
|
|
55
|
-
<
|
|
56
|
-
<
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
71
|
+
<Menu>
|
|
72
|
+
<MenuButton as={TriggerButton} />
|
|
73
|
+
<MenuList>
|
|
74
|
+
<MenuItem>
|
|
75
|
+
<Box display="flex" alignItems="center" gap="8">
|
|
76
|
+
<Icon color="green.50" name="BuildstatusSuccessful" />
|
|
77
|
+
<span>Successful</span>
|
|
78
|
+
<Badge>Latest</Badge>
|
|
79
|
+
</Box>
|
|
80
|
+
</MenuItem>
|
|
81
|
+
<MenuItem>
|
|
82
|
+
<Box display="flex" alignItems="center" gap="8">
|
|
83
|
+
<Icon color="red.50" name="BuildstatusFailed" />
|
|
84
|
+
<span>Failed</span>
|
|
85
|
+
</Box>
|
|
86
|
+
</MenuItem>
|
|
87
|
+
</MenuList>
|
|
88
|
+
</Menu>
|
|
60
89
|
);
|
|
61
90
|
};
|
|
62
|
-
|
|
63
|
-
export const WithCustomListWIP: ComponentStory<typeof Menu> = () => (
|
|
64
|
-
<Menu>
|
|
65
|
-
<MenuButton as={Button}>Actions</MenuButton>
|
|
66
|
-
<MenuList>
|
|
67
|
-
<CustomItem />
|
|
68
|
-
<MenuItem iconName="AddonsTuorqouise">Create a Copy</MenuItem>
|
|
69
|
-
<MenuItem iconName="AddonsTuorqouise">Mark as Draft</MenuItem>
|
|
70
|
-
<MenuItem iconName="AddonsTuorqouise">Delete</MenuItem>
|
|
71
|
-
<MenuItem iconName="AddonsTuorqouise">Attend a Workshop</MenuItem>
|
|
72
|
-
</MenuList>
|
|
73
|
-
</Menu>
|
|
74
|
-
);
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { SystemStyleObject } from '@chakra-ui/theme-tools';
|
|
2
2
|
|
|
3
|
+
const disabledItem: SystemStyleObject = {
|
|
4
|
+
_disabled: {
|
|
5
|
+
backgroundColor: 'neutral.100',
|
|
6
|
+
color: 'neutral.70',
|
|
7
|
+
cursor: 'not-allowed',
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
|
|
3
11
|
const MenuTheme: SystemStyleObject = {
|
|
4
12
|
baseStyle: {
|
|
5
13
|
list: {
|
|
@@ -18,10 +26,13 @@ const MenuTheme: SystemStyleObject = {
|
|
|
18
26
|
_focus: {
|
|
19
27
|
backgroundColor: 'neutral.93',
|
|
20
28
|
boxShadow: 'none',
|
|
29
|
+
...disabledItem,
|
|
21
30
|
},
|
|
22
31
|
_active: {
|
|
23
32
|
backgroundColor: 'neutral.90',
|
|
33
|
+
...disabledItem,
|
|
24
34
|
},
|
|
35
|
+
...disabledItem,
|
|
25
36
|
},
|
|
26
37
|
},
|
|
27
38
|
};
|
|
@@ -3,6 +3,6 @@ import { Menu as ChakraMenu, MenuProps as ChakraMenuProps } from '@chakra-ui/rea
|
|
|
3
3
|
|
|
4
4
|
export type MenuProps = ChakraMenuProps;
|
|
5
5
|
|
|
6
|
-
const Menu = (props: MenuProps) => <ChakraMenu {...props} />;
|
|
6
|
+
const Menu = (props: MenuProps) => <ChakraMenu matchWidth {...props} />;
|
|
7
7
|
|
|
8
8
|
export default Menu;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MenuButton as ChakraMenuButton, MenuButtonProps as ChakraMenuButtonProps, forwardRef } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
export type MenuButtonProps = ChakraMenuButtonProps;
|
|
5
|
+
|
|
6
|
+
const MenuButton = forwardRef<MenuButtonProps, 'button'>((props, ref) => {
|
|
7
|
+
return <ChakraMenuButton {...props} ref={ref} />;
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export default MenuButton;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { MenuItem as ChakraMenuItem, MenuItemProps } from '@chakra-ui/react';
|
|
2
|
+
import { MenuItem as ChakraMenuItem, MenuItemProps as ChakraMenuItemProps, forwardRef } from '@chakra-ui/react';
|
|
3
3
|
import { Icon, TypeIconName } from '@bitrise/bitkit';
|
|
4
4
|
|
|
5
5
|
const dangerStyle = {
|
|
@@ -13,22 +13,28 @@ const dangerStyle = {
|
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
iconName
|
|
16
|
+
export interface MenuItemProps extends ChakraMenuItemProps {
|
|
17
|
+
as?: 'a' | 'button';
|
|
18
|
+
iconName?: TypeIconName;
|
|
19
19
|
isDanger?: boolean;
|
|
20
|
-
|
|
21
|
-
};
|
|
20
|
+
}
|
|
22
21
|
|
|
23
|
-
const MenuItem = (props
|
|
24
|
-
const { iconName, isDanger, ...rest } = props;
|
|
25
|
-
const properties:
|
|
26
|
-
|
|
27
|
-
icon: <Icon name={iconName} />,
|
|
22
|
+
const MenuItem = forwardRef<MenuItemProps, 'button'>((props, ref) => {
|
|
23
|
+
const { as, iconName, isDanger, isDisabled, ...rest } = props;
|
|
24
|
+
const properties: ChakraMenuItemProps = {
|
|
25
|
+
as: isDisabled ? 'button' : as,
|
|
28
26
|
iconSpacing: '12',
|
|
29
|
-
|
|
27
|
+
isDisabled,
|
|
28
|
+
...rest,
|
|
30
29
|
};
|
|
31
|
-
|
|
32
|
-
}
|
|
30
|
+
if (iconName) {
|
|
31
|
+
properties.icon = <Icon name={iconName} />;
|
|
32
|
+
}
|
|
33
|
+
// There is no variant for MenuItem
|
|
34
|
+
if (isDanger) {
|
|
35
|
+
properties.sx = dangerStyle;
|
|
36
|
+
}
|
|
37
|
+
return <ChakraMenuItem {...properties} ref={ref} />;
|
|
38
|
+
});
|
|
33
39
|
|
|
34
40
|
export default MenuItem;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MenuList as ChakraMenuList, MenuListProps as ChakraMenuListProps, forwardRef } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
export type MenuListProps = ChakraMenuListProps;
|
|
5
|
+
|
|
6
|
+
const MenuList = forwardRef<MenuListProps, 'div'>((props, ref) => {
|
|
7
|
+
return <ChakraMenuList {...props} ref={ref} />;
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export default MenuList;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Flex } from '@chakra-ui/react';
|
|
2
1
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
2
|
+
import Box from '../Box/Box';
|
|
3
3
|
import OverflowMenu from './OverflowMenu';
|
|
4
4
|
import OverflowMenuItem from './OverflowMenuItem';
|
|
5
5
|
|
|
@@ -9,26 +9,21 @@ export default {
|
|
|
9
9
|
} as ComponentMeta<typeof OverflowMenu>;
|
|
10
10
|
|
|
11
11
|
export const WithProps: ComponentStory<typeof OverflowMenu> = (props) => (
|
|
12
|
-
<
|
|
12
|
+
<Box display="flex" flexDirection="column" alignItems="flex-end" minHeight="400px">
|
|
13
13
|
<OverflowMenu {...props}>
|
|
14
14
|
<OverflowMenuItem iconName="PlusAdd">Add member</OverflowMenuItem>
|
|
15
15
|
<OverflowMenuItem iconName="MinusRemove">Remove member</OverflowMenuItem>
|
|
16
|
-
<OverflowMenuItem iconName="
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
<OverflowMenuItem as="a" iconName="Link" href="#">
|
|
17
|
+
As a link
|
|
18
|
+
</OverflowMenuItem>
|
|
19
|
+
<OverflowMenuItem iconName="Pencil" isDisabled>
|
|
20
|
+
Disabled item
|
|
20
21
|
</OverflowMenuItem>
|
|
21
|
-
</OverflowMenu>
|
|
22
|
-
<OverflowMenu {...props}>
|
|
23
|
-
<OverflowMenuItem iconName="PlusAdd">Add member</OverflowMenuItem>
|
|
24
|
-
<OverflowMenuItem iconName="MinusRemove">Remove member</OverflowMenuItem>
|
|
25
|
-
<OverflowMenuItem iconName="Filter">Assign access to apps</OverflowMenuItem>
|
|
26
|
-
<OverflowMenuItem iconName="Pencil">Rename group</OverflowMenuItem>
|
|
27
22
|
<OverflowMenuItem iconName="Trash" isDanger>
|
|
28
|
-
|
|
23
|
+
Danger version
|
|
29
24
|
</OverflowMenuItem>
|
|
30
25
|
</OverflowMenu>
|
|
31
|
-
</
|
|
26
|
+
</Box>
|
|
32
27
|
);
|
|
33
28
|
WithProps.args = {
|
|
34
29
|
...OverflowMenu.defaultProps,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { MenuButton, MenuList, MenuListProps } from '@chakra-ui/react';
|
|
3
2
|
import IconButton from '../IconButton/IconButton';
|
|
4
|
-
import Menu from '../Menu/Menu';
|
|
3
|
+
import Menu, { MenuProps } from '../Menu/Menu';
|
|
4
|
+
import MenuButton from '../Menu/MenuButton';
|
|
5
|
+
import MenuList, { MenuListProps } from '../Menu/MenuList';
|
|
5
6
|
|
|
6
|
-
export interface OverflowMenuProps {
|
|
7
|
+
export interface OverflowMenuProps extends MenuProps {
|
|
7
8
|
children: MenuListProps['children'];
|
|
8
9
|
triggerLabel?: string;
|
|
9
10
|
}
|
|
@@ -11,7 +12,14 @@ export interface OverflowMenuProps {
|
|
|
11
12
|
const OverflowMenu = ({ children, triggerLabel }: OverflowMenuProps) => {
|
|
12
13
|
return (
|
|
13
14
|
<Menu isLazy>
|
|
14
|
-
<MenuButton
|
|
15
|
+
<MenuButton
|
|
16
|
+
aria-label={triggerLabel}
|
|
17
|
+
as={IconButton}
|
|
18
|
+
iconName="MoreVertical"
|
|
19
|
+
isTooltipDisabled
|
|
20
|
+
size="small"
|
|
21
|
+
variant="tertiary"
|
|
22
|
+
/>
|
|
15
23
|
<MenuList>{children}</MenuList>
|
|
16
24
|
</Menu>
|
|
17
25
|
);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { forwardRef } from '@chakra-ui/react';
|
|
3
|
+
import MenuItem, { MenuItemProps } from '../Menu/MenuItem';
|
|
3
4
|
|
|
4
5
|
export interface OverflowMenuItemProps extends MenuItemProps {
|
|
5
6
|
children: MenuItemProps['children'];
|
|
6
7
|
}
|
|
7
8
|
|
|
8
|
-
const OverflowMenuItem = (props
|
|
9
|
-
return <MenuItem {...props} />;
|
|
10
|
-
};
|
|
9
|
+
const OverflowMenuItem = forwardRef<OverflowMenuItemProps, 'button'>((props, ref) => {
|
|
10
|
+
return <MenuItem {...props} ref={ref} />;
|
|
11
|
+
});
|
|
11
12
|
|
|
12
13
|
export default OverflowMenuItem;
|