@bitrise/bitkit 9.20.0-alpha-chakra.3 → 9.20.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 +1 -1
- package/src/Components/Button/Button.stories.tsx +0 -1
- package/src/Components/Button/Button.tsx +5 -18
- package/src/Components/IconButton/IconButton.stories.tsx +26 -0
- package/src/Components/IconButton/IconButton.tsx +37 -0
- package/src/Components/Icons/16x16/BuildstatusLoadingAnimated.tsx +2 -2
- package/src/Components/Icons/24x24/BuildstatusLoadingAnimated.tsx +2 -2
- package/src/Components/Menu/Menu.stories.tsx +3 -6
- package/src/Components/OverflowMenu/OverflowMenu.tsx +2 -4
- package/src/Old/Icon/tsx/IconsBuildstatusLoadingAnimated.tsx +2 -2
- package/src/index.ts +3 -0
- package/src/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -4,9 +4,7 @@ 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;
|
|
8
7
|
isDanger?: boolean;
|
|
9
|
-
isIconOnly?: boolean;
|
|
10
8
|
leftIconName?: TypeIconName;
|
|
11
9
|
rightIconName?: TypeIconName;
|
|
12
10
|
size?: 'small' | 'medium';
|
|
@@ -17,35 +15,24 @@ export interface ButtonProps extends ChakraButtonProps {
|
|
|
17
15
|
* 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.
|
|
18
16
|
*/
|
|
19
17
|
const Button = forwardRef<ButtonProps, 'button'>((props, ref) => {
|
|
20
|
-
const { as,
|
|
18
|
+
const { as, isDanger, isDisabled, leftIconName, rightIconName, size = 'medium', variant, ...rest } = props;
|
|
21
19
|
const properties: ChakraButtonProps = {
|
|
22
|
-
as,
|
|
20
|
+
as: isDisabled ? 'button' : as,
|
|
23
21
|
isDisabled,
|
|
24
22
|
size,
|
|
25
23
|
variant: isDanger ? `${variant}--danger` : variant,
|
|
26
24
|
...rest,
|
|
27
25
|
};
|
|
28
|
-
|
|
29
|
-
properties.as = 'button';
|
|
30
|
-
}
|
|
26
|
+
const iconSize = size === 'medium' ? '24' : '16';
|
|
31
27
|
if (leftIconName) {
|
|
32
|
-
properties.leftIcon = <Icon name={leftIconName} size={
|
|
28
|
+
properties.leftIcon = <Icon name={leftIconName} size={iconSize} />;
|
|
33
29
|
}
|
|
34
30
|
if (rightIconName) {
|
|
35
|
-
properties.rightIcon = <Icon name={rightIconName} size={
|
|
31
|
+
properties.rightIcon = <Icon name={rightIconName} size={iconSize} />;
|
|
36
32
|
}
|
|
37
33
|
if ((properties.leftIcon || properties.rightIcon) && !properties.iconSpacing) {
|
|
38
34
|
properties.iconSpacing = size === 'medium' ? '0.625rem' : '0.375rem';
|
|
39
35
|
}
|
|
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
|
-
}
|
|
49
36
|
|
|
50
37
|
return <ChakraButton {...properties} ref={ref} />;
|
|
51
38
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
2
|
+
import { sortObjectByKey } from '../../utils/storyUtils';
|
|
3
|
+
import IconButton from './IconButton';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Components/IconButton',
|
|
7
|
+
component: IconButton,
|
|
8
|
+
argTypes: {
|
|
9
|
+
as: {
|
|
10
|
+
control: 'inline-radio',
|
|
11
|
+
options: ['a', 'button'],
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
} as ComponentMeta<typeof IconButton>;
|
|
15
|
+
|
|
16
|
+
const Template: ComponentStory<typeof IconButton> = (props) => <IconButton {...props} />;
|
|
17
|
+
|
|
18
|
+
export const WithProps = Template.bind({});
|
|
19
|
+
WithProps.args = sortObjectByKey({
|
|
20
|
+
...IconButton.defaultProps,
|
|
21
|
+
'aria-label': 'This is the label',
|
|
22
|
+
iconName: 'Bitbot',
|
|
23
|
+
isDanger: false,
|
|
24
|
+
isDisabled: false,
|
|
25
|
+
isLoading: false,
|
|
26
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IconButton as ChakraIconButton, IconButtonProps as ChakraIconButtonProps, forwardRef } from '@chakra-ui/react';
|
|
3
|
+
import Icon, { TypeIconName } from '../Icon/Icon';
|
|
4
|
+
|
|
5
|
+
export interface IconButtonProps extends ChakraIconButtonProps {
|
|
6
|
+
as?: 'a' | 'button';
|
|
7
|
+
iconName: TypeIconName;
|
|
8
|
+
isDanger?: boolean;
|
|
9
|
+
label?: string;
|
|
10
|
+
size?: 'small' | 'medium';
|
|
11
|
+
variant?: 'primary' | 'secondary' | 'tertiary';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* IconButton composes the `Button` component except that it renders only an icon.
|
|
16
|
+
*/
|
|
17
|
+
const IconButton = forwardRef<IconButtonProps, 'button'>((props, ref) => {
|
|
18
|
+
const { as, iconName, isDanger, isDisabled, label, variant, ...rest } = props;
|
|
19
|
+
const properties: ChakraIconButtonProps = {
|
|
20
|
+
as: isDisabled ? 'button' : as,
|
|
21
|
+
icon: <Icon name={iconName} />,
|
|
22
|
+
isDisabled,
|
|
23
|
+
// TODO: Use Tooltip
|
|
24
|
+
title: label || rest['aria-label'],
|
|
25
|
+
variant: isDanger ? `${variant}--danger` : variant,
|
|
26
|
+
...rest,
|
|
27
|
+
};
|
|
28
|
+
return <ChakraIconButton {...properties} ref={ref} />;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
IconButton.defaultProps = {
|
|
32
|
+
as: 'button',
|
|
33
|
+
size: 'medium',
|
|
34
|
+
variant: 'primary',
|
|
35
|
+
} as IconButtonProps;
|
|
36
|
+
|
|
37
|
+
export default IconButton;
|
|
@@ -4,7 +4,7 @@ import { Icon, IconProps, forwardRef } from '@chakra-ui/react';
|
|
|
4
4
|
const BuildstatusLoadingAnimated = forwardRef<IconProps, 'svg'>((props, ref) => (
|
|
5
5
|
<Icon ref={ref} viewBox="0 0 16 16" {...props}>
|
|
6
6
|
<circle cx={8} cy={8} r={7} stroke="currentColor" strokeWidth={1.1} strokeDasharray={48} fill="none">
|
|
7
|
-
<animate attributeName="stroke-dashoffset" from={
|
|
7
|
+
<animate attributeName="stroke-dashoffset" from={96} to={0} dur="3.5s" repeatCount="indefinite" />
|
|
8
8
|
<animateTransform
|
|
9
9
|
attributeName="transform"
|
|
10
10
|
type="rotate"
|
|
@@ -15,7 +15,7 @@ const BuildstatusLoadingAnimated = forwardRef<IconProps, 'svg'>((props, ref) =>
|
|
|
15
15
|
/>
|
|
16
16
|
</circle>
|
|
17
17
|
<circle cx={8} cy={8} r={4} stroke="currentColor" strokeWidth={1.1} strokeDasharray={48} fill="none">
|
|
18
|
-
<animate attributeName="stroke-dashoffset" from={
|
|
18
|
+
<animate attributeName="stroke-dashoffset" from={96} to={0} dur="3.5s" repeatCount="indefinite" />
|
|
19
19
|
<animateTransform
|
|
20
20
|
attributeName="transform"
|
|
21
21
|
type="rotate"
|
|
@@ -4,7 +4,7 @@ import { Icon, IconProps, forwardRef } from '@chakra-ui/react';
|
|
|
4
4
|
const BuildstatusLoadingAnimated = forwardRef<IconProps, 'svg'>((props, ref) => (
|
|
5
5
|
<Icon ref={ref} viewBox="0 0 24 24" {...props}>
|
|
6
6
|
<circle cx={12} cy={12} r={11} stroke="currentColor" strokeWidth={2} strokeDasharray={48} fill="none">
|
|
7
|
-
<animate attributeName="stroke-dashoffset" from={
|
|
7
|
+
<animate attributeName="stroke-dashoffset" from={96} to={0} dur="3.5s" repeatCount="indefinite" />
|
|
8
8
|
<animateTransform
|
|
9
9
|
attributeName="transform"
|
|
10
10
|
type="rotate"
|
|
@@ -15,7 +15,7 @@ const BuildstatusLoadingAnimated = forwardRef<IconProps, 'svg'>((props, ref) =>
|
|
|
15
15
|
/>
|
|
16
16
|
</circle>
|
|
17
17
|
<circle cx={12} cy={12} r={6} stroke="currentColor" strokeWidth={2} strokeDasharray={48} fill="none">
|
|
18
|
-
<animate attributeName="stroke-dashoffset" from={
|
|
18
|
+
<animate attributeName="stroke-dashoffset" from={96} to={0} dur="3.5s" repeatCount="indefinite" />
|
|
19
19
|
<animateTransform
|
|
20
20
|
attributeName="transform"
|
|
21
21
|
type="rotate"
|
|
@@ -1,6 +1,7 @@
|
|
|
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';
|
|
4
5
|
import Menu from './Menu';
|
|
5
6
|
import MenuItem from './MenuItem';
|
|
6
7
|
|
|
@@ -29,9 +30,7 @@ export const WithButton: ComponentStory<typeof Menu> = () => (
|
|
|
29
30
|
|
|
30
31
|
export const WithIconButton: ComponentStory<typeof Menu> = () => (
|
|
31
32
|
<Menu>
|
|
32
|
-
<MenuButton as={
|
|
33
|
-
Open menu
|
|
34
|
-
</MenuButton>
|
|
33
|
+
<MenuButton as={IconButton} iconName="AddOnsColorTuorqouise" aria-label="Open menu" />
|
|
35
34
|
<List />
|
|
36
35
|
</Menu>
|
|
37
36
|
);
|
|
@@ -41,9 +40,7 @@ export const WithButtonGroup: ComponentStory<typeof Menu> = () => (
|
|
|
41
40
|
<ButtonGroup isAttached>
|
|
42
41
|
<Button>Button</Button>
|
|
43
42
|
<Menu>
|
|
44
|
-
<MenuButton as={
|
|
45
|
-
Open menu
|
|
46
|
-
</MenuButton>
|
|
43
|
+
<MenuButton as={IconButton} iconName="AddOnsColorTuorqouise" aria-label="Open menu" />
|
|
47
44
|
<List />
|
|
48
45
|
</Menu>
|
|
49
46
|
</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 IconButton from '../IconButton/IconButton';
|
|
4
4
|
import Menu from '../Menu/Menu';
|
|
5
5
|
|
|
6
6
|
export interface OverflowMenuProps {
|
|
@@ -11,9 +11,7 @@ export interface OverflowMenuProps {
|
|
|
11
11
|
const OverflowMenu = ({ children, triggerLabel }: OverflowMenuProps) => {
|
|
12
12
|
return (
|
|
13
13
|
<Menu isLazy>
|
|
14
|
-
<MenuButton as={
|
|
15
|
-
{triggerLabel}
|
|
16
|
-
</MenuButton>
|
|
14
|
+
<MenuButton aria-label={triggerLabel} as={IconButton} iconName="MoreVertical" size="small" variant="tertiary" />
|
|
17
15
|
<MenuList>{children}</MenuList>
|
|
18
16
|
</Menu>
|
|
19
17
|
);
|
|
@@ -4,7 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
const SvgIconsBuildstatusLoadingAnimated = (props: React.SVGProps<SVGSVGElement>) => (
|
|
5
5
|
<svg {...props} fill="none" viewBox="0 0 24 24">
|
|
6
6
|
<circle cx={12} cy={12} r={11} stroke="currentColor" strokeWidth={2} strokeDasharray={48}>
|
|
7
|
-
<animate attributeName="stroke-dashoffset" from={
|
|
7
|
+
<animate attributeName="stroke-dashoffset" from={96} to={0} dur="3.5s" repeatCount="indefinite" />
|
|
8
8
|
<animateTransform
|
|
9
9
|
attributeName="transform"
|
|
10
10
|
type="rotate"
|
|
@@ -15,7 +15,7 @@ const SvgIconsBuildstatusLoadingAnimated = (props: React.SVGProps<SVGSVGElement>
|
|
|
15
15
|
/>
|
|
16
16
|
</circle>
|
|
17
17
|
<circle cx={12} cy={12} r={6} stroke="currentColor" strokeWidth={2} strokeDasharray={48}>
|
|
18
|
-
<animate attributeName="stroke-dashoffset" from={
|
|
18
|
+
<animate attributeName="stroke-dashoffset" from={96} to={0} dur="3.5s" repeatCount="indefinite" />
|
|
19
19
|
<animateTransform
|
|
20
20
|
attributeName="transform"
|
|
21
21
|
type="rotate"
|
package/src/index.ts
CHANGED
|
@@ -59,3 +59,6 @@ export { default as TabPanel } from './Components/Tabs/TabPanel';
|
|
|
59
59
|
|
|
60
60
|
export type { BadgeProps } from './Components/Badge/Badge';
|
|
61
61
|
export { default as Badge } from './Components/Badge/Badge';
|
|
62
|
+
|
|
63
|
+
export type { IconButtonProps } from './Components/IconButton/IconButton';
|
|
64
|
+
export { default as IconButton } from './Components/IconButton/IconButton';
|