@livechat/design-system-react-components 1.0.0-alpha.2 → 1.0.0-alpha.4
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/.eslintrc +9 -0
- package/.storybook/main.js +20 -0
- package/.storybook/preview-head.html +31 -0
- package/.storybook/preview.js +21 -0
- package/package.json +40 -37
- package/src/components/Alert/Alert.module.scss +88 -0
- package/src/components/Alert/Alert.spec.tsx +78 -0
- package/src/components/Alert/Alert.stories.tsx +73 -0
- package/src/components/Alert/Alert.tsx +94 -0
- package/src/components/Alert/index.ts +1 -0
- package/src/components/Badge/Badge.module.scss +23 -0
- package/src/components/Badge/Badge.spec.tsx +12 -0
- package/src/components/Badge/Badge.stories.tsx +24 -0
- package/src/components/Badge/Badge.tsx +24 -0
- package/src/components/Badge/index.ts +1 -0
- package/src/components/Button/Button.module.scss +257 -0
- package/src/components/Button/Button.spec.tsx +110 -0
- package/src/components/Button/Button.stories.tsx +152 -0
- package/src/components/Button/Button.tsx +88 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/ButtonGroup/ButtonGroup.module.scss +31 -0
- package/src/components/ButtonGroup/ButtonGroup.spec.tsx +61 -0
- package/src/components/ButtonGroup/ButtonGroup.stories.tsx +53 -0
- package/src/components/ButtonGroup/ButtonGroup.tsx +75 -0
- package/src/components/ButtonGroup/index.ts +1 -0
- package/src/components/Card/Card.module.scss +31 -0
- package/src/components/Card/Card.spec.tsx +38 -0
- package/src/components/Card/Card.stories.tsx +30 -0
- package/src/components/Card/Card.tsx +34 -0
- package/src/components/Card/index.ts +2 -0
- package/src/components/Checkbox/Checkbox.module.scss +99 -0
- package/src/components/Checkbox/Checkbox.tsx +39 -0
- package/src/components/Checkbox/CheckboxField.spec.tsx +58 -0
- package/src/components/Checkbox/CheckboxField.stories.tsx +30 -0
- package/src/components/Checkbox/CheckboxField.tsx +46 -0
- package/src/components/Checkbox/index.ts +2 -0
- package/src/components/FieldDescription/FieldDescription.module.scss +5 -0
- package/src/components/FieldDescription/FieldDescription.tsx +23 -0
- package/src/components/FieldDescription/index.ts +1 -0
- package/src/components/FieldError/FieldError.module.scss +5 -0
- package/src/components/FieldError/FieldError.tsx +23 -0
- package/src/components/FieldError/index.ts +1 -0
- package/src/components/FieldGroup/FieldGroup.module.scss +25 -0
- package/src/components/FieldGroup/FieldGroup.spec.tsx +42 -0
- package/src/components/FieldGroup/FieldGroup.stories.tsx +34 -0
- package/src/components/FieldGroup/FieldGroup.tsx +38 -0
- package/src/components/FieldGroup/index.ts +1 -0
- package/src/components/Form/Form.module.scss +22 -0
- package/src/components/Form/Form.spec.tsx +38 -0
- package/src/components/Form/Form.stories.tsx +42 -0
- package/src/components/Form/Form.tsx +46 -0
- package/src/components/Form/index.ts +2 -0
- package/src/components/FormGroup/FormGroup.module.scss +20 -0
- package/src/components/FormGroup/FormGroup.spec.tsx +34 -0
- package/src/components/FormGroup/FormGroup.stories.tsx +30 -0
- package/src/components/FormGroup/FormGroup.tsx +44 -0
- package/src/components/FormGroup/index.ts +1 -0
- package/src/components/Icon/Icon.module.scss +70 -0
- package/src/components/Icon/Icon.stories.tsx +53 -0
- package/src/components/Icon/Icon.tsx +118 -0
- package/src/components/Icon/index.ts +1 -0
- package/src/components/InputField/InputField.module.scss +37 -0
- package/src/components/InputField/InputField.spec.tsx +53 -0
- package/src/components/InputField/InputField.stories.tsx +73 -0
- package/src/components/InputField/InputField.tsx +72 -0
- package/src/components/InputField/index.ts +1 -0
- package/src/components/Link/Link.module.scss +18 -0
- package/src/components/Link/Link.stories.tsx +17 -0
- package/src/components/Link/Link.tsx +37 -0
- package/src/components/Link/index.ts +1 -0
- package/src/components/Loader/Loader.module.scss +66 -0
- package/src/components/Loader/Loader.spec.tsx +64 -0
- package/src/components/Loader/Loader.stories.tsx +25 -0
- package/src/components/Loader/Loader.tsx +48 -0
- package/src/components/Loader/index.ts +1 -0
- package/src/components/Modal/ActionModal.tsx +37 -0
- package/src/components/Modal/Modal.module.scss +131 -0
- package/src/components/Modal/Modal.stories.tsx +85 -0
- package/src/components/Modal/Modal.tsx +41 -0
- package/src/components/Modal/ModalBase.spec.tsx +58 -0
- package/src/components/Modal/ModalBase.tsx +66 -0
- package/src/components/Modal/ModalCloseButton.tsx +20 -0
- package/src/components/Modal/ModalPortal.tsx +35 -0
- package/src/components/Modal/index.ts +11 -0
- package/src/components/NumericInput/NumericInput.module.scss +110 -0
- package/src/components/NumericInput/NumericInput.spec.tsx +129 -0
- package/src/components/NumericInput/NumericInput.stories.tsx +56 -0
- package/src/components/NumericInput/NumericInput.tsx +161 -0
- package/src/components/NumericInput/NumericInputField.stories.tsx +58 -0
- package/src/components/NumericInput/NumericInputField.tsx +57 -0
- package/src/components/NumericInput/index.ts +2 -0
- package/src/components/Popover/Popover.module.scss +16 -0
- package/src/components/Popover/Popover.spec.tsx +39 -0
- package/src/components/Popover/Popover.stories.css +23 -0
- package/src/components/Popover/Popover.stories.tsx +164 -0
- package/src/components/Popover/Popover.tsx +124 -0
- package/src/components/Popover/index.ts +1 -0
- package/src/components/Progress/ProgressBar.module.scss +48 -0
- package/src/components/Progress/ProgressBar.spec.tsx +33 -0
- package/src/components/Progress/ProgressBar.stories.tsx +23 -0
- package/src/components/Progress/ProgressBar.tsx +62 -0
- package/src/components/Progress/ProgressCircle.module.scss +64 -0
- package/src/components/Progress/ProgressCircle.spec.tsx +34 -0
- package/src/components/Progress/ProgressCircle.stories.tsx +28 -0
- package/src/components/Progress/ProgressCircle.tsx +104 -0
- package/src/components/Progress/constants.ts +23 -0
- package/src/components/Progress/helpers.ts +23 -0
- package/src/components/Progress/index.ts +1 -0
- package/src/components/PromoBanner/PromoBanner.module.scss +121 -0
- package/src/components/PromoBanner/PromoBanner.spec.tsx +119 -0
- package/src/components/PromoBanner/PromoBanner.stories.tsx +125 -0
- package/src/components/PromoBanner/PromoBanner.tsx +99 -0
- package/src/components/PromoBanner/index.ts +1 -0
- package/src/components/RadioButton/RadioButton.module.scss +100 -0
- package/src/components/RadioButton/RadioButton.spec.tsx +70 -0
- package/src/components/RadioButton/RadioButton.stories.tsx +34 -0
- package/src/components/RadioButton/RadioButton.tsx +54 -0
- package/src/components/RadioButton/index.ts +1 -0
- package/src/components/Switch/Switch.module.scss +126 -0
- package/src/components/Switch/Switch.spec.tsx +40 -0
- package/src/components/Switch/Switch.stories.tsx +23 -0
- package/src/components/Switch/Switch.tsx +100 -0
- package/src/components/Switch/index.ts +1 -0
- package/src/components/Tab/Tab.module.scss +56 -0
- package/src/components/Tab/Tab.spec.tsx +34 -0
- package/src/components/Tab/Tab.stories.tsx +20 -0
- package/src/components/Tab/Tab.tsx +49 -0
- package/src/components/Tab/TabsWrapper.module.scss +11 -0
- package/src/components/Tab/TabsWrapper.spec.tsx +19 -0
- package/src/components/Tab/TabsWrapper.stories.tsx +46 -0
- package/src/components/Tab/TabsWrapper.tsx +24 -0
- package/src/components/Tab/index.ts +2 -0
- package/src/components/Tag/Tag.module.scss +131 -0
- package/src/components/Tag/Tag.spec.tsx +93 -0
- package/src/components/Tag/Tag.stories.tsx +151 -0
- package/src/components/Tag/Tag.tsx +129 -0
- package/src/components/Tag/index.ts +1 -0
- package/src/components/TagInput/EditableTag.tsx +54 -0
- package/src/components/TagInput/EditableTagContent.tsx +81 -0
- package/src/components/TagInput/EmailTagInput.tsx +31 -0
- package/src/components/TagInput/TagInput.module.scss +81 -0
- package/src/components/TagInput/TagInput.spec.tsx +58 -0
- package/src/components/TagInput/TagInput.stories.tsx +49 -0
- package/src/components/TagInput/TagInput.tsx +133 -0
- package/src/components/TagInput/index.ts +4 -0
- package/src/components/TextField/TextField.module.scss +90 -0
- package/src/components/TextField/TextField.spec.tsx +40 -0
- package/src/components/TextField/TextField.stories.tsx +60 -0
- package/src/components/TextField/TextField.tsx +100 -0
- package/src/components/TextField/index.ts +1 -0
- package/src/components/Toast/Toast.module.scss +218 -0
- package/src/components/Toast/Toast.spec.tsx +96 -0
- package/src/components/Toast/Toast.stories.tsx +64 -0
- package/src/components/Toast/Toast.tsx +121 -0
- package/src/components/Toast/ToastWrapper.spec.tsx +13 -0
- package/src/components/Toast/ToastWrapper.stories.tsx +55 -0
- package/src/components/Toast/ToastWrapper.tsx +87 -0
- package/src/components/Toast/index.ts +2 -0
- package/src/components/Typography/Heading.tsx +36 -0
- package/src/components/Typography/Text.tsx +49 -0
- package/src/components/Typography/Typography.module.scss +132 -0
- package/src/components/Typography/index.ts +2 -0
- package/src/index.scss +9 -0
- package/src/index.ts +32 -0
- package/src/stories/ColorTokens.stories.mdx +10 -0
- package/src/stories/Icons.stories.mdx +12 -0
- package/src/stories/Typography.stories.mdx +65 -0
- package/src/stories/components/ColorTokens.tsx +99 -0
- package/src/stories/components/IconsShowcase.tsx +25 -0
- package/src/stories/components/iconsShowcase.css +13 -0
- package/src/test/setup.ts +1 -0
- package/{dist/test-utils.d.ts → src/test/utils.ts} +3 -2
- package/src/themes/dark.scss +127 -0
- package/src/themes/designTokens.ts +126 -0
- package/src/themes/legacy.scss +128 -0
- package/src/themes/light.scss +127 -0
- package/src/utils/keyCodes.ts +12 -0
- package/src/utils/noop.ts +2 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +25 -0
- package/tsconfig.node.json +8 -0
- package/vite.config.ts +44 -0
- package/dist/components/Alert.d.ts +0 -19
- package/dist/components/Alert.spec.d.ts +0 -1
- package/dist/components/Badge.d.ts +0 -6
- package/dist/components/Badge.spec.d.ts +0 -1
- package/dist/components/Button.d.ts +0 -13
- package/dist/components/Button.spec.d.ts +0 -1
- package/dist/components/ButtonGroup.d.ts +0 -11
- package/dist/components/ButtonGroup.spec.d.ts +0 -1
- package/dist/components/Card.d.ts +0 -6
- package/dist/components/Card.spec.d.ts +0 -1
- package/dist/components/Checkbox.d.ts +0 -7
- package/dist/components/CheckboxField.d.ts +0 -7
- package/dist/components/CheckboxField.spec.d.ts +0 -1
- package/dist/components/FieldDescription.d.ts +0 -3
- package/dist/components/FieldError.d.ts +0 -3
- package/dist/components/FieldGroup.d.ts +0 -8
- package/dist/components/FieldGroup.spec.d.ts +0 -1
- package/dist/components/FieldLabel.d.ts +0 -3
- package/dist/components/Form.d.ts +0 -7
- package/dist/components/Form.spec.d.ts +0 -1
- package/dist/components/FormGroup.d.ts +0 -7
- package/dist/components/FormGroup.spec.d.ts +0 -1
- package/dist/components/Heading.d.ts +0 -11
- package/dist/components/Icon.d.ts +0 -69
- package/dist/components/Loader.d.ts +0 -10
- package/dist/components/Loader.spec.d.ts +0 -1
- package/dist/components/Modal/ActionModal.d.ts +0 -8
- package/dist/components/Modal/Modal.d.ts +0 -7
- package/dist/components/Modal/ModalBase.d.ts +0 -6
- package/dist/components/Modal/ModalBase.spec.d.ts +0 -1
- package/dist/components/Modal/ModalCloseButton.d.ts +0 -3
- package/dist/components/Modal/ModalPortal.d.ts +0 -7
- package/dist/components/ProgressBar.d.ts +0 -9
- package/dist/components/ProgressBar.spec.d.ts +0 -1
- package/dist/components/ProgressCircle.d.ts +0 -9
- package/dist/components/ProgressCircle.spec.d.ts +0 -1
- package/dist/components/PromoBanner.d.ts +0 -19
- package/dist/components/PromoBanner.spec.d.ts +0 -1
- package/dist/components/RadioButton.d.ts +0 -7
- package/dist/components/RadioButton.spec.d.ts +0 -1
- package/dist/components/Switch.d.ts +0 -17
- package/dist/components/Switch.spec.d.ts +0 -1
- package/dist/components/Tab.d.ts +0 -12
- package/dist/components/Tab.spec.d.ts +0 -1
- package/dist/components/TabsWrapper.d.ts +0 -3
- package/dist/components/TabsWrapper.spec.d.ts +0 -1
- package/dist/components/Text.d.ts +0 -15
- package/dist/components/Toast.d.ts +0 -22
- package/dist/components/Toast.spec.d.ts +0 -1
- package/dist/components/ToastWrapper.d.ts +0 -26
- package/dist/components/ToastWrapper.spec.d.ts +0 -1
- package/dist/components/constants.d.ts +0 -12
- package/dist/components/helpers.d.ts +0 -3
- package/dist/constants/keyCodes.d.ts +0 -3
- package/dist/index.css +0 -2
- package/dist/index.css.map +0 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/index.modern.js +0 -2
- package/dist/index.modern.js.map +0 -1
- package/dist/index.module.js +0 -2
- package/dist/index.module.js.map +0 -1
- package/dist/index.umd.js +0 -2
- package/dist/index.umd.js.map +0 -1
- package/dist/stories/Alert.stories.d.ts +0 -14
- package/dist/stories/Badge.stories.d.ts +0 -16
- package/dist/stories/Button.stories.d.ts +0 -20
- package/dist/stories/ButtonGroup.stories.d.ts +0 -18
- package/dist/stories/Card.stories.d.ts +0 -10
- package/dist/stories/CheckboxField.stories.d.ts +0 -9
- package/dist/stories/FieldGroup.stories.d.ts +0 -9
- package/dist/stories/Form.stories.d.ts +0 -6
- package/dist/stories/FormGroup.stories.d.ts +0 -9
- package/dist/stories/Icon.stories.d.ts +0 -14
- package/dist/stories/Loader.stories.d.ts +0 -8
- package/dist/stories/Modal.stories.d.ts +0 -19
- package/dist/stories/ProgressCircle.stories.d.ts +0 -13
- package/dist/stories/Progressbar.stories.d.ts +0 -13
- package/dist/stories/PromoBanner.stories.d.ts +0 -13
- package/dist/stories/RadioButton.stories.d.ts +0 -9
- package/dist/stories/Switch.stories.d.ts +0 -12
- package/dist/stories/Tab.stories.d.ts +0 -10
- package/dist/stories/TabsWrapper.stories.d.ts +0 -15
- package/dist/stories/Toast.stories.d.ts +0 -15
- package/dist/stories/ToastWrapper.stories.d.ts +0 -40
- package/dist/stories/foundations/components/ColorTokens.d.ts +0 -2
- package/dist/stories/foundations/components/IconsShowcase.d.ts +0 -6
- package/dist/utils/noop.d.ts +0 -1
package/.eslintrc
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const foundations = ['Typography', 'ColorTokens', 'Icons'].map(
|
|
2
|
+
(name) => `../src/stories/${name}.stories.mdx`
|
|
3
|
+
);
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
stories: [
|
|
7
|
+
...foundations,
|
|
8
|
+
'../src/**/*.stories.mdx',
|
|
9
|
+
'../src/**/*.stories.@(js|jsx|ts|tsx)',
|
|
10
|
+
],
|
|
11
|
+
addons: [
|
|
12
|
+
'@storybook/addon-links',
|
|
13
|
+
'@storybook/addon-essentials',
|
|
14
|
+
'storybook-addon-themes',
|
|
15
|
+
],
|
|
16
|
+
framework: '@storybook/react',
|
|
17
|
+
core: {
|
|
18
|
+
builder: 'storybook-builder-vite',
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
window.global = window;
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<style>
|
|
6
|
+
body {
|
|
7
|
+
background-color: var(--background);
|
|
8
|
+
color: var(--content-default);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.spacer {
|
|
12
|
+
margin-bottom: 5px;
|
|
13
|
+
}
|
|
14
|
+
.spacer > * + * {
|
|
15
|
+
margin-left: 5px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.lc-dark-theme,
|
|
19
|
+
.lc-light-theme,
|
|
20
|
+
.lc-legacy-theme {
|
|
21
|
+
background-color: var(--background);
|
|
22
|
+
color: var(--content-default);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
* {
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
font-family: "Source Sans Pro", -apple-system, BlinkMacSystemFont, Segoe UI,
|
|
28
|
+
Helvetica Neue, Arial, sans-serif;
|
|
29
|
+
-webkit-font-smoothing: antialiased;
|
|
30
|
+
}
|
|
31
|
+
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import '../src/themes/legacy.scss';
|
|
2
|
+
import '../src/themes/light.scss';
|
|
3
|
+
import '../src/themes/dark.scss';
|
|
4
|
+
|
|
5
|
+
export const parameters = {
|
|
6
|
+
actions: { argTypesRegex: '^on[A-Z].*' },
|
|
7
|
+
controls: {
|
|
8
|
+
matchers: {
|
|
9
|
+
color: /(background|color)$/i,
|
|
10
|
+
date: /Date$/,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
themes: {
|
|
14
|
+
default: 'legacy',
|
|
15
|
+
list: [
|
|
16
|
+
{ name: 'legacy', class: 'lc-legacy-theme', color: '#4284f5' },
|
|
17
|
+
{ name: 'light', class: 'lc-light-theme', color: '#06f' },
|
|
18
|
+
{ name: 'dark', class: 'lc-dark-theme', color: '#000' },
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
};
|
package/package.json
CHANGED
|
@@ -1,67 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livechat/design-system-react-components",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"author": "",
|
|
9
9
|
"license": "ISC",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"unpkg": "./dist/index.umd.js",
|
|
15
|
-
"types": "dist/index.d.ts",
|
|
16
|
-
"styles": "dist/index.css",
|
|
17
|
-
"files": [
|
|
18
|
-
"dist"
|
|
19
|
-
],
|
|
10
|
+
"main": "./dist/dsrc.cjs.js",
|
|
11
|
+
"module": "./dist/dsrc.es.js",
|
|
12
|
+
"unpkg": "./dist/dsrc.umd.js",
|
|
13
|
+
"types": "./dist/src/index.d.ts",
|
|
20
14
|
"scripts": {
|
|
21
15
|
"dev": "run-p dev:*",
|
|
22
16
|
"dev:storybook": "start-storybook -p 6006 --quiet",
|
|
23
|
-
"dev:lib": "
|
|
24
|
-
"
|
|
17
|
+
"dev:lib": "vite build -w",
|
|
18
|
+
"dev:styles": "npm run build:styles -- --watch",
|
|
19
|
+
"build": "run-s build:*",
|
|
20
|
+
"build:lib": "tsc && vite build",
|
|
21
|
+
"build:styles": "sass src/themes:dist/themes",
|
|
25
22
|
"build-storybook": "build-storybook",
|
|
26
23
|
"chromatic": "dotenv -e ../../.env chromatic -- --exit-zero-on-changes",
|
|
27
24
|
"lint": "eslint src --ext js,jsx,ts,tsx",
|
|
28
|
-
"test": "
|
|
29
|
-
"test:watch": "
|
|
25
|
+
"test": "vitest run",
|
|
26
|
+
"test:watch": "vitest watch",
|
|
27
|
+
"test:coverage": "vitest run --coverage"
|
|
30
28
|
},
|
|
31
29
|
"peerDependencies": {
|
|
32
30
|
"react": "^17.0.2",
|
|
33
31
|
"react-dom": "^17.0.2"
|
|
34
32
|
},
|
|
35
33
|
"devDependencies": {
|
|
36
|
-
"@babel/core": "^7.
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@storybook/addon-
|
|
41
|
-
"@storybook/
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@testing-library/
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"@types/jest": "^27.0.1",
|
|
48
|
-
"@types/react": "^17.0.20",
|
|
34
|
+
"@babel/core": "^7.17.7",
|
|
35
|
+
"@livechat/design-system-icons": "^1.0.0-alpha.4",
|
|
36
|
+
"@storybook/addon-actions": "^6.4.13",
|
|
37
|
+
"@storybook/addon-essentials": "^6.4.13",
|
|
38
|
+
"@storybook/addon-links": "^6.4.13",
|
|
39
|
+
"@storybook/react": "^6.4.13",
|
|
40
|
+
"@testing-library/jest-dom": "^5.16.2",
|
|
41
|
+
"@testing-library/react": "^12.1.4",
|
|
42
|
+
"@testing-library/user-event": "^13.5.0",
|
|
43
|
+
"@types/lodash.escape": "^4.0.6",
|
|
44
|
+
"@types/react": "^17.0.33",
|
|
49
45
|
"@types/react-dom": "^17.0.10",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
46
|
+
"@types/react-transition-group": "^4.4.4",
|
|
47
|
+
"@vitejs/plugin-react": "^1.0.7",
|
|
48
|
+
"babel-loader": "^8.2.3",
|
|
52
49
|
"chromatic": "^5.9.2",
|
|
53
|
-
"
|
|
54
|
-
"microbundle": "^0.14.0",
|
|
50
|
+
"jsdom": "^19.0.0",
|
|
55
51
|
"react": "^17.0.2",
|
|
56
52
|
"react-dom": "^17.0.2",
|
|
53
|
+
"sass": "^1.49.9",
|
|
57
54
|
"storybook-addon-themes": "^6.1.0",
|
|
58
|
-
"
|
|
55
|
+
"storybook-builder-vite": "^0.1.20",
|
|
56
|
+
"typescript": "^4.5.4",
|
|
57
|
+
"vite": "^2.8.0",
|
|
58
|
+
"vite-plugin-dts": "^0.9.10",
|
|
59
|
+
"vitest": "^0.6.3"
|
|
59
60
|
},
|
|
60
61
|
"dependencies": {
|
|
61
|
-
"@
|
|
62
|
-
"
|
|
63
|
-
"
|
|
62
|
+
"@popperjs/core": "^2.11.2",
|
|
63
|
+
"clsx": "^1.1.1",
|
|
64
|
+
"lodash.escape": "^4.0.1",
|
|
65
|
+
"polished": "^4.1.3",
|
|
66
|
+
"react-popper": "^2.2.5",
|
|
64
67
|
"react-transition-group": "^4.4.2"
|
|
65
68
|
},
|
|
66
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "d92d4b040d6f91f8cce3e3e255d78d8de381713a"
|
|
67
70
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
.alert {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
overflow: hidden;
|
|
4
|
+
padding: 20px;
|
|
5
|
+
position: relative;
|
|
6
|
+
width: 100%;
|
|
7
|
+
word-break: break-word;
|
|
8
|
+
|
|
9
|
+
&__content-text {
|
|
10
|
+
color: var(--content-default);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&__content {
|
|
14
|
+
display: flex;
|
|
15
|
+
justify-content: flex-start;
|
|
16
|
+
width: 100%;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&--small {
|
|
20
|
+
max-width: 400px;
|
|
21
|
+
|
|
22
|
+
.alert__content {
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
|
|
25
|
+
&-text {
|
|
26
|
+
margin: 14px 0 0;
|
|
27
|
+
max-width: 246px;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&--medium {
|
|
33
|
+
max-width: 800px;
|
|
34
|
+
|
|
35
|
+
.alert__content {
|
|
36
|
+
&-text {
|
|
37
|
+
margin: 0 30px 0 16px;
|
|
38
|
+
max-width: 640px;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&--large {
|
|
44
|
+
.alert__content {
|
|
45
|
+
&-text {
|
|
46
|
+
margin: 0 30px 0 16px;
|
|
47
|
+
max-width: 720px;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&__close-icon {
|
|
53
|
+
background-color: transparent;
|
|
54
|
+
border: 0;
|
|
55
|
+
box-shadow: none;
|
|
56
|
+
height: 24px;
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
padding: 0;
|
|
59
|
+
position: absolute;
|
|
60
|
+
right: 12px;
|
|
61
|
+
top: 12px;
|
|
62
|
+
width: 24px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&--info {
|
|
66
|
+
background-color: var(--surface-feedback-info);
|
|
67
|
+
box-shadow: inset 0 3px 0 0 var(--color-action-default);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&--warning {
|
|
71
|
+
background-color: var(--surface-feedback-warning);
|
|
72
|
+
box-shadow: inset 0 3px 0 0 var(--color-warning-default);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&--success {
|
|
76
|
+
background-color: var(--surface-feedback-positive);
|
|
77
|
+
box-shadow: inset 0 3px 0 0 var(--color-positive-default);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&--error {
|
|
81
|
+
background-color: var(--surface-feedback-negative);
|
|
82
|
+
box-shadow: inset 0 3px 0 0 var(--color-negative-default);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&__icon {
|
|
86
|
+
flex-shrink: 0;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { render, fireEvent, vi } from 'test-utils';
|
|
3
|
+
import { Alert, AlertSize, AlertType, AlertProps } from './Alert';
|
|
4
|
+
|
|
5
|
+
import styles from './Alert.module.scss';
|
|
6
|
+
|
|
7
|
+
const renderComponent = (props: AlertProps) => {
|
|
8
|
+
return render(
|
|
9
|
+
<Alert {...props} className="my-css-class">
|
|
10
|
+
This example content
|
|
11
|
+
</Alert>
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
describe('<Alert> component', () => {
|
|
16
|
+
it('should allow for custom class', () => {
|
|
17
|
+
const { container } = renderComponent({});
|
|
18
|
+
|
|
19
|
+
expect(container.firstChild).toHaveClass('my-css-class');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should render as info by default', () => {
|
|
23
|
+
const { container } = renderComponent({});
|
|
24
|
+
|
|
25
|
+
expect(container.firstChild).toHaveClass(styles['alert--info']);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should render as warning', () => {
|
|
29
|
+
const { container } = renderComponent({ type: AlertType.Warning });
|
|
30
|
+
|
|
31
|
+
expect(container.firstChild).toHaveClass(styles['alert--warning']);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should render as success', () => {
|
|
35
|
+
const { container } = renderComponent({ type: AlertType.Success });
|
|
36
|
+
|
|
37
|
+
expect(container.firstChild).toHaveClass(styles['alert--success']);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should render as error', () => {
|
|
41
|
+
const { container } = renderComponent({ type: AlertType.Error });
|
|
42
|
+
|
|
43
|
+
expect(container.firstChild).toHaveClass(styles['alert--error']);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should render as small by default', () => {
|
|
47
|
+
const { container } = renderComponent({});
|
|
48
|
+
|
|
49
|
+
expect(container.firstChild).toHaveClass(styles['alert--small']);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should render as medium', () => {
|
|
53
|
+
const { container } = renderComponent({ size: AlertSize.Medium });
|
|
54
|
+
|
|
55
|
+
expect(container.firstChild).toHaveClass(styles['alert--medium']);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should render as large', () => {
|
|
59
|
+
const { container } = renderComponent({ size: AlertSize.Large });
|
|
60
|
+
|
|
61
|
+
expect(container.firstChild).toHaveClass(styles['alert--large']);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should render with close icon and call onClose function', () => {
|
|
65
|
+
const mockedFunction = vi.fn();
|
|
66
|
+
const { getByRole } = renderComponent({ onClose: mockedFunction });
|
|
67
|
+
|
|
68
|
+
expect(getByRole('button')).toBeVisible();
|
|
69
|
+
fireEvent.click(getByRole('button'));
|
|
70
|
+
expect(mockedFunction).toHaveBeenCalled();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should not render with close icon if no onClose function passed', () => {
|
|
74
|
+
const { queryByRole } = renderComponent({});
|
|
75
|
+
|
|
76
|
+
expect(queryByRole('button')).toBeFalsy();
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentMeta, Story } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
Alert as AlertComponent,
|
|
6
|
+
AlertSize,
|
|
7
|
+
AlertType,
|
|
8
|
+
AlertProps,
|
|
9
|
+
} from './Alert';
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: 'Components/Alert',
|
|
13
|
+
component: AlertComponent,
|
|
14
|
+
parameters: {
|
|
15
|
+
componentSubtitle: `
|
|
16
|
+
Alert banners are used to let users know about important
|
|
17
|
+
informations that require immediate action or attention.
|
|
18
|
+
`,
|
|
19
|
+
},
|
|
20
|
+
argTypes: { onClose: { defaultValue: null } },
|
|
21
|
+
} as ComponentMeta<typeof AlertComponent>;
|
|
22
|
+
|
|
23
|
+
const StoryTemplate: Story<AlertProps> = (args: AlertProps) => (
|
|
24
|
+
<div>
|
|
25
|
+
<AlertComponent {...args}>
|
|
26
|
+
A description with a <b>maximum of 100 characters</b>. That usually means
|
|
27
|
+
only one or two sentences.
|
|
28
|
+
</AlertComponent>
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export const Alert = StoryTemplate.bind({});
|
|
33
|
+
Alert.args = {};
|
|
34
|
+
|
|
35
|
+
export const InfoAlert = StoryTemplate.bind({});
|
|
36
|
+
InfoAlert.args = {
|
|
37
|
+
type: AlertType.Info,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const WarningAlert = StoryTemplate.bind({});
|
|
41
|
+
WarningAlert.args = {
|
|
42
|
+
type: AlertType.Warning,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const SuccessAlert = StoryTemplate.bind({});
|
|
46
|
+
SuccessAlert.args = {
|
|
47
|
+
type: AlertType.Success,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const ErrorAlert = StoryTemplate.bind({});
|
|
51
|
+
ErrorAlert.args = {
|
|
52
|
+
type: AlertType.Error,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const BannerWithClose = StoryTemplate.bind({});
|
|
56
|
+
BannerWithClose.args = {
|
|
57
|
+
onClose: () => alert('onClose click'),
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const SmallAlert = StoryTemplate.bind({});
|
|
61
|
+
SmallAlert.args = {
|
|
62
|
+
size: AlertSize.Small,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const MediumBanner = StoryTemplate.bind({});
|
|
66
|
+
MediumBanner.args = {
|
|
67
|
+
size: AlertSize.Medium,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const LargeAlert = StoryTemplate.bind({});
|
|
71
|
+
LargeAlert.args = {
|
|
72
|
+
size: AlertSize.Large,
|
|
73
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import cx from 'clsx';
|
|
3
|
+
import {
|
|
4
|
+
Close as CloseIcon,
|
|
5
|
+
Warning as WarningIcon,
|
|
6
|
+
Info as InfoIcon,
|
|
7
|
+
Block as BlockIcon,
|
|
8
|
+
CheckCircleSolid as CheckIcon,
|
|
9
|
+
} from '@livechat/design-system-icons/react/material';
|
|
10
|
+
|
|
11
|
+
import { Text } from '../Typography';
|
|
12
|
+
import { Icon, IconSizeName, IconTypeName } from '../Icon';
|
|
13
|
+
|
|
14
|
+
import styles from './Alert.module.scss';
|
|
15
|
+
|
|
16
|
+
export enum AlertSize {
|
|
17
|
+
Small = 'small',
|
|
18
|
+
Medium = 'medium',
|
|
19
|
+
Large = 'large',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export enum AlertType {
|
|
23
|
+
Info = 'info',
|
|
24
|
+
Warning = 'warning',
|
|
25
|
+
Success = 'success',
|
|
26
|
+
Error = 'error',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface AlertProps {
|
|
30
|
+
className?: string;
|
|
31
|
+
size?: AlertSize;
|
|
32
|
+
type?: AlertType;
|
|
33
|
+
onClose?: () => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const IconConfig = {
|
|
37
|
+
[AlertType.Info]: {
|
|
38
|
+
source: InfoIcon,
|
|
39
|
+
iconType: IconTypeName.Link,
|
|
40
|
+
},
|
|
41
|
+
[AlertType.Warning]: {
|
|
42
|
+
source: WarningIcon,
|
|
43
|
+
iconType: IconTypeName.Warning,
|
|
44
|
+
},
|
|
45
|
+
[AlertType.Success]: {
|
|
46
|
+
source: CheckIcon,
|
|
47
|
+
iconType: IconTypeName.Success,
|
|
48
|
+
},
|
|
49
|
+
[AlertType.Error]: {
|
|
50
|
+
source: BlockIcon,
|
|
51
|
+
iconType: IconTypeName.Error,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const baseClass = 'alert';
|
|
56
|
+
|
|
57
|
+
export const Alert: React.FC<AlertProps> = ({
|
|
58
|
+
children,
|
|
59
|
+
className,
|
|
60
|
+
size = AlertSize.Small,
|
|
61
|
+
type = AlertType.Info,
|
|
62
|
+
onClose,
|
|
63
|
+
}) => {
|
|
64
|
+
const mergedClassNames = cx(
|
|
65
|
+
styles[baseClass],
|
|
66
|
+
styles[`${baseClass}--${type}`],
|
|
67
|
+
styles[`${baseClass}--${size}`],
|
|
68
|
+
className
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<div className={mergedClassNames}>
|
|
73
|
+
<div className={styles[`${baseClass}__content`]}>
|
|
74
|
+
<Icon {...IconConfig[type]} />
|
|
75
|
+
<Text as="div" className={styles[`${baseClass}__content-text`]}>
|
|
76
|
+
{children}
|
|
77
|
+
</Text>
|
|
78
|
+
</div>
|
|
79
|
+
{onClose && (
|
|
80
|
+
<button
|
|
81
|
+
type="button"
|
|
82
|
+
className={styles[`${baseClass}__close-icon`]}
|
|
83
|
+
onClick={onClose}
|
|
84
|
+
>
|
|
85
|
+
<Icon
|
|
86
|
+
source={CloseIcon}
|
|
87
|
+
size={IconSizeName.Large}
|
|
88
|
+
iconType={IconTypeName.Primary}
|
|
89
|
+
/>
|
|
90
|
+
</button>
|
|
91
|
+
)}
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Alert } from './Alert';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.badge {
|
|
2
|
+
background-color: var(--color-negative-default);
|
|
3
|
+
border-radius: 18px;
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
color: var(--content-invert-default);
|
|
6
|
+
display: inline-block;
|
|
7
|
+
font-size: 10px;
|
|
8
|
+
font-weight: 600;
|
|
9
|
+
height: 18px;
|
|
10
|
+
line-height: 18px;
|
|
11
|
+
min-width: 18px;
|
|
12
|
+
padding: 0 3px;
|
|
13
|
+
text-align: center;
|
|
14
|
+
|
|
15
|
+
& + & {
|
|
16
|
+
margin-left: 4px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&--secondary {
|
|
20
|
+
background-color: var(--surface-secondary-default);
|
|
21
|
+
color: var(--surface-invert-default);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { render } from 'test-utils';
|
|
3
|
+
|
|
4
|
+
import { Badge } from './Badge';
|
|
5
|
+
|
|
6
|
+
describe('Badge', () => {
|
|
7
|
+
it('should accept custom className', () => {
|
|
8
|
+
const { container } = render(<Badge className="my-custom-class" />);
|
|
9
|
+
|
|
10
|
+
expect(container.firstChild).toHaveClass('my-custom-class');
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Badge as BadgeComponent, BadgeProps } from './Badge';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Components/Badge',
|
|
6
|
+
component: BadgeComponent,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const Badge = (args: BadgeProps): React.ReactElement => (
|
|
10
|
+
<div
|
|
11
|
+
style={{
|
|
12
|
+
display: 'inline-flex',
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
alignContent: 'center',
|
|
15
|
+
}}
|
|
16
|
+
>
|
|
17
|
+
<BadgeComponent {...args} />
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
Badge.args = {
|
|
22
|
+
secondary: false,
|
|
23
|
+
children: '7',
|
|
24
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import styles from './Badge.module.scss';
|
|
4
|
+
import cx from 'clsx';
|
|
5
|
+
|
|
6
|
+
export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
secondary?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const Badge: React.FC<BadgeProps> = ({
|
|
11
|
+
children,
|
|
12
|
+
className,
|
|
13
|
+
secondary = false,
|
|
14
|
+
}) => {
|
|
15
|
+
return (
|
|
16
|
+
<span
|
|
17
|
+
className={cx(styles.badge, className, {
|
|
18
|
+
[styles['badge--secondary']]: secondary,
|
|
19
|
+
})}
|
|
20
|
+
>
|
|
21
|
+
{children}
|
|
22
|
+
</span>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Badge } from './Badge';
|