@bitrise/bitkit 9.18.1 → 9.20.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit",
3
3
  "description": "Bitrise React component library",
4
- "version": "9.18.1",
4
+ "version": "9.20.0-alpha-chakra.1",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -0,0 +1,13 @@
1
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
2
+ import Badge from './Badge';
3
+
4
+ export default {
5
+ title: 'Components/Badge',
6
+ component: Badge,
7
+ } as ComponentMeta<typeof Badge>;
8
+
9
+ export const WithProps: ComponentStory<typeof Badge> = (props) => <Badge {...props} />;
10
+ WithProps.args = {
11
+ children: 'Coming soon',
12
+ ...Badge.defaultProps,
13
+ };
@@ -0,0 +1,15 @@
1
+ const BadgeTheme = {
2
+ baseStyle: {
3
+ display: 'inline-block',
4
+ paddingX: '8',
5
+ paddingY: '3',
6
+ fontSize: '1',
7
+ lineHeight: '1',
8
+ fontWeight: 'bold',
9
+ textTransform: 'uppercase',
10
+ borderRadius: '4',
11
+ cursor: 'default',
12
+ },
13
+ };
14
+
15
+ export default BadgeTheme;
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { Badge as ChakraBadge, BadgeProps as ChakraBadgeProps } from '@chakra-ui/react';
3
+
4
+ export type BadgeProps = ChakraBadgeProps;
5
+
6
+ /**
7
+ * Badges are used to highlight an item's status for quick recognition.
8
+ */
9
+ const Badge = (props: BadgeProps) => {
10
+ return <ChakraBadge {...props} />;
11
+ };
12
+
13
+ Badge.defaultProps = {
14
+ color: 'neutral.100',
15
+ backgroundColor: 'purple.40',
16
+ } as BadgeProps;
17
+
18
+ export default Badge;
@@ -21,5 +21,6 @@ WithProps.args = sortObjectByKey({
21
21
  children: 'Button',
22
22
  isDanger: false,
23
23
  isDisabled: false,
24
+ isIconOnly: false,
24
25
  isLoading: false,
25
26
  });
@@ -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: string;
7
8
  isDanger?: boolean;
9
+ isIconOnly?: boolean;
8
10
  leftIconName?: TypeIconName;
9
11
  rightIconName?: TypeIconName;
10
12
  size?: 'small' | 'medium';
@@ -15,17 +17,14 @@ 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
- as,
22
+ as: isDisabled ? 'button' : as,
21
23
  isDisabled,
22
24
  size,
23
25
  variant: isDanger ? `${variant}--danger` : variant,
24
26
  ...rest,
25
27
  };
26
- if (isDisabled) {
27
- properties.as = 'button';
28
- }
29
28
  if (leftIconName) {
30
29
  properties.leftIcon = <Icon name={leftIconName} />;
31
30
  }
@@ -35,6 +34,15 @@ const Button = forwardRef<ButtonProps, 'button'>((props, ref) => {
35
34
  if ((properties.leftIcon || properties.rightIcon) && !properties.iconSpacing) {
36
35
  properties.iconSpacing = size === 'medium' ? '0.625rem' : '0.375rem';
37
36
  }
37
+ if (isIconOnly) {
38
+ properties['aria-label'] = children;
39
+ properties.iconSpacing = 0;
40
+ properties.padding = 0;
41
+ // TODO: Use Tooltip later for this:
42
+ properties.title = children;
43
+ } else {
44
+ properties.children = children;
45
+ }
38
46
 
39
47
  return <ChakraButton {...properties} ref={ref} />;
40
48
  });
@@ -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={IconButton} iconName="AddOnsColorTuorqouise" aria-label="Open menu" />
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={IconButton} iconName="AddOnsColorTuorqouise" aria-label="Open menu" />
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 IconButton from '../IconButton/IconButton';
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 aria-label={triggerLabel} as={IconButton} iconName="MoreVertical" size="small" variant="tertiary" />
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
  );
@@ -2,7 +2,6 @@ import * as React from 'react';
2
2
  import { TypeIconName } from '../Icon/tsx';
3
3
  import Flex, { Props as FlexProps } from '../Flex/Flex';
4
4
  import Hamburger from '../Hamburger/Hamburger';
5
- import Badge from '../Badge/Badge';
6
5
  import Icon from '../Icon/Icon';
7
6
  import Link from '../Link/Link';
8
7
  import Image from '../Image/Image';
@@ -83,14 +82,6 @@ const AddonBeam: React.FunctionComponent<Props> = (props: Props) => {
83
82
  by Bitrise
84
83
  </Text>
85
84
  </Flex>
86
-
87
- {isBeta && (
88
- <Flex>
89
- <Badge backgroundColor="yellow.80" textColor="purple.10">
90
- BETA
91
- </Badge>
92
- </Flex>
93
- )}
94
85
  </Flex>
95
86
 
96
87
  {!isInResponsiveView && appName && (
package/src/index.ts CHANGED
@@ -56,3 +56,6 @@ export { default as TabPanels } from './Components/Tabs/TabPanels';
56
56
 
57
57
  export type { TabPanelProps } from './Components/Tabs/TabPanel';
58
58
  export { default as TabPanel } from './Components/Tabs/TabPanel';
59
+
60
+ export type { BadgeProps } from './Components/Badge/Badge';
61
+ export { default as Badge } from './Components/Badge/Badge';
package/src/old.ts CHANGED
@@ -37,9 +37,6 @@ export { default as AppLayoutSidebar } from './Old/AppLayout/AppLayoutSidebar';
37
37
  export type { Props as AvatarProps } from './Old/Avatar/Avatar';
38
38
  export { default as Avatar } from './Old/Avatar/Avatar';
39
39
 
40
- export type { Props as BadgeProps } from './Old/Badge/Badge';
41
- export { default as Badge } from './Old/Badge/Badge';
42
-
43
40
  export type { Props as BaseProps } from './Old/Base/Base';
44
41
  export type { TypeBorderRadius } from './Old/Base/Base';
45
42
  export type { TypeColors } from './Old/Base/Base';
package/src/theme.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import Badge from './Components/Badge/Badge.theme';
1
2
  import Button from './Components/Button/Button.theme';
2
3
  import Card from './Components/Card/Card.theme';
3
4
  import ColorButton from './Components/ColorButton/ColorButton.theme';
@@ -47,6 +48,7 @@ const theme = {
47
48
  },
48
49
  },
49
50
  components: {
51
+ Badge,
50
52
  Button,
51
53
  Card,
52
54
  ColorButton,