@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,102 @@
|
|
|
1
|
+
import React, { memo, useState } from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import isEqual from 'react-fast-compare';
|
|
5
|
+
import { FaArrowLeft } from 'react-icons/fa';
|
|
6
|
+
import { Drawer } from '../drawer/drawer';
|
|
7
|
+
import { Sections } from './sections';
|
|
8
|
+
import styles from './side-bar.module.less';
|
|
9
|
+
import { Button } from '../button/button';
|
|
10
|
+
|
|
11
|
+
export const SideBar = memo(
|
|
12
|
+
({ options, startOpen, onShiftClickToggleOpen, top }) => {
|
|
13
|
+
const [isOpen, setIsOpen] = useState(startOpen || false);
|
|
14
|
+
|
|
15
|
+
const onClick = (evt, value, label, clickHandler) => {
|
|
16
|
+
evt.preventDefault();
|
|
17
|
+
if (typeof clickHandler === 'function') {
|
|
18
|
+
evt.target.value = value;
|
|
19
|
+
evt.target.label = label;
|
|
20
|
+
clickHandler(evt);
|
|
21
|
+
}
|
|
22
|
+
setIsOpen(false);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const visible = options.sections.length > 0;
|
|
26
|
+
return (
|
|
27
|
+
<Drawer
|
|
28
|
+
fixed
|
|
29
|
+
open={isOpen}
|
|
30
|
+
top={top}
|
|
31
|
+
background="var(--color-background-sidebar)"
|
|
32
|
+
closedWidth={70}
|
|
33
|
+
enableButton={visible}
|
|
34
|
+
buttonPosition="bottom"
|
|
35
|
+
buttonAnimate
|
|
36
|
+
button={
|
|
37
|
+
visible && (
|
|
38
|
+
<Button
|
|
39
|
+
onClick={(evt) => {
|
|
40
|
+
if (evt.shiftKey) {
|
|
41
|
+
onShiftClickToggleOpen(evt);
|
|
42
|
+
}
|
|
43
|
+
setIsOpen(!isOpen);
|
|
44
|
+
}}
|
|
45
|
+
colored
|
|
46
|
+
round
|
|
47
|
+
icon={<FaArrowLeft />}
|
|
48
|
+
/>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
>
|
|
52
|
+
<div className={cx(styles.sidebar, !isOpen ? styles.collapsed : '')}>
|
|
53
|
+
{visible && (
|
|
54
|
+
<div className={styles.inner}>
|
|
55
|
+
<h4 className={styles.title}>{options.title}</h4>
|
|
56
|
+
<Sections
|
|
57
|
+
isOpen={isOpen}
|
|
58
|
+
sections={options.sections}
|
|
59
|
+
onClick={onClick}
|
|
60
|
+
/>
|
|
61
|
+
</div>
|
|
62
|
+
)}
|
|
63
|
+
</div>
|
|
64
|
+
</Drawer>
|
|
65
|
+
);
|
|
66
|
+
},
|
|
67
|
+
(prevProps, nextProps) => isEqual(prevProps, nextProps),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
SideBar.defaultProps = {
|
|
71
|
+
startOpen: false,
|
|
72
|
+
onShiftClickToggleOpen: () => {},
|
|
73
|
+
top: undefined,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
SideBar.propTypes = {
|
|
77
|
+
options: PropTypes.shape({
|
|
78
|
+
title: PropTypes.string.isRequired,
|
|
79
|
+
sections: PropTypes.arrayOf(
|
|
80
|
+
PropTypes.shape({
|
|
81
|
+
heading: PropTypes.string.isRequired,
|
|
82
|
+
items: PropTypes.arrayOf(
|
|
83
|
+
PropTypes.shape({
|
|
84
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node])
|
|
85
|
+
.isRequired,
|
|
86
|
+
value: PropTypes.string.isRequired,
|
|
87
|
+
icon: PropTypes.oneOfType([PropTypes.string, PropTypes.node])
|
|
88
|
+
.isRequired,
|
|
89
|
+
onClick: PropTypes.func.isRequired,
|
|
90
|
+
isActive: PropTypes.bool,
|
|
91
|
+
isExperimental: PropTypes.bool,
|
|
92
|
+
invalid: PropTypes.bool,
|
|
93
|
+
testId: PropTypes.string,
|
|
94
|
+
}),
|
|
95
|
+
).isRequired,
|
|
96
|
+
}),
|
|
97
|
+
).isRequired,
|
|
98
|
+
}).isRequired,
|
|
99
|
+
startOpen: PropTypes.bool,
|
|
100
|
+
onShiftClickToggleOpen: PropTypes.func,
|
|
101
|
+
top: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
102
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
@import '../../style/variables.less';
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
--color-background-sidebar: var(--color-neutral-950);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
@sidebarPadding: 1.4rem;
|
|
8
|
+
|
|
9
|
+
.sidebar {
|
|
10
|
+
background-color: var(--color-background-sidebar);
|
|
11
|
+
color: white;
|
|
12
|
+
position: relative;
|
|
13
|
+
|
|
14
|
+
@media print {
|
|
15
|
+
display: none;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.inner {
|
|
20
|
+
padding: @sidebarPadding;
|
|
21
|
+
scrollbar-width: none; /* Firefox */
|
|
22
|
+
-ms-overflow-style: none; /* IE 10+ */
|
|
23
|
+
|
|
24
|
+
&::-webkit-scrollbar {
|
|
25
|
+
width: 0px; /* Remove scrollbar space */
|
|
26
|
+
background: transparent; /* Optional: just make scrollbar invisible */
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.title,
|
|
31
|
+
.subtitle,
|
|
32
|
+
.label {
|
|
33
|
+
transition: opacity 0.2s, max-height 0.2s, margin 0.2s, color 0.2s;
|
|
34
|
+
max-height: 50px;
|
|
35
|
+
|
|
36
|
+
.collapsed & {
|
|
37
|
+
opacity: 0;
|
|
38
|
+
max-height: 0;
|
|
39
|
+
margin-bottom: 0;
|
|
40
|
+
margin-top: 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.title {
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
max-width: 100%;
|
|
47
|
+
text-overflow: ellipsis;
|
|
48
|
+
white-space: nowrap;
|
|
49
|
+
margin-top: 0;
|
|
50
|
+
font-size: 16px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.subtitle {
|
|
54
|
+
margin-bottom: 0.75rem;
|
|
55
|
+
white-space: nowrap;
|
|
56
|
+
font-size: 12px;
|
|
57
|
+
letter-spacing: 0.1em;
|
|
58
|
+
opacity: 0.6;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.list {
|
|
62
|
+
margin-left: -@sidebarPadding;
|
|
63
|
+
margin-right: -@sidebarPadding;
|
|
64
|
+
margin-bottom: 2rem;
|
|
65
|
+
margin-top: 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.item {
|
|
69
|
+
font-size: 16px;
|
|
70
|
+
color: white;
|
|
71
|
+
font-weight: normal;
|
|
72
|
+
display: flex;
|
|
73
|
+
padding: 0.4rem @sidebarPadding;
|
|
74
|
+
align-items: center;
|
|
75
|
+
|
|
76
|
+
&:focus {
|
|
77
|
+
outline: none; // Remove dotted outline on FF
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&::-moz-focus-inner {
|
|
81
|
+
border: 0; // Remove dotted outline on FF
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&:hover,
|
|
85
|
+
&:focus {
|
|
86
|
+
color: var(--color-primary-400);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&:active {
|
|
90
|
+
color: var(--color-primary-300);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
&.active {
|
|
94
|
+
color: white;
|
|
95
|
+
background: black;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&.experimental {
|
|
99
|
+
background: #40130b;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.icon {
|
|
104
|
+
margin-right: 10px;
|
|
105
|
+
line-height: 0;
|
|
106
|
+
flex-shrink: 0;
|
|
107
|
+
transition: opacity 0.4s;
|
|
108
|
+
opacity: 0.4;
|
|
109
|
+
display: block;
|
|
110
|
+
|
|
111
|
+
.item:hover &,
|
|
112
|
+
.item:focus & {
|
|
113
|
+
opacity: 0.6;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.item:active & {
|
|
117
|
+
opacity: 0.8;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.item.active & {
|
|
121
|
+
opacity: 1;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
> * {
|
|
125
|
+
opacity: 1;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
> span {
|
|
129
|
+
// Fix for Tooltip
|
|
130
|
+
display: block;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.label {
|
|
135
|
+
white-space: nowrap;
|
|
136
|
+
overflow: hidden;
|
|
137
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FaAngleDoubleRight } from 'react-icons/fa';
|
|
3
|
+
import { SideBar, Flex, Badge } from '../../..';
|
|
4
|
+
import svgIcon from '../../images/icons/icons8-junction.svg';
|
|
5
|
+
|
|
6
|
+
const sections = [
|
|
7
|
+
{
|
|
8
|
+
heading: 'First Heading',
|
|
9
|
+
items: [
|
|
10
|
+
{
|
|
11
|
+
label: 'Section A',
|
|
12
|
+
value: '/path/to/something',
|
|
13
|
+
onClick: () => {},
|
|
14
|
+
icon: svgIcon,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
label: (
|
|
18
|
+
<Flex alignItems="center" gap="10px">
|
|
19
|
+
Section B
|
|
20
|
+
<Badge small title="BETA" />
|
|
21
|
+
</Flex>
|
|
22
|
+
),
|
|
23
|
+
value: '/path/to/something',
|
|
24
|
+
onClick: () => {},
|
|
25
|
+
icon: svgIcon,
|
|
26
|
+
isActive: true,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
label: 'Section C',
|
|
30
|
+
value: '/path/to/something',
|
|
31
|
+
onClick: () => {},
|
|
32
|
+
icon: svgIcon,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: 'Experimental Section',
|
|
36
|
+
value: '/path/to/something',
|
|
37
|
+
onClick: () => {},
|
|
38
|
+
icon: svgIcon,
|
|
39
|
+
isExperimental: true,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
heading: 'Second Heading',
|
|
45
|
+
items: [
|
|
46
|
+
{
|
|
47
|
+
label: 'Section 1',
|
|
48
|
+
value: '/path/to/something',
|
|
49
|
+
onClick: () => {},
|
|
50
|
+
icon: <FaAngleDoubleRight />,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
label: 'Section 2',
|
|
54
|
+
value: '/path/to/something',
|
|
55
|
+
onClick: () => {},
|
|
56
|
+
icon: <FaAngleDoubleRight />,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
label: 'Invalid Section',
|
|
60
|
+
value: '/path/to/something',
|
|
61
|
+
onClick: () => {},
|
|
62
|
+
icon: svgIcon,
|
|
63
|
+
invalid: true,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
export default {
|
|
70
|
+
title: 'Navigation/SideBar',
|
|
71
|
+
component: SideBar,
|
|
72
|
+
parameters: {
|
|
73
|
+
layout: 'fullscreen',
|
|
74
|
+
docs: {
|
|
75
|
+
inlineStories: false,
|
|
76
|
+
iframeHeight: 500,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
args: {
|
|
80
|
+
options: {
|
|
81
|
+
title: 'Title',
|
|
82
|
+
sections,
|
|
83
|
+
},
|
|
84
|
+
startOpen: false,
|
|
85
|
+
},
|
|
86
|
+
argTypes: {
|
|
87
|
+
top: { control: { type: 'text' } },
|
|
88
|
+
startOpen: { control: { type: 'boolean' } },
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const Template = (args) => (
|
|
93
|
+
<SideBar // eslint-disable-next-line react/jsx-props-no-spreading
|
|
94
|
+
{...args}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
export const Default = Template.bind({});
|
|
99
|
+
|
|
100
|
+
export const StartOpen = Template.bind({});
|
|
101
|
+
StartOpen.args = { startOpen: true };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
@import '../../style/variables.less';
|
|
2
|
+
@import '~rc-slider/assets/index.css';
|
|
3
|
+
|
|
4
|
+
.rc-slider {
|
|
5
|
+
.rc-slider-rail {
|
|
6
|
+
background-color: var(--color-border);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.rc-slider-track {
|
|
10
|
+
background-color: var(--color-background-primary);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.rc-slider-dot {
|
|
14
|
+
border-color: var(--color-border);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.rc-slider-dot-active {
|
|
18
|
+
border-color: var(--color-background-primary);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.rc-slider-handle {
|
|
22
|
+
border-color: var(--color-background-primary);
|
|
23
|
+
|
|
24
|
+
&:focus {
|
|
25
|
+
border-color: var(--color-background-primary);
|
|
26
|
+
box-shadow: 0 0 0 3px var(--color-background-primary);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.rc-slider-mark-text {
|
|
31
|
+
color: var(--color-text-faint);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.rc-slider-mark-text-active {
|
|
35
|
+
color: var(--color-text-muted);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&-disabled {
|
|
39
|
+
background-color: transparent !important;
|
|
40
|
+
|
|
41
|
+
.rc-slider-mark-text,
|
|
42
|
+
.rc-slider-handle,
|
|
43
|
+
.rc-slider-dot {
|
|
44
|
+
cursor: default !important;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TooltipLayer } from '../tooltip/tooltip-layer';
|
|
3
|
+
|
|
4
|
+
//See https://github.com/react-component/slider/issues/409#issuecomment-606750232
|
|
5
|
+
export const SliderTooltip = ({ text }) => {
|
|
6
|
+
return (
|
|
7
|
+
<TooltipLayer
|
|
8
|
+
text={text}
|
|
9
|
+
layerProps={{
|
|
10
|
+
style: {
|
|
11
|
+
whiteSpace: 'nowrap',
|
|
12
|
+
position: 'fixed',
|
|
13
|
+
transform: 'translate(-50%, -100%)',
|
|
14
|
+
marginTop: -15,
|
|
15
|
+
marginLeft: 5,
|
|
16
|
+
},
|
|
17
|
+
}}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
import RcSlider, { Handle } from 'rc-slider';
|
|
4
|
+
import memoizeOne from 'memoize-one';
|
|
5
|
+
import isEqual from 'react-fast-compare';
|
|
6
|
+
import { FaFastBackward, FaFastForward } from 'react-icons/fa';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import cx from 'classnames';
|
|
9
|
+
import { SliderTooltip } from './slider-tooltip';
|
|
10
|
+
import './rc-slider.less';
|
|
11
|
+
import styles from './slider.module.less';
|
|
12
|
+
import { Tooltip } from '../tooltip/tooltip';
|
|
13
|
+
import { Button } from '../button/button';
|
|
14
|
+
import { DisabledContext } from '../../helpers/disabled-context';
|
|
15
|
+
|
|
16
|
+
const formatMarkers = (marks) => {
|
|
17
|
+
const formatted = marks.reduce((acc, { label, tooltip, value }) => {
|
|
18
|
+
const isTooltip = tooltip !== undefined;
|
|
19
|
+
const formattedValue = isTooltip ? (
|
|
20
|
+
<Tooltip text={tooltip}>{label}</Tooltip>
|
|
21
|
+
) : (
|
|
22
|
+
label || value
|
|
23
|
+
);
|
|
24
|
+
acc[value] = formattedValue;
|
|
25
|
+
return acc;
|
|
26
|
+
}, {});
|
|
27
|
+
return formatted;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const memoizedFormatMarkers = memoizeOne(formatMarkers, isEqual);
|
|
31
|
+
|
|
32
|
+
export const Slider = ({
|
|
33
|
+
name,
|
|
34
|
+
label,
|
|
35
|
+
width,
|
|
36
|
+
labelWidth,
|
|
37
|
+
value,
|
|
38
|
+
min,
|
|
39
|
+
max,
|
|
40
|
+
step,
|
|
41
|
+
marks,
|
|
42
|
+
showArrows,
|
|
43
|
+
showTooltip,
|
|
44
|
+
tooltipFormatter,
|
|
45
|
+
disabled,
|
|
46
|
+
vertical,
|
|
47
|
+
onChange,
|
|
48
|
+
range,
|
|
49
|
+
}) => {
|
|
50
|
+
const disabledContext = useContext(DisabledContext);
|
|
51
|
+
|
|
52
|
+
const formattedMarks = memoizedFormatMarkers(marks);
|
|
53
|
+
|
|
54
|
+
const onChangeValue = (value) => {
|
|
55
|
+
//rc-slider doesn't pass the Synthetic event
|
|
56
|
+
//but we can still follow the standard event format
|
|
57
|
+
onChange({
|
|
58
|
+
target: {
|
|
59
|
+
name,
|
|
60
|
+
value,
|
|
61
|
+
label,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const ButtonMin = () => (
|
|
67
|
+
<div className={styles.button}>
|
|
68
|
+
<Button
|
|
69
|
+
basic
|
|
70
|
+
small
|
|
71
|
+
onClick={() => onChangeValue(min)}
|
|
72
|
+
disabled={disabled || value === min || disabledContext}
|
|
73
|
+
icon={<FaFastBackward />}
|
|
74
|
+
/>
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const ButtonMax = () => (
|
|
79
|
+
<div className={styles.button}>
|
|
80
|
+
<Button
|
|
81
|
+
basic
|
|
82
|
+
small
|
|
83
|
+
onClick={() => onChangeValue(max)}
|
|
84
|
+
disabled={disabled || value === max || disabledContext}
|
|
85
|
+
icon={<FaFastForward />}
|
|
86
|
+
/>
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<div
|
|
92
|
+
className={cx(
|
|
93
|
+
styles.container,
|
|
94
|
+
vertical.enabled ? styles.vertical : '',
|
|
95
|
+
!_.isEmpty(marks) ? styles.hasMarks : '',
|
|
96
|
+
)}
|
|
97
|
+
style={
|
|
98
|
+
vertical.enabled
|
|
99
|
+
? { width: vertical.width, height: vertical.height }
|
|
100
|
+
: { width }
|
|
101
|
+
}
|
|
102
|
+
>
|
|
103
|
+
{showArrows && (vertical.enabled ? <ButtonMax /> : <ButtonMin />)}
|
|
104
|
+
{range ? (
|
|
105
|
+
<RcSlider.Range
|
|
106
|
+
allowCross={false}
|
|
107
|
+
className={cx(
|
|
108
|
+
(disabled || disabledContext) && styles.rcSliderDisabled,
|
|
109
|
+
showArrows && styles.hasArrows,
|
|
110
|
+
)}
|
|
111
|
+
value={value}
|
|
112
|
+
max={max}
|
|
113
|
+
min={min}
|
|
114
|
+
step={step}
|
|
115
|
+
marks={formattedMarks}
|
|
116
|
+
onChange={(v) => onChangeValue(v)}
|
|
117
|
+
disabled={disabled || disabledContext}
|
|
118
|
+
vertical={vertical.enabled}
|
|
119
|
+
handle={
|
|
120
|
+
showTooltip
|
|
121
|
+
? ({ index, value, dragging, ...handleProps }) => (
|
|
122
|
+
<Handle
|
|
123
|
+
key={index}
|
|
124
|
+
value={value}
|
|
125
|
+
{...handleProps} // eslint-disable-line react/jsx-props-no-spreading
|
|
126
|
+
>
|
|
127
|
+
{dragging && (
|
|
128
|
+
<SliderTooltip text={tooltipFormatter(value)} />
|
|
129
|
+
)}
|
|
130
|
+
</Handle>
|
|
131
|
+
)
|
|
132
|
+
: undefined
|
|
133
|
+
}
|
|
134
|
+
/>
|
|
135
|
+
) : (
|
|
136
|
+
<RcSlider
|
|
137
|
+
className={cx(
|
|
138
|
+
(disabled || disabledContext) && styles.rcSliderDisabled,
|
|
139
|
+
showArrows && styles.hasArrows,
|
|
140
|
+
)}
|
|
141
|
+
value={value}
|
|
142
|
+
max={max}
|
|
143
|
+
min={min}
|
|
144
|
+
step={step}
|
|
145
|
+
marks={formattedMarks}
|
|
146
|
+
onChange={(v) => onChangeValue(v)}
|
|
147
|
+
disabled={disabled || disabledContext}
|
|
148
|
+
vertical={vertical.enabled}
|
|
149
|
+
handle={
|
|
150
|
+
showTooltip
|
|
151
|
+
? ({ index, value, dragging, ...handleProps }) => (
|
|
152
|
+
<Handle
|
|
153
|
+
key={index}
|
|
154
|
+
value={value}
|
|
155
|
+
{...handleProps} // eslint-disable-line react/jsx-props-no-spreading
|
|
156
|
+
>
|
|
157
|
+
{dragging && (
|
|
158
|
+
<SliderTooltip text={tooltipFormatter(value)} />
|
|
159
|
+
)}
|
|
160
|
+
</Handle>
|
|
161
|
+
)
|
|
162
|
+
: undefined
|
|
163
|
+
}
|
|
164
|
+
/>
|
|
165
|
+
)}
|
|
166
|
+
|
|
167
|
+
{showArrows && (vertical.enabled ? <ButtonMin /> : <ButtonMax />)}
|
|
168
|
+
{label && (
|
|
169
|
+
<label className={styles.label} style={{ width: labelWidth }}>
|
|
170
|
+
{label}
|
|
171
|
+
</label>
|
|
172
|
+
)}
|
|
173
|
+
</div>
|
|
174
|
+
);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
Slider.defaultProps = {
|
|
178
|
+
name: undefined,
|
|
179
|
+
label: null,
|
|
180
|
+
width: '100%',
|
|
181
|
+
labelWidth: 'auto',
|
|
182
|
+
step: 1,
|
|
183
|
+
marks: [],
|
|
184
|
+
showArrows: false,
|
|
185
|
+
showTooltip: false,
|
|
186
|
+
tooltipFormatter: (v) => v,
|
|
187
|
+
disabled: false,
|
|
188
|
+
range: false,
|
|
189
|
+
vertical: {
|
|
190
|
+
enabled: false,
|
|
191
|
+
width: '100px',
|
|
192
|
+
height: '400px',
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
Slider.propTypes = {
|
|
197
|
+
name: PropTypes.string,
|
|
198
|
+
label: PropTypes.oneOfType([
|
|
199
|
+
PropTypes.string,
|
|
200
|
+
PropTypes.number,
|
|
201
|
+
PropTypes.node,
|
|
202
|
+
]),
|
|
203
|
+
width: PropTypes.string,
|
|
204
|
+
labelWidth: PropTypes.string,
|
|
205
|
+
value: PropTypes.oneOfType([PropTypes.number, PropTypes.array]).isRequired,
|
|
206
|
+
min: PropTypes.number.isRequired,
|
|
207
|
+
max: PropTypes.number.isRequired,
|
|
208
|
+
step: PropTypes.number,
|
|
209
|
+
marks: PropTypes.arrayOf(
|
|
210
|
+
PropTypes.shape({
|
|
211
|
+
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
212
|
+
.isRequired,
|
|
213
|
+
label: PropTypes.oneOfType([
|
|
214
|
+
PropTypes.number,
|
|
215
|
+
PropTypes.string,
|
|
216
|
+
PropTypes.node,
|
|
217
|
+
]),
|
|
218
|
+
tooltip: PropTypes.oneOfType([
|
|
219
|
+
PropTypes.number,
|
|
220
|
+
PropTypes.string,
|
|
221
|
+
PropTypes.node,
|
|
222
|
+
]),
|
|
223
|
+
}),
|
|
224
|
+
),
|
|
225
|
+
onChange: PropTypes.func.isRequired,
|
|
226
|
+
showArrows: PropTypes.bool,
|
|
227
|
+
showTooltip: PropTypes.bool,
|
|
228
|
+
tooltipFormatter: PropTypes.func,
|
|
229
|
+
disabled: PropTypes.bool,
|
|
230
|
+
range: PropTypes.bool,
|
|
231
|
+
//for vertical variant:
|
|
232
|
+
vertical: PropTypes.object,
|
|
233
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@import '../../style/variables.less';
|
|
2
|
+
|
|
3
|
+
.container {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
min-height: 38px;
|
|
7
|
+
|
|
8
|
+
&.hasMarks {
|
|
9
|
+
padding-bottom: 20px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&.vertical {
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
padding-bottom: 0;
|
|
15
|
+
|
|
16
|
+
.hasArrows {
|
|
17
|
+
margin-top: 5px;
|
|
18
|
+
margin-bottom: 5px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.button {
|
|
22
|
+
svg {
|
|
23
|
+
transform: rotate(-90deg);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.label {
|
|
30
|
+
white-space: nowrap;
|
|
31
|
+
margin-left: 10px;
|
|
32
|
+
line-height: 1;
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
text-overflow: ellipsis;
|
|
35
|
+
flex-shrink: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.rcSliderDisabled {
|
|
39
|
+
background-color: transparent;
|
|
40
|
+
}
|