@bitrise/bitkit 9.14.2 → 9.15.0-alpha-chakra-colorbutton.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/Button/Button.stories.tsx +6 -0
- package/src/Components/ColorButton/ColorButton.stories.tsx +25 -0
- package/src/Components/ColorButton/ColorButton.theme.ts +22 -0
- package/src/Components/ColorButton/ColorButton.tsx +36 -0
- package/src/index.ts +3 -0
- package/src/old.ts +0 -6
- package/src/theme.ts +2 -0
- package/src/tsconfig.tsbuildinfo +1 -1
- package/src/Old/Button/ColorButton.css +0 -81
- package/src/Old/Button/ColorButton.test.tsx +0 -18
- package/src/Old/Button/ColorButton.tsx +0 -31
- package/src/Old/Button/__snapshots__/ColorButton.test.tsx.snap +0 -13
- package/src/Old/Progress/ProgressColorButton.tsx +0 -22
package/package.json
CHANGED
|
@@ -5,6 +5,12 @@ import Button from './Button';
|
|
|
5
5
|
export default {
|
|
6
6
|
title: 'Components/Button',
|
|
7
7
|
component: Button,
|
|
8
|
+
argTypes: {
|
|
9
|
+
as: {
|
|
10
|
+
control: 'inline-radio',
|
|
11
|
+
options: ['a', 'button'],
|
|
12
|
+
},
|
|
13
|
+
},
|
|
8
14
|
} as ComponentMeta<typeof Button>;
|
|
9
15
|
|
|
10
16
|
const Template: ComponentStory<typeof Button> = (props) => <Button {...props} />;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
2
|
+
import { sortObjectByKey } from '../../utils/storyUtils';
|
|
3
|
+
import ColorButton from './ColorButton';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Components/ColorButton',
|
|
7
|
+
component: ColorButton,
|
|
8
|
+
argTypes: {
|
|
9
|
+
as: {
|
|
10
|
+
control: 'inline-radio',
|
|
11
|
+
options: ['a', 'button'],
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
} as ComponentMeta<typeof ColorButton>;
|
|
15
|
+
|
|
16
|
+
const Template: ComponentStory<typeof ColorButton> = (props) => <ColorButton {...props} />;
|
|
17
|
+
|
|
18
|
+
export const WithProps = Template.bind({});
|
|
19
|
+
WithProps.args = sortObjectByKey({
|
|
20
|
+
...ColorButton.defaultProps,
|
|
21
|
+
children: 'ColorButton',
|
|
22
|
+
colorScheme: 'blue',
|
|
23
|
+
isDisabled: false,
|
|
24
|
+
isLoading: false,
|
|
25
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const schemeColors = {
|
|
2
|
+
default: { backgroundColor: 'inherit', color: 'inherit' },
|
|
3
|
+
blue: { backgroundColor: 'blue.93', color: 'blue.40' },
|
|
4
|
+
red: { backgroundColor: 'red.93', color: 'red.40' },
|
|
5
|
+
green: { backgroundColor: 'green.95', color: 'green.50' },
|
|
6
|
+
yellow: { backgroundColor: 'yellow.95', color: 'yellow.40' },
|
|
7
|
+
purple: { backgroundColor: 'purple.95', color: 'purple.40' },
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const ColorButtonTheme = {
|
|
11
|
+
baseStyle: ({ colorScheme: c }: { colorScheme?: 'blue' | 'red' | 'green' | 'yellow' | 'purple' }) => {
|
|
12
|
+
return {
|
|
13
|
+
display: 'inline-flex',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
justifyContent: 'center',
|
|
16
|
+
...schemeColors[c || 'default'],
|
|
17
|
+
_hover: schemeColors[c || 'default'],
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default ColorButtonTheme;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button as ChakraButton, ButtonProps as ChakraButtonProps, forwardRef, useStyleConfig } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
export interface ColorButtonProps extends ChakraButtonProps {
|
|
5
|
+
as?: 'a' | 'button';
|
|
6
|
+
colorScheme?: 'blue' | 'red' | 'green' | 'yellow' | 'purple';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The ColorButton 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.
|
|
11
|
+
*/
|
|
12
|
+
const ColorButton = forwardRef<ColorButtonProps, 'button'>((props, ref) => {
|
|
13
|
+
const { as, colorScheme, isDisabled, isLoading, ...rest } = props;
|
|
14
|
+
const styles = {
|
|
15
|
+
...useStyleConfig('Button', { size: 'small' }),
|
|
16
|
+
...useStyleConfig('ColorButton', { colorScheme }),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const properties: ChakraButtonProps = {
|
|
20
|
+
as,
|
|
21
|
+
__css: styles,
|
|
22
|
+
isDisabled,
|
|
23
|
+
isLoading,
|
|
24
|
+
...rest,
|
|
25
|
+
};
|
|
26
|
+
if (isDisabled) {
|
|
27
|
+
properties.as = 'button';
|
|
28
|
+
}
|
|
29
|
+
return <ChakraButton {...properties} size="small" ref={ref} />;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
ColorButton.defaultProps = {
|
|
33
|
+
as: 'button',
|
|
34
|
+
} as ColorButtonProps;
|
|
35
|
+
|
|
36
|
+
export default ColorButton;
|
package/src/index.ts
CHANGED
|
@@ -28,3 +28,6 @@ export { default as Card } from './Components/Card/Card';
|
|
|
28
28
|
|
|
29
29
|
export type { CardContentProps } from './Components/Card/CardContent';
|
|
30
30
|
export { default as CardContent } from './Components/Card/CardContent';
|
|
31
|
+
|
|
32
|
+
export type { ColorButtonProps } from './Components/ColorButton/ColorButton';
|
|
33
|
+
export { default as ColorButton } from './Components/ColorButton/ColorButton';
|
package/src/old.ts
CHANGED
|
@@ -52,9 +52,6 @@ export { default as Bounds } from './Old/Bounds/Bounds';
|
|
|
52
52
|
export type { Props as CheckboxProps } from './Old/Checkbox/Checkbox';
|
|
53
53
|
export { default as Checkbox } from './Old/Checkbox/Checkbox';
|
|
54
54
|
|
|
55
|
-
export type { Props as ColorButtonProps } from './Old/Button/ColorButton';
|
|
56
|
-
export { default as ColorButton } from './Old/Button/ColorButton';
|
|
57
|
-
|
|
58
55
|
export type { Props as DatePickerProps } from './Old/DatePicker/DatePicker';
|
|
59
56
|
export { default as DatePicker } from './Old/DatePicker/DatePicker';
|
|
60
57
|
|
|
@@ -168,9 +165,6 @@ export { default as ProgressBar } from './Old/Progress/ProgressBar';
|
|
|
168
165
|
export type { Props as ProgressBitbotProps } from './Old/Progress/ProgressBitbot';
|
|
169
166
|
export { default as ProgressBitbot } from './Old/Progress/ProgressBitbot';
|
|
170
167
|
|
|
171
|
-
export type { Props as ProgressColorButtonProps } from './Old/Progress/ProgressColorButton';
|
|
172
|
-
export { default as ProgressColorButton } from './Old/Progress/ProgressColorButton';
|
|
173
|
-
|
|
174
168
|
export type { Props as ProgressSpinnerProps } from './Old/Progress/ProgressSpinner';
|
|
175
169
|
export { default as ProgressSpinner } from './Old/Progress/ProgressSpinner';
|
|
176
170
|
|
package/src/theme.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Button from './Components/Button/Button.theme';
|
|
2
2
|
import Card from './Components/Card/Card.theme';
|
|
3
|
+
import ColorButton from './Components/ColorButton/ColorButton.theme';
|
|
3
4
|
import Divider from './Components/Divider/Divider.theme';
|
|
4
5
|
import Link from './Components/Link/Link.theme';
|
|
5
6
|
import Menu from './Components/Menu/Menu.theme';
|
|
@@ -47,6 +48,7 @@ const theme = {
|
|
|
47
48
|
components: {
|
|
48
49
|
Button,
|
|
49
50
|
Card,
|
|
51
|
+
ColorButton,
|
|
50
52
|
Divider,
|
|
51
53
|
Link,
|
|
52
54
|
Menu,
|