@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
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { render, fireEvent, vi } from 'test-utils';
|
|
3
|
+
import { InputFieldProps, InputField } from './InputField';
|
|
4
|
+
|
|
5
|
+
import styles from './InputField.module.scss';
|
|
6
|
+
|
|
7
|
+
const renderComponent = (props: InputFieldProps) => {
|
|
8
|
+
return render(<InputField {...props} className="my-css-class" />);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
describe('<InputField> component', () => {
|
|
12
|
+
it('should allow for custom class', () => {
|
|
13
|
+
const { container } = renderComponent({
|
|
14
|
+
id: 'input-field-example',
|
|
15
|
+
onChange: vi.fn(),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
expect(container.firstChild).toHaveClass('my-css-class');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should allow for field custom class', () => {
|
|
22
|
+
const { getByRole } = renderComponent({
|
|
23
|
+
id: 'input-field-example',
|
|
24
|
+
onChange: vi.fn(),
|
|
25
|
+
placeholder: 'placeholder',
|
|
26
|
+
fieldClassName: 'my-field-css-class',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
expect(getByRole('textbox')).toHaveClass('my-field-css-class');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should have error class', () => {
|
|
33
|
+
const { getByRole } = renderComponent({
|
|
34
|
+
id: 'input-field-example',
|
|
35
|
+
onChange: vi.fn(),
|
|
36
|
+
error: 'Error',
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
expect(getByRole('textbox')).toHaveClass(styles['input-field--error']);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should call onChange when value changes', () => {
|
|
43
|
+
const mockedFunction = vi.fn();
|
|
44
|
+
const { getByRole } = renderComponent({
|
|
45
|
+
id: 'input-field-example',
|
|
46
|
+
onChange: mockedFunction,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
fireEvent.change(getByRole('textbox'), { target: { value: 'test' } });
|
|
50
|
+
const event = mockedFunction.mock.calls[0][0];
|
|
51
|
+
expect(event.target.value).toEqual('test');
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentMeta, Story } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
InputFieldProps,
|
|
6
|
+
InputField as InputFieldComponent,
|
|
7
|
+
} from './InputField';
|
|
8
|
+
import { Text } from '../Typography';
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
title: 'Forms (WIP)/InputField',
|
|
12
|
+
component: InputFieldComponent,
|
|
13
|
+
parameters: {
|
|
14
|
+
componentSubtitle: `
|
|
15
|
+
InputField contains a TextField component, so most of the props are directed to
|
|
16
|
+
handle TextField elements, e.g. label or description.
|
|
17
|
+
The InputField itself is prepared to accept props dedicated to the <input>,
|
|
18
|
+
which we can pass by InputField.
|
|
19
|
+
`,
|
|
20
|
+
},
|
|
21
|
+
} as ComponentMeta<typeof InputFieldComponent>;
|
|
22
|
+
|
|
23
|
+
const StoryTemplate: Story<InputFieldProps> = (args: InputFieldProps) => (
|
|
24
|
+
<div>
|
|
25
|
+
<InputFieldComponent
|
|
26
|
+
labelText="Input Field label"
|
|
27
|
+
placeholder="Placeholder..."
|
|
28
|
+
description={
|
|
29
|
+
<div>
|
|
30
|
+
<Text as="span" size="sm">
|
|
31
|
+
Help text
|
|
32
|
+
</Text>
|
|
33
|
+
</div>
|
|
34
|
+
}
|
|
35
|
+
{...args}
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
export const InputField = StoryTemplate.bind({});
|
|
41
|
+
InputField.args = {};
|
|
42
|
+
|
|
43
|
+
export const InputFieldWithInline = StoryTemplate.bind({});
|
|
44
|
+
InputFieldWithInline.args = {
|
|
45
|
+
inline: true,
|
|
46
|
+
id: 'withInline',
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const InputFieldWithDisabled = StoryTemplate.bind({});
|
|
50
|
+
InputFieldWithDisabled.args = {
|
|
51
|
+
disabled: true,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const InputFieldWithCustomInputStyles = StoryTemplate.bind({});
|
|
55
|
+
InputFieldWithCustomInputStyles.args = {
|
|
56
|
+
style: {
|
|
57
|
+
width: 400,
|
|
58
|
+
height: 50,
|
|
59
|
+
borderColor: 'var(--color-positive-default)',
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const InputFieldWithMaxLength = StoryTemplate.bind({});
|
|
64
|
+
InputFieldWithMaxLength.args = {
|
|
65
|
+
maxLength: 20,
|
|
66
|
+
id: 'withMaxLength',
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const InputFieldWithError = StoryTemplate.bind({});
|
|
70
|
+
InputFieldWithError.args = {
|
|
71
|
+
error: 'Error text',
|
|
72
|
+
id: 'withError',
|
|
73
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import cx from 'clsx';
|
|
3
|
+
import { TextField } from '../TextField';
|
|
4
|
+
|
|
5
|
+
import styles from './InputField.module.scss';
|
|
6
|
+
|
|
7
|
+
const baseClass = 'input-field';
|
|
8
|
+
|
|
9
|
+
export interface InputFieldProps
|
|
10
|
+
extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
11
|
+
id: string;
|
|
12
|
+
labelText?: string;
|
|
13
|
+
labelAdornment?: React.ReactNode;
|
|
14
|
+
className?: string;
|
|
15
|
+
inline?: boolean;
|
|
16
|
+
error?: string;
|
|
17
|
+
description?: React.ReactNode;
|
|
18
|
+
labelRightNode?: React.ReactNode;
|
|
19
|
+
fieldClassName?: string;
|
|
20
|
+
maxLength?: number;
|
|
21
|
+
onChange: () => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const InputField: React.FC<InputFieldProps> = React.forwardRef(
|
|
25
|
+
(
|
|
26
|
+
{
|
|
27
|
+
id,
|
|
28
|
+
labelText,
|
|
29
|
+
labelAdornment,
|
|
30
|
+
className,
|
|
31
|
+
inline,
|
|
32
|
+
error,
|
|
33
|
+
description,
|
|
34
|
+
labelRightNode,
|
|
35
|
+
fieldClassName,
|
|
36
|
+
style,
|
|
37
|
+
type = 'text',
|
|
38
|
+
...restProps
|
|
39
|
+
},
|
|
40
|
+
ref: React.Ref<HTMLInputElement>
|
|
41
|
+
) => {
|
|
42
|
+
const mergedClassNames = cx(
|
|
43
|
+
styles[baseClass],
|
|
44
|
+
{
|
|
45
|
+
[styles[`${baseClass}--error`]]: error,
|
|
46
|
+
},
|
|
47
|
+
fieldClassName
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<TextField
|
|
52
|
+
inline={inline}
|
|
53
|
+
error={error}
|
|
54
|
+
description={description}
|
|
55
|
+
labelText={labelText}
|
|
56
|
+
labelAdornment={labelAdornment}
|
|
57
|
+
className={className}
|
|
58
|
+
labelFor={id}
|
|
59
|
+
labelRightNode={labelRightNode}
|
|
60
|
+
>
|
|
61
|
+
<input
|
|
62
|
+
{...restProps}
|
|
63
|
+
id={id}
|
|
64
|
+
ref={ref}
|
|
65
|
+
className={mergedClassNames}
|
|
66
|
+
style={style}
|
|
67
|
+
type={type}
|
|
68
|
+
/>
|
|
69
|
+
</TextField>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InputField } from './InputField';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.link {
|
|
2
|
+
color: var(--color-action-default);
|
|
3
|
+
cursor: pointer;
|
|
4
|
+
text-decoration: none;
|
|
5
|
+
|
|
6
|
+
&:hover {
|
|
7
|
+
color: var(--color-action-hover);
|
|
8
|
+
text-decoration: underline;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&:active {
|
|
12
|
+
color: var(--color-action-active);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&--bold {
|
|
16
|
+
font-weight: 600;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentMeta } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { Link as LinkComponent, LinkProps } from './Link';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/Link',
|
|
8
|
+
component: LinkComponent,
|
|
9
|
+
} as ComponentMeta<typeof LinkComponent>;
|
|
10
|
+
|
|
11
|
+
export const Link = ({ ...args }: LinkProps): React.ReactElement => (
|
|
12
|
+
<LinkComponent {...args}>This is a link</LinkComponent>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
Link.args = {
|
|
16
|
+
bold: false,
|
|
17
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import cx from 'clsx';
|
|
3
|
+
|
|
4
|
+
import styles from './Link.module.scss';
|
|
5
|
+
|
|
6
|
+
export interface LinkProps
|
|
7
|
+
extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
8
|
+
bold: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const baseClass = 'link';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Simple component which renders an `<a>` element.
|
|
15
|
+
*
|
|
16
|
+
* Place the `<Link>` inside a `<Text>` component or pass a custom className to set the typography styles.
|
|
17
|
+
*
|
|
18
|
+
* Use `<Button kind="link">` to act as a `<button>` - <a target="_self" href="/story/components-button--kinds">see the story</a>.
|
|
19
|
+
*
|
|
20
|
+
* Use `<Button href="">` to display as a `<Button>` - <a target="_self" href="/story/components-button--link">see the story</a>.
|
|
21
|
+
*/
|
|
22
|
+
export const Link: React.FC<LinkProps> = ({
|
|
23
|
+
bold = false,
|
|
24
|
+
className = '',
|
|
25
|
+
...rest
|
|
26
|
+
}) => {
|
|
27
|
+
return (
|
|
28
|
+
<a
|
|
29
|
+
className={cx(
|
|
30
|
+
styles[baseClass],
|
|
31
|
+
bold && styles[`${baseClass}--bold`],
|
|
32
|
+
className
|
|
33
|
+
)}
|
|
34
|
+
{...rest}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Link } from './Link';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
@keyframes rotate {
|
|
2
|
+
from {
|
|
3
|
+
transform: rotate(0deg);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
to {
|
|
7
|
+
transform: rotate(1turn);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.loader {
|
|
12
|
+
align-items: center;
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
flex-direction: row;
|
|
15
|
+
flex-wrap: nowrap;
|
|
16
|
+
|
|
17
|
+
&__spinner {
|
|
18
|
+
flex-shrink: 0;
|
|
19
|
+
height: 36px;
|
|
20
|
+
width: 36px;
|
|
21
|
+
|
|
22
|
+
&--small {
|
|
23
|
+
height: 15px;
|
|
24
|
+
width: 15px;
|
|
25
|
+
|
|
26
|
+
[class*='spinner-circle'] {
|
|
27
|
+
border-width: 2px;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&--medium {
|
|
32
|
+
height: 36px;
|
|
33
|
+
width: 36px;
|
|
34
|
+
|
|
35
|
+
[class*='spinner-circle'] {
|
|
36
|
+
border-width: 3px;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&--large {
|
|
41
|
+
height: 56px;
|
|
42
|
+
width: 56px;
|
|
43
|
+
|
|
44
|
+
[class*='spinner-circle'] {
|
|
45
|
+
border-width: 4px;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&-circle {
|
|
50
|
+
animation: rotate 1s infinite linear;
|
|
51
|
+
border-color: var(--surface-secondary-subtle);
|
|
52
|
+
border-radius: 50%;
|
|
53
|
+
border-style: solid;
|
|
54
|
+
border-top-color: var(--color-action-default);
|
|
55
|
+
border-width: 3px;
|
|
56
|
+
box-sizing: border-box;
|
|
57
|
+
height: 100%;
|
|
58
|
+
width: 100%;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&__label {
|
|
63
|
+
color: var(--content-subtle);
|
|
64
|
+
margin-left: 10px;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { render } from 'test-utils';
|
|
3
|
+
|
|
4
|
+
import { Loader } from './Loader';
|
|
5
|
+
import styles from './Loader.module.scss';
|
|
6
|
+
|
|
7
|
+
describe('<Loader> component', () => {
|
|
8
|
+
function renderLoader(props = {}) {
|
|
9
|
+
const result = render(<Loader {...props} />);
|
|
10
|
+
return {
|
|
11
|
+
...result,
|
|
12
|
+
loaderEl: result.container.firstChild,
|
|
13
|
+
spinnerEl: result.container.querySelector(
|
|
14
|
+
`.${styles['loader__spinner']}`
|
|
15
|
+
),
|
|
16
|
+
circleEl: result.container.querySelector(
|
|
17
|
+
`.${styles['loader__spinner-circle']}`
|
|
18
|
+
),
|
|
19
|
+
labelEl: result.container.querySelector(`.${styles['loader__label']}`),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
it('should have default set of classNames', () => {
|
|
24
|
+
const { loaderEl, spinnerEl, circleEl } = renderLoader();
|
|
25
|
+
|
|
26
|
+
expect(loaderEl).toHaveClass(styles['loader']);
|
|
27
|
+
expect(spinnerEl).toBeVisible();
|
|
28
|
+
expect(spinnerEl).toHaveClass(styles['loader__spinner--medium']);
|
|
29
|
+
expect(circleEl).toBeVisible();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should allow for custom className', () => {
|
|
33
|
+
const { loaderEl } = renderLoader({ className: 'my-loader-class' });
|
|
34
|
+
|
|
35
|
+
expect(loaderEl).toHaveClass('my-loader-class');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should not display "label" by default', () => {
|
|
39
|
+
const { labelEl } = renderLoader();
|
|
40
|
+
|
|
41
|
+
expect(labelEl).not.toBeInTheDocument();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should display label passed via "label" prop', () => {
|
|
45
|
+
const { labelEl } = renderLoader({ label: 'my custom label' });
|
|
46
|
+
|
|
47
|
+
expect(labelEl).toBeVisible();
|
|
48
|
+
expect(labelEl).toHaveTextContent('my custom label');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should allow for change colors of loader', () => {
|
|
52
|
+
const { circleEl } = renderLoader({
|
|
53
|
+
primaryColor: 'red',
|
|
54
|
+
secondaryColor: 'blue',
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const { borderColor, borderTopColor } = getComputedStyle(
|
|
58
|
+
circleEl as HTMLElement
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
expect(borderColor).toBe('blue');
|
|
62
|
+
expect(borderTopColor).toBe('red');
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentMeta } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { Loader, LoaderProps } from './Loader';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/Loader',
|
|
8
|
+
component: Loader,
|
|
9
|
+
} as ComponentMeta<typeof Loader>;
|
|
10
|
+
|
|
11
|
+
export const sizes = (): React.ReactElement => (
|
|
12
|
+
<div className="spacer">
|
|
13
|
+
<Loader size="small" />
|
|
14
|
+
<Loader size="medium" />
|
|
15
|
+
<Loader size="large"></Loader>
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export const labeled = (args: LoaderProps): React.ReactElement => (
|
|
20
|
+
<Loader size="small" label="Loading..." {...args} />
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export const customColors = (args: LoaderProps): React.ReactElement => (
|
|
24
|
+
<Loader primaryColor="#d64646" secondaryColor="#eec4c5" {...args} />
|
|
25
|
+
);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import cx from 'clsx';
|
|
3
|
+
|
|
4
|
+
import { Text } from '../Typography';
|
|
5
|
+
|
|
6
|
+
import styles from './Loader.module.scss';
|
|
7
|
+
|
|
8
|
+
const baseClass = 'loader';
|
|
9
|
+
const spinnerClass = `${baseClass}__spinner`;
|
|
10
|
+
|
|
11
|
+
export interface LoaderProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
12
|
+
size?: 'small' | 'medium' | 'large';
|
|
13
|
+
label?: string;
|
|
14
|
+
/** Fragment circle color */
|
|
15
|
+
primaryColor?: string;
|
|
16
|
+
/** Main circle color */
|
|
17
|
+
secondaryColor?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const Loader: React.FC<LoaderProps> = ({
|
|
21
|
+
primaryColor,
|
|
22
|
+
secondaryColor,
|
|
23
|
+
label,
|
|
24
|
+
className,
|
|
25
|
+
size = 'medium',
|
|
26
|
+
}) => {
|
|
27
|
+
return (
|
|
28
|
+
<div className={cx(styles[baseClass], className)}>
|
|
29
|
+
<div
|
|
30
|
+
className={cx(styles[spinnerClass], styles[`${spinnerClass}--${size}`])}
|
|
31
|
+
>
|
|
32
|
+
<div
|
|
33
|
+
className={styles['loader__spinner-circle']}
|
|
34
|
+
style={{
|
|
35
|
+
/* stylelint-disable */
|
|
36
|
+
borderColor: secondaryColor,
|
|
37
|
+
borderTopColor: primaryColor,
|
|
38
|
+
}}
|
|
39
|
+
/>
|
|
40
|
+
</div>
|
|
41
|
+
{label && (
|
|
42
|
+
<Text as="div" size="md" className={styles['loader__label']}>
|
|
43
|
+
{label}
|
|
44
|
+
</Text>
|
|
45
|
+
)}
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Loader } from './Loader';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import cx from 'clsx';
|
|
3
|
+
import { ModalBaseProps, ModalBase } from './ModalBase';
|
|
4
|
+
|
|
5
|
+
import styles from './Modal.module.scss';
|
|
6
|
+
|
|
7
|
+
export interface ActionModalProps extends ModalBaseProps {
|
|
8
|
+
icon?: React.ReactNode;
|
|
9
|
+
heading?: React.ReactNode;
|
|
10
|
+
actions?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const baseClass = 'action-modal';
|
|
14
|
+
|
|
15
|
+
export const ActionModal: React.FC<ActionModalProps> = ({
|
|
16
|
+
children,
|
|
17
|
+
className = '',
|
|
18
|
+
icon,
|
|
19
|
+
heading,
|
|
20
|
+
actions,
|
|
21
|
+
...props
|
|
22
|
+
}) => {
|
|
23
|
+
const mergedClassNames = cx(styles[baseClass], className);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<ModalBase className={mergedClassNames} {...props}>
|
|
27
|
+
{icon && <div className={styles[`${baseClass}__icon`]}>{icon}</div>}
|
|
28
|
+
{heading && (
|
|
29
|
+
<div className={styles[`${baseClass}__heading`]}>{heading}</div>
|
|
30
|
+
)}
|
|
31
|
+
<div className={styles[`${baseClass}__content`]}>{children}</div>
|
|
32
|
+
{actions && (
|
|
33
|
+
<div className={styles[`${baseClass}__actions`]}>{actions}</div>
|
|
34
|
+
)}
|
|
35
|
+
</ModalBase>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
.modal-base {
|
|
2
|
+
background-color: var(--surface-basic-default);
|
|
3
|
+
border-radius: 4px;
|
|
4
|
+
box-shadow: 0 20px 60px 0 rgba(0, 0, 0, 0.3);
|
|
5
|
+
color: var(--content-default);
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
margin: 10px;
|
|
9
|
+
max-width: 800px;
|
|
10
|
+
min-width: 400px;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
position: relative;
|
|
13
|
+
|
|
14
|
+
&__overlay {
|
|
15
|
+
align-items: center;
|
|
16
|
+
background-color: var(--surface-overlay);
|
|
17
|
+
display: none;
|
|
18
|
+
height: 100%;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
left: 0;
|
|
21
|
+
position: fixed;
|
|
22
|
+
top: 0;
|
|
23
|
+
width: 100%;
|
|
24
|
+
z-index: 13000;
|
|
25
|
+
|
|
26
|
+
&--visible {
|
|
27
|
+
display: flex;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&__close {
|
|
32
|
+
align-items: center;
|
|
33
|
+
background-color: transparent;
|
|
34
|
+
border-style: none;
|
|
35
|
+
box-shadow: none;
|
|
36
|
+
color: var(--content-subtle);
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
display: flex;
|
|
39
|
+
height: 24px;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
outline: none;
|
|
42
|
+
padding: 0;
|
|
43
|
+
position: absolute;
|
|
44
|
+
right: 18px;
|
|
45
|
+
top: 18px;
|
|
46
|
+
width: 24px;
|
|
47
|
+
z-index: 1;
|
|
48
|
+
|
|
49
|
+
&:hover {
|
|
50
|
+
color: var(--content-default);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.modal {
|
|
56
|
+
&__header {
|
|
57
|
+
background-color: var(--surface-basic-default);
|
|
58
|
+
box-shadow: inset 0 -1px 0 var(--border-subtle);
|
|
59
|
+
box-sizing: border-box;
|
|
60
|
+
color: var(--content-default);
|
|
61
|
+
padding: 20px;
|
|
62
|
+
width: 100%;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&__heading {
|
|
66
|
+
color: var(--content-default);
|
|
67
|
+
margin: 0;
|
|
68
|
+
max-width: calc(100% - 32px);
|
|
69
|
+
padding: 0;
|
|
70
|
+
text-align: left;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&__body {
|
|
74
|
+
background-color: var(--surface-basic-default);
|
|
75
|
+
box-sizing: border-box;
|
|
76
|
+
color: var(--content-default);
|
|
77
|
+
display: flex;
|
|
78
|
+
flex-direction: column;
|
|
79
|
+
flex-grow: 1;
|
|
80
|
+
padding: 20px;
|
|
81
|
+
position: relative;
|
|
82
|
+
width: 100%;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&__footer {
|
|
86
|
+
box-shadow: inset 0 1px 0 var(--border-subtle);
|
|
87
|
+
box-sizing: border-box;
|
|
88
|
+
display: flex;
|
|
89
|
+
flex-shrink: 0;
|
|
90
|
+
justify-content: flex-end;
|
|
91
|
+
padding: 20px;
|
|
92
|
+
width: 100%;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.action-modal {
|
|
97
|
+
align-items: center;
|
|
98
|
+
box-sizing: border-box;
|
|
99
|
+
justify-content: center;
|
|
100
|
+
padding: 52px 20px;
|
|
101
|
+
|
|
102
|
+
&__heading {
|
|
103
|
+
color: var(--content-default);
|
|
104
|
+
font-size: 24px;
|
|
105
|
+
font-weight: 600;
|
|
106
|
+
line-height: 1.33;
|
|
107
|
+
margin: 0 0 20px;
|
|
108
|
+
text-align: center;
|
|
109
|
+
width: 100%;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
&__content {
|
|
113
|
+
color: var(--content-default);
|
|
114
|
+
font-size: 15px;
|
|
115
|
+
line-height: 1.33;
|
|
116
|
+
text-align: center;
|
|
117
|
+
width: 100%;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&__actions {
|
|
121
|
+
box-sizing: border-box;
|
|
122
|
+
display: flex;
|
|
123
|
+
justify-content: center;
|
|
124
|
+
margin-top: 32px;
|
|
125
|
+
width: 100%;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&__icon {
|
|
129
|
+
margin-bottom: 20px;
|
|
130
|
+
}
|
|
131
|
+
}
|