@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,32 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
|
|
3
|
+
const actionShape = PropTypes.shape({
|
|
4
|
+
label: PropTypes.string.isRequired,
|
|
5
|
+
icon: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
|
|
6
|
+
onClick: PropTypes.func.isRequired,
|
|
7
|
+
disabled: PropTypes.bool,
|
|
8
|
+
primary: PropTypes.bool,
|
|
9
|
+
hidden: PropTypes.bool,
|
|
10
|
+
//optional, added as data-testid, e.g. for GUI tests
|
|
11
|
+
testId: PropTypes.string,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const subActionShape = PropTypes.shape({
|
|
15
|
+
icon: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
|
|
16
|
+
testId: PropTypes.string,
|
|
17
|
+
subActions: PropTypes.arrayOf(actionShape).isRequired,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Deprecated
|
|
21
|
+
const childComponentShape = PropTypes.shape({
|
|
22
|
+
childComponent: PropTypes.oneOfType([
|
|
23
|
+
PropTypes.func,
|
|
24
|
+
PropTypes.node, //React component
|
|
25
|
+
]).isRequired,
|
|
26
|
+
//optional, added as data-testid, e.g. for GUI tests
|
|
27
|
+
testId: PropTypes.string,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const actionsShape = PropTypes.arrayOf(
|
|
31
|
+
PropTypes.oneOfType([actionShape, subActionShape, childComponentShape]),
|
|
32
|
+
);
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
FaArrowDown,
|
|
4
|
+
FaArrowUp,
|
|
5
|
+
FaDownload,
|
|
6
|
+
FaPlus,
|
|
7
|
+
FaQuestionCircle,
|
|
8
|
+
} from 'react-icons/fa';
|
|
9
|
+
import { Actions } from './actions';
|
|
10
|
+
|
|
11
|
+
const actions = [
|
|
12
|
+
{
|
|
13
|
+
label: 'Download',
|
|
14
|
+
icon: <FaDownload />,
|
|
15
|
+
onClick: () => {},
|
|
16
|
+
testId: 'download',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
label: 'Help',
|
|
20
|
+
icon: <FaQuestionCircle />,
|
|
21
|
+
onClick: () => {},
|
|
22
|
+
disabled: true,
|
|
23
|
+
testId: 'help',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
label: 'More',
|
|
27
|
+
testId: 'more',
|
|
28
|
+
subActions: [
|
|
29
|
+
{
|
|
30
|
+
label: 'Move Up',
|
|
31
|
+
icon: <FaArrowUp />,
|
|
32
|
+
disabled: true,
|
|
33
|
+
onClick: () => {},
|
|
34
|
+
testId: 'move-up',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: 'Move Down',
|
|
38
|
+
icon: <FaArrowDown />,
|
|
39
|
+
onClick: () => {},
|
|
40
|
+
testId: 'move-down',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
primary: true,
|
|
46
|
+
label: 'Add',
|
|
47
|
+
icon: <FaPlus />,
|
|
48
|
+
onClick: () => {},
|
|
49
|
+
testId: 'add',
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
export default {
|
|
54
|
+
title: 'Basic/Actions',
|
|
55
|
+
component: Actions,
|
|
56
|
+
args: {
|
|
57
|
+
actions,
|
|
58
|
+
right: false,
|
|
59
|
+
},
|
|
60
|
+
decorators: [
|
|
61
|
+
(story) => <div style={{ display: 'inline-flex' }}>{story()}</div>,
|
|
62
|
+
],
|
|
63
|
+
parameters: {
|
|
64
|
+
docs: {
|
|
65
|
+
source: {
|
|
66
|
+
excludeDecorators: true,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const Template = (args) => (
|
|
73
|
+
<Actions
|
|
74
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
75
|
+
{...args}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
export const Default = Template.bind({});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import styles from './badge.module.less';
|
|
5
|
+
|
|
6
|
+
const isDark = (hexColor) => {
|
|
7
|
+
// https://stackoverflow.com/a/12043228/942635
|
|
8
|
+
const c = hexColor.substring(1); // strip #
|
|
9
|
+
const rgb = parseInt(c, 16); // convert RRGGBB to decimal
|
|
10
|
+
/* eslint-disable no-bitwise*/
|
|
11
|
+
const r = (rgb >> 16) & 0xff; // extract red
|
|
12
|
+
const g = (rgb >> 8) & 0xff; // extract green
|
|
13
|
+
const b = (rgb >> 0) & 0xff; // extract blue
|
|
14
|
+
/* eslint-enable no-bitwise*/
|
|
15
|
+
const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; // per ITU-R BT.709
|
|
16
|
+
return luma < 128;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const Badge = ({ children, color, title, dot, margin, small }) => {
|
|
20
|
+
const visible = !(title === null && dot === null);
|
|
21
|
+
return (
|
|
22
|
+
<div className={styles.wrapper}>
|
|
23
|
+
{visible && (
|
|
24
|
+
<sup
|
|
25
|
+
className={cx(
|
|
26
|
+
styles.badge,
|
|
27
|
+
isDark(color) ? styles.dark : styles.light,
|
|
28
|
+
title !== null ? styles.label : styles.dot,
|
|
29
|
+
small ? styles.small : '',
|
|
30
|
+
children ? styles.hasChildren : '',
|
|
31
|
+
)}
|
|
32
|
+
style={{ background: color || undefined, margin }}
|
|
33
|
+
>
|
|
34
|
+
{title}
|
|
35
|
+
</sup>
|
|
36
|
+
)}
|
|
37
|
+
{children}
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
Badge.defaultProps = {
|
|
43
|
+
children: null,
|
|
44
|
+
color: '',
|
|
45
|
+
title: null,
|
|
46
|
+
dot: null,
|
|
47
|
+
margin: null,
|
|
48
|
+
small: false,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
Badge.propTypes = {
|
|
52
|
+
children: PropTypes.node,
|
|
53
|
+
color: PropTypes.string,
|
|
54
|
+
title: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
55
|
+
dot: PropTypes.bool,
|
|
56
|
+
margin: PropTypes.string,
|
|
57
|
+
small: PropTypes.bool,
|
|
58
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
@import '../../style/variables.less';
|
|
2
|
+
|
|
3
|
+
.wrapper {
|
|
4
|
+
display: inline-flex;
|
|
5
|
+
position: relative;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.badge {
|
|
9
|
+
background: var(--color-background-primary);
|
|
10
|
+
display: inline-block;
|
|
11
|
+
position: static;
|
|
12
|
+
|
|
13
|
+
&.label {
|
|
14
|
+
line-height: 22px;
|
|
15
|
+
min-width: 22px;
|
|
16
|
+
padding: 0 5px;
|
|
17
|
+
font-size: 12px;
|
|
18
|
+
font-weight: 400;
|
|
19
|
+
text-align: center;
|
|
20
|
+
white-space: nowrap;
|
|
21
|
+
border-radius: 11px;
|
|
22
|
+
font-weight: bold;
|
|
23
|
+
letter-spacing: normal;
|
|
24
|
+
|
|
25
|
+
&.dark {
|
|
26
|
+
color: #fff;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&.light {
|
|
30
|
+
color: rgba(0, 0, 0, 0.6);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&.small {
|
|
35
|
+
line-height: 13px;
|
|
36
|
+
min-width: 13px;
|
|
37
|
+
font-size: 9px;
|
|
38
|
+
border-radius: 6.5px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&.dot {
|
|
42
|
+
width: 6px;
|
|
43
|
+
height: 6px;
|
|
44
|
+
border-radius: 100%;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&.hasChildren {
|
|
48
|
+
position: absolute;
|
|
49
|
+
right: 0;
|
|
50
|
+
top: 0;
|
|
51
|
+
transform: translate(50%, -50%);
|
|
52
|
+
transform-origin: 100% 0%;
|
|
53
|
+
z-index: 3;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Badge, Button } from '../../..';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Basic/Badge',
|
|
6
|
+
component: Badge,
|
|
7
|
+
args: {
|
|
8
|
+
title: '3',
|
|
9
|
+
color: '',
|
|
10
|
+
small: false,
|
|
11
|
+
children: <Button name="example" label="Button" onClick={() => {}} />,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const Template = (args) => (
|
|
16
|
+
<Badge
|
|
17
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
18
|
+
{...args}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export const Default = Template.bind({});
|
|
23
|
+
|
|
24
|
+
export const Small = Template.bind({});
|
|
25
|
+
Small.args = { small: true };
|
|
26
|
+
|
|
27
|
+
export const Dot = Template.bind({});
|
|
28
|
+
Dot.args = { dot: true, title: undefined };
|
|
29
|
+
|
|
30
|
+
export const Standalone = Template.bind({});
|
|
31
|
+
Standalone.args = { children: undefined };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import { Link } from './link';
|
|
5
|
+
import styles from './breadcrumb.module.less';
|
|
6
|
+
|
|
7
|
+
export const Breadcrumb = ({ links, small }) => {
|
|
8
|
+
return (
|
|
9
|
+
<div className={cx(styles.breadcrumb, small && styles.small)}>
|
|
10
|
+
{links.map((link, i) => {
|
|
11
|
+
const isFinal = links.length === i + 1;
|
|
12
|
+
const { type, label, url, onClick, active, disabled, element } = link;
|
|
13
|
+
return (
|
|
14
|
+
<span key={i}>
|
|
15
|
+
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
16
|
+
<Link
|
|
17
|
+
type={type}
|
|
18
|
+
label={label}
|
|
19
|
+
url={url}
|
|
20
|
+
onClick={onClick}
|
|
21
|
+
active={active}
|
|
22
|
+
disabled={disabled}
|
|
23
|
+
element={element}
|
|
24
|
+
/>
|
|
25
|
+
{!isFinal && <span className={styles.separator}>/</span>}
|
|
26
|
+
</span>
|
|
27
|
+
);
|
|
28
|
+
})}
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
Breadcrumb.defaultProps = {
|
|
34
|
+
small: false,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
Breadcrumb.propTypes = {
|
|
38
|
+
links: PropTypes.arrayOf(
|
|
39
|
+
PropTypes.shape({
|
|
40
|
+
type: PropTypes.oneOf(['label', 'link', 'custom']),
|
|
41
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
42
|
+
url: PropTypes.string,
|
|
43
|
+
onClick: PropTypes.func,
|
|
44
|
+
active: PropTypes.bool,
|
|
45
|
+
element: PropTypes.node,
|
|
46
|
+
}),
|
|
47
|
+
).isRequired,
|
|
48
|
+
small: PropTypes.bool,
|
|
49
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
@import '../../style/variables.less';
|
|
2
|
+
|
|
3
|
+
.breadcrumb {
|
|
4
|
+
font-size: 1.5rem;
|
|
5
|
+
|
|
6
|
+
&.small {
|
|
7
|
+
font-size: inherit;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.labelContainer {
|
|
11
|
+
color: var(--color-text-primary);
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
|
|
14
|
+
&:hover {
|
|
15
|
+
color: var(--color-text-primary-hover);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&:active {
|
|
19
|
+
color: var(--color-text-primary-active);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&.active {
|
|
23
|
+
color: inherit;
|
|
24
|
+
cursor: default;
|
|
25
|
+
pointer-events: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&.disabled {
|
|
29
|
+
color: var(--color-text-faint);
|
|
30
|
+
cursor: default;
|
|
31
|
+
pointer-events: none;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.separator {
|
|
36
|
+
margin: 0 10px;
|
|
37
|
+
color: var(--color-border);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Breadcrumb } from '../../..';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Navigation/Breadcrumb',
|
|
6
|
+
component: Breadcrumb,
|
|
7
|
+
args: {
|
|
8
|
+
links: [
|
|
9
|
+
{
|
|
10
|
+
label: 'Animals',
|
|
11
|
+
onClick: () => console.log('label clicked'),
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
label: 'Mammals',
|
|
15
|
+
url: 'animals/mammals',
|
|
16
|
+
disabled: true,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
label: 'Cats',
|
|
20
|
+
url: 'animals/mammals/cats',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: 'custom', //e.g. react router <Link>
|
|
24
|
+
element: <span>Large</span>,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: 'Tiger',
|
|
28
|
+
url: 'animals/mammals/cats/tiger',
|
|
29
|
+
active: true,
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const Template = (args) => (
|
|
36
|
+
<Breadcrumb
|
|
37
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
38
|
+
{...args}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
export const Default = Template.bind({});
|
|
43
|
+
|
|
44
|
+
export const Small = Template.bind({});
|
|
45
|
+
Small.args = { small: true };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { isValidElement, useContext } from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import styles from './breadcrumb.module.less';
|
|
4
|
+
import { DisabledContext } from '../../helpers/disabled-context';
|
|
5
|
+
|
|
6
|
+
export const Link = ({
|
|
7
|
+
type,
|
|
8
|
+
label,
|
|
9
|
+
url,
|
|
10
|
+
onClick,
|
|
11
|
+
active,
|
|
12
|
+
disabled,
|
|
13
|
+
element,
|
|
14
|
+
}) => {
|
|
15
|
+
const disabledContext = useContext(DisabledContext);
|
|
16
|
+
|
|
17
|
+
const isLink = type === 'link' && url !== undefined;
|
|
18
|
+
const isCustom = type === 'custom' && isValidElement(element);
|
|
19
|
+
return (
|
|
20
|
+
<span
|
|
21
|
+
onClick={onClick}
|
|
22
|
+
className={cx(
|
|
23
|
+
styles.labelContainer,
|
|
24
|
+
active && styles.active,
|
|
25
|
+
(disabled || disabledContext) && styles.disabled,
|
|
26
|
+
)}
|
|
27
|
+
>
|
|
28
|
+
{isLink ? <a href={url}>{label}</a> : isCustom ? element : label}
|
|
29
|
+
</span>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import buttonStyles from './button.module.less';
|
|
5
|
+
import { Icon } from '../icon/icon';
|
|
6
|
+
import { Spinner } from '../spinner/spinner';
|
|
7
|
+
import { DisabledContext } from '../../helpers/disabled-context';
|
|
8
|
+
|
|
9
|
+
export const Button = ({
|
|
10
|
+
active,
|
|
11
|
+
basic,
|
|
12
|
+
colored,
|
|
13
|
+
disabled,
|
|
14
|
+
groupOrder,
|
|
15
|
+
icon,
|
|
16
|
+
inverted,
|
|
17
|
+
label,
|
|
18
|
+
loading,
|
|
19
|
+
name,
|
|
20
|
+
onClick,
|
|
21
|
+
pill,
|
|
22
|
+
round,
|
|
23
|
+
small,
|
|
24
|
+
width,
|
|
25
|
+
title,
|
|
26
|
+
styles,
|
|
27
|
+
testId,
|
|
28
|
+
}) => {
|
|
29
|
+
const disabledContext = useContext(DisabledContext);
|
|
30
|
+
|
|
31
|
+
const color = (() => {
|
|
32
|
+
if (colored) {
|
|
33
|
+
switch (colored) {
|
|
34
|
+
case 'danger':
|
|
35
|
+
case 'red':
|
|
36
|
+
return buttonStyles.red;
|
|
37
|
+
case 'success':
|
|
38
|
+
case 'green':
|
|
39
|
+
return buttonStyles.green;
|
|
40
|
+
case 'muted':
|
|
41
|
+
return buttonStyles.muted;
|
|
42
|
+
default:
|
|
43
|
+
return buttonStyles.orange;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return '';
|
|
47
|
+
})();
|
|
48
|
+
|
|
49
|
+
const order = (() => {
|
|
50
|
+
if (groupOrder) {
|
|
51
|
+
switch (groupOrder) {
|
|
52
|
+
case 'first':
|
|
53
|
+
return buttonStyles.groupOrderFirst;
|
|
54
|
+
case 'last':
|
|
55
|
+
return buttonStyles.groupOrderLast;
|
|
56
|
+
default:
|
|
57
|
+
return buttonStyles.groupOrderMiddle;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return '';
|
|
61
|
+
})();
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<button
|
|
65
|
+
type="button"
|
|
66
|
+
className={cx(
|
|
67
|
+
buttonStyles.button,
|
|
68
|
+
active ? buttonStyles.active : '',
|
|
69
|
+
basic ? buttonStyles.basic : '',
|
|
70
|
+
color,
|
|
71
|
+
disabled || disabledContext ? buttonStyles.disabled : '',
|
|
72
|
+
(icon || loading) && !label ? buttonStyles.iconOnly : '',
|
|
73
|
+
inverted ? buttonStyles.inverted : '',
|
|
74
|
+
order,
|
|
75
|
+
pill ? buttonStyles.pill : '',
|
|
76
|
+
round ? buttonStyles.round : '',
|
|
77
|
+
small ? buttonStyles.small : '',
|
|
78
|
+
styles,
|
|
79
|
+
)}
|
|
80
|
+
disabled={disabled || disabledContext}
|
|
81
|
+
name={name}
|
|
82
|
+
onClick={onClick}
|
|
83
|
+
{...(title ? { title } : {})} // eslint-disable-line react/jsx-props-no-spreading
|
|
84
|
+
style={{ width }}
|
|
85
|
+
data-testid={testId}
|
|
86
|
+
>
|
|
87
|
+
{icon && (
|
|
88
|
+
<span className={buttonStyles.icon}>
|
|
89
|
+
<Icon icon={icon} />
|
|
90
|
+
</span>
|
|
91
|
+
)}
|
|
92
|
+
{loading && (
|
|
93
|
+
<span className={buttonStyles.icon}>
|
|
94
|
+
<Spinner
|
|
95
|
+
small={!small /*regular button use small spinner*/}
|
|
96
|
+
tiny={small /*small button use tiny spinner*/}
|
|
97
|
+
dark={!colored && !basic}
|
|
98
|
+
colored={basic}
|
|
99
|
+
/>
|
|
100
|
+
</span>
|
|
101
|
+
)}
|
|
102
|
+
{label}
|
|
103
|
+
</button>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
Button.defaultProps = {
|
|
108
|
+
active: false,
|
|
109
|
+
basic: false,
|
|
110
|
+
colored: false,
|
|
111
|
+
disabled: false,
|
|
112
|
+
groupOrder: null,
|
|
113
|
+
icon: null,
|
|
114
|
+
label: '',
|
|
115
|
+
loading: false,
|
|
116
|
+
name: undefined,
|
|
117
|
+
pill: false,
|
|
118
|
+
round: false,
|
|
119
|
+
small: false,
|
|
120
|
+
styles: '',
|
|
121
|
+
width: '',
|
|
122
|
+
title: '',
|
|
123
|
+
onClick: () => {},
|
|
124
|
+
testId: undefined,
|
|
125
|
+
inverted: false,
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
Button.propTypes = {
|
|
129
|
+
/** Show active state (non-colored buttons only) */
|
|
130
|
+
active: PropTypes.bool,
|
|
131
|
+
/** Link style button */
|
|
132
|
+
basic: PropTypes.bool,
|
|
133
|
+
colored: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
134
|
+
disabled: PropTypes.bool,
|
|
135
|
+
icon: PropTypes.oneOfType([
|
|
136
|
+
PropTypes.node,
|
|
137
|
+
PropTypes.string, //deprecated
|
|
138
|
+
]),
|
|
139
|
+
/** Position of button in `ButtonGroup` or `InputGroup` */
|
|
140
|
+
groupOrder: PropTypes.string,
|
|
141
|
+
label: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
|
|
142
|
+
title: PropTypes.string,
|
|
143
|
+
/** Adds activity indicator */
|
|
144
|
+
loading: PropTypes.bool,
|
|
145
|
+
name: PropTypes.string,
|
|
146
|
+
onClick: PropTypes.func,
|
|
147
|
+
round: PropTypes.bool,
|
|
148
|
+
small: PropTypes.bool,
|
|
149
|
+
styles: PropTypes.string,
|
|
150
|
+
width: PropTypes.string,
|
|
151
|
+
testId: PropTypes.string,
|
|
152
|
+
/** *Deprecated* */
|
|
153
|
+
pill: PropTypes.bool,
|
|
154
|
+
/** *Deprecated* */
|
|
155
|
+
inverted: PropTypes.bool,
|
|
156
|
+
};
|