@bitrise/bitkit 9.19.2 → 9.20.0-alpha-chakra.3
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/Button/Button.stories.tsx +1 -0
- package/src/Components/Button/Button.tsx +14 -3
- package/src/Components/Menu/Menu.stories.tsx +6 -3
- package/src/Components/OverflowMenu/OverflowMenu.tsx +4 -2
- package/src/tsconfig.tsbuildinfo +1 -1
- package/src/Components/IconButton/IconButton.stories.tsx +0 -19
- package/src/Components/IconButton/IconButton.tsx +0 -37
package/package.json
CHANGED
|
@@ -4,7 +4,9 @@ import Icon, { TypeIconName } from '../Icon/Icon';
|
|
|
4
4
|
|
|
5
5
|
export interface ButtonProps extends ChakraButtonProps {
|
|
6
6
|
as?: 'a' | 'button';
|
|
7
|
+
children: React.ReactChild | React.ReactFragment;
|
|
7
8
|
isDanger?: boolean;
|
|
9
|
+
isIconOnly?: boolean;
|
|
8
10
|
leftIconName?: TypeIconName;
|
|
9
11
|
rightIconName?: TypeIconName;
|
|
10
12
|
size?: 'small' | 'medium';
|
|
@@ -15,7 +17,7 @@ export interface ButtonProps extends ChakraButtonProps {
|
|
|
15
17
|
* The Button component is used to trigger an action or event, such as submitting a form, opening a dialog, canceling an action, or performing a delete operation.
|
|
16
18
|
*/
|
|
17
19
|
const Button = forwardRef<ButtonProps, 'button'>((props, ref) => {
|
|
18
|
-
const { as, isDanger, isDisabled, leftIconName, rightIconName, size, variant, ...rest } = props;
|
|
20
|
+
const { as, children, isDanger, isDisabled, isIconOnly, leftIconName, rightIconName, size, variant, ...rest } = props;
|
|
19
21
|
const properties: ChakraButtonProps = {
|
|
20
22
|
as,
|
|
21
23
|
isDisabled,
|
|
@@ -27,14 +29,23 @@ const Button = forwardRef<ButtonProps, 'button'>((props, ref) => {
|
|
|
27
29
|
properties.as = 'button';
|
|
28
30
|
}
|
|
29
31
|
if (leftIconName) {
|
|
30
|
-
properties.leftIcon = <Icon name={leftIconName} />;
|
|
32
|
+
properties.leftIcon = <Icon name={leftIconName} size={size === 'medium' ? '24' : '16'} />;
|
|
31
33
|
}
|
|
32
34
|
if (rightIconName) {
|
|
33
|
-
properties.rightIcon = <Icon name={rightIconName} />;
|
|
35
|
+
properties.rightIcon = <Icon name={rightIconName} size={size === 'medium' ? '24' : '16'} />;
|
|
34
36
|
}
|
|
35
37
|
if ((properties.leftIcon || properties.rightIcon) && !properties.iconSpacing) {
|
|
36
38
|
properties.iconSpacing = size === 'medium' ? '0.625rem' : '0.375rem';
|
|
37
39
|
}
|
|
40
|
+
if (isIconOnly) {
|
|
41
|
+
properties['aria-label'] = children.toString();
|
|
42
|
+
properties.iconSpacing = 0;
|
|
43
|
+
properties.padding = 0;
|
|
44
|
+
// TODO: Use Tooltip later for this:
|
|
45
|
+
// properties.title = children.toString();
|
|
46
|
+
} else {
|
|
47
|
+
properties.children = children;
|
|
48
|
+
}
|
|
38
49
|
|
|
39
50
|
return <ChakraButton {...properties} ref={ref} />;
|
|
40
51
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
2
2
|
import { Box, ButtonGroup, HStack, MenuButton, MenuList, useMenuItem, useStyleConfig } from '@chakra-ui/react';
|
|
3
3
|
import Button from '../Button/Button';
|
|
4
|
-
import IconButton from '../IconButton/IconButton';
|
|
5
4
|
import Menu from './Menu';
|
|
6
5
|
import MenuItem from './MenuItem';
|
|
7
6
|
|
|
@@ -30,7 +29,9 @@ export const WithButton: ComponentStory<typeof Menu> = () => (
|
|
|
30
29
|
|
|
31
30
|
export const WithIconButton: ComponentStory<typeof Menu> = () => (
|
|
32
31
|
<Menu>
|
|
33
|
-
<MenuButton as={
|
|
32
|
+
<MenuButton as={Button} isIconOnly leftIconName="AddonsTuorqouise">
|
|
33
|
+
Open menu
|
|
34
|
+
</MenuButton>
|
|
34
35
|
<List />
|
|
35
36
|
</Menu>
|
|
36
37
|
);
|
|
@@ -40,7 +41,9 @@ export const WithButtonGroup: ComponentStory<typeof Menu> = () => (
|
|
|
40
41
|
<ButtonGroup isAttached>
|
|
41
42
|
<Button>Button</Button>
|
|
42
43
|
<Menu>
|
|
43
|
-
<MenuButton as={
|
|
44
|
+
<MenuButton as={Button} isIconOnly leftIconName="AddonsTuorqouise">
|
|
45
|
+
Open menu
|
|
46
|
+
</MenuButton>
|
|
44
47
|
<List />
|
|
45
48
|
</Menu>
|
|
46
49
|
</ButtonGroup>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { MenuButton, MenuList, MenuListProps } from '@chakra-ui/react';
|
|
3
|
-
import
|
|
3
|
+
import Button from '../Button/Button';
|
|
4
4
|
import Menu from '../Menu/Menu';
|
|
5
5
|
|
|
6
6
|
export interface OverflowMenuProps {
|
|
@@ -11,7 +11,9 @@ export interface OverflowMenuProps {
|
|
|
11
11
|
const OverflowMenu = ({ children, triggerLabel }: OverflowMenuProps) => {
|
|
12
12
|
return (
|
|
13
13
|
<Menu isLazy>
|
|
14
|
-
<MenuButton
|
|
14
|
+
<MenuButton as={Button} leftIconName="MoreVertical" isIconOnly size="small" variant="tertiary">
|
|
15
|
+
{triggerLabel}
|
|
16
|
+
</MenuButton>
|
|
15
17
|
<MenuList>{children}</MenuList>
|
|
16
18
|
</Menu>
|
|
17
19
|
);
|