@livechat/design-system-react-components 1.0.0-alpha.4 → 1.0.0-alpha.5
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/dist/dsrc.cjs.js +1 -0
- package/dist/dsrc.es.js +2213 -0
- package/dist/dsrc.umd.js +1 -0
- package/dist/src/components/Alert/Alert.d.ts +19 -0
- package/{src/components/Alert/index.ts → dist/src/components/Alert/index.d.ts} +0 -0
- package/dist/src/components/Badge/Badge.d.ts +5 -0
- package/{src/components/Badge/index.ts → dist/src/components/Badge/index.d.ts} +0 -0
- package/dist/src/components/Button/Button.d.ts +13 -0
- package/{src/components/Button/index.ts → dist/src/components/Button/index.d.ts} +0 -0
- package/dist/src/components/ButtonGroup/ButtonGroup.d.ts +11 -0
- package/{src/components/ButtonGroup/index.ts → dist/src/components/ButtonGroup/index.d.ts} +0 -0
- package/dist/src/components/Card/Card.d.ts +6 -0
- package/{src/components/Card/index.ts → dist/src/components/Card/index.d.ts} +0 -0
- package/dist/src/components/Checkbox/Checkbox.d.ts +7 -0
- package/dist/src/components/Checkbox/CheckboxField.d.ts +7 -0
- package/{src/components/Checkbox/index.ts → dist/src/components/Checkbox/index.d.ts} +0 -0
- package/dist/src/components/FieldDescription/FieldDescription.d.ts +3 -0
- package/{src/components/FieldDescription/index.ts → dist/src/components/FieldDescription/index.d.ts} +0 -0
- package/dist/src/components/FieldError/FieldError.d.ts +3 -0
- package/{src/components/FieldError/index.ts → dist/src/components/FieldError/index.d.ts} +0 -0
- package/dist/src/components/FieldGroup/FieldGroup.d.ts +8 -0
- package/{src/components/FieldGroup/index.ts → dist/src/components/FieldGroup/index.d.ts} +0 -0
- package/dist/src/components/Form/Form.d.ts +7 -0
- package/{src/components/Form/index.ts → dist/src/components/Form/index.d.ts} +0 -0
- package/dist/src/components/FormGroup/FormGroup.d.ts +7 -0
- package/{src/components/FormGroup/index.ts → dist/src/components/FormGroup/index.d.ts} +0 -0
- package/dist/src/components/Icon/Icon.d.ts +70 -0
- package/{src/components/Icon/index.ts → dist/src/components/Icon/index.d.ts} +0 -0
- package/dist/src/components/InputField/InputField.d.ts +15 -0
- package/{src/components/InputField/index.ts → dist/src/components/InputField/index.d.ts} +0 -0
- package/{src/components/Link/Link.tsx → dist/src/components/Link/Link.d.ts} +3 -26
- package/{src/components/Link/index.ts → dist/src/components/Link/index.d.ts} +0 -0
- package/dist/src/components/Loader/Loader.d.ts +10 -0
- package/{src/components/Loader/index.ts → dist/src/components/Loader/index.d.ts} +0 -0
- package/dist/src/components/Modal/ActionModal.d.ts +8 -0
- package/dist/src/components/Modal/Modal.d.ts +7 -0
- package/dist/src/components/Modal/ModalBase.d.ts +6 -0
- package/dist/src/components/Modal/ModalCloseButton.d.ts +3 -0
- package/dist/src/components/Modal/ModalPortal.d.ts +7 -0
- package/{src/components/Modal/index.ts → dist/src/components/Modal/index.d.ts} +0 -1
- package/dist/src/components/NumericInput/NumericInput.d.ts +14 -0
- package/dist/src/components/NumericInput/NumericInputField.d.ts +19 -0
- package/{src/components/NumericInput/index.ts → dist/src/components/NumericInput/index.d.ts} +0 -0
- package/dist/src/components/Popover/Popover.d.ts +15 -0
- package/{src/components/Popover/index.ts → dist/src/components/Popover/index.d.ts} +0 -0
- package/dist/src/components/Progress/ProgressCircle.d.ts +9 -0
- package/dist/src/components/Progress/constants.d.ts +12 -0
- package/dist/src/components/Progress/helpers.d.ts +3 -0
- package/{src/components/Progress/index.ts → dist/src/components/Progress/index.d.ts} +0 -0
- package/dist/src/components/PromoBanner/PromoBanner.d.ts +19 -0
- package/{src/components/PromoBanner/index.ts → dist/src/components/PromoBanner/index.d.ts} +0 -0
- package/dist/src/components/RadioButton/RadioButton.d.ts +7 -0
- package/{src/components/RadioButton/index.ts → dist/src/components/RadioButton/index.d.ts} +0 -0
- package/dist/src/components/Switch/Switch.d.ts +20 -0
- package/{src/components/Switch/index.ts → dist/src/components/Switch/index.d.ts} +0 -0
- package/dist/src/components/Tab/Tab.d.ts +12 -0
- package/dist/src/components/Tab/TabsWrapper.d.ts +3 -0
- package/{src/components/Tab/index.ts → dist/src/components/Tab/index.d.ts} +0 -0
- package/dist/src/components/Tag/Tag.d.ts +12 -0
- package/{src/components/Tag/index.ts → dist/src/components/Tag/index.d.ts} +0 -0
- package/dist/src/components/TagInput/EditableTag.d.ts +11 -0
- package/dist/src/components/TagInput/EditableTagContent.d.ts +11 -0
- package/dist/src/components/TagInput/EmailTagInput.d.ts +5 -0
- package/dist/src/components/TagInput/TagInput.d.ts +12 -0
- package/{src/components/TagInput/index.ts → dist/src/components/TagInput/index.d.ts} +0 -0
- package/dist/src/components/TextField/TextField.d.ts +13 -0
- package/{src/components/TextField/index.ts → dist/src/components/TextField/index.d.ts} +0 -0
- package/dist/src/components/Toast/Toast.d.ts +22 -0
- package/dist/src/components/Toast/ToastWrapper.d.ts +27 -0
- package/{src/components/Toast/index.ts → dist/src/components/Toast/index.d.ts} +0 -0
- package/dist/src/components/Typography/Heading.d.ts +11 -0
- package/dist/src/components/Typography/Text.d.ts +15 -0
- package/{src/components/Typography/index.ts → dist/src/components/Typography/index.d.ts} +0 -0
- package/{src/index.ts → dist/src/index.d.ts} +0 -3
- package/dist/src/themes/designTokens.d.ts +126 -0
- package/dist/src/utils/keyCodes.d.ts +12 -0
- package/dist/src/utils/noop.d.ts +1 -0
- package/{src → dist/src}/vite-env.d.ts +0 -0
- package/dist/style.css +1 -0
- package/{src/themes/dark.scss → dist/themes/dark.css} +2 -0
- package/dist/themes/dark.css.map +1 -0
- package/{src/themes/legacy.scss → dist/themes/legacy.css} +2 -0
- package/dist/themes/legacy.css.map +1 -0
- package/{src/themes/light.scss → dist/themes/light.css} +2 -0
- package/dist/themes/light.css.map +1 -0
- package/package.json +5 -2
- package/.eslintrc +0 -9
- package/.storybook/main.js +0 -20
- package/.storybook/preview-head.html +0 -31
- package/.storybook/preview.js +0 -21
- package/src/components/Alert/Alert.module.scss +0 -88
- package/src/components/Alert/Alert.spec.tsx +0 -78
- package/src/components/Alert/Alert.stories.tsx +0 -73
- package/src/components/Alert/Alert.tsx +0 -94
- package/src/components/Badge/Badge.module.scss +0 -23
- package/src/components/Badge/Badge.spec.tsx +0 -12
- package/src/components/Badge/Badge.stories.tsx +0 -24
- package/src/components/Badge/Badge.tsx +0 -24
- package/src/components/Button/Button.module.scss +0 -257
- package/src/components/Button/Button.spec.tsx +0 -110
- package/src/components/Button/Button.stories.tsx +0 -152
- package/src/components/Button/Button.tsx +0 -88
- package/src/components/ButtonGroup/ButtonGroup.module.scss +0 -31
- package/src/components/ButtonGroup/ButtonGroup.spec.tsx +0 -61
- package/src/components/ButtonGroup/ButtonGroup.stories.tsx +0 -53
- package/src/components/ButtonGroup/ButtonGroup.tsx +0 -75
- package/src/components/Card/Card.module.scss +0 -31
- package/src/components/Card/Card.spec.tsx +0 -38
- package/src/components/Card/Card.stories.tsx +0 -30
- package/src/components/Card/Card.tsx +0 -34
- package/src/components/Checkbox/Checkbox.module.scss +0 -99
- package/src/components/Checkbox/Checkbox.tsx +0 -39
- package/src/components/Checkbox/CheckboxField.spec.tsx +0 -58
- package/src/components/Checkbox/CheckboxField.stories.tsx +0 -30
- package/src/components/Checkbox/CheckboxField.tsx +0 -46
- package/src/components/FieldDescription/FieldDescription.module.scss +0 -5
- package/src/components/FieldDescription/FieldDescription.tsx +0 -23
- package/src/components/FieldError/FieldError.module.scss +0 -5
- package/src/components/FieldError/FieldError.tsx +0 -23
- package/src/components/FieldGroup/FieldGroup.module.scss +0 -25
- package/src/components/FieldGroup/FieldGroup.spec.tsx +0 -42
- package/src/components/FieldGroup/FieldGroup.stories.tsx +0 -34
- package/src/components/FieldGroup/FieldGroup.tsx +0 -38
- package/src/components/Form/Form.module.scss +0 -22
- package/src/components/Form/Form.spec.tsx +0 -38
- package/src/components/Form/Form.stories.tsx +0 -42
- package/src/components/Form/Form.tsx +0 -46
- package/src/components/FormGroup/FormGroup.module.scss +0 -20
- package/src/components/FormGroup/FormGroup.spec.tsx +0 -34
- package/src/components/FormGroup/FormGroup.stories.tsx +0 -30
- package/src/components/FormGroup/FormGroup.tsx +0 -44
- package/src/components/Icon/Icon.module.scss +0 -70
- package/src/components/Icon/Icon.stories.tsx +0 -53
- package/src/components/Icon/Icon.tsx +0 -118
- package/src/components/InputField/InputField.module.scss +0 -37
- package/src/components/InputField/InputField.spec.tsx +0 -53
- package/src/components/InputField/InputField.stories.tsx +0 -73
- package/src/components/InputField/InputField.tsx +0 -72
- package/src/components/Link/Link.module.scss +0 -18
- package/src/components/Link/Link.stories.tsx +0 -17
- package/src/components/Loader/Loader.module.scss +0 -66
- package/src/components/Loader/Loader.spec.tsx +0 -64
- package/src/components/Loader/Loader.stories.tsx +0 -25
- package/src/components/Loader/Loader.tsx +0 -48
- package/src/components/Modal/ActionModal.tsx +0 -37
- package/src/components/Modal/Modal.module.scss +0 -131
- package/src/components/Modal/Modal.stories.tsx +0 -85
- package/src/components/Modal/Modal.tsx +0 -41
- package/src/components/Modal/ModalBase.spec.tsx +0 -58
- package/src/components/Modal/ModalBase.tsx +0 -66
- package/src/components/Modal/ModalCloseButton.tsx +0 -20
- package/src/components/Modal/ModalPortal.tsx +0 -35
- package/src/components/NumericInput/NumericInput.module.scss +0 -110
- package/src/components/NumericInput/NumericInput.spec.tsx +0 -129
- package/src/components/NumericInput/NumericInput.stories.tsx +0 -56
- package/src/components/NumericInput/NumericInput.tsx +0 -161
- package/src/components/NumericInput/NumericInputField.stories.tsx +0 -58
- package/src/components/NumericInput/NumericInputField.tsx +0 -57
- package/src/components/Popover/Popover.module.scss +0 -16
- package/src/components/Popover/Popover.spec.tsx +0 -39
- package/src/components/Popover/Popover.stories.css +0 -23
- package/src/components/Popover/Popover.stories.tsx +0 -164
- package/src/components/Popover/Popover.tsx +0 -124
- package/src/components/Progress/ProgressBar.module.scss +0 -48
- package/src/components/Progress/ProgressBar.spec.tsx +0 -33
- package/src/components/Progress/ProgressBar.stories.tsx +0 -23
- package/src/components/Progress/ProgressBar.tsx +0 -62
- package/src/components/Progress/ProgressCircle.module.scss +0 -64
- package/src/components/Progress/ProgressCircle.spec.tsx +0 -34
- package/src/components/Progress/ProgressCircle.stories.tsx +0 -28
- package/src/components/Progress/ProgressCircle.tsx +0 -104
- package/src/components/Progress/constants.ts +0 -23
- package/src/components/Progress/helpers.ts +0 -23
- package/src/components/PromoBanner/PromoBanner.module.scss +0 -121
- package/src/components/PromoBanner/PromoBanner.spec.tsx +0 -119
- package/src/components/PromoBanner/PromoBanner.stories.tsx +0 -125
- package/src/components/PromoBanner/PromoBanner.tsx +0 -99
- package/src/components/RadioButton/RadioButton.module.scss +0 -100
- package/src/components/RadioButton/RadioButton.spec.tsx +0 -70
- package/src/components/RadioButton/RadioButton.stories.tsx +0 -34
- package/src/components/RadioButton/RadioButton.tsx +0 -54
- package/src/components/Switch/Switch.module.scss +0 -126
- package/src/components/Switch/Switch.spec.tsx +0 -40
- package/src/components/Switch/Switch.stories.tsx +0 -23
- package/src/components/Switch/Switch.tsx +0 -100
- package/src/components/Tab/Tab.module.scss +0 -56
- package/src/components/Tab/Tab.spec.tsx +0 -34
- package/src/components/Tab/Tab.stories.tsx +0 -20
- package/src/components/Tab/Tab.tsx +0 -49
- package/src/components/Tab/TabsWrapper.module.scss +0 -11
- package/src/components/Tab/TabsWrapper.spec.tsx +0 -19
- package/src/components/Tab/TabsWrapper.stories.tsx +0 -46
- package/src/components/Tab/TabsWrapper.tsx +0 -24
- package/src/components/Tag/Tag.module.scss +0 -131
- package/src/components/Tag/Tag.spec.tsx +0 -93
- package/src/components/Tag/Tag.stories.tsx +0 -151
- package/src/components/Tag/Tag.tsx +0 -129
- package/src/components/TagInput/EditableTag.tsx +0 -54
- package/src/components/TagInput/EditableTagContent.tsx +0 -81
- package/src/components/TagInput/EmailTagInput.tsx +0 -31
- package/src/components/TagInput/TagInput.module.scss +0 -81
- package/src/components/TagInput/TagInput.spec.tsx +0 -58
- package/src/components/TagInput/TagInput.stories.tsx +0 -49
- package/src/components/TagInput/TagInput.tsx +0 -133
- package/src/components/TextField/TextField.module.scss +0 -90
- package/src/components/TextField/TextField.spec.tsx +0 -40
- package/src/components/TextField/TextField.stories.tsx +0 -60
- package/src/components/TextField/TextField.tsx +0 -100
- package/src/components/Toast/Toast.module.scss +0 -218
- package/src/components/Toast/Toast.spec.tsx +0 -96
- package/src/components/Toast/Toast.stories.tsx +0 -64
- package/src/components/Toast/Toast.tsx +0 -121
- package/src/components/Toast/ToastWrapper.spec.tsx +0 -13
- package/src/components/Toast/ToastWrapper.stories.tsx +0 -55
- package/src/components/Toast/ToastWrapper.tsx +0 -87
- package/src/components/Typography/Heading.tsx +0 -36
- package/src/components/Typography/Text.tsx +0 -49
- package/src/components/Typography/Typography.module.scss +0 -132
- package/src/index.scss +0 -9
- package/src/stories/ColorTokens.stories.mdx +0 -10
- package/src/stories/Icons.stories.mdx +0 -12
- package/src/stories/Typography.stories.mdx +0 -65
- package/src/stories/components/ColorTokens.tsx +0 -99
- package/src/stories/components/IconsShowcase.tsx +0 -25
- package/src/stories/components/iconsShowcase.css +0 -13
- package/src/test/setup.ts +0 -1
- package/src/test/utils.ts +0 -3
- package/src/themes/designTokens.ts +0 -126
- package/src/utils/keyCodes.ts +0 -12
- package/src/utils/noop.ts +0 -2
- package/tsconfig.json +0 -25
- package/tsconfig.node.json +0 -8
- package/vite.config.ts +0 -44
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ComponentMeta } from '@storybook/react';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
RadioButton as RadioButtonComponent,
|
|
6
|
-
RadioButtonProps,
|
|
7
|
-
} from './RadioButton';
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
title: 'Forms (WIP)/Radio Button',
|
|
11
|
-
component: RadioButtonComponent,
|
|
12
|
-
argTypes: { onChange: { action: 'changed' } },
|
|
13
|
-
parameters: {
|
|
14
|
-
componentSubtitle: `
|
|
15
|
-
Use radio buttons where there’s a list of two or more mutually exclusive items, and the users must select exactly one option.
|
|
16
|
-
`,
|
|
17
|
-
},
|
|
18
|
-
} as ComponentMeta<typeof RadioButtonComponent>;
|
|
19
|
-
|
|
20
|
-
export const RadioButton = ({
|
|
21
|
-
children,
|
|
22
|
-
...args
|
|
23
|
-
}: RadioButtonProps): React.ReactElement => (
|
|
24
|
-
<div>
|
|
25
|
-
<RadioButtonComponent {...args}>{children}</RadioButtonComponent>
|
|
26
|
-
</div>
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
RadioButton.args = {
|
|
30
|
-
checked: false,
|
|
31
|
-
disabled: false,
|
|
32
|
-
description: 'Help text',
|
|
33
|
-
children: 'Radio label',
|
|
34
|
-
} as RadioButtonProps;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import cx from 'clsx';
|
|
3
|
-
import { FieldDescription } from '../FieldDescription';
|
|
4
|
-
import { Text } from '../Typography';
|
|
5
|
-
|
|
6
|
-
import styles from './RadioButton.module.scss';
|
|
7
|
-
|
|
8
|
-
export interface RadioButtonProps
|
|
9
|
-
extends React.HTMLAttributes<HTMLInputElement> {
|
|
10
|
-
description?: React.ReactNode;
|
|
11
|
-
checked?: boolean;
|
|
12
|
-
disabled?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const baseClass = 'radio-button';
|
|
16
|
-
|
|
17
|
-
export const RadioButton: React.FC<RadioButtonProps> = ({
|
|
18
|
-
children,
|
|
19
|
-
className = '',
|
|
20
|
-
description,
|
|
21
|
-
checked,
|
|
22
|
-
disabled,
|
|
23
|
-
...props
|
|
24
|
-
}) => {
|
|
25
|
-
const mergedClassNames = cx(styles[baseClass], className, {
|
|
26
|
-
[styles[`${baseClass}--selected`]]: checked,
|
|
27
|
-
[styles[`${baseClass}--disabled`]]: disabled,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<div className={mergedClassNames}>
|
|
32
|
-
<label className={styles[`${baseClass}__label`]}>
|
|
33
|
-
<div className={styles[`${baseClass}__circle`]}>
|
|
34
|
-
<span className={styles[`${baseClass}__inner-circle`]} />
|
|
35
|
-
<input
|
|
36
|
-
className={styles[`${baseClass}__input`]}
|
|
37
|
-
{...props}
|
|
38
|
-
type="radio"
|
|
39
|
-
checked={checked}
|
|
40
|
-
disabled={disabled}
|
|
41
|
-
/>
|
|
42
|
-
</div>
|
|
43
|
-
<Text as="div" size="md" className={styles[`${baseClass}__text`]}>
|
|
44
|
-
{children}
|
|
45
|
-
</Text>
|
|
46
|
-
</label>
|
|
47
|
-
{description && (
|
|
48
|
-
<FieldDescription className={styles[`${baseClass}__helper`]}>
|
|
49
|
-
{description}
|
|
50
|
-
</FieldDescription>
|
|
51
|
-
)}
|
|
52
|
-
</div>
|
|
53
|
-
);
|
|
54
|
-
};
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
$switch-transition-duration: 300ms;
|
|
2
|
-
$switch-transition-timing-function: cubic-bezier(0.33, 0, 0.67, 1);
|
|
3
|
-
|
|
4
|
-
$base-class: 'switch';
|
|
5
|
-
$basic-height: 28px;
|
|
6
|
-
$basic-width: 44px;
|
|
7
|
-
$basic-size: $basic-height - 4px;
|
|
8
|
-
$basic-move: $basic-width - $basic-size;
|
|
9
|
-
|
|
10
|
-
$compact-height: 16px;
|
|
11
|
-
$compact-width: 25px;
|
|
12
|
-
$compact-size: $compact-height - 2px;
|
|
13
|
-
$compact-move: $compact-width - $compact-size;
|
|
14
|
-
|
|
15
|
-
/* stylelint-disable max-nesting-depth */
|
|
16
|
-
.#{$base-class} {
|
|
17
|
-
display: inline-block;
|
|
18
|
-
outline: none;
|
|
19
|
-
position: relative;
|
|
20
|
-
|
|
21
|
-
&:hover {
|
|
22
|
-
.#{$base-class}__track {
|
|
23
|
-
&--enabled {
|
|
24
|
-
background-color: var(--color-positive-default);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
&--disabled {
|
|
28
|
-
background-color: var(--surface-secondary-default);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
&--basic {
|
|
34
|
-
height: $basic-height;
|
|
35
|
-
width: $basic-width;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
&--compact {
|
|
39
|
-
height: $compact-height;
|
|
40
|
-
width: $compact-width;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
&__input {
|
|
44
|
-
cursor: pointer;
|
|
45
|
-
height: 100%;
|
|
46
|
-
margin: 0;
|
|
47
|
-
opacity: 0;
|
|
48
|
-
width: 100%;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
&__input:focus + .#{$base-class}__container {
|
|
52
|
-
.#{$base-class}__track {
|
|
53
|
-
//TODO use shadow token instead of hex color
|
|
54
|
-
box-shadow: 0 0 1px 2px rgba(#4379d6, 0.7);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
&__container {
|
|
59
|
-
align-items: center;
|
|
60
|
-
display: flex;
|
|
61
|
-
height: 100%;
|
|
62
|
-
left: 0;
|
|
63
|
-
pointer-events: none;
|
|
64
|
-
position: absolute;
|
|
65
|
-
top: 0;
|
|
66
|
-
width: 100%;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
&__track {
|
|
70
|
-
border-radius: 24px;
|
|
71
|
-
flex: 1;
|
|
72
|
-
height: 100%;
|
|
73
|
-
transition-duration: $switch-transition-duration;
|
|
74
|
-
transition-property: background-color;
|
|
75
|
-
transition-timing-function: $switch-transition-timing-function;
|
|
76
|
-
|
|
77
|
-
&--enabled {
|
|
78
|
-
background-color: var(--color-positive-default);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
&--disabled {
|
|
82
|
-
background-color: var(--surface-secondary-default);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
&__slider {
|
|
87
|
-
background: var(--content-white-locked);
|
|
88
|
-
border-radius: 50%;
|
|
89
|
-
position: absolute;
|
|
90
|
-
top: 50%;
|
|
91
|
-
transform: translateY(-50%);
|
|
92
|
-
transition-duration: $switch-transition-duration;
|
|
93
|
-
transition-property: left, right;
|
|
94
|
-
transition-timing-function: $switch-transition-timing-function;
|
|
95
|
-
|
|
96
|
-
&--basic {
|
|
97
|
-
height: calc(#{$basic-size});
|
|
98
|
-
width: calc(#{$basic-size});
|
|
99
|
-
|
|
100
|
-
&--enabled {
|
|
101
|
-
left: calc(#{$basic-move} - 2px);
|
|
102
|
-
right: 2px;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
&--disabled {
|
|
106
|
-
left: 2px;
|
|
107
|
-
right: calc(#{$basic-move} - 2px);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
&--compact {
|
|
112
|
-
height: calc(#{$compact-size});
|
|
113
|
-
width: calc(#{$compact-size});
|
|
114
|
-
|
|
115
|
-
&--enabled {
|
|
116
|
-
left: calc(#{$compact-move} - 2px);
|
|
117
|
-
right: 2px;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
&--disabled {
|
|
121
|
-
left: 2px;
|
|
122
|
-
right: calc(#{$compact-move} - 2px);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { render, fireEvent, vi } from 'test-utils';
|
|
3
|
-
import { Switch } from './Switch';
|
|
4
|
-
|
|
5
|
-
describe('Switch', () => {
|
|
6
|
-
it('should call onChange without changing state when custom handler is passed', () => {
|
|
7
|
-
const toggleFn = vi.fn();
|
|
8
|
-
const { getByRole } = render(<Switch onChange={toggleFn} />);
|
|
9
|
-
const checkbox = getByRole('checkbox') as HTMLInputElement;
|
|
10
|
-
expect(checkbox.checked).toEqual(false);
|
|
11
|
-
fireEvent.click(checkbox);
|
|
12
|
-
expect(toggleFn).toHaveBeenCalled();
|
|
13
|
-
expect(checkbox.checked).toEqual(false);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('should change state to enabled when user clicks on disabled switch', () => {
|
|
17
|
-
const { getByRole } = render(<Switch />);
|
|
18
|
-
const checkbox = getByRole('checkbox') as HTMLInputElement;
|
|
19
|
-
expect(checkbox.checked).toEqual(false);
|
|
20
|
-
fireEvent.click(checkbox);
|
|
21
|
-
expect(checkbox.checked).toEqual(true);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should change state to disabled when user clicks on enabled switch', () => {
|
|
25
|
-
const { getByRole } = render(<Switch on={true} />);
|
|
26
|
-
const checkbox = getByRole('checkbox') as HTMLInputElement;
|
|
27
|
-
expect(checkbox.checked).toEqual(true);
|
|
28
|
-
fireEvent.click(checkbox);
|
|
29
|
-
expect(checkbox.checked).toEqual(false);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should be enabled if defaultOn is set to true', () => {
|
|
33
|
-
const { getByRole } = render(<Switch defaultOn={true} />);
|
|
34
|
-
const checkbox = getByRole('checkbox') as HTMLInputElement;
|
|
35
|
-
expect(checkbox.checked).toEqual(true);
|
|
36
|
-
fireEvent.click(checkbox);
|
|
37
|
-
expect(checkbox.checked).toEqual(false);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
1;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ComponentMeta } from '@storybook/react';
|
|
3
|
-
|
|
4
|
-
import { Switch as SwitchComponent, SwitchProps, SwitchSize } from './Switch';
|
|
5
|
-
import noop from '../../utils/noop';
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
title: 'Components/Switch',
|
|
9
|
-
component: SwitchComponent,
|
|
10
|
-
} as ComponentMeta<typeof SwitchComponent>;
|
|
11
|
-
|
|
12
|
-
export const Switch = (args: SwitchProps): React.ReactElement => {
|
|
13
|
-
return (
|
|
14
|
-
<div>
|
|
15
|
-
<SwitchComponent {...args} />
|
|
16
|
-
</div>
|
|
17
|
-
);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
Switch.args = {
|
|
21
|
-
size: SwitchSize.Basic,
|
|
22
|
-
onChange: noop,
|
|
23
|
-
};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import cx from 'clsx';
|
|
3
|
-
|
|
4
|
-
import noop from '../../utils/noop';
|
|
5
|
-
|
|
6
|
-
import styles from './Switch.module.scss';
|
|
7
|
-
|
|
8
|
-
const baseClass = 'switch';
|
|
9
|
-
|
|
10
|
-
export const enum SwitchSize {
|
|
11
|
-
Basic = 'basic',
|
|
12
|
-
Compact = 'compact',
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const enum SwitchStyles {
|
|
16
|
-
Enabled = 'enabled',
|
|
17
|
-
Disabled = 'disabled',
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface SwitchProps {
|
|
21
|
-
className?: string;
|
|
22
|
-
defaultOn?: boolean;
|
|
23
|
-
disabled?: boolean;
|
|
24
|
-
innerRef?: React.LegacyRef<HTMLInputElement> | undefined;
|
|
25
|
-
name?: string;
|
|
26
|
-
on?: boolean;
|
|
27
|
-
onChange?(e: React.FormEvent, value: boolean): void;
|
|
28
|
-
size?: SwitchSize;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const Switch: React.FC<SwitchProps> = ({
|
|
32
|
-
className = '',
|
|
33
|
-
defaultOn = false,
|
|
34
|
-
disabled = false,
|
|
35
|
-
name = baseClass,
|
|
36
|
-
on,
|
|
37
|
-
onChange = noop,
|
|
38
|
-
size = SwitchSize.Basic,
|
|
39
|
-
innerRef,
|
|
40
|
-
...props
|
|
41
|
-
}) => {
|
|
42
|
-
const getEnabledValue = () => {
|
|
43
|
-
return on !== undefined ? on : defaultOn;
|
|
44
|
-
};
|
|
45
|
-
const [enabled, setEnabled] = React.useState(getEnabledValue());
|
|
46
|
-
|
|
47
|
-
React.useEffect(() => {
|
|
48
|
-
if (on !== undefined) {
|
|
49
|
-
setEnabled(on);
|
|
50
|
-
}
|
|
51
|
-
}, [on]);
|
|
52
|
-
|
|
53
|
-
const valueStyles = enabled ? SwitchStyles.Enabled : SwitchStyles.Disabled;
|
|
54
|
-
const mergedClassNames = cx(
|
|
55
|
-
styles[baseClass],
|
|
56
|
-
styles[`${baseClass}--${size}`],
|
|
57
|
-
className
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
const handleChange = (e: React.FormEvent) => {
|
|
61
|
-
const hasOnChangePassed = onChange !== noop;
|
|
62
|
-
if (hasOnChangePassed) {
|
|
63
|
-
onChange(e, enabled);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
e.stopPropagation();
|
|
67
|
-
setEnabled((prevEnabled) => !prevEnabled);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<span className={mergedClassNames}>
|
|
72
|
-
<input
|
|
73
|
-
type="checkbox"
|
|
74
|
-
className={styles[`${baseClass}__input`]}
|
|
75
|
-
onChange={handleChange}
|
|
76
|
-
checked={enabled}
|
|
77
|
-
name={name}
|
|
78
|
-
ref={innerRef}
|
|
79
|
-
disabled={disabled}
|
|
80
|
-
test-id="foo"
|
|
81
|
-
{...props}
|
|
82
|
-
/>
|
|
83
|
-
<span className={styles[`${baseClass}__container`]}>
|
|
84
|
-
<span
|
|
85
|
-
className={cx(
|
|
86
|
-
styles[`${baseClass}__track`],
|
|
87
|
-
styles[`${baseClass}__track--${valueStyles}`]
|
|
88
|
-
)}
|
|
89
|
-
/>
|
|
90
|
-
<span
|
|
91
|
-
className={cx(
|
|
92
|
-
styles[`${baseClass}__slider`],
|
|
93
|
-
styles[`${baseClass}__slider--${size}`],
|
|
94
|
-
styles[`${baseClass}__slider--${size}--${valueStyles}`]
|
|
95
|
-
)}
|
|
96
|
-
/>
|
|
97
|
-
</span>
|
|
98
|
-
</span>
|
|
99
|
-
);
|
|
100
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
.tab {
|
|
2
|
-
align-items: center;
|
|
3
|
-
background: none;
|
|
4
|
-
border: 0;
|
|
5
|
-
color: var(--content-default);
|
|
6
|
-
cursor: pointer;
|
|
7
|
-
display: flex;
|
|
8
|
-
flex-direction: row;
|
|
9
|
-
margin: 0 8px 11px;
|
|
10
|
-
outline: none;
|
|
11
|
-
overflow: visible;
|
|
12
|
-
padding: 0 12px 1px;
|
|
13
|
-
position: relative;
|
|
14
|
-
transition: color 0.25s;
|
|
15
|
-
|
|
16
|
-
&__description {
|
|
17
|
-
color: var(--content-subtle);
|
|
18
|
-
display: inline-block;
|
|
19
|
-
padding-left: 3px;
|
|
20
|
-
transition: color 0.25s;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
&::before {
|
|
24
|
-
background-color: var(--color-action-default);
|
|
25
|
-
bottom: 0;
|
|
26
|
-
content: '';
|
|
27
|
-
display: block;
|
|
28
|
-
height: 0;
|
|
29
|
-
left: 0;
|
|
30
|
-
position: absolute;
|
|
31
|
-
right: 0;
|
|
32
|
-
z-index: 1;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
&--selected {
|
|
36
|
-
color: var(--color-action-default);
|
|
37
|
-
|
|
38
|
-
.tab__description {
|
|
39
|
-
color: var(--color-action-default);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
&::before {
|
|
43
|
-
bottom: -12px;
|
|
44
|
-
height: 3px;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
&:hover {
|
|
49
|
-
color: var(--color-action-default);
|
|
50
|
-
text-decoration: none;
|
|
51
|
-
|
|
52
|
-
.tab__description {
|
|
53
|
-
color: var(--color-action-default);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { render } from 'test-utils';
|
|
3
|
-
import { Tab } from './Tab';
|
|
4
|
-
|
|
5
|
-
import styles from './Tab.module.scss';
|
|
6
|
-
|
|
7
|
-
describe('<Tab /> component', () => {
|
|
8
|
-
it('should render unselected Tab by default', () => {
|
|
9
|
-
const { getByText } = render(<Tab>Hello</Tab>);
|
|
10
|
-
expect(getByText('Hello')).not.toHaveClass(styles['tab--selected']);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("should render selected Tab if 'isSelected' is provided", () => {
|
|
14
|
-
const { getByText } = render(<Tab isSelected>Hello</Tab>);
|
|
15
|
-
expect(getByText('Hello')).toHaveClass(styles['tab--selected']);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should render properly formatted description', () => {
|
|
19
|
-
const { getByText } = render(<Tab description="1">Hello</Tab>);
|
|
20
|
-
expect(getByText('(1)')).toBeVisible();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('should render with button element by default', () => {
|
|
24
|
-
const { getByRole } = render(<Tab>Hello</Tab>);
|
|
25
|
-
expect(getByRole('button')).toHaveTextContent('Hello');
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("should render with anchor element if 'href' is provided", () => {
|
|
29
|
-
const { getByRole } = render(<Tab href="http://example.com">Hello</Tab>);
|
|
30
|
-
const link = getByRole('link');
|
|
31
|
-
expect(link).toHaveTextContent('Hello');
|
|
32
|
-
expect(link).toHaveAttribute('href', 'http://example.com');
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ComponentMeta } from '@storybook/react';
|
|
3
|
-
|
|
4
|
-
import { Tab as TabComponent, TabProps } from './Tab';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Components/Tabs',
|
|
8
|
-
component: TabComponent,
|
|
9
|
-
} as ComponentMeta<typeof TabComponent>;
|
|
10
|
-
|
|
11
|
-
type ITabArgs = TabProps;
|
|
12
|
-
|
|
13
|
-
export const Tab = (args: ITabArgs): React.ReactElement => {
|
|
14
|
-
return <TabComponent {...args} />;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
Tab.args = {
|
|
18
|
-
children: 'Lorem ipsum',
|
|
19
|
-
description: '1',
|
|
20
|
-
} as ITabArgs;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import cx from 'clsx';
|
|
3
|
-
import { Text } from '../Typography';
|
|
4
|
-
|
|
5
|
-
import styles from './Tab.module.scss';
|
|
6
|
-
|
|
7
|
-
type HTMLProps =
|
|
8
|
-
| (React.AnchorHTMLAttributes<HTMLAnchorElement> & { href: string })
|
|
9
|
-
| (React.ButtonHTMLAttributes<HTMLButtonElement> & { href?: never });
|
|
10
|
-
|
|
11
|
-
export type TabProps = HTMLProps & {
|
|
12
|
-
description?: React.ReactNode;
|
|
13
|
-
isSelected?: boolean;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const baseClass = 'tab';
|
|
17
|
-
|
|
18
|
-
export const Tab: React.FC<TabProps> = ({
|
|
19
|
-
children,
|
|
20
|
-
className,
|
|
21
|
-
description,
|
|
22
|
-
isSelected,
|
|
23
|
-
...restProps
|
|
24
|
-
}) => {
|
|
25
|
-
return (
|
|
26
|
-
<Text
|
|
27
|
-
{...restProps}
|
|
28
|
-
as={restProps.href ? 'a' : 'button'}
|
|
29
|
-
size="md"
|
|
30
|
-
bold={isSelected}
|
|
31
|
-
className={cx(
|
|
32
|
-
styles[baseClass],
|
|
33
|
-
className,
|
|
34
|
-
isSelected && styles[`${baseClass}--selected`]
|
|
35
|
-
)}
|
|
36
|
-
>
|
|
37
|
-
{children}
|
|
38
|
-
{description && (
|
|
39
|
-
<Text
|
|
40
|
-
as="span"
|
|
41
|
-
size="md"
|
|
42
|
-
className={styles[`${baseClass}__description`]}
|
|
43
|
-
>
|
|
44
|
-
({description})
|
|
45
|
-
</Text>
|
|
46
|
-
)}
|
|
47
|
-
</Text>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { render } from 'test-utils';
|
|
3
|
-
import { TabsWrapper, TabsList } from './TabsWrapper';
|
|
4
|
-
|
|
5
|
-
describe('<TabsWrapper /> component', () => {
|
|
6
|
-
it('should render nested elements as children', () => {
|
|
7
|
-
const { getByRole } = render(
|
|
8
|
-
<TabsWrapper>
|
|
9
|
-
<TabsList>
|
|
10
|
-
<h3>Hello</h3>
|
|
11
|
-
</TabsList>
|
|
12
|
-
</TabsWrapper>
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
const heading = getByRole('heading');
|
|
16
|
-
expect(heading).toBeVisible();
|
|
17
|
-
expect(heading).toHaveTextContent('Hello');
|
|
18
|
-
});
|
|
19
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ComponentMeta } from '@storybook/react';
|
|
3
|
-
|
|
4
|
-
import { TabsList, TabsWrapper as TabsWrapperComponenet } from './TabsWrapper';
|
|
5
|
-
import { Tab } from './Tab';
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
title: 'Components/Tabs',
|
|
9
|
-
component: TabsWrapperComponenet,
|
|
10
|
-
} as ComponentMeta<typeof TabsWrapperComponenet>;
|
|
11
|
-
|
|
12
|
-
type ITabArgs = {
|
|
13
|
-
items: Array<{
|
|
14
|
-
id: string;
|
|
15
|
-
title: string;
|
|
16
|
-
count: number;
|
|
17
|
-
}>;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const TabsWrapper = ({ items }: ITabArgs): React.ReactElement => {
|
|
21
|
-
const [selectedTab, setSelectedTab] = React.useState(items[0].id);
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<TabsWrapperComponenet>
|
|
25
|
-
<TabsList>
|
|
26
|
-
{items.map(({ id, title, count }) => (
|
|
27
|
-
<Tab
|
|
28
|
-
key={id}
|
|
29
|
-
description={count}
|
|
30
|
-
isSelected={selectedTab === id}
|
|
31
|
-
onClick={() => setSelectedTab(id)}
|
|
32
|
-
>
|
|
33
|
-
{title}
|
|
34
|
-
</Tab>
|
|
35
|
-
))}
|
|
36
|
-
</TabsList>
|
|
37
|
-
</TabsWrapperComponenet>
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
TabsWrapper.args = {
|
|
42
|
-
items: [
|
|
43
|
-
{ id: 'agents', title: 'Agents', count: 1 },
|
|
44
|
-
{ id: 'groups', title: 'Groups', count: 3 },
|
|
45
|
-
],
|
|
46
|
-
} as ITabArgs;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import cx from 'clsx';
|
|
3
|
-
|
|
4
|
-
import styles from './TabsWrapper.module.scss';
|
|
5
|
-
|
|
6
|
-
const baseClass = 'tabs';
|
|
7
|
-
|
|
8
|
-
export const TabsWrapper: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({
|
|
9
|
-
className,
|
|
10
|
-
children,
|
|
11
|
-
}) => {
|
|
12
|
-
return <div className={cx(styles[baseClass], className)}>{children}</div>;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const TabsList: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({
|
|
16
|
-
className,
|
|
17
|
-
children,
|
|
18
|
-
}) => {
|
|
19
|
-
return (
|
|
20
|
-
<div className={cx(styles[`${baseClass}__list`], className)}>
|
|
21
|
-
{children}
|
|
22
|
-
</div>
|
|
23
|
-
);
|
|
24
|
-
};
|