@bitrise/bitkit 10.16.3 → 10.17.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": "10.16.3",
4
+ "version": "10.17.0",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -56,5 +56,8 @@ export const DefaultVariant: ComponentStory<typeof Accordion> = (props) => (
56
56
  Content - you can use any style prop on AccordionItem
57
57
  </AccordionItem>
58
58
  <AccordionItem buttonContent={<ButtonContentElement title="Without children" />} id="third" />
59
+ <AccordionItem buttonContent="Fourth, enabled element" fontSize="2" id="fourth">
60
+ Fourth, enabled element
61
+ </AccordionItem>
59
62
  </Accordion>
60
63
  );
@@ -1,5 +1,22 @@
1
1
  import type { ComponentStyleConfig } from '@chakra-ui/theme';
2
2
 
3
+ const buttonStyle = {
4
+ display: 'flex',
5
+ alignItems: 'center',
6
+ justifyContent: 'space-between',
7
+ width: '100%',
8
+ padding: '16',
9
+ borderBottom: '1px solid',
10
+ borderColor: 'neutral.93',
11
+ borderRadius: '8',
12
+ };
13
+
14
+ const iconStyle = {
15
+ width: '24',
16
+ height: '24',
17
+ marginLeft: '16',
18
+ };
19
+
3
20
  const AccordionTheme: ComponentStyleConfig = {
4
21
  baseStyle: ({ colorScheme }) => ({
5
22
  item: {
@@ -9,28 +26,29 @@ const AccordionTheme: ComponentStyleConfig = {
9
26
  boxShadow: 'small',
10
27
  marginBottom: '16',
11
28
  },
12
- button: {
13
- display: 'flex',
14
- alignItems: 'center',
15
- justifyContent: 'space-between',
16
- width: '100%',
17
- padding: '16',
29
+ enabledButton: {
30
+ ...buttonStyle,
18
31
  background: colorScheme === 'gray' ? 'neutral.95' : 'neutral.100',
19
- borderBottom: '1px solid',
20
- borderColor: 'neutral.93',
21
- borderRadius: '8',
22
- '&[type="button"]:hover': {
32
+ _hover: {
23
33
  background: 'purple.95',
24
34
  },
25
- '&[aria-expanded="true"]': {
35
+ _expanded: {
26
36
  borderBottomLeftRadius: '0',
27
37
  borderBottomRightRadius: '0',
28
38
  },
29
39
  },
30
- icon: {
31
- width: '24',
32
- height: '24',
33
- marginLeft: '16',
40
+ disabledButton: {
41
+ ...buttonStyle,
42
+ background: colorScheme === 'gray' ? 'neutral.95' : 'neutral.100',
43
+ cursor: 'default',
44
+ },
45
+ enabledIcon: {
46
+ ...iconStyle,
47
+ },
48
+ disabledIcon: {
49
+ ...iconStyle,
50
+ opacity: '0.4',
51
+ transform: 'none',
34
52
  },
35
53
  panel: {
36
54
  padding: '16',
@@ -8,7 +8,6 @@ import {
8
8
  AccordionIcon,
9
9
  useAccordionStyles,
10
10
  } from '@chakra-ui/react';
11
- import Box from '../Box/Box';
12
11
  import Text from '../Text/Text';
13
12
 
14
13
  export interface AccordionItemProps extends AccordionPanelProps {
@@ -21,14 +20,12 @@ const AccordionItem = (props: AccordionItemProps) => {
21
20
  const { buttonContent, children, id, ...rest } = props;
22
21
  const styles = useAccordionStyles();
23
22
 
24
- const ButtonComponent = children ? AccordionButton : Box;
25
-
26
23
  return (
27
24
  <ChakraAccordionItem sx={styles.item} id={id}>
28
- <ButtonComponent sx={styles.button}>
25
+ <AccordionButton sx={children ? styles.enabledButton : styles.disabledButton}>
29
26
  {isValidElement(buttonContent) ? buttonContent : <Text as="span">{buttonContent}</Text>}
30
- <AccordionIcon opacity={children ? 1 : 0.4} />
31
- </ButtonComponent>
27
+ <AccordionIcon sx={children ? styles.enabledIcon : styles.disabledIcon} />
28
+ </AccordionButton>
32
29
  {!!children && <AccordionPanel {...rest}>{children}</AccordionPanel>}
33
30
  </ChakraAccordionItem>
34
31
  );
@@ -1,13 +1,13 @@
1
1
  import { ComponentMeta, ComponentStoryFn } from '@storybook/react';
2
2
  import { action } from '@storybook/addon-actions';
3
- import Notification, { NotificationText, NotificationTitle } from './Notification';
3
+ import Link from '../Link/Link';
4
+ import Notification from './Notification';
4
5
 
5
6
  export default {
6
7
  title: 'Components/Notification',
7
8
  component: Notification,
8
9
  argTypes: {
9
- title: { type: 'string', defaultValue: 'title' },
10
- description: { type: 'string', defaultValue: 'description' },
10
+ children: { type: 'string', defaultValue: 'text' },
11
11
  action: {
12
12
  control: 'inline-radio',
13
13
  options: ['unset', 'link', 'action'],
@@ -31,12 +31,7 @@ export default {
31
31
  },
32
32
  } as ComponentMeta<typeof Notification>;
33
33
 
34
- const Template: ComponentStoryFn<typeof Notification> = ({ title, description, ...props }) => (
35
- <Notification {...props}>
36
- <NotificationTitle>{title}</NotificationTitle>
37
- <NotificationText>{description}</NotificationText>
38
- </Notification>
39
- );
34
+ const Template: ComponentStoryFn<typeof Notification> = (props) => <Notification {...props} />;
40
35
 
41
36
  export const Default: ComponentStoryFn<typeof Notification> = (props) => <Template {...props} />;
42
37
  Default.args = {
@@ -64,3 +59,26 @@ WithAction.args = {
64
59
  label: 'Upgrade',
65
60
  },
66
61
  };
62
+
63
+ export const WithActionAfterContent: ComponentStoryFn<typeof Notification> = (props) => <Template {...props} />;
64
+ WithActionAfterContent.storyName = 'With action after content';
65
+ WithActionAfterContent.args = {
66
+ action: {
67
+ label: 'Upgrade',
68
+ placement: 'after-content',
69
+ },
70
+ };
71
+
72
+ export const WithLink: ComponentStoryFn<typeof Notification> = (props) => <Template {...props} />;
73
+ WithLink.storyName = 'With link';
74
+ WithLink.args = {
75
+ children: (
76
+ <>
77
+ Unable to send build status back to your git host. Please check{' '}
78
+ <Link href="#/" isUnderlined>
79
+ our guide
80
+ </Link>
81
+ .
82
+ </>
83
+ ),
84
+ };
@@ -1,13 +1,5 @@
1
1
  import { cloneElement, createContext, ReactElement, useContext, useMemo } from 'react';
2
- import {
3
- Alert as ChakraAlert,
4
- AlertTitle as NotificationTitle,
5
- AlertProps,
6
- forwardRef,
7
- AlertDescription as NotificationText,
8
- Spinner,
9
- chakra,
10
- } from '@chakra-ui/react';
2
+ import { Alert as ChakraAlert, AlertProps, forwardRef, Spinner } from '@chakra-ui/react';
11
3
 
12
4
  import { ColorScheme } from '../../Foundations/Colors/Colors';
13
5
  import Box from '../Box/Box';
@@ -25,9 +17,9 @@ const STATUSES: Record<NotificationStatus, { colorScheme: ColorScheme; defaultIc
25
17
  progress: {
26
18
  colorScheme: 'purple',
27
19
  defaultIcon: (
28
- <chakra.span w="24" h="24" p="2">
29
- <Spinner w="100" h="100" />
30
- </chakra.span>
20
+ <Box width={24} height={24} padding={2}>
21
+ <Spinner width={20} height={20} />
22
+ </Box>
31
23
  ),
32
24
  },
33
25
  } as const;
@@ -36,6 +28,7 @@ export type ActionProps = {
36
28
  label: string;
37
29
  href?: string;
38
30
  onClick?: () => void;
31
+ placement?: 'end' | 'after-content';
39
32
  } & Omit<ColorButtonProps, 'as' | 'onClick' | 'colorScheme'>;
40
33
  export interface NotificationProps extends Omit<AlertProps, 'status' | 'colorScheme' | 'onClose'> {
41
34
  status: NotificationStatus;
@@ -70,6 +63,7 @@ const Notification = forwardRef<NotificationProps, 'div'>((props, ref) => {
70
63
  const { colorScheme, defaultIcon } = STATUSES[status];
71
64
  const icon = iconName ? <Icon name={iconName} /> : defaultIcon;
72
65
  let actionButton;
66
+ const actionPlacement = action?.placement ?? 'end';
73
67
  if (action) {
74
68
  actionButton = <NotificationAction marginRight="12" {...action} alignSelf="center" />;
75
69
  }
@@ -81,12 +75,18 @@ const Notification = forwardRef<NotificationProps, 'div'>((props, ref) => {
81
75
  <ChakraAlert ref={ref} {...rest} colorScheme={colorScheme}>
82
76
  <ActionContext.Provider value={actionContext}>
83
77
  {showIcon && cloneElement(icon, { flexShrink: 0, marginTop })}
84
- <Box wordBreak="break-word" display="flex" flexDirection="column" flexGrow={1} marginTop={marginTop}>
78
+ <Box wordBreak="break-word" flexGrow={actionPlacement === 'end' ? 1 : undefined} marginTop={marginTop}>
85
79
  {children}
86
80
  </Box>
87
81
  {actionButton}
88
82
  {onClose && (
89
- <CloseButton flexShrink={0} colorScheme={colorScheme} onClick={onClose}>
83
+ <CloseButton
84
+ flexShrink={0}
85
+ marginLeft="auto"
86
+ marginTop={marginTop}
87
+ colorScheme={colorScheme}
88
+ onClick={onClose}
89
+ >
90
90
  <Icon name="CloseSmall" />
91
91
  </CloseButton>
92
92
  )}
@@ -95,5 +95,5 @@ const Notification = forwardRef<NotificationProps, 'div'>((props, ref) => {
95
95
  );
96
96
  });
97
97
 
98
- export { NotificationTitle, NotificationText, NotificationAction };
98
+ export { NotificationAction };
99
99
  export default Notification;
@@ -1,12 +1,7 @@
1
- import { useToast as useChakraToast, UseToastOptions } from '@chakra-ui/react';
1
+ import { useToast as useChakraToast, UseToastOptions, AlertTitle, AlertDescription } from '@chakra-ui/react';
2
2
  import { DateTime } from 'luxon';
3
- import Notification, {
4
- ActionProps,
5
- NotificationAction,
6
- NotificationProps,
7
- NotificationText,
8
- NotificationTitle,
9
- } from '../Notification/Notification';
3
+ import Box from '../Box/Box';
4
+ import Notification, { ActionProps, NotificationAction, NotificationProps } from '../Notification/Notification';
10
5
 
11
6
  export interface ToastOptions {
12
7
  title: string;
@@ -37,10 +32,12 @@ const useToast = () => {
37
32
  status={opts.status}
38
33
  onClose={opts.isClosable ? onClose : undefined}
39
34
  >
40
- <NotificationTitle>{opts.title}</NotificationTitle>
41
- <NotificationText>{opts.description}</NotificationText>
42
- {!opts.action && timestamp && <NotificationText marginTop="8">{timestamp}</NotificationText>}
43
- {opts.action && <NotificationAction alignSelf="start" marginTop="8" marginBottom="4" {...opts.action} />}
35
+ <Box display="flex" flexDirection="column">
36
+ <AlertTitle>{opts.title}</AlertTitle>
37
+ <AlertDescription>{opts.description}</AlertDescription>
38
+ {!opts.action && timestamp && <AlertDescription marginTop="8">{timestamp}</AlertDescription>}
39
+ {opts.action && <NotificationAction alignSelf="start" marginTop="8" marginBottom="4" {...opts.action} />}
40
+ </Box>
44
41
  </Notification>
45
42
  ),
46
43
  });