@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,114 @@
|
|
|
1
|
+
@import '../../style/variables.less';
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
--color-border-message: rgba(black, 0.1);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
html[data-theme='dark'] {
|
|
8
|
+
--color-border-message: transparent;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@line_height: 20px;
|
|
12
|
+
@line_spacing: 3px;
|
|
13
|
+
|
|
14
|
+
.container {
|
|
15
|
+
padding: 10px 14px;
|
|
16
|
+
border-radius: 4px;
|
|
17
|
+
display: inline-flex;
|
|
18
|
+
align-items: flex-start;
|
|
19
|
+
line-height: @line_height;
|
|
20
|
+
flex-wrap: wrap;
|
|
21
|
+
overflow-y: auto;
|
|
22
|
+
scrollbar-width: none;
|
|
23
|
+
-ms-overflow-style: none;
|
|
24
|
+
border: 1px solid var(--color-border-message);
|
|
25
|
+
|
|
26
|
+
&::-webkit-scrollbar {
|
|
27
|
+
width: 0px;
|
|
28
|
+
background: transparent;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&.block {
|
|
32
|
+
display: flex;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&.info {
|
|
36
|
+
color: var(--color-text-info);
|
|
37
|
+
background-color: var(--color-background-info);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&.success {
|
|
41
|
+
color: var(--color-text-success);
|
|
42
|
+
background-color: var(--color-background-success);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&.warning {
|
|
46
|
+
color: var(--color-text-warning);
|
|
47
|
+
background-color: var(--color-background-warning);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&.error {
|
|
51
|
+
color: var(--color-text-error);
|
|
52
|
+
background-color: var(--color-background-error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.content {
|
|
57
|
+
flex: 1;
|
|
58
|
+
min-width: 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.heading {
|
|
62
|
+
font-weight: bold;
|
|
63
|
+
letter-spacing: 0.1em;
|
|
64
|
+
text-transform: uppercase;
|
|
65
|
+
font-size: 0.9rem;
|
|
66
|
+
line-height: @line_height;
|
|
67
|
+
margin-bottom: @line_spacing;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.icon,
|
|
71
|
+
.dismiss {
|
|
72
|
+
display: flex;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
align-items: center;
|
|
75
|
+
height: @line_height;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.icon {
|
|
79
|
+
margin-right: 12px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.dismiss {
|
|
83
|
+
margin-left: 12px;
|
|
84
|
+
color: var(--color-text);
|
|
85
|
+
|
|
86
|
+
&.absolute {
|
|
87
|
+
position: absolute;
|
|
88
|
+
top: 10px;
|
|
89
|
+
right: 14px;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.legendToggle,
|
|
94
|
+
.dismiss {
|
|
95
|
+
opacity: 0.4;
|
|
96
|
+
|
|
97
|
+
&:hover {
|
|
98
|
+
opacity: 0.8;
|
|
99
|
+
cursor: pointer;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
&:active {
|
|
103
|
+
opacity: 1;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.legendToggle {
|
|
108
|
+
margin-top: @line_spacing;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.detailsText {
|
|
112
|
+
margin-top: @line_spacing;
|
|
113
|
+
word-break: break-word;
|
|
114
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { useArgs } from '@storybook/addons';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Message } from '../../..';
|
|
4
|
+
|
|
5
|
+
const message = {
|
|
6
|
+
visible: true,
|
|
7
|
+
heading: undefined,
|
|
8
|
+
content: 'Here is some info',
|
|
9
|
+
type: 'Info',
|
|
10
|
+
withDismiss: false,
|
|
11
|
+
icon: false,
|
|
12
|
+
details: undefined,
|
|
13
|
+
maxHeight: undefined,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
title: 'Basic/Message',
|
|
18
|
+
component: Message,
|
|
19
|
+
args: {
|
|
20
|
+
...message,
|
|
21
|
+
},
|
|
22
|
+
argTypes: {
|
|
23
|
+
type: {
|
|
24
|
+
control: {
|
|
25
|
+
type: 'inline-radio',
|
|
26
|
+
},
|
|
27
|
+
options: ['Info', 'Error', 'Warning', 'Success'],
|
|
28
|
+
},
|
|
29
|
+
heading: {
|
|
30
|
+
control: { type: 'text' },
|
|
31
|
+
},
|
|
32
|
+
details: {
|
|
33
|
+
control: { type: 'text' },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const Template = (args) => {
|
|
39
|
+
const [_, updateArgs] = useArgs();
|
|
40
|
+
|
|
41
|
+
const handleClose = () => {
|
|
42
|
+
updateArgs({ visible: false });
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
updateArgs({ visible: true });
|
|
45
|
+
}, 1000);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Message
|
|
50
|
+
message={{
|
|
51
|
+
...args,
|
|
52
|
+
onClose: handleClose,
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const Default = Template.bind({});
|
|
59
|
+
|
|
60
|
+
export const Heading = Template.bind({});
|
|
61
|
+
Heading.args = { heading: 'Message Heading' };
|
|
62
|
+
|
|
63
|
+
export const Icon = Template.bind({});
|
|
64
|
+
Icon.args = { icon: true };
|
|
65
|
+
|
|
66
|
+
export const Details = Template.bind({});
|
|
67
|
+
Details.args = {
|
|
68
|
+
details:
|
|
69
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque at mi ac quam condimentum blandit at sit amet lectus. Nullam volutpat erat maximus, venenatis nisl sed, aliquam libero.',
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const FullWidth = Template.bind({});
|
|
73
|
+
FullWidth.args = { width: '100%' };
|
|
74
|
+
|
|
75
|
+
export const FixedWidth = Template.bind({});
|
|
76
|
+
FixedWidth.args = { width: '300px' };
|
|
77
|
+
|
|
78
|
+
export const MaxHeight = Template.bind({});
|
|
79
|
+
MaxHeight.args = {
|
|
80
|
+
maxHeight: '100px',
|
|
81
|
+
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. '.repeat(
|
|
82
|
+
20,
|
|
83
|
+
),
|
|
84
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import { Portal } from '../portal/portal';
|
|
5
|
+
import styles from './modal.module.less';
|
|
6
|
+
|
|
7
|
+
const Wrapper = ({ children }) => (
|
|
8
|
+
<div className={cx(styles.wrapper)}>{children}</div>
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
const Content = ({ children, width, centered }) => {
|
|
12
|
+
return (
|
|
13
|
+
<div
|
|
14
|
+
className={cx(styles.contentContainer, centered ? styles.centered : '')}
|
|
15
|
+
style={{ maxWidth: width }}
|
|
16
|
+
>
|
|
17
|
+
{children}
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const Modal = ({ children, visible, centered, width }) => {
|
|
23
|
+
return (
|
|
24
|
+
<>
|
|
25
|
+
<Portal id="modalContainer">
|
|
26
|
+
{visible ? (
|
|
27
|
+
<Wrapper>
|
|
28
|
+
<Content width={width} centered={centered}>
|
|
29
|
+
{children}
|
|
30
|
+
</Content>
|
|
31
|
+
</Wrapper>
|
|
32
|
+
) : null}
|
|
33
|
+
</Portal>
|
|
34
|
+
<div id="modalContainer" />
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
Modal.defaultProps = {
|
|
40
|
+
visible: false,
|
|
41
|
+
centered: false,
|
|
42
|
+
width: '100%',
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
Modal.propTypes = {
|
|
46
|
+
children: PropTypes.node.isRequired,
|
|
47
|
+
visible: PropTypes.bool,
|
|
48
|
+
centered: PropTypes.bool,
|
|
49
|
+
width: PropTypes.string,
|
|
50
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@import '../../style/variables.less';
|
|
2
|
+
|
|
3
|
+
.wrapper {
|
|
4
|
+
z-index: @zindex_modal;
|
|
5
|
+
position: fixed;
|
|
6
|
+
top: 0;
|
|
7
|
+
left: 0;
|
|
8
|
+
height: 100%;
|
|
9
|
+
width: 100%;
|
|
10
|
+
background: rgba(0, 0, 0, 0.8);
|
|
11
|
+
padding: 30px;
|
|
12
|
+
overflow-x: hidden;
|
|
13
|
+
overflow-y: auto;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.contentContainer {
|
|
19
|
+
color: var(--color-background-raised);
|
|
20
|
+
max-height: 100%;
|
|
21
|
+
flex-grow: 1;
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: flex-start;
|
|
26
|
+
|
|
27
|
+
button:not(:last-child) {
|
|
28
|
+
margin-right: 12px;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.centered > * {
|
|
33
|
+
margin-top: auto;
|
|
34
|
+
margin-bottom: auto;
|
|
35
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { useArgs } from '@storybook/addons';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import {
|
|
4
|
+
Modal,
|
|
5
|
+
Button,
|
|
6
|
+
Dialog,
|
|
7
|
+
Popover,
|
|
8
|
+
Input,
|
|
9
|
+
InputGroup,
|
|
10
|
+
Field,
|
|
11
|
+
Menu,
|
|
12
|
+
Select,
|
|
13
|
+
Spacer,
|
|
14
|
+
Tooltip,
|
|
15
|
+
} from '../../..';
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
title: 'Modals/Modal',
|
|
19
|
+
component: Modal,
|
|
20
|
+
args: {
|
|
21
|
+
visible: true,
|
|
22
|
+
centered: true,
|
|
23
|
+
width: '300px',
|
|
24
|
+
heading: 'Are you sure?',
|
|
25
|
+
content: <>This will complete the transaction</>,
|
|
26
|
+
footer: (
|
|
27
|
+
<>
|
|
28
|
+
<Button label="Okay" colored onClick={() => {}} />
|
|
29
|
+
<Button label="Cancel" onClick={() => {}} />
|
|
30
|
+
</>
|
|
31
|
+
),
|
|
32
|
+
onClose: () => {},
|
|
33
|
+
},
|
|
34
|
+
parameters: {
|
|
35
|
+
docs: {
|
|
36
|
+
inlineStories: false,
|
|
37
|
+
iframeHeight: 400,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const Template = (args) => {
|
|
43
|
+
const [{ visible, centered, ...dialogProps }, updateArgs] = useArgs();
|
|
44
|
+
const toggleModal = () => {
|
|
45
|
+
updateArgs({ visible: !visible });
|
|
46
|
+
};
|
|
47
|
+
return (
|
|
48
|
+
<>
|
|
49
|
+
<Modal visible={visible} centered={centered}>
|
|
50
|
+
<Dialog
|
|
51
|
+
dialog={{
|
|
52
|
+
...dialogProps,
|
|
53
|
+
onClose: toggleModal,
|
|
54
|
+
}}
|
|
55
|
+
/>
|
|
56
|
+
</Modal>
|
|
57
|
+
<Button label="Open Modal" onClick={toggleModal} />
|
|
58
|
+
</>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const Default = Template.bind({});
|
|
63
|
+
|
|
64
|
+
export const Centered = Template.bind({});
|
|
65
|
+
Centered.args = { centered: true };
|
|
66
|
+
|
|
67
|
+
export const Scroll = Template.bind({});
|
|
68
|
+
Scroll.args = {
|
|
69
|
+
scroll: true,
|
|
70
|
+
content: (
|
|
71
|
+
<div>{'Example modal content goes here lorem ipsum. '.repeat(100)}</div>
|
|
72
|
+
),
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const FullWidth = Template.bind({});
|
|
76
|
+
FullWidth.args = {
|
|
77
|
+
width: '100%',
|
|
78
|
+
content: (
|
|
79
|
+
<div>{'Example modal content goes here lorem ipsum. '.repeat(100)}</div>
|
|
80
|
+
),
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const NoContentPadding = Template.bind({});
|
|
84
|
+
NoContentPadding.args = { contentPadding: 0 };
|
|
85
|
+
|
|
86
|
+
export const WithPopoverLayers = Template.bind({});
|
|
87
|
+
WithPopoverLayers.args = {
|
|
88
|
+
content: (
|
|
89
|
+
<>
|
|
90
|
+
<Tooltip text="Tooltip text">Hover for tooltip</Tooltip>
|
|
91
|
+
<Spacer />
|
|
92
|
+
<Field label="Custom Select" helpText="Select an animal">
|
|
93
|
+
<Select
|
|
94
|
+
name="example"
|
|
95
|
+
options={[
|
|
96
|
+
'Aardvarks',
|
|
97
|
+
'Kangaroos',
|
|
98
|
+
'Monkeys',
|
|
99
|
+
'Possums',
|
|
100
|
+
'Gorilla',
|
|
101
|
+
'Puma',
|
|
102
|
+
'Patagonian Mara',
|
|
103
|
+
'Tarsier',
|
|
104
|
+
'Koala',
|
|
105
|
+
'Panda',
|
|
106
|
+
'Red Panda',
|
|
107
|
+
'Impala',
|
|
108
|
+
'Tiger',
|
|
109
|
+
'Crocodile',
|
|
110
|
+
'Bat',
|
|
111
|
+
]}
|
|
112
|
+
onChange={() => {}}
|
|
113
|
+
value="Monkeys"
|
|
114
|
+
error="Bad value"
|
|
115
|
+
/>
|
|
116
|
+
</Field>
|
|
117
|
+
<Field label="Nested Menu">
|
|
118
|
+
<Menu
|
|
119
|
+
maxHeight="240px"
|
|
120
|
+
menu={{
|
|
121
|
+
label: 'Menu',
|
|
122
|
+
trigger: 'DropDownButton',
|
|
123
|
+
sections: [
|
|
124
|
+
{
|
|
125
|
+
type: 'Menu',
|
|
126
|
+
menu: {
|
|
127
|
+
trigger: 'Text',
|
|
128
|
+
label: 'Children',
|
|
129
|
+
sections: [...Array(100).keys()].map(() => ({
|
|
130
|
+
type: 'Option',
|
|
131
|
+
label: Math.random().toString(36).substring(7),
|
|
132
|
+
onClick: () => {},
|
|
133
|
+
})),
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
].concat(
|
|
137
|
+
[...Array(100).keys()].map(() => ({
|
|
138
|
+
type: 'Option',
|
|
139
|
+
label: Math.random().toString(36).substring(7),
|
|
140
|
+
onClick: () => {},
|
|
141
|
+
})),
|
|
142
|
+
),
|
|
143
|
+
}}
|
|
144
|
+
/>
|
|
145
|
+
</Field>
|
|
146
|
+
<Popover
|
|
147
|
+
content={
|
|
148
|
+
<InputGroup small>
|
|
149
|
+
<Input value="Value" width="150px" error="Bad value" />
|
|
150
|
+
<Button colored label="Save" onClick={() => {}} />
|
|
151
|
+
<Button label="Cancel" onClick={close} />
|
|
152
|
+
</InputGroup>
|
|
153
|
+
}
|
|
154
|
+
>
|
|
155
|
+
<Button colored label="Toggle me" onClick={() => {}} />
|
|
156
|
+
</Popover>
|
|
157
|
+
</>
|
|
158
|
+
),
|
|
159
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import { Option } from './option';
|
|
4
|
+
import { Divider } from '../divider/divider';
|
|
5
|
+
import styles from './option-dropdown.module.less';
|
|
6
|
+
import { Heading } from './heading';
|
|
7
|
+
|
|
8
|
+
export const Layer = ({ options, onChangeOptions, showHeader }) => {
|
|
9
|
+
return (
|
|
10
|
+
<div className={cx('menu', styles.menu)}>
|
|
11
|
+
{showHeader && (
|
|
12
|
+
<>
|
|
13
|
+
<div className={styles.header}>
|
|
14
|
+
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
15
|
+
<a
|
|
16
|
+
onClick={(evt) => {
|
|
17
|
+
const next = options.map((option) => ({
|
|
18
|
+
...option,
|
|
19
|
+
selected: true,
|
|
20
|
+
}));
|
|
21
|
+
onChangeOptions(evt, next);
|
|
22
|
+
}}
|
|
23
|
+
>
|
|
24
|
+
All
|
|
25
|
+
</a>
|
|
26
|
+
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
27
|
+
<a
|
|
28
|
+
onClick={(evt) => {
|
|
29
|
+
const next = options.map((option) => ({
|
|
30
|
+
...option,
|
|
31
|
+
selected: false,
|
|
32
|
+
}));
|
|
33
|
+
onChangeOptions(evt, next);
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
Clear
|
|
37
|
+
</a>
|
|
38
|
+
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
39
|
+
<a
|
|
40
|
+
onClick={(evt) => {
|
|
41
|
+
const next = options.map((option) => ({
|
|
42
|
+
...option,
|
|
43
|
+
selected: !option.selected,
|
|
44
|
+
}));
|
|
45
|
+
onChangeOptions(evt, next);
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
Invert
|
|
49
|
+
</a>
|
|
50
|
+
</div>
|
|
51
|
+
<Divider margin="7px" />
|
|
52
|
+
</>
|
|
53
|
+
)}
|
|
54
|
+
|
|
55
|
+
{options.map((option, index) => {
|
|
56
|
+
switch (option.type) {
|
|
57
|
+
case 'Heading':
|
|
58
|
+
return <Heading key={index} label={option.label} />;
|
|
59
|
+
case 'Divider':
|
|
60
|
+
return <Divider key={index} margin="7px" />;
|
|
61
|
+
default:
|
|
62
|
+
return (
|
|
63
|
+
<Option
|
|
64
|
+
key={index}
|
|
65
|
+
option={option}
|
|
66
|
+
onChange={(evt) => {
|
|
67
|
+
const { value } = option;
|
|
68
|
+
const next = options.map((option) =>
|
|
69
|
+
option.value !== value
|
|
70
|
+
? option
|
|
71
|
+
: { ...option, selected: !option.selected },
|
|
72
|
+
);
|
|
73
|
+
onChangeOptions(evt, next);
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
})}
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Menu } from '../menu/menu';
|
|
4
|
+
import { Layer } from './layer';
|
|
5
|
+
|
|
6
|
+
export const OptionDropdown = ({
|
|
7
|
+
name,
|
|
8
|
+
label,
|
|
9
|
+
options,
|
|
10
|
+
onChange,
|
|
11
|
+
showHeader,
|
|
12
|
+
}) => {
|
|
13
|
+
return (
|
|
14
|
+
<Menu
|
|
15
|
+
menu={{
|
|
16
|
+
label,
|
|
17
|
+
trigger: 'DropDownButton',
|
|
18
|
+
possiblePlacements: ['top-start', 'bottom-start'],
|
|
19
|
+
sections: (
|
|
20
|
+
<Layer
|
|
21
|
+
options={options}
|
|
22
|
+
onChangeOptions={(evt, nextOptions) => {
|
|
23
|
+
evt.stopPropagation();
|
|
24
|
+
evt.target.name = name;
|
|
25
|
+
evt.target.value = nextOptions;
|
|
26
|
+
onChange(evt);
|
|
27
|
+
}}
|
|
28
|
+
showHeader={showHeader}
|
|
29
|
+
/>
|
|
30
|
+
),
|
|
31
|
+
}}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
OptionDropdown.defaultProps = {
|
|
37
|
+
name: undefined,
|
|
38
|
+
showHeader: true,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
OptionDropdown.propTypes = {
|
|
42
|
+
name: PropTypes.string,
|
|
43
|
+
label: PropTypes.string.isRequired,
|
|
44
|
+
options: PropTypes.arrayOf(
|
|
45
|
+
PropTypes.shape({
|
|
46
|
+
label: PropTypes.string,
|
|
47
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
48
|
+
selected: PropTypes.bool,
|
|
49
|
+
}),
|
|
50
|
+
).isRequired,
|
|
51
|
+
onChange: PropTypes.func.isRequired,
|
|
52
|
+
showHeader: PropTypes.bool,
|
|
53
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
@import '../../style/variables.less';
|
|
2
|
+
|
|
3
|
+
.menu {
|
|
4
|
+
min-width: 160px;
|
|
5
|
+
padding: 7px 0;
|
|
6
|
+
border: 1px solid var(--color-border);
|
|
7
|
+
border-radius: 4px;
|
|
8
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
9
|
+
background-color: var(--color-background-raised);
|
|
10
|
+
margin-top: 2px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.header {
|
|
14
|
+
padding: 7px 16px;
|
|
15
|
+
display: flex;
|
|
16
|
+
justify-content: space-between;
|
|
17
|
+
|
|
18
|
+
a {
|
|
19
|
+
color: var(--color-text-primary);
|
|
20
|
+
font-weight: normal;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
|
|
23
|
+
&:hover {
|
|
24
|
+
color: var(--color-text-primary-hover);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&:active {
|
|
28
|
+
color: var(--color-text-primary-active);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.item {
|
|
34
|
+
padding: 7px 16px;
|
|
35
|
+
background: transparent;
|
|
36
|
+
cursor: default;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.heading {
|
|
40
|
+
color: var(--color-text-muted);
|
|
41
|
+
letter-spacing: 0.1em;
|
|
42
|
+
text-transform: uppercase;
|
|
43
|
+
font-size: 12px;
|
|
44
|
+
padding: 7px 16px;
|
|
45
|
+
max-width: 100%;
|
|
46
|
+
display: block;
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
text-overflow: ellipsis;
|
|
49
|
+
white-space: nowrap;
|
|
50
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useArgs } from '@storybook/addons';
|
|
3
|
+
import { OptionDropdown } from './option-dropdown';
|
|
4
|
+
|
|
5
|
+
const options = [
|
|
6
|
+
{ label: 'Animals', type: 'Heading' },
|
|
7
|
+
{ type: 'Divider' },
|
|
8
|
+
{ label: 'Aardvarks', value: 'termites' },
|
|
9
|
+
{ label: 'Kangaroos', value: 'grass' },
|
|
10
|
+
{ label: 'Monkeys', value: 'bananas' },
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
title: 'Forms/OptionDropdown',
|
|
15
|
+
component: OptionDropdown,
|
|
16
|
+
args: {
|
|
17
|
+
label: 'Label',
|
|
18
|
+
options,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const Template = (args) => {
|
|
23
|
+
const [_, updateArgs] = useArgs();
|
|
24
|
+
const handleChange = (evt) => {
|
|
25
|
+
updateArgs({ options: evt.target.value });
|
|
26
|
+
};
|
|
27
|
+
return (
|
|
28
|
+
<OptionDropdown
|
|
29
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
30
|
+
{...args}
|
|
31
|
+
onChange={handleChange}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
export const Default = Template.bind({});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import { CheckBox } from '../check-box/check-box';
|
|
4
|
+
import styles from './option-dropdown.module.less';
|
|
5
|
+
|
|
6
|
+
export const Option = ({ option, onChange }) => {
|
|
7
|
+
const { key, label, selected } = option;
|
|
8
|
+
return (
|
|
9
|
+
<div key={key} className={styles.item}>
|
|
10
|
+
<CheckBox label={label} noMargin checked={selected} onChange={onChange} />
|
|
11
|
+
</div>
|
|
12
|
+
);
|
|
13
|
+
};
|