@bitrise/bitkit 9.9.0-alpha-link-release.1 → 9.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit",
3
3
  "description": "Bitrise React component library",
4
- "version": "9.9.0-alpha-link-release.1",
4
+ "version": "9.11.0",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -15,7 +15,4 @@ WithProps.args = sortObjectByKey({
15
15
  children: 'Button',
16
16
  isDanger: false,
17
17
  isDisabled: false,
18
- href: '#',
19
- target: '_self',
20
- type: 'button',
21
18
  });
@@ -1,34 +1,23 @@
1
- import React, { forwardRef, HTMLAttributeAnchorTarget } from 'react';
1
+ import React, { HTMLAttributeAnchorTarget } from 'react';
2
2
  import { Button as ChakraButton, ButtonProps as ChackraButtonProps } from '@chakra-ui/react';
3
3
  import Icon from '../../Old/Icon/Icon';
4
4
  import { TypeIconName } from '../../Old/Icon/tsx';
5
5
 
6
- export interface LinkProps extends ChackraButtonProps {
7
- as: 'a';
8
- target?: HTMLAttributeAnchorTarget;
9
- }
10
-
11
6
  export interface ButtonProps extends ChackraButtonProps {
12
- as?: 'button';
13
- }
14
-
15
- export type Props = {
16
- children: string;
17
- className?: string;
7
+ as?: 'a' | 'button';
8
+ href?: string;
18
9
  isDanger?: boolean;
19
- isDisabled?: boolean;
20
10
  leftIconName?: TypeIconName;
21
- onClick?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
22
- ref?: ChackraButtonProps['itemRef'];
23
11
  rightIconName?: TypeIconName;
24
12
  size?: 'small' | 'medium';
13
+ target?: HTMLAttributeAnchorTarget;
25
14
  variant?: 'primary' | 'secondary' | 'tertiary';
26
- } & (LinkProps | ButtonProps);
15
+ }
27
16
 
28
17
  /**
29
18
  * 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.
30
19
  */
