@bitrise/bitkit 10.4.1 → 10.5.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": "10.4.1",
4
+ "version": "10.5.1",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -31,12 +31,28 @@ export default {
31
31
  },
32
32
  } as ComponentMeta<typeof Notification>;
33
33
 
34
- export const Default: ComponentStoryFn<typeof Notification> = ({ title, description, ...args }) => (
35
- <Notification {...args}>
34
+ const Template: ComponentStoryFn<typeof Notification> = ({ title, description, ...props }) => (
35
+ <Notification {...props}>
36
36
  <NotificationTitle>{title}</NotificationTitle>
37
37
  <NotificationText>{description}</NotificationText>
38
38
  </Notification>
39
39
  );
40
+
41
+ export const Default: ComponentStoryFn<typeof Notification> = (props) => <Template {...props} />;
40
42
  Default.args = {
41
43
  action: undefined,
42
44
  };
45
+
46
+ export const WithCustomIcon: ComponentStoryFn<typeof Notification> = (props) => <Template {...props} />;
47
+ WithCustomIcon.storyName = 'With custom icon';
48
+ WithCustomIcon.args = {
49
+ action: undefined,
50
+ iconName: 'Bitbot',
51
+ };
52
+
53
+ export const WithoutIcon: ComponentStoryFn<typeof Notification> = (props) => <Template {...props} />;
54
+ WithoutIcon.storyName = 'Without icon';
55
+ WithoutIcon.args = {
56
+ action: undefined,
57
+ showIcon: false,
58
+ };
@@ -13,17 +13,17 @@ import { ColorScheme } from '@/Foundations/Colors/Colors';
13
13
  import Box from '../Box/Box';
14
14
  import CloseButton from '../CloseButton/CloseButton';
15
15
  import ColorButton, { ColorButtonProps } from '../ColorButton/ColorButton';
16
- import Icon from '../Icon/Icon';
16
+ import Icon, { TypeIconName } from '../Icon/Icon';
17
17
 
18
- const STATUSES: Record<string, { colorScheme: ColorScheme; icon: ReactNode }> = {
19
- info: { colorScheme: 'blue', icon: <Icon flexShrink={0} name="Info" /> },
20
- error: { colorScheme: 'red', icon: <Icon flexShrink={0} name="ErrorGeneral" /> },
21
- success: { colorScheme: 'green', icon: <Icon flexShrink={0} name="Tick" /> },
22
- warning: { colorScheme: 'yellow', icon: <Icon flexShrink={0} name="Warning" /> },
18
+ const STATUSES: Record<string, { colorScheme: ColorScheme; defaultIcon: ReactNode }> = {
19
+ info: { colorScheme: 'blue', defaultIcon: <Icon name="Info" /> },
20
+ error: { colorScheme: 'red', defaultIcon: <Icon name="ErrorGeneral" /> },
21
+ success: { colorScheme: 'green', defaultIcon: <Icon name="Tick" /> },
22
+ warning: { colorScheme: 'yellow', defaultIcon: <Icon name="Warning" /> },
23
23
  progress: {
24
24
  colorScheme: 'purple',
25
- icon: (
26
- <chakra.span w="24" h="24" p="2" flexShrink={0}>
25
+ defaultIcon: (
26
+ <chakra.span w="24" h="24" p="2">
27
27
  <Spinner w="100%" h="100%" />
28
28
  </chakra.span>
29
29
  ),
@@ -38,6 +38,8 @@ export interface NotificationProps extends Omit<AlertProps, 'status' | 'colorSch
38
38
  status: keyof typeof STATUSES;
39
39
  onClose?: () => void;
40
40
  action?: ActionProps;
41
+ iconName?: TypeIconName;
42
+ showIcon?: boolean;
41
43
  }
42
44
 
43
45
  const ActionContext = createContext<{ colorScheme: ColorScheme }>({ colorScheme: 'blue' });
@@ -59,8 +61,9 @@ const NotificationAction = ({ label, href, ...rest }: ActionProps) => {
59
61
  };
60
62
 
61
63
  const Notification = forwardRef<NotificationProps, 'div'>((props, ref) => {
62
- const { status, action, children, onClose, ...rest } = props;
63
- const { colorScheme, icon } = STATUSES[status];
64
+ const { status, action, children, onClose, showIcon = true, iconName, ...rest } = props;
65
+ const { colorScheme, defaultIcon } = STATUSES[status];
66
+ const icon = iconName ? <Icon name={iconName} /> : defaultIcon;
64
67
  let actionButton;
65
68
  if (action) {
66
69
  actionButton = <NotificationAction marginRight="12" {...action} alignSelf="center" />;
@@ -69,7 +72,7 @@ const Notification = forwardRef<NotificationProps, 'div'>((props, ref) => {
69
72
  return (
70
73
  <ChakraAlert ref={ref} {...rest} colorScheme={colorScheme}>
71
74
  <ActionContext.Provider value={actionContext}>
72
- {icon}
75
+ {showIcon && <Box flexShrink={0}>{icon}</Box>}
73
76
  <Box wordBreak="break-word" display="flex" flexDirection="column" flexGrow={1}>
74
77
  {children}
75
78
  </Box>
@@ -2,6 +2,8 @@ import { createContext, useContext, useMemo } from 'react';
2
2
  import { Alert as ChakraAlert, AlertProps, forwardRef } from '@chakra-ui/react';
3
3
 
4
4
  import { ColorScheme } from '@/Foundations/Colors/Colors';
5
+ import { BREAKPOINTS } from '@/Foundations/Breakpoints/Breakpoints';
6
+
5
7
  import CloseButton from '../CloseButton/CloseButton';
6
8
  import ColorButton, { ColorButtonProps } from '../ColorButton/ColorButton';
7
9
  import Icon from '../Icon/Icon';
@@ -61,9 +63,22 @@ const Ribbon = forwardRef<RibbonProps, 'div'>((props, ref) => {
61
63
  {...rest}
62
64
  >
63
65
  <ActionContext.Provider value={actionContext}>
64
- {onClose && <Box width={24} height={24} marginRight="auto" />}
65
- {children}
66
- {actionButton}
66
+ {onClose && (
67
+ <Box
68
+ display={{ [BREAKPOINTS.MOBILE]: 'none', [BREAKPOINTS.DESKTOP]: 'block' }}
69
+ width={24}
70
+ height={24}
71
+ marginEnd="auto"
72
+ />
73
+ )}
74
+ <Box
75
+ display="flex"
76
+ flexDirection={{ [BREAKPOINTS.MOBILE]: 'column', [BREAKPOINTS.DESKTOP]: 'row' }}
77
+ gap={{ [BREAKPOINTS.MOBILE]: 12, [BREAKPOINTS.DESKTOP]: 16 }}
78
+ >
79
+ {children}
80
+ {actionButton}
81
+ </Box>
67
82
  {onClose && (
68
83
  <CloseButton flexShrink={0} colorScheme={colorScheme} marginStart="auto" onClick={onClose}>
69
84
  <Icon name="CloseSmall" />
@@ -1,11 +1,11 @@
1
1
  import * as React from 'react';
2
- import Text, { Props as TextProps } from '../Text/Text';
2
+ import Text, { TextProps } from '../../Components/Text/Text';
3
3
 
4
4
  export type Props = TextProps;
5
5
 
6
6
  /** Provides specific styling for an inline input label */
7
7
  const InputInlineHelp: React.FunctionComponent<Props> = (props: Props) => {
8
- return <Text margin="x2" size="2" textColor="neutral.50" {...props} />;
8
+ return <Text marginY="8" size="2" color="neutral.50" {...props} />;
9
9
  };
10
10
 
11
11
  export default InputInlineHelp;