@bitrise/bitkit 10.6.0-alpha-notification.1 → 10.8.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.6.0-alpha-notification.1",
4
+ "version": "10.8.0",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -1,5 +1,6 @@
1
1
  import { ComponentStory, ComponentMeta } from '@storybook/react';
2
2
  import { sortObjectByKey } from '../../utils/storyUtils';
3
+ import Box from '../Box/Box';
3
4
  import ColorButton from './ColorButton';
4
5
 
5
6
  export default {
@@ -13,7 +14,11 @@ export default {
13
14
  },
14
15
  } as ComponentMeta<typeof ColorButton>;
15
16
 
16
- const Template: ComponentStory<typeof ColorButton> = (props) => <ColorButton {...props} />;
17
+ const Template: ComponentStory<typeof ColorButton> = ({ colorScheme, ...props }) => (
18
+ <Box padding={16} backgroundColor={colorScheme === 'neutral' ? 'black' : undefined}>
19
+ <ColorButton colorScheme={colorScheme} {...props} />
20
+ </Box>
21
+ );
17
22
 
18
23
  export const WithProps = Template.bind({});
19
24
  WithProps.args = sortObjectByKey({
@@ -1,4 +1,6 @@
1
- const schemeColors = {
1
+ import { ColorScheme } from '../../Foundations/Colors/Colors';
2
+
3
+ const schemeColors: Record<ColorScheme, any> = {
2
4
  blue: {
3
5
  color: 'blue.40',
4
6
  _active: {
@@ -44,16 +46,25 @@ const schemeColors = {
44
46
  backgroundColor: 'purple.93',
45
47
  },
46
48
  },
49
+ neutral: {
50
+ color: 'neutral.100',
51
+ _active: {
52
+ backgroundColor: 'rgba(255, 255, 255, 0.3)',
53
+ },
54
+ _hover: {
55
+ backgroundColor: 'rgba(255, 255, 255, 0.15)',
56
+ },
57
+ },
47
58
  };
48
59
 
49
60
  const ColorButtonTheme = {
50
- baseStyle: ({ colorScheme: c }: { colorScheme?: 'blue' | 'red' | 'green' | 'yellow' | 'purple' }) => {
61
+ baseStyle: ({ colorScheme }: { colorScheme?: ColorScheme }) => {
51
62
  return {
52
63
  display: 'inline-flex',
53
64
  alignItems: 'center',
54
65
  justifyContent: 'center',
55
66
  backgroundColor: 'transparent',
56
- ...schemeColors[c || 'blue'],
67
+ ...schemeColors[colorScheme || 'blue'],
57
68
  };
58
69
  },
59
70
  };
@@ -36,7 +36,7 @@ const DialogTheme: ComponentStyleConfig = {
36
36
  body: {
37
37
  flex: 1,
38
38
  paddingX: '32',
39
- overflow: 'auto',
39
+ overflow: scrollBehavior === 'inside' ? 'auto' : undefined,
40
40
  },
41
41
  footer: {
42
42
  display: 'flex',
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { Icon, IconProps, forwardRef } from '@chakra-ui/react';
3
+
4
+ const StepstatusNext = forwardRef<IconProps, 'svg'>((props, ref) => (
5
+ <Icon ref={ref} viewBox="0 0 16 16" {...props}>
6
+ <path
7
+ fillRule="evenodd"
8
+ clipRule="evenodd"
9
+ d="M12 1.07026C10.8233 0.389577 9.45715 0 8 0C3.58172 0 0 3.58172 0 8C0 12.4183 3.58172 16 8 16C12.4183 16 16 12.4183 16 8C16 5.97111 15.2447 4.11862 14 2.70835V3V4H13.3338C14.1707 5.11421 14.6667 6.49919 14.6667 8C14.6667 11.6819 11.6819 14.6667 8 14.6667L8 8L8 1.33333C9.50081 1.33333 10.8858 1.82926 12 2.66618V1.07026Z"
10
+ fill="currentColor"
11
+ />
12
+ </Icon>
13
+ ));
14
+
15
+ export default StepstatusNext;
@@ -158,6 +158,7 @@ export { default as StepsTuorqouise } from './StepsTuorqouise';
158
158
  export { default as StepsViolet } from './StepsViolet';
159
159
  export { default as StepsWhite } from './StepsWhite';
160
160
  export { default as Steps } from './Steps';
161
+ export { default as StepstatusNext } from './StepstatusNext';
161
162
  export { default as StepstatusSkip } from './StepstatusSkip';
162
163
  export { default as StepstatusWarning } from './StepstatusWarning';
163
164
  export { default as Stopwatch } from './Stopwatch';
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { Icon, IconProps, forwardRef } from '@chakra-ui/react';
3
+
4
+ const StepstatusNext = forwardRef<IconProps, 'svg'>((props, ref) => (
5
+ <Icon ref={ref} viewBox="0 0 24 24" {...props}>
6
+ <path
7
+ fillRule="evenodd"
8
+ clipRule="evenodd"
9
+ d="M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12V0Zm2 21.8v2.034a11.966 11.966 0 0 0 6.276-3.144l-1.415-1.415A9.974 9.974 0 0 1 14 21.8Zm6.175-4.04 1.432 1.432A11.937 11.937 0 0 0 23.959 13H21.95a9.945 9.945 0 0 1-1.776 4.76ZM21.951 11a9.942 9.942 0 0 0-1.677-4.617l1.436-1.436A11.936 11.936 0 0 1 23.959 11H21.95Zm-1.552-7.57-1.414 1.414A9.977 9.977 0 0 0 14 2.2V.166a11.968 11.968 0 0 1 6.4 3.263Z"
10
+ fill="currentColor"
11
+ />
12
+ </Icon>
13
+ ));
14
+
15
+ export default StepstatusNext;
@@ -158,6 +158,7 @@ export { default as StepsTuorqouise } from './StepsTuorqouise';
158
158
  export { default as StepsViolet } from './StepsViolet';
159
159
  export { default as StepsWhite } from './StepsWhite';
160
160
  export { default as Steps } from './Steps';
161
+ export { default as StepstatusNext } from './StepstatusNext';
161
162
  export { default as StepstatusSkip } from './StepstatusSkip';
162
163
  export { default as StepstatusWarning } from './StepstatusWarning';
163
164
  export { default as Stopwatch } from './Stopwatch';
@@ -0,0 +1,7 @@
1
+ import { PopoverArrowProps as ChakraPopoverArrowProps, PopoverArrow as ChakraPopoverArrow } from '@chakra-ui/react';
2
+
3
+ export type PopoverArrowProps = ChakraPopoverArrowProps;
4
+
5
+ const PopoverArrow = (props: PopoverArrowProps) => <ChakraPopoverArrow {...props} />;
6
+
7
+ export default PopoverArrow;
@@ -127,6 +127,6 @@ const colors = {
127
127
 
128
128
  export type Colors = typeof colors;
129
129
 
130
- export type ColorScheme = 'blue' | 'red' | 'green' | 'yellow' | 'purple';
130
+ export type ColorScheme = 'blue' | 'red' | 'green' | 'yellow' | 'purple' | 'neutral';
131
131
 
132
132
  export default colors;
@@ -0,0 +1,34 @@
1
+ .Notification {
2
+ border: 0.0625rem solid transparent;
3
+ border-radius: var(--size--x2);
4
+ }
5
+
6
+ .Notification--type-alert {
7
+ border-color: var(--color-red--3);
8
+ background-color: var(--color-red--1);
9
+ color: var(--color-red--4);
10
+ }
11
+
12
+ .Notification--type-inform {
13
+ border-color: var(--color-blue--2);
14
+ background-color: var(--color-blue--1);
15
+ color: var(--color-blue--4);
16
+ }
17
+
18
+ .Notification--type-progress {
19
+ border-color: var(--color-grape--2);
20
+ background-color: var(--color-grape--1);
21
+ color: var(--color-eggplant);
22
+ }
23
+
24
+ .Notification--type-success {
25
+ border-color: var(--color-green--2);
26
+ background-color: var(--color-green--1);
27
+ color: var(--color-green--5);
28
+ }
29
+
30
+ .Notification--type-warning {
31
+ border-color: var(--color-yellow--3);
32
+ background-color: var(--color-yellow--1);
33
+ color: var(--color-yellow--5);
34
+ }
@@ -0,0 +1,33 @@
1
+ import { shallow } from 'enzyme';
2
+ import { shallowToJson } from 'enzyme-to-json';
3
+ import Notification from './Notification';
4
+
5
+ describe('Notification', () => {
6
+ test('default template', () => {
7
+ expect(shallowToJson(shallow(<Notification type="alert">Content</Notification>))).toMatchSnapshot();
8
+ });
9
+
10
+ test('default icon can be overridden', () => {
11
+ expect(
12
+ shallowToJson(
13
+ shallow(
14
+ <Notification icon="Bell" type="alert">
15
+ Content
16
+ </Notification>,
17
+ ),
18
+ ),
19
+ ).toMatchSnapshot();
20
+ });
21
+
22
+ test('with onRemove has a close icon', () => {
23
+ expect(
24
+ shallowToJson(
25
+ shallow(
26
+ <Notification onRemove={() => {}} type="alert">
27
+ Content
28
+ </Notification>,
29
+ ),
30
+ ),
31
+ ).toMatchSnapshot();
32
+ });
33
+ });
@@ -0,0 +1,69 @@
1
+ import * as React from 'react';
2
+ import classnames from 'classnames';
3
+ import Flex, { Props as FlexProps } from '../Flex/Flex';
4
+ import Icon, { TypeIconName } from '../../Components/Icon/Icon';
5
+ import Link from '../../Components/Link/Link';
6
+ import ProgressSpinner from '../Progress/ProgressSpinner';
7
+ import './Notification.css';
8
+
9
+ type TypeNotificationType = 'alert' | 'inform' | 'progress' | 'success' | 'warning';
10
+
11
+ export interface Props extends FlexProps {
12
+ /**
13
+ * A callback to remove the notification, that when provided will
14
+ * render a clickable cross, that when clicked will call the given
15
+ * function.
16
+ */
17
+ onRemove?: (e: React.SyntheticEvent) => void;
18
+ /**
19
+ * Name of one of the Bitkit icons that will accompany the message
20
+ * of the notification. By default, some of the notification
21
+ * types have icons, but these can be overridden.
22
+ */
23
+ icon?: TypeIconName;
24
+ /**
25
+ * The type of the notification that affects the styling and content.
26
+ */
27
+ type: TypeNotificationType;
28
+ }
29
+
30
+ const defaultIcons: {
31
+ [key: string]: TypeIconName;
32
+ } = {
33
+ alert: 'ErrorGeneral',
34
+ success: 'Tick',
35
+ warning: 'Warning',
36
+ };
37
+
38
+ /**
39
+ * Notification component used to inform the user of something important.
40
+ */
41
+ const Notification: React.FunctionComponent<Props> = (props: Props) => {
42
+ const { children, onRemove, type, icon, className, ...rest } = props;
43
+
44
+ const classes = classnames('Notification', `Notification--type-${type}`, className);
45
+ const defaultIcon = defaultIcons[type];
46
+
47
+ return (
48
+ <Flex {...rest} alignChildrenVertical="middle" className={classes} direction="horizontal" gap="x2" padding="x3">
49
+ {(icon || defaultIcon || type === 'progress') && (
50
+ <Flex>{type === 'progress' ? <ProgressSpinner /> : <Icon name={icon || defaultIcon} />}</Flex>
51
+ )}
52
+
53
+ <Flex grow shrink>
54
+ {children}
55
+ </Flex>
56
+
57
+ {onRemove && (
58
+ <Flex>
59
+ {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
60
+ <Link as="button" onClick={onRemove}>
61
+ <Icon name="CloseSmall" />
62
+ </Link>
63
+ </Flex>
64
+ )}
65
+ </Flex>
66
+ );
67
+ };
68
+
69
+ export default Notification;
@@ -0,0 +1,78 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Notification default icon can be overridden 1`] = `
4
+ <Flex
5
+ alignChildrenVertical="middle"
6
+ className="Notification Notification--type-alert"
7
+ direction="horizontal"
8
+ gap="x2"
9
+ padding="x3"
10
+ >
11
+ <Flex>
12
+ <ForwardRef
13
+ name="Bell"
14
+ />
15
+ </Flex>
16
+ <Flex
17
+ grow={true}
18
+ shrink={true}
19
+ >
20
+ Content
21
+ </Flex>
22
+ </Flex>
23
+ `;
24
+
25
+ exports[`Notification default template 1`] = `
26
+ <Flex
27
+ alignChildrenVertical="middle"
28
+ className="Notification Notification--type-alert"
29
+ direction="horizontal"
30
+ gap="x2"
31
+ padding="x3"
32
+ >
33
+ <Flex>
34
+ <ForwardRef
35
+ name="ErrorGeneral"
36
+ />
37
+ </Flex>
38
+ <Flex
39
+ grow={true}
40
+ shrink={true}
41
+ >
42
+ Content
43
+ </Flex>
44
+ </Flex>
45
+ `;
46
+
47
+ exports[`Notification with onRemove has a close icon 1`] = `
48
+ <Flex
49
+ alignChildrenVertical="middle"
50
+ className="Notification Notification--type-alert"
51
+ direction="horizontal"
52
+ gap="x2"
53
+ padding="x3"
54
+ >
55
+ <Flex>
56
+ <ForwardRef
57
+ name="ErrorGeneral"
58
+ />
59
+ </Flex>
60
+ <Flex
61
+ grow={true}
62
+ shrink={true}
63
+ >
64
+ Content
65
+ </Flex>
66
+ <Flex>
67
+ <ForwardRef
68
+ as="button"
69
+ isUnderlined={false}
70
+ onClick={[Function]}
71
+ >
72
+ <ForwardRef
73
+ name="CloseSmall"
74
+ />
75
+ </ForwardRef>
76
+ </Flex>
77
+ </Flex>
78
+ `;
package/src/index.ts CHANGED
@@ -106,6 +106,9 @@ export { default as PopoverTrigger } from './Components/Popover/PopoverTrigger';
106
106
  export type { PopoverContentProps } from './Components/Popover/PopoverContent';
107
107
  export { default as PopoverContent } from './Components/Popover/PopoverContent';
108
108
 
109
+ export type { PopoverArrowProps } from './Components/Popover/PopoverArrow';
110
+ export { default as PopoverArrow } from './Components/Popover/PopoverArrow';
111
+
109
112
  export type { AvatarProps } from './Components/Avatar/Avatar';
110
113
  export { default as Avatar } from './Components/Avatar/Avatar';
111
114
 
@@ -139,7 +142,4 @@ export { default as BreadcrumbLink } from './Components/Breadcrumb/BreadcrumbLin
139
142
  export type { RibbonProps } from './Components/Ribbon/Ribbon';
140
143
  export { default as Ribbon } from './Components/Ribbon/Ribbon';
141
144
 
142
- export type { NotificationProps } from './Components/Notification/Notification';
143
- export { default as Notification } from './Components/Notification/Notification';
144
-
145
145
  export { BREAKPOINTS } from './Foundations/Breakpoints/Breakpoints';
package/src/old.ts CHANGED
@@ -54,6 +54,9 @@ export { default as InputLabel } from './Old/Input/InputLabel';
54
54
  export type { Props as LogoProps } from './Old/Logo/Logo';
55
55
  export { default as Logo } from './Old/Logo/Logo';
56
56
 
57
+ export type { Props as NotificationProps } from './Old/Notification/Notification';
58
+ export { default as Notification } from './Old/Notification/Notification';
59
+
57
60
  export type { Props as ProgressBarProps } from './Old/Progress/ProgressBar';
58
61
  export { default as ProgressBar } from './Old/Progress/ProgressBar';
59
62