@bitrise/bitkit 9.15.0-alpha-chakra.1 → 9.15.0-alpha-chakra.2

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,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit",
3
3
  "description": "Bitrise React component library",
4
- "version": "9.15.0-alpha-chakra.1",
4
+ "version": "9.15.0-alpha-chakra.2",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -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/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';
@@ -48,6 +49,7 @@ const theme = {
48
49
  components: {
49
50
  Button,
50
51
  Card,
52
+ ColorButton,
51
53
  Divider,
52
54
  Link,
53
55
  Menu,