@oliasoft-open-source/react-ui-library 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +2 -0
- package/.eslintrc.js +125 -0
- package/.gitlab-ci.yml +45 -0
- package/.husky/pre-commit +4 -0
- package/.prettierignore +3 -0
- package/.prettierrc +4 -0
- package/.storybook/main.js +36 -0
- package/.storybook/preview.js +40 -0
- package/.storybook/storybook.less +8 -0
- package/LICENSE +21 -0
- package/README.md +5 -0
- package/babel.config.js +31 -0
- package/index.js +76 -0
- package/jest.config.js +9 -0
- package/package.json +136 -0
- package/src/components/accordion/accordion.jsx +132 -0
- package/src/components/accordion/accordion.module.less +66 -0
- package/src/components/accordion/accordion.stories.jsx +171 -0
- package/src/components/accordion/chevron/chevron.jsx +12 -0
- package/src/components/accordion/chevron/chevron.module.less +12 -0
- package/src/components/accordion/helpers/accordion-with-default-toggle.jsx +106 -0
- package/src/components/accordion/helpers/accordion-with-default-toggle.module.less +24 -0
- package/src/components/actions/actions.jsx +129 -0
- package/src/components/actions/actions.module.less +44 -0
- package/src/components/actions/actions.shape.js +32 -0
- package/src/components/actions/actions.stories.jsx +79 -0
- package/src/components/badge/badge.jsx +58 -0
- package/src/components/badge/badge.module.less +55 -0
- package/src/components/badge/badge.stories.jsx +31 -0
- package/src/components/breadcrumb/breadcrumb.jsx +49 -0
- package/src/components/breadcrumb/breadcrumb.module.less +39 -0
- package/src/components/breadcrumb/breadcrumb.stories.jsx +45 -0
- package/src/components/breadcrumb/link.jsx +31 -0
- package/src/components/button/button.jsx +156 -0
- package/src/components/button/button.module.less +300 -0
- package/src/components/button/button.stories.jsx +74 -0
- package/src/components/button-group/button-group.jsx +140 -0
- package/src/components/button-group/button-group.module.less +24 -0
- package/src/components/button-group/button-group.stories-data.jsx +67 -0
- package/src/components/button-group/button-group.stories.jsx +63 -0
- package/src/components/buttons-and-links.stories.mdx +55 -0
- package/src/components/card/card.jsx +51 -0
- package/src/components/card/card.module.less +48 -0
- package/src/components/card/card.stories.jsx +39 -0
- package/src/components/check-box/check-box.jsx +92 -0
- package/src/components/check-box/check-box.module.less +101 -0
- package/src/components/check-box/check-box.stories.jsx +27 -0
- package/src/components/color/color.stories-data.jsx +71 -0
- package/src/components/color/color.stories.mdx +37 -0
- package/src/components/dialog/dialog.jsx +64 -0
- package/src/components/dialog/dialog.module.less +76 -0
- package/src/components/divider/divider.jsx +40 -0
- package/src/components/divider/divider.module.less +28 -0
- package/src/components/divider/divider.stories.jsx +50 -0
- package/src/components/drawer/drawer-tabs.jsx +43 -0
- package/src/components/drawer/drawer.jsx +150 -0
- package/src/components/drawer/drawer.module.less +167 -0
- package/src/components/drawer/drawer.stories.jsx +156 -0
- package/src/components/empty/empty.jsx +52 -0
- package/src/components/empty/empty.module.less +17 -0
- package/src/components/empty/empty.stories.jsx +26 -0
- package/src/components/file-input/file-input.jsx +101 -0
- package/src/components/file-input/file-input.module.less +3 -0
- package/src/components/file-input/file-input.stories.jsx +109 -0
- package/src/components/form/field.jsx +96 -0
- package/src/components/form/field.stories.jsx +101 -0
- package/src/components/form/form.module.less +30 -0
- package/src/components/form/form.stories.jsx +191 -0
- package/src/components/heading/heading.jsx +105 -0
- package/src/components/heading/heading.module.less +59 -0
- package/src/components/heading/heading.stories.jsx +60 -0
- package/src/components/icon/deprecated-icon.jsx +97 -0
- package/src/components/icon/icon.jsx +71 -0
- package/src/components/icon/icon.module.less +33 -0
- package/src/components/icon/icon.stories.jsx +37 -0
- package/src/components/icon/icons.example.module.less +4 -0
- package/src/components/input/input.jsx +167 -0
- package/src/components/input/input.module.less +94 -0
- package/src/components/input/input.stories.jsx +28 -0
- package/src/components/input-group/input-group-addon/input-group-addon.jsx +36 -0
- package/src/components/input-group/input-group-addon/input-group-addon.module.less +31 -0
- package/src/components/input-group/input-group.jsx +51 -0
- package/src/components/input-group/input-group.module.less +10 -0
- package/src/components/input-group/input-group.stories.jsx +77 -0
- package/src/components/input-validation.stories.mdx +61 -0
- package/src/components/inputs.stories.mdx +201 -0
- package/src/components/label/label.jsx +115 -0
- package/src/components/label/label.module.less +43 -0
- package/src/components/label/label.stories.jsx +60 -0
- package/src/components/layout/column/column.jsx +85 -0
- package/src/components/layout/column/styles.js +45 -0
- package/src/components/layout/column.stories.jsx +60 -0
- package/src/components/layout/examples/afe.stories.jsx +180 -0
- package/src/components/layout/examples/blowout.stories.jsx +68 -0
- package/src/components/layout/examples/casing-loads.stories.jsx +297 -0
- package/src/components/layout/examples/formation.stories.jsx +110 -0
- package/src/components/layout/examples/projects.stories.jsx +108 -0
- package/src/components/layout/examples/reservoirs.stories.jsx +211 -0
- package/src/components/layout/examples/site.stories.jsx +263 -0
- package/src/components/layout/flex/flex.jsx +48 -0
- package/src/components/layout/flex/flex.stories.jsx +54 -0
- package/src/components/layout/form-row/form-row.jsx +15 -0
- package/src/components/layout/form-row/form-row.module.less +11 -0
- package/src/components/layout/grid/grid.jsx +62 -0
- package/src/components/layout/grid/grid.stories.jsx +65 -0
- package/src/components/layout/page/page.jsx +42 -0
- package/src/components/layout/page/page.module.less +27 -0
- package/src/components/layout/page.stories.jsx +93 -0
- package/src/components/layout/placeholder.jsx +2 -0
- package/src/components/layout/print-header/print-header.jsx +22 -0
- package/src/components/layout/print-header/print-header.module.less +9 -0
- package/src/components/layout/row/row.jsx +75 -0
- package/src/components/layout/row/row.module.less +7 -0
- package/src/components/layout/spacer/spacer.jsx +26 -0
- package/src/components/layout/spacer/spacer.stories.jsx +50 -0
- package/src/components/layout-forms.stories.mdx +104 -0
- package/src/components/layout-general.stories.mdx +215 -0
- package/src/components/list/list-row/item-content.jsx +15 -0
- package/src/components/list/list-row/label.jsx +11 -0
- package/src/components/list/list-row/list-heading.jsx +52 -0
- package/src/components/list/list-row/list-row.jsx +128 -0
- package/src/components/list/list-row/list-subheading.jsx +72 -0
- package/src/components/list/list-row/meta-content.jsx +24 -0
- package/src/components/list/list-row/meta-count.jsx +10 -0
- package/src/components/list/list-row/name.jsx +45 -0
- package/src/components/list/list.jsx +276 -0
- package/src/components/list/list.module.less +256 -0
- package/src/components/list/list.stories-data.jsx +287 -0
- package/src/components/list/list.stories.jsx +458 -0
- package/src/components/list/toggle-narrow.jsx +13 -0
- package/src/components/loader/loader.jsx +63 -0
- package/src/components/loader/loader.module.less +63 -0
- package/src/components/loader/loader.stories.jsx +155 -0
- package/src/components/menu/index.js +7 -0
- package/src/components/menu/layer/divider.jsx +4 -0
- package/src/components/menu/layer/heading.jsx +15 -0
- package/src/components/menu/layer/layer.jsx +82 -0
- package/src/components/menu/layer/option.jsx +77 -0
- package/src/components/menu/layer/path.js +44 -0
- package/src/components/menu/layer/placementOptions.js +6 -0
- package/src/components/menu/layer/section.jsx +66 -0
- package/src/components/menu/menu.jsx +359 -0
- package/src/components/menu/menu.module.less +241 -0
- package/src/components/menu/menu.stories-data.jsx +168 -0
- package/src/components/menu/menu.stories.jsx +126 -0
- package/src/components/menu/menu.test.js +58 -0
- package/src/components/menu/trigger/button.jsx +50 -0
- package/src/components/menu/trigger/component.jsx +14 -0
- package/src/components/menu/trigger/text.jsx +25 -0
- package/src/components/menu/trigger/trigger.jsx +86 -0
- package/src/components/message/dismiss.jsx +26 -0
- package/src/components/message/message.jsx +137 -0
- package/src/components/message/message.module.less +114 -0
- package/src/components/message/message.stories.jsx +84 -0
- package/src/components/modal/modal.jsx +50 -0
- package/src/components/modal/modal.module.less +35 -0
- package/src/components/modal/modal.stories.jsx +159 -0
- package/src/components/option-dropdown/heading.jsx +6 -0
- package/src/components/option-dropdown/layer.jsx +81 -0
- package/src/components/option-dropdown/option-dropdown.jsx +53 -0
- package/src/components/option-dropdown/option-dropdown.module.less +50 -0
- package/src/components/option-dropdown/option-dropdown.stories.jsx +35 -0
- package/src/components/option-dropdown/option.jsx +13 -0
- package/src/components/pagination/pagination.jsx +139 -0
- package/src/components/pagination/pagination.module.less +11 -0
- package/src/components/pagination/pagination.stories.jsx +78 -0
- package/src/components/pagination/pagination.test.js +92 -0
- package/src/components/pagination/pagination.viewdata.js +66 -0
- package/src/components/pop-confirm/content.jsx +25 -0
- package/src/components/pop-confirm/pop-confirm.jsx +61 -0
- package/src/components/pop-confirm/pop-confirm.module.less +18 -0
- package/src/components/pop-confirm/pop-confirm.stories.jsx +53 -0
- package/src/components/popover/popover.jsx +112 -0
- package/src/components/popover/popover.module.less +22 -0
- package/src/components/popover/popover.stories.jsx +59 -0
- package/src/components/portal/portal.jsx +16 -0
- package/src/components/portal/portal.stories.jsx +69 -0
- package/src/components/progress-bar/progress-bar.jsx +64 -0
- package/src/components/progress-bar/progress-bar.module.less +64 -0
- package/src/components/progress-bar/progress-bar.stories.jsx +23 -0
- package/src/components/radio-button/radio-button.jsx +139 -0
- package/src/components/radio-button/radio-button.module.less +135 -0
- package/src/components/radio-button/radio-button.stories.jsx +37 -0
- package/src/components/radio-button/radio-input.jsx +52 -0
- package/src/components/select/custom-select/custom-select.jsx +440 -0
- package/src/components/select/custom-select/custom-select.module.less +123 -0
- package/src/components/select/custom-select/custom-select.reducer.js +157 -0
- package/src/components/select/custom-select/layer/heading.jsx +13 -0
- package/src/components/select/custom-select/layer/layer.jsx +73 -0
- package/src/components/select/custom-select/layer/option.jsx +54 -0
- package/src/components/select/custom-select/layer/placementOptions.js +7 -0
- package/src/components/select/custom-select/layer/section.jsx +35 -0
- package/src/components/select/custom-select/trigger/input.jsx +100 -0
- package/src/components/select/custom-select/trigger/trigger.jsx +155 -0
- package/src/components/select/custom-select/trigger/trigger.module.less +289 -0
- package/src/components/select/native-select/native-select.jsx +198 -0
- package/src/components/select/native-select/native-select.module.less +107 -0
- package/src/components/select/select.input.js +146 -0
- package/src/components/select/select.jsx +207 -0
- package/src/components/select/select.stories-data.jsx +92 -0
- package/src/components/select/select.stories.jsx +135 -0
- package/src/components/select/select.test.js +519 -0
- package/src/components/side-bar/container.module.less +29 -0
- package/src/components/side-bar/link.jsx +83 -0
- package/src/components/side-bar/sections.jsx +23 -0
- package/src/components/side-bar/side-bar.jsx +102 -0
- package/src/components/side-bar/side-bar.module.less +137 -0
- package/src/components/side-bar/side-bar.stories.jsx +101 -0
- package/src/components/slider/rc-slider.less +47 -0
- package/src/components/slider/slider-tooltip.jsx +20 -0
- package/src/components/slider/slider.jsx +233 -0
- package/src/components/slider/slider.module.less +40 -0
- package/src/components/slider/slider.stories.jsx +110 -0
- package/src/components/spinner/spinner.jsx +37 -0
- package/src/components/spinner/spinner.module.less +115 -0
- package/src/components/spinner/spinner.stories.jsx +24 -0
- package/src/components/table/cell/cell.jsx +614 -0
- package/src/components/table/cell/cell.module.less +152 -0
- package/src/components/table/footer/footer.jsx +66 -0
- package/src/components/table/footer/footer.module.less +14 -0
- package/src/components/table/helper.js +64 -0
- package/src/components/table/helper.test.js +166 -0
- package/src/components/table/icon/icon.module.less +31 -0
- package/src/components/table/row/expanded-content-row.jsx +16 -0
- package/src/components/table/row/row.jsx +253 -0
- package/src/components/table/row/row.module.less +62 -0
- package/src/components/table/table-scroll-wrapper.jsx +48 -0
- package/src/components/table/table.jsx +232 -0
- package/src/components/table/table.module.less +145 -0
- package/src/components/table/table.stories-data.jsx +752 -0
- package/src/components/table/table.stories.jsx +814 -0
- package/src/components/table/table.test.js +30 -0
- package/src/components/table/table.variables.less +19 -0
- package/src/components/table/table.viewdata.js +26 -0
- package/src/components/table/title/title.jsx +30 -0
- package/src/components/table/title/title.module.less +9 -0
- package/src/components/tabs/content.jsx +14 -0
- package/src/components/tabs/label.jsx +50 -0
- package/src/components/tabs/tabs.jsx +191 -0
- package/src/components/tabs/tabs.module.less +73 -0
- package/src/components/tabs/tabs.stories.jsx +110 -0
- package/src/components/text/text.jsx +64 -0
- package/src/components/text/text.module.less +45 -0
- package/src/components/text/text.stories.jsx +31 -0
- package/src/components/text-link/text-link.jsx +23 -0
- package/src/components/text-link/text-link.stories.jsx +20 -0
- package/src/components/textarea/textarea.jsx +126 -0
- package/src/components/textarea/textarea.module.less +55 -0
- package/src/components/textarea/textarea.stories.jsx +26 -0
- package/src/components/toaster/toaster.jsx +39 -0
- package/src/components/toaster/toaster.less +17 -0
- package/src/components/toaster/toaster.stories.jsx +116 -0
- package/src/components/toggle/toggle.jsx +65 -0
- package/src/components/toggle/toggle.module.less +139 -0
- package/src/components/toggle/toggle.stories.jsx +26 -0
- package/src/components/tooltip/tooltip-layer.jsx +72 -0
- package/src/components/tooltip/tooltip.jsx +108 -0
- package/src/components/tooltip/tooltip.module.less +28 -0
- package/src/components/tooltip/tooltip.stories.jsx +71 -0
- package/src/components/top-bar/element/element.jsx +72 -0
- package/src/components/top-bar/element/link.jsx +29 -0
- package/src/components/top-bar/title.jsx +24 -0
- package/src/components/top-bar/top-bar.jsx +79 -0
- package/src/components/top-bar/top-bar.module.less +191 -0
- package/src/components/top-bar/top-bar.stories.jsx +137 -0
- package/src/components/top-bar/warning.jsx +6 -0
- package/src/components/tree/tree-item.jsx +79 -0
- package/src/components/tree/tree-placeholder.jsx +6 -0
- package/src/components/tree/tree.jsx +129 -0
- package/src/components/tree/tree.module.less +33 -0
- package/src/components/tree/tree.stories-data.jsx +89 -0
- package/src/components/tree/tree.stories.jsx +106 -0
- package/src/docs/components/page/page.jsx +16 -0
- package/src/docs/config/config.js +1 -0
- package/src/docs/html/favicon.png +0 -0
- package/src/docs/html/index.html +11 -0
- package/src/docs/navigation/footer/footer.jsx +48 -0
- package/src/docs/navigation/header/header.jsx +39 -0
- package/src/docs/navigation/header/header.module.less +32 -0
- package/src/docs/navigation/routes/routes.jsx +16 -0
- package/src/docs/start.jsx +12 -0
- package/src/docs/views/main/main.jsx +209 -0
- package/src/docs/views/main/main.module.less +14 -0
- package/src/docs/views/not-found/not-found.jsx +5 -0
- package/src/helpers/disabled-context.js +8 -0
- package/src/helpers/styles.js +68 -0
- package/src/helpers/text.js +6 -0
- package/src/helpers/types.js +5 -0
- package/src/hooks/index.js +3 -0
- package/src/hooks/use-focus.js +11 -0
- package/src/hooks/use-keyboard-event.js +16 -0
- package/src/hooks/use-window-width.js +20 -0
- package/src/images/icons/icon-drop.png +0 -0
- package/src/images/icons/icon-share.png +0 -0
- package/src/images/icons/icons8-junction.svg +4 -0
- package/src/images/logo.png +0 -0
- package/src/images/logo.svg +13 -0
- package/src/images/oliasoft-logo.svg +1 -0
- package/src/style/colors.less +26 -0
- package/src/style/external.less +10 -0
- package/src/style/fonts/lato/Lato-Bold.woff2 +0 -0
- package/src/style/fonts/lato/Lato-BoldItalic.woff2 +0 -0
- package/src/style/fonts/lato/Lato-Italic.woff2 +0 -0
- package/src/style/fonts/lato/Lato-Regular.woff2 +0 -0
- package/src/style/fonts.less +27 -0
- package/src/style/global.less +51 -0
- package/src/style/mixins.less +67 -0
- package/src/style/reset/reset.less +34 -0
- package/src/style/shared.less +25 -0
- package/src/style/theme.dark.less +37 -0
- package/src/style/theme.default.less +74 -0
- package/src/style/variables.less +49 -0
- package/webpack/webpack.common.js +39 -0
- package/webpack/webpack.common.rules.js +102 -0
- package/webpack/webpack.dev.js +22 -0
- package/webpack/webpack.prod.js +23 -0
- package/webpack/webpack.resolve.js +22 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
@import '../../style/variables.less';
|
|
2
|
+
|
|
3
|
+
@boxShadowOuter: 0 1px 2px rgba(0, 0, 0, 0.1);
|
|
4
|
+
|
|
5
|
+
:root {
|
|
6
|
+
--color-background-button-default: var(--color-neutral-0);
|
|
7
|
+
--color-background-button-default-hover: var(--color-neutral-50);
|
|
8
|
+
--color-background-button-default-active: var(--color-neutral-100);
|
|
9
|
+
|
|
10
|
+
--color-background-button-primary: var(--color-primary-500);
|
|
11
|
+
--color-background-button-primary-hover: var(--color-primary-550);
|
|
12
|
+
--color-background-button-primary-active: var(--color-primary-600);
|
|
13
|
+
|
|
14
|
+
--color-background-button-success: var(--color-success-500);
|
|
15
|
+
--color-background-button-success-hover: var(--color-success-550);
|
|
16
|
+
--color-background-button-success-active: var(--color-success-600);
|
|
17
|
+
|
|
18
|
+
--color-background-button-error: var(--color-error-500);
|
|
19
|
+
--color-background-button-error-hover: var(--color-error-550);
|
|
20
|
+
--color-background-button-error-active: var(--color-error-600);
|
|
21
|
+
|
|
22
|
+
--color-border-button: rgba(black, 0.15);
|
|
23
|
+
--color-border-button-hover: rgba(black, 0.2);
|
|
24
|
+
|
|
25
|
+
--color-text-button-muted: rgba(black, 0.4);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
html[data-theme='dark'] {
|
|
29
|
+
--color-background-button-default: var(--color-neutral-700);
|
|
30
|
+
--color-background-button-default-hover: var(--color-neutral-650);
|
|
31
|
+
--color-background-button-default-active: var(--color-neutral-600);
|
|
32
|
+
|
|
33
|
+
--color-background-button-primary: var(--color-primary-muted-500);
|
|
34
|
+
--color-background-button-primary-hover: var(--color-primary-muted-550);
|
|
35
|
+
--color-background-button-primary-active: var(--color-primary-muted-600);
|
|
36
|
+
|
|
37
|
+
--color-background-button-success: var(--color-success-muted-500);
|
|
38
|
+
--color-background-button-success-hover: var(--color-success-muted-550);
|
|
39
|
+
--color-background-button-success-active: var(--color-success-muted-600);
|
|
40
|
+
|
|
41
|
+
--color-background-button-error: var(--color-error-muted-500);
|
|
42
|
+
--color-background-button-error-hover: var(--color-error-muted-550);
|
|
43
|
+
--color-background-button-error-active: var(--color-error-muted-600);
|
|
44
|
+
|
|
45
|
+
--color-border-button: transparent;
|
|
46
|
+
--color-border-button-hover: transparent;
|
|
47
|
+
|
|
48
|
+
--color-text-button-muted: rgba(white, 0.4);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.button {
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
display: inline-flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
justify-content: center;
|
|
56
|
+
outline: 0;
|
|
57
|
+
border: 1px solid var(--color-border-button);
|
|
58
|
+
vertical-align: baseline;
|
|
59
|
+
background: var(--color-background-button-default);
|
|
60
|
+
color: var(--color-text);
|
|
61
|
+
font-family: @default_font;
|
|
62
|
+
padding: @input_padding_y @input_padding_x;
|
|
63
|
+
text-transform: none;
|
|
64
|
+
text-shadow: none;
|
|
65
|
+
font-weight: 700;
|
|
66
|
+
line-height: 1em;
|
|
67
|
+
font-style: normal;
|
|
68
|
+
text-align: center;
|
|
69
|
+
text-decoration: none;
|
|
70
|
+
border-radius: @input_border_radius;
|
|
71
|
+
user-select: none;
|
|
72
|
+
transition: opacity 0.1s ease, background-color 0.1s ease, color 0.1s ease,
|
|
73
|
+
box-shadow 0.1s ease, background 0.1s ease;
|
|
74
|
+
max-width: 100%;
|
|
75
|
+
min-height: @input_height;
|
|
76
|
+
box-shadow: @boxShadowOuter;
|
|
77
|
+
|
|
78
|
+
&:hover {
|
|
79
|
+
background: var(--color-background-button-default-hover);
|
|
80
|
+
border-color: var(--color-border-button-hover);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&:active {
|
|
84
|
+
background: var(--color-background-button-default-active);
|
|
85
|
+
box-shadow: none;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
&.active {
|
|
89
|
+
border-color: var(--color-background-button-primary);
|
|
90
|
+
color: var(--color-text-primary);
|
|
91
|
+
position: relative;
|
|
92
|
+
z-index: 2;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
&:hover,
|
|
96
|
+
&:focus,
|
|
97
|
+
&:active {
|
|
98
|
+
position: relative;
|
|
99
|
+
z-index: 1;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.icon {
|
|
103
|
+
margin: 0 8px 0 -4px;
|
|
104
|
+
|
|
105
|
+
svg {
|
|
106
|
+
height: 14px;
|
|
107
|
+
width: 14px;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.iconOnly {
|
|
113
|
+
padding: 0.78571429em 0.78571429em 0.78571429em;
|
|
114
|
+
display: inline-flex;
|
|
115
|
+
align-items: center;
|
|
116
|
+
justify-content: center;
|
|
117
|
+
|
|
118
|
+
.icon {
|
|
119
|
+
margin: 0;
|
|
120
|
+
line-height: 0;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.basic {
|
|
125
|
+
color: var(--color-text-primary);
|
|
126
|
+
background: transparent;
|
|
127
|
+
box-shadow: none !important;
|
|
128
|
+
border: none !important;
|
|
129
|
+
|
|
130
|
+
&.muted {
|
|
131
|
+
color: var(--color-text-button-muted);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
&:hover,
|
|
135
|
+
&:focus {
|
|
136
|
+
color: var(--color-text-primary-hover);
|
|
137
|
+
background: rgba(0, 0, 0, 0.05);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
&:active,
|
|
141
|
+
&.active {
|
|
142
|
+
color: var(--color-text-primary-active);
|
|
143
|
+
background: rgba(0, 0, 0, 0.1);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.disabled {
|
|
148
|
+
cursor: default;
|
|
149
|
+
pointer-events: none !important;
|
|
150
|
+
color: var(--color-text-faint) !important;
|
|
151
|
+
box-shadow: none !important;
|
|
152
|
+
|
|
153
|
+
&:not(.active) {
|
|
154
|
+
&:not(.basic) {
|
|
155
|
+
background: var(--color-background-disabled) !important;
|
|
156
|
+
border: 1px solid var(--color-border) !important;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.small {
|
|
162
|
+
font-size: @input_font_size_small;
|
|
163
|
+
min-height: @input_height_small;
|
|
164
|
+
padding: 0 0.75rem;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.pill,
|
|
168
|
+
.round {
|
|
169
|
+
text-transform: uppercase;
|
|
170
|
+
letter-spacing: 0.1em;
|
|
171
|
+
font-size: 13px;
|
|
172
|
+
font-weight: bold;
|
|
173
|
+
border-radius: 19px;
|
|
174
|
+
display: inline-flex;
|
|
175
|
+
align-items: center;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.round {
|
|
179
|
+
padding: 0;
|
|
180
|
+
width: @input_height;
|
|
181
|
+
line-height: 1; // Fix for rendering issue on Windows
|
|
182
|
+
|
|
183
|
+
&.small {
|
|
184
|
+
width: @input_height_small;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.orange {
|
|
189
|
+
background-color: var(--color-background-button-primary);
|
|
190
|
+
|
|
191
|
+
&:hover,
|
|
192
|
+
&:focus {
|
|
193
|
+
background-color: var(--color-background-button-primary-hover);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
&:active {
|
|
197
|
+
background-color: var(--color-background-button-primary-active);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.red {
|
|
202
|
+
background-color: var(--color-background-button-error);
|
|
203
|
+
|
|
204
|
+
&:hover,
|
|
205
|
+
&:focus {
|
|
206
|
+
background-color: var(--color-background-button-error-hover);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
&:active {
|
|
210
|
+
background-color: var(--color-background-button-error-active);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.green {
|
|
215
|
+
background-color: var(--color-background-button-success);
|
|
216
|
+
|
|
217
|
+
&:hover,
|
|
218
|
+
&:focus {
|
|
219
|
+
background-color: var(--color-background-button-success-hover);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
&:active {
|
|
223
|
+
background-color: var(--color-background-button-success-active);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.orange,
|
|
228
|
+
.red,
|
|
229
|
+
.green {
|
|
230
|
+
color: #fff;
|
|
231
|
+
|
|
232
|
+
// &:not(.disabled) {
|
|
233
|
+
// border-color: transparent !important;
|
|
234
|
+
// }
|
|
235
|
+
|
|
236
|
+
&:hover,
|
|
237
|
+
&:focus {
|
|
238
|
+
color: #fff;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
&:active {
|
|
242
|
+
color: #fff;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.inverted {
|
|
247
|
+
background-color: transparent;
|
|
248
|
+
border-color: var(--color-text);
|
|
249
|
+
box-shadow: none;
|
|
250
|
+
|
|
251
|
+
&:hover,
|
|
252
|
+
&:focus,
|
|
253
|
+
&:active {
|
|
254
|
+
box-shadow: none;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
&.orange {
|
|
258
|
+
color: var(--color-background-button-primary);
|
|
259
|
+
border-color: var(--color-background-button-primary);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
&.red {
|
|
263
|
+
color: var(--color-background-button-error);
|
|
264
|
+
border-color: var(--color-background-button-error);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
&.green {
|
|
268
|
+
color: var(--color-background-button-success);
|
|
269
|
+
border-color: var(--color-background-button-success);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
&.orange,
|
|
273
|
+
&.red,
|
|
274
|
+
&.green {
|
|
275
|
+
&:hover,
|
|
276
|
+
&:focus,
|
|
277
|
+
&:active {
|
|
278
|
+
color: white;
|
|
279
|
+
box-shadow: none;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.groupOrderFirst,
|
|
285
|
+
.groupOrderMiddle,
|
|
286
|
+
.groupOrderLast {
|
|
287
|
+
margin-right: 0;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.groupOrderFirst,
|
|
291
|
+
.groupOrderMiddle {
|
|
292
|
+
border-top-right-radius: 0 !important;
|
|
293
|
+
border-bottom-right-radius: 0 !important;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.groupOrderLast,
|
|
297
|
+
.groupOrderMiddle {
|
|
298
|
+
border-top-left-radius: 0 !important;
|
|
299
|
+
border-bottom-left-radius: 0 !important;
|
|
300
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FaTrash } from 'react-icons/fa';
|
|
3
|
+
import { Button } from './button';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Forms/Button',
|
|
7
|
+
component: Button,
|
|
8
|
+
parameters: {
|
|
9
|
+
canvas: {
|
|
10
|
+
page: null,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
argTypes: {
|
|
14
|
+
colored: {
|
|
15
|
+
control: {
|
|
16
|
+
type: 'inline-radio',
|
|
17
|
+
},
|
|
18
|
+
options: {
|
|
19
|
+
off: false,
|
|
20
|
+
primary: 'primary',
|
|
21
|
+
success: 'success',
|
|
22
|
+
danger: 'danger',
|
|
23
|
+
muted: 'muted',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
icon: {
|
|
27
|
+
control: { type: 'inline-radio' },
|
|
28
|
+
options: {
|
|
29
|
+
off: undefined,
|
|
30
|
+
on: <FaTrash />,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
args: {
|
|
35
|
+
label: 'Label',
|
|
36
|
+
colored: false,
|
|
37
|
+
disabled: false,
|
|
38
|
+
icon: undefined,
|
|
39
|
+
basic: false,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const Template = (args) => (
|
|
44
|
+
<Button
|
|
45
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
46
|
+
{...args}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
export const Default = Template.bind({});
|
|
51
|
+
|
|
52
|
+
export const Small = Template.bind({});
|
|
53
|
+
Small.args = { small: true };
|
|
54
|
+
|
|
55
|
+
export const Basic = Template.bind({});
|
|
56
|
+
Basic.args = { basic: true };
|
|
57
|
+
|
|
58
|
+
export const WithIcon = Template.bind({});
|
|
59
|
+
WithIcon.args = { icon: <FaTrash /> };
|
|
60
|
+
|
|
61
|
+
export const Round = Template.bind({});
|
|
62
|
+
Round.args = { round: true, icon: <FaTrash />, label: undefined };
|
|
63
|
+
|
|
64
|
+
export const RoundMuted = Template.bind({});
|
|
65
|
+
RoundMuted.args = {
|
|
66
|
+
round: true,
|
|
67
|
+
icon: <FaTrash />,
|
|
68
|
+
label: undefined,
|
|
69
|
+
colored: 'muted',
|
|
70
|
+
basic: true,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const FullWidth = Template.bind({});
|
|
74
|
+
FullWidth.args = { width: '100%' };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import { Button } from '../button/button';
|
|
5
|
+
import { Tooltip } from '../tooltip/tooltip';
|
|
6
|
+
import styles from './button-group.module.less';
|
|
7
|
+
import { isStringNumberOrNode } from '../../helpers/types';
|
|
8
|
+
import { DisabledContext } from '../../helpers/disabled-context';
|
|
9
|
+
|
|
10
|
+
export class ButtonGroup extends React.PureComponent {
|
|
11
|
+
onClick = (evt, key, value, label, disabledContextValue, disabledButton) => {
|
|
12
|
+
evt.preventDefault();
|
|
13
|
+
evt.stopPropagation();
|
|
14
|
+
if (this.props.disabled || disabledButton || disabledContextValue) return;
|
|
15
|
+
this.props.onSelected(key, value, label);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
renderIcon = (icon) => {
|
|
19
|
+
if (icon) {
|
|
20
|
+
return <i className={cx('icon', icon)} />;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
renderButtons = () => {
|
|
25
|
+
const buttons = this.props.items;
|
|
26
|
+
return buttons.map((button, i) => {
|
|
27
|
+
const type = Array.isArray(button) ? 'array' : typeof button;
|
|
28
|
+
const groupOrder =
|
|
29
|
+
i === 0 ? 'first' : i === buttons.length - 1 ? 'last' : 'middle';
|
|
30
|
+
const label =
|
|
31
|
+
type === 'string'
|
|
32
|
+
? button
|
|
33
|
+
: type === 'object'
|
|
34
|
+
? button.label
|
|
35
|
+
: type === 'array'
|
|
36
|
+
? button[1]
|
|
37
|
+
: null;
|
|
38
|
+
const value =
|
|
39
|
+
type === 'string'
|
|
40
|
+
? button
|
|
41
|
+
: type === 'object'
|
|
42
|
+
? button.value
|
|
43
|
+
: type === 'array'
|
|
44
|
+
? button[0]
|
|
45
|
+
: null;
|
|
46
|
+
const key = type === 'object' ? button.key : value;
|
|
47
|
+
const hidden = type === 'object' ? button.hidden : false;
|
|
48
|
+
const icon = type === 'object' ? button.icon : false;
|
|
49
|
+
const active =
|
|
50
|
+
type === 'object'
|
|
51
|
+
? key === this.props.value
|
|
52
|
+
: value === this.props.value;
|
|
53
|
+
const { error, maxTooltipWidth, testId, tooltip, warning } = button;
|
|
54
|
+
if (!hidden) {
|
|
55
|
+
return (
|
|
56
|
+
<DisabledContext.Consumer key={i}>
|
|
57
|
+
{(disabledContextValue) => (
|
|
58
|
+
<Tooltip
|
|
59
|
+
key={i}
|
|
60
|
+
error={!!error}
|
|
61
|
+
warning={!!warning}
|
|
62
|
+
text={tooltip || error || warning}
|
|
63
|
+
maxWidth={maxTooltipWidth}
|
|
64
|
+
display="block"
|
|
65
|
+
enabled={
|
|
66
|
+
(tooltip && isStringNumberOrNode(tooltip)) ||
|
|
67
|
+
(error && isStringNumberOrNode(error)) ||
|
|
68
|
+
(warning && isStringNumberOrNode(warning)) ||
|
|
69
|
+
false
|
|
70
|
+
}
|
|
71
|
+
placement="bottom-center"
|
|
72
|
+
>
|
|
73
|
+
<Button
|
|
74
|
+
active={active}
|
|
75
|
+
basic={this.props.basic}
|
|
76
|
+
disabled={this.props.disabled || button.disabled}
|
|
77
|
+
groupOrder={groupOrder}
|
|
78
|
+
icon={icon}
|
|
79
|
+
label={label}
|
|
80
|
+
onClick={(evt) =>
|
|
81
|
+
this.onClick(
|
|
82
|
+
evt,
|
|
83
|
+
key,
|
|
84
|
+
value,
|
|
85
|
+
label,
|
|
86
|
+
disabledContextValue,
|
|
87
|
+
button.disabled,
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
small={this.props.small}
|
|
91
|
+
testId={testId}
|
|
92
|
+
/>
|
|
93
|
+
</Tooltip>
|
|
94
|
+
)}
|
|
95
|
+
</DisabledContext.Consumer>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
renderHeader = () => {
|
|
102
|
+
if (this.props.header) {
|
|
103
|
+
return <label className={styles.label}>{this.props.header}</label>;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
render() {
|
|
108
|
+
const { testId } = this.props;
|
|
109
|
+
return (
|
|
110
|
+
<div>
|
|
111
|
+
<div>
|
|
112
|
+
{this.renderHeader()}
|
|
113
|
+
<div className={styles.buttonGroup} data-testid={testId}>
|
|
114
|
+
{this.renderButtons()}
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
ButtonGroup.defaultProps = {
|
|
123
|
+
basic: false,
|
|
124
|
+
items: [],
|
|
125
|
+
header: '',
|
|
126
|
+
onSelected: () => {},
|
|
127
|
+
small: false,
|
|
128
|
+
value: '',
|
|
129
|
+
testId: undefined,
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
ButtonGroup.propTypes = {
|
|
133
|
+
basic: PropTypes.bool, // Deprecated?
|
|
134
|
+
items: PropTypes.array,
|
|
135
|
+
header: PropTypes.string,
|
|
136
|
+
onSelected: PropTypes.func,
|
|
137
|
+
small: PropTypes.bool,
|
|
138
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
139
|
+
testId: PropTypes.string,
|
|
140
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
@import '../../style/variables.less';
|
|
2
|
+
|
|
3
|
+
.label {
|
|
4
|
+
display: inline-block;
|
|
5
|
+
width: auto;
|
|
6
|
+
margin: 0 0.85714286em 0 0;
|
|
7
|
+
vertical-align: baseline;
|
|
8
|
+
font-size: 0.92857143em;
|
|
9
|
+
font-weight: 700;
|
|
10
|
+
color: var(--color-text);
|
|
11
|
+
text-transform: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.buttonGroup {
|
|
15
|
+
display: inline-flex;
|
|
16
|
+
flex-direction: row;
|
|
17
|
+
// font-size: 0;
|
|
18
|
+
vertical-align: baseline;
|
|
19
|
+
margin: 0 0.25em 0 0;
|
|
20
|
+
|
|
21
|
+
> *:not(:last-child) {
|
|
22
|
+
margin-right: -1px;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FaQuestion, FaSortAmountDown, FaTrash } from 'react-icons/fa';
|
|
3
|
+
|
|
4
|
+
export const buttonsArrayOfObjects = [
|
|
5
|
+
{ key: 0, label: 'Aardvarks', value: 'termites' },
|
|
6
|
+
{ key: 1, label: 'Kangaroos', value: 'grass' },
|
|
7
|
+
{ key: 2, label: 'Monkeys', value: 'bananas' },
|
|
8
|
+
{ key: 3, label: 'Possums', value: 'slugs', hidden: true },
|
|
9
|
+
{ key: 4, label: 'Pandas', value: 'bamboo', disabled: true },
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
export const buttonsWithIcons = [
|
|
13
|
+
{
|
|
14
|
+
key: 0,
|
|
15
|
+
label: 'Sort',
|
|
16
|
+
value: 'upload',
|
|
17
|
+
icon: <FaSortAmountDown />,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
key: 1,
|
|
21
|
+
label: 'Delete',
|
|
22
|
+
value: 'delete',
|
|
23
|
+
icon: <FaTrash />,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
key: 2,
|
|
27
|
+
label: 'Help',
|
|
28
|
+
value: 'help',
|
|
29
|
+
icon: <FaQuestion />,
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
export const buttonsArrayOfStrings = ['One', 'Two', 'Three'];
|
|
34
|
+
|
|
35
|
+
export const buttonsArrayOfArrays = [
|
|
36
|
+
['first_item', 'One'],
|
|
37
|
+
['second_item', 'Two'],
|
|
38
|
+
['third_item', 'Three'],
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
export const buttonsWithTooltips = [
|
|
42
|
+
{
|
|
43
|
+
key: 0,
|
|
44
|
+
label: 'Aardvarks',
|
|
45
|
+
value: 'termites',
|
|
46
|
+
tooltip: 'Eats 50k termites / night',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
key: 1,
|
|
50
|
+
label: 'Kangaroos',
|
|
51
|
+
value: 'grass',
|
|
52
|
+
tooltip: <span>Babies are called joeys</span>,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
key: 2,
|
|
56
|
+
label: 'Monkeys',
|
|
57
|
+
value: 'bananas',
|
|
58
|
+
warning: 'A bit cheeky',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
key: 3,
|
|
62
|
+
label: 'Pandas',
|
|
63
|
+
value: 'bamboo',
|
|
64
|
+
disabled: true,
|
|
65
|
+
tooltip: 'Extinct',
|
|
66
|
+
},
|
|
67
|
+
];
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useArgs } from '@storybook/addons';
|
|
3
|
+
import { ButtonGroup } from './button-group';
|
|
4
|
+
import * as storyData from './button-group.stories-data';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Forms/ButtonGroup',
|
|
8
|
+
component: ButtonGroup,
|
|
9
|
+
args: {
|
|
10
|
+
disabled: false,
|
|
11
|
+
items: storyData.buttonsArrayOfObjects,
|
|
12
|
+
value: 0,
|
|
13
|
+
small: false,
|
|
14
|
+
testId: undefined,
|
|
15
|
+
onSelected: () => {},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const Template = (args) => {
|
|
20
|
+
const [_, updateArgs] = useArgs();
|
|
21
|
+
const handleChange = (evt) => {
|
|
22
|
+
updateArgs({ value: evt });
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<ButtonGroup
|
|
27
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
28
|
+
{...args}
|
|
29
|
+
onSelected={handleChange}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
export const Default = Template.bind({});
|
|
34
|
+
|
|
35
|
+
export const Icons = Template.bind({});
|
|
36
|
+
Icons.args = { items: storyData.buttonsWithIcons };
|
|
37
|
+
|
|
38
|
+
export const Tooltips = Template.bind({});
|
|
39
|
+
Tooltips.args = { items: storyData.buttonsWithTooltips };
|
|
40
|
+
|
|
41
|
+
export const Disabled = Template.bind({});
|
|
42
|
+
Disabled.args = { disabled: true };
|
|
43
|
+
|
|
44
|
+
export const ArrayOfStrings = Template.bind({});
|
|
45
|
+
ArrayOfStrings.args = { items: storyData.buttonsArrayOfStrings };
|
|
46
|
+
ArrayOfStrings.parameters = {
|
|
47
|
+
docs: {
|
|
48
|
+
description: {
|
|
49
|
+
story: 'For simple cases when button key, label and value are the same.',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const ArrayOfArrays = Template.bind({});
|
|
55
|
+
ArrayOfArrays.args = { items: storyData.buttonsArrayOfArrays };
|
|
56
|
+
ArrayOfArrays.parameters = {
|
|
57
|
+
docs: {
|
|
58
|
+
description: {
|
|
59
|
+
story:
|
|
60
|
+
'Avoid this deprecated legacy usage (still supported, but may be removed in future).',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
};
|