@bitrise/bitkit 10.6.0-alpha-notification.1 → 10.6.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 +1 -1
- package/src/Components/ColorButton/ColorButton.stories.tsx +6 -1
- package/src/Components/ColorButton/ColorButton.theme.ts +14 -3
- package/src/Components/Dialog/Dialog.theme.ts +1 -1
- package/src/Foundations/Colors/Colors.ts +1 -1
- package/src/Old/Notification/Notification.css +34 -0
- package/src/Old/Notification/Notification.test.tsx +33 -0
- package/src/Old/Notification/Notification.tsx +69 -0
- package/src/Old/Notification/__snapshots__/Notification.test.tsx.snap +78 -0
- package/src/index.ts +0 -3
- package/src/old.ts +3 -0
- package/src/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -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> = (
|
|
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
|
-
|
|
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
|
|
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[
|
|
67
|
+
...schemeColors[colorScheme || 'blue'],
|
|
57
68
|
};
|
|
58
69
|
},
|
|
59
70
|
};
|
|
@@ -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
|
@@ -139,7 +139,4 @@ export { default as BreadcrumbLink } from './Components/Breadcrumb/BreadcrumbLin
|
|
|
139
139
|
export type { RibbonProps } from './Components/Ribbon/Ribbon';
|
|
140
140
|
export { default as Ribbon } from './Components/Ribbon/Ribbon';
|
|
141
141
|
|
|
142
|
-
export type { NotificationProps } from './Components/Notification/Notification';
|
|
143
|
-
export { default as Notification } from './Components/Notification/Notification';
|
|
144
|
-
|
|
145
142
|
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
|
|