@bitrise/bitkit 9.3.0-alpha.1 → 9.3.0-alpha.4

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.3.0-alpha.1",
4
+ "version": "9.3.0-alpha.4",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "lib/cjs/index.js",
7
7
  "esnext": "lib/esn/index.js",
@@ -9,12 +9,15 @@
9
9
  } from '@bitrise/bitkit';
10
10
  import CodeBlock from '../../CodeBlock/CodeBlock';
11
11
  import Section from '../../Section/Section';
12
- import SectionSubTitle from '../../Section/SectionSubTitle';
13
12
  import Button2 from '../../../../src/Button2/Button2';
14
13
 
15
14
  const SectionButtons = () => {
16
15
  const [selectedTab, setSelectedTab] = React.useState(1);
17
16
 
17
+ const buttonRef = React.useRef<HTMLButtonElement>(null);
18
+
19
+ console.log({ buttonRef });
20
+
18
21
  return (
19
22
  <Section>
20
23
  <Tabs gap="x6" margin="x8">
@@ -35,16 +38,16 @@
35
38
  <>
36
39
  <Base margin="x12">
37
40
  <Buttons alignChildrenVertical="end" margin="x3">
38
- <Button2 size="small">Primary</Button2>
41
+ <Button2 as="a" href="https://www.bitrise.io" onClick={ (e) => console.log(e) } size="small" target="_blank">Primary</Button2>
39
42
  <Button2 disabled size="small" variant="primary">Disabled</Button2>
40
- <Button2 size="medium" variant="primary">Primary</Button2>
43
+ <Button2 size="medium" type="submit" variant="primary">Primary</Button2>
41
44
  <Button2 disabled size="medium" variant="primary">Disabled</Button2>
42
45
  </Buttons>
43
46
 
44
47
  <Buttons alignChildrenVertical="end" margin="x3">
45
- <Button2 size="small" variant="secondary">Secondary</Button2>
48
+ <Button2 onClick={ () => alert('onClick') } size="small" variant="secondary">Secondary</Button2>
46
49
  <Button2 disabled size="small" variant="secondary">Disabled</Button2>
47
- <Button2 size="medium" variant="secondary">Secondary</Button2>
50
+ <Button2 ref={ buttonRef } size="medium" variant="secondary">Secondary buttonRef</Button2>
48
51
  <Button2 disabled size="medium" variant="secondary">Disabled</Button2>
49
52
  </Buttons>
50
53
 
@@ -281,8 +281,7 @@ const SectionButtons = () => {
281
281
  text: 'Log out',
282
282
  },
283
283
  ] }>
284
- <Icon name="Bitbot" />
285
- <Text>Account</Text>
284
+ Account
286
285
  </ButtonWithDropdown>
287
286
  </Flex>
288
287
  ) }
@@ -1,29 +1,25 @@
1
1
  /* eslint-disable object-shorthand */
2
2
  import * as React from 'react';
3
- import { Button as ChakraButton, ButtonProps } from '@chakra-ui/react';
3
+ import { Button as ChakraButton, ButtonProps, forwardRef } from '@chakra-ui/react';
4
4
 
5
5
  interface Props extends Pick<ButtonProps, 'as' | 'disabled' | 'leftIcon' | 'rightIcon' |'sx'> {
6
6
  children: ButtonProps['children'];
7
- /**
8
- * Allows the Button to fill the container space rather than shrinking
9
- * down to the content
10
- */
11
- variant?: 'primary' | 'secondary' | 'tertiary' | 'dangerPrimary' | 'dangerSecondary';
12
- /**
13
- * Sets the size of the Button. Small allows the Button to fit
14
- * into smaller spaces, while large will help the button stand
15
- * out on a page with lots of space.
16
- */
7
+ href?: string;
8
+ onClick?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
9
+ ref?: any;
17
10
  size?: 'small' | 'medium';
18
- }
11
+ target?: '_blank' | '_parent' | '_self' | '_top';
12
+ type?: ButtonProps['type'];
13
+ variant?: 'primary' | 'secondary' | 'tertiary' | 'dangerPrimary' | 'dangerSecondary';
14
+ }
19
15
 
20
- const Button2 = (props: Props) => {
16
+ const Button2 = forwardRef((props: Props, ref) => {
21
17
  const defaults = {
22
18
  size: 'medium',
23
19
  variant: 'primary',
24
20
  };
25
21
  const iconSpacing = props.size === 'medium' ? '10px' : '6px';
26
- return <ChakraButton iconSpacing={ iconSpacing } { ...defaults } { ...props } />;
27
- };
22
+ return <ChakraButton iconSpacing={ iconSpacing } ref={ ref } { ...defaults } { ...props } />;
23
+ });
28
24
 
29
25
  export default Button2;
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import {
3
- Button,
4
- ButtonProps,
3
+ Button2,
5
4
  DropdownMenu,
6
5
  DropdownMenuItem,
7
6
  DropdownMenuItemProps,
@@ -12,6 +11,7 @@ import {
12
11
  PlacementReference,
13
12
  } from '@bitrise/bitkit';
14
13
 
14
+ import { ButtonProps } from '@chakra-ui/react';
15
15
  export interface ItemProps extends DropdownMenuItemProps {
16
16
  component?: string;
17
17
  disabled?: boolean;
@@ -22,7 +22,7 @@ export interface ItemProps extends DropdownMenuItemProps {
22
22
 
23
23
  export interface Props {
24
24
  buttonProps?: ButtonProps;
25
- children?: React.ReactElement | React.ReactNodeArray;
25
+ children?: React.ReactNode | undefined;
26
26
  dropdownWidth?: string;
27
27
  items: ItemProps[];
28
28
  placementProps?: PlacementProps;
@@ -41,16 +41,16 @@ const ButtonWithDropdown = ({
41
41
  <PlacementManager>
42
42
  <PlacementReference>
43
43
  { ({ ref }) => (
44
- <Button innerRef={ ref } onClick={ () => setVisible(true) } { ...buttonProps }>
44
+ /* @ts-ignore */
45
+ <Button2 onClick={ () => setVisible(!visible) } ref={ ref } rightIcon={ <Icon name="ChevronDown" /> } { ...buttonProps }>
45
46
  { children }
46
- <Icon name="ChevronDown" />
47
- </Button>
47
+ </Button2>
48
48
  ) }
49
49
  </PlacementReference>
50
50
  { !buttonProps.disabled && (
51
51
  <Placement
52
52
  disableMargin="left-right"
53
- onClose={ () => setVisible(false) }
53
+ // onClose={ () => setVisible(false) }
54
54
  placement="bottom-end"
55
55
  visible={ visible }
56
56
  { ...placementProps }>