31
- const Button = forwardRef<HTMLButtonElement, Props>((props: Props, ref) => {
20
+ const Button = (props: ButtonProps) => {
32
21
  const { as, isDanger, leftIconName, rightIconName, size, variant, ...rest } = props;
33
22
  const properties: ChackraButtonProps = {
34
23
  as,
@@ -42,18 +31,17 @@ const Button = forwardRef<HTMLButtonElement, Props>((props: Props, ref) => {
42
31
  if (rightIconName) {
43
32
  properties.rightIcon = <Icon name={rightIconName} />;
44
33
  }
45
- if (leftIconName || rightIconName) {
34
+ if ((properties.leftIcon || properties.rightIcon) && !properties.iconSpacing) {
46
35
  properties.iconSpacing = size === 'medium' ? '0.625rem' : '0.375rem';
47
36
  }
48
37
 
49
- return <ChakraButton ref={ref} {...properties} />;
50
- });
38
+ return <ChakraButton {...properties} />;
39
+ };
51
40
 
52
41
  Button.defaultProps = {
53
- // eslint-disable-next-line react/default-props-match-prop-types
54
42
  as: 'button',
55
43
  size: 'medium',
56
44
  variant: 'primary',
57
- };
45
+ } as ButtonProps;
58
46
 
59
47
  export default Button;
@@ -1,3 +1,4 @@
1
+ /* eslint-disable jsx-a11y/anchor-is-valid */
1
2
  import { ComponentStory, ComponentMeta } from '@storybook/react';
2
3
  import { sortObjectByKey } from '../../utils/storyUtils';
3
4
  import Text from '../Text/Text';
@@ -12,13 +13,12 @@ const args = sortObjectByKey({
12
13
  ...Link.defaultProps,
13
14
  children: 'The quick brown fox jumps over the lazy dog.',
14
15
  href: '#',
15
- target: '_self',
16
16
  });
17
17
 
18
- export const WithProps: ComponentStory<typeof Link> = ({ ...props }) => <Link {...props} />;
18
+ export const WithProps: ComponentStory<typeof Link> = (props) => <Link {...props} />;
19
19
  WithProps.args = args;
20
20
 
21
- export const InsideText: ComponentStory<typeof Link> = ({ ...props }) => (
21
+ export const InsideText: ComponentStory<typeof Link> = (props) => (
22
22
  <Text size="2">
23
23
  This is a text with link: <Link {...props} />
24
24
  <br />
@@ -1,15 +1,25 @@
1
1
  import { textSizes } from '../../Foundations/Typography/Typography';
2
2
 
3
+ const schemeColors = {
4
+ purple: { color: 'purple.50', hover: 'purple.30' },
5
+ white: { color: 'neutral.100', hover: 'neutral.95' },
6
+ gray: { color: 'neutral.70', hover: 'neutral.50' },
7
+ default: { color: 'inherit', hover: 'inherit' },
8
+ };
9
+
3
10
  const LinkTheme = {
4
- baseStyle: {
5
- color: 'text.link',
6
- fontSize: 'inherit',
7
- _focus: {
8
- outline: 'none',
9
- },
10
- _hover: {
11
- color: 'text.linkHover',
12
- },
11
+ baseStyle: ({ colorScheme: c }: { colorScheme?: 'purple' | 'white' | 'gray' }) => {
12
+ const { color, hover } = schemeColors[c || 'default'];
13
+ return {
14
+ color,
15
+ fontSize: 'inherit',
16
+ _focus: {
17
+ outline: 'none',
18
+ },
19
+ _hover: {
20
+ color: hover,
21
+ },
22
+ };
13
23
  },
14
24
  ...textSizes,
15
25
  };
@@ -1,28 +1,32 @@
1
- import React, { HTMLAttributeAnchorTarget } from 'react';
1
+ import React from 'react';
2
2
  import { Link as ChakraLink, LinkProps as ChakraLinkProps } from '@chakra-ui/react';
3
3
  import { TextSizes } from '../../Foundations/Typography/Typography';
4
4
 
5
5
  export interface LinkProps extends ChakraLinkProps {
6
+ as?: 'a' | 'button';
7
+ colorScheme?: 'purple' | 'white' | 'gray';
6
8
  isUnderlined?: boolean;
7
9
  size?: TextSizes;
8
- target?: HTMLAttributeAnchorTarget;
9
10
  }
10
11
 
11
12
  /**
12
- * Links are accessible elements used primarily for navigation. This component is styled to resemble a hyperlink and semantically renders an `<a>`
13
+ * Links are accessible elements used primarily for navigation.
13
14
  */
14
15
  const Link = (props: LinkProps) => {
15
- const { isUnderlined, ...rest } = props;
16
- const properties: ChakraLinkProps = { ...rest };
17
- properties.as = 'a';
16
+ const { as, isUnderlined, ...rest } = props;
17
+ const properties: ChakraLinkProps = { as, ...rest };
18
18
  if (isUnderlined) {
19
19
  properties.textDecoration = 'underline';
20
20
  }
21
+ if (as === 'button') {
22
+ properties.type = 'button';
23
+ }
21
24
  return <ChakraLink {...properties} />;
22
25
  };
23
26
 
24
27
  Link.defaultProps = {
25
- isUnderlined: true,
28
+ as: 'a',
29
+ isUnderlined: false,
26
30
  } as LinkProps;
27
31
 
28
32
  export default Link;
@@ -50,7 +50,6 @@ import Coffee from './IconsCoffee';
50
50
  import Console from './IconsConsole';
51
51
  import Credit from './IconsCredit';
52
52
  import Creditcard from './IconsCreditcard';
53
- import Crown from './IconsCrown';
54
53
  import DeleteNope from './IconsDeleteNope';
55
54
  import Deployment from './IconsDeployment';
56
55
  import Doc from './IconsDoc';
@@ -224,7 +223,6 @@ export type TypeIconName =
224
223
  | 'Console'
225
224
  | 'Credit'
226
225
  | 'Creditcard'
227
- | 'Crown'
228
226
  | 'DeleteNope'
229
227
  | 'Deployment'
230
228
  | 'Doc'
@@ -398,7 +396,6 @@ export const IconList: TypeIconName[] = [
398
396
  'Console',
399
397
  'Credit',
400
398
  'Creditcard',
401
- 'Crown',
402
399
  'DeleteNope',
403
400
  'Deployment',
404
401
  'Doc',
@@ -575,7 +572,6 @@ export const IconMap: {
575
572
  Console,
576
573
  Credit,
577
574
  Creditcard,
578
- Crown,
579
575
  DeleteNope,
580
576
  Deployment,
581
577
  Doc,
package/src/theme.ts CHANGED
@@ -34,6 +34,9 @@ const theme = {
34
34
  hr: {
35
35
  borderTopWidth: 0,
36
36
  },
37
+ a: {
38
+ textDecoration: 'none',
39
+ },
37
40
  '*:focus-visible': {
38
41
  boxShadow: 'outline',
39
42
  outline: 'none',