@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.
Files changed (317) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.js +125 -0
  3. package/.gitlab-ci.yml +45 -0
  4. package/.husky/pre-commit +4 -0
  5. package/.prettierignore +3 -0
  6. package/.prettierrc +4 -0
  7. package/.storybook/main.js +36 -0
  8. package/.storybook/preview.js +40 -0
  9. package/.storybook/storybook.less +8 -0
  10. package/LICENSE +21 -0
  11. package/README.md +5 -0
  12. package/babel.config.js +31 -0
  13. package/index.js +76 -0
  14. package/jest.config.js +9 -0
  15. package/package.json +136 -0
  16. package/src/components/accordion/accordion.jsx +132 -0
  17. package/src/components/accordion/accordion.module.less +66 -0
  18. package/src/components/accordion/accordion.stories.jsx +171 -0
  19. package/src/components/accordion/chevron/chevron.jsx +12 -0
  20. package/src/components/accordion/chevron/chevron.module.less +12 -0
  21. package/src/components/accordion/helpers/accordion-with-default-toggle.jsx +106 -0
  22. package/src/components/accordion/helpers/accordion-with-default-toggle.module.less +24 -0
  23. package/src/components/actions/actions.jsx +129 -0
  24. package/src/components/actions/actions.module.less +44 -0
  25. package/src/components/actions/actions.shape.js +32 -0
  26. package/src/components/actions/actions.stories.jsx +79 -0
  27. package/src/components/badge/badge.jsx +58 -0
  28. package/src/components/badge/badge.module.less +55 -0
  29. package/src/components/badge/badge.stories.jsx +31 -0
  30. package/src/components/breadcrumb/breadcrumb.jsx +49 -0
  31. package/src/components/breadcrumb/breadcrumb.module.less +39 -0
  32. package/src/components/breadcrumb/breadcrumb.stories.jsx +45 -0
  33. package/src/components/breadcrumb/link.jsx +31 -0
  34. package/src/components/button/button.jsx +156 -0
  35. package/src/components/button/button.module.less +300 -0
  36. package/src/components/button/button.stories.jsx +74 -0
  37. package/src/components/button-group/button-group.jsx +140 -0
  38. package/src/components/button-group/button-group.module.less +24 -0
  39. package/src/components/button-group/button-group.stories-data.jsx +67 -0
  40. package/src/components/button-group/button-group.stories.jsx +63 -0
  41. package/src/components/buttons-and-links.stories.mdx +55 -0
  42. package/src/components/card/card.jsx +51 -0
  43. package/src/components/card/card.module.less +48 -0
  44. package/src/components/card/card.stories.jsx +39 -0
  45. package/src/components/check-box/check-box.jsx +92 -0
  46. package/src/components/check-box/check-box.module.less +101 -0
  47. package/src/components/check-box/check-box.stories.jsx +27 -0
  48. package/src/components/color/color.stories-data.jsx +71 -0
  49. package/src/components/color/color.stories.mdx +37 -0
  50. package/src/components/dialog/dialog.jsx +64 -0
  51. package/src/components/dialog/dialog.module.less +76 -0
  52. package/src/components/divider/divider.jsx +40 -0
  53. package/src/components/divider/divider.module.less +28 -0
  54. package/src/components/divider/divider.stories.jsx +50 -0
  55. package/src/components/drawer/drawer-tabs.jsx +43 -0
  56. package/src/components/drawer/drawer.jsx +150 -0
  57. package/src/components/drawer/drawer.module.less +167 -0
  58. package/src/components/drawer/drawer.stories.jsx +156 -0
  59. package/src/components/empty/empty.jsx +52 -0
  60. package/src/components/empty/empty.module.less +17 -0
  61. package/src/components/empty/empty.stories.jsx +26 -0
  62. package/src/components/file-input/file-input.jsx +101 -0
  63. package/src/components/file-input/file-input.module.less +3 -0
  64. package/src/components/file-input/file-input.stories.jsx +109 -0
  65. package/src/components/form/field.jsx +96 -0
  66. package/src/components/form/field.stories.jsx +101 -0
  67. package/src/components/form/form.module.less +30 -0
  68. package/src/components/form/form.stories.jsx +191 -0
  69. package/src/components/heading/heading.jsx +105 -0
  70. package/src/components/heading/heading.module.less +59 -0
  71. package/src/components/heading/heading.stories.jsx +60 -0
  72. package/src/components/icon/deprecated-icon.jsx +97 -0
  73. package/src/components/icon/icon.jsx +71 -0
  74. package/src/components/icon/icon.module.less +33 -0
  75. package/src/components/icon/icon.stories.jsx +37 -0
  76. package/src/components/icon/icons.example.module.less +4 -0
  77. package/src/components/input/input.jsx +167 -0
  78. package/src/components/input/input.module.less +94 -0
  79. package/src/components/input/input.stories.jsx +28 -0
  80. package/src/components/input-group/input-group-addon/input-group-addon.jsx +36 -0
  81. package/src/components/input-group/input-group-addon/input-group-addon.module.less +31 -0
  82. package/src/components/input-group/input-group.jsx +51 -0
  83. package/src/components/input-group/input-group.module.less +10 -0
  84. package/src/components/input-group/input-group.stories.jsx +77 -0
  85. package/src/components/input-validation.stories.mdx +61 -0
  86. package/src/components/inputs.stories.mdx +201 -0
  87. package/src/components/label/label.jsx +115 -0
  88. package/src/components/label/label.module.less +43 -0
  89. package/src/components/label/label.stories.jsx +60 -0
  90. package/src/components/layout/column/column.jsx +85 -0
  91. package/src/components/layout/column/styles.js +45 -0
  92. package/src/components/layout/column.stories.jsx +60 -0
  93. package/src/components/layout/examples/afe.stories.jsx +180 -0
  94. package/src/components/layout/examples/blowout.stories.jsx +68 -0
  95. package/src/components/layout/examples/casing-loads.stories.jsx +297 -0
  96. package/src/components/layout/examples/formation.stories.jsx +110 -0
  97. package/src/components/layout/examples/projects.stories.jsx +108 -0
  98. package/src/components/layout/examples/reservoirs.stories.jsx +211 -0
  99. package/src/components/layout/examples/site.stories.jsx +263 -0
  100. package/src/components/layout/flex/flex.jsx +48 -0
  101. package/src/components/layout/flex/flex.stories.jsx +54 -0
  102. package/src/components/layout/form-row/form-row.jsx +15 -0
  103. package/src/components/layout/form-row/form-row.module.less +11 -0
  104. package/src/components/layout/grid/grid.jsx +62 -0
  105. package/src/components/layout/grid/grid.stories.jsx +65 -0
  106. package/src/components/layout/page/page.jsx +42 -0
  107. package/src/components/layout/page/page.module.less +27 -0
  108. package/src/components/layout/page.stories.jsx +93 -0
  109. package/src/components/layout/placeholder.jsx +2 -0
  110. package/src/components/layout/print-header/print-header.jsx +22 -0
  111. package/src/components/layout/print-header/print-header.module.less +9 -0
  112. package/src/components/layout/row/row.jsx +75 -0
  113. package/src/components/layout/row/row.module.less +7 -0
  114. package/src/components/layout/spacer/spacer.jsx +26 -0
  115. package/src/components/layout/spacer/spacer.stories.jsx +50 -0
  116. package/src/components/layout-forms.stories.mdx +104 -0
  117. package/src/components/layout-general.stories.mdx +215 -0
  118. package/src/components/list/list-row/item-content.jsx +15 -0
  119. package/src/components/list/list-row/label.jsx +11 -0
  120. package/src/components/list/list-row/list-heading.jsx +52 -0
  121. package/src/components/list/list-row/list-row.jsx +128 -0
  122. package/src/components/list/list-row/list-subheading.jsx +72 -0
  123. package/src/components/list/list-row/meta-content.jsx +24 -0
  124. package/src/components/list/list-row/meta-count.jsx +10 -0
  125. package/src/components/list/list-row/name.jsx +45 -0
  126. package/src/components/list/list.jsx +276 -0
  127. package/src/components/list/list.module.less +256 -0
  128. package/src/components/list/list.stories-data.jsx +287 -0
  129. package/src/components/list/list.stories.jsx +458 -0
  130. package/src/components/list/toggle-narrow.jsx +13 -0
  131. package/src/components/loader/loader.jsx +63 -0
  132. package/src/components/loader/loader.module.less +63 -0
  133. package/src/components/loader/loader.stories.jsx +155 -0
  134. package/src/components/menu/index.js +7 -0
  135. package/src/components/menu/layer/divider.jsx +4 -0
  136. package/src/components/menu/layer/heading.jsx +15 -0
  137. package/src/components/menu/layer/layer.jsx +82 -0
  138. package/src/components/menu/layer/option.jsx +77 -0
  139. package/src/components/menu/layer/path.js +44 -0
  140. package/src/components/menu/layer/placementOptions.js +6 -0
  141. package/src/components/menu/layer/section.jsx +66 -0
  142. package/src/components/menu/menu.jsx +359 -0
  143. package/src/components/menu/menu.module.less +241 -0
  144. package/src/components/menu/menu.stories-data.jsx +168 -0
  145. package/src/components/menu/menu.stories.jsx +126 -0
  146. package/src/components/menu/menu.test.js +58 -0
  147. package/src/components/menu/trigger/button.jsx +50 -0
  148. package/src/components/menu/trigger/component.jsx +14 -0
  149. package/src/components/menu/trigger/text.jsx +25 -0
  150. package/src/components/menu/trigger/trigger.jsx +86 -0
  151. package/src/components/message/dismiss.jsx +26 -0
  152. package/src/components/message/message.jsx +137 -0
  153. package/src/components/message/message.module.less +114 -0
  154. package/src/components/message/message.stories.jsx +84 -0
  155. package/src/components/modal/modal.jsx +50 -0
  156. package/src/components/modal/modal.module.less +35 -0
  157. package/src/components/modal/modal.stories.jsx +159 -0
  158. package/src/components/option-dropdown/heading.jsx +6 -0
  159. package/src/components/option-dropdown/layer.jsx +81 -0
  160. package/src/components/option-dropdown/option-dropdown.jsx +53 -0
  161. package/src/components/option-dropdown/option-dropdown.module.less +50 -0
  162. package/src/components/option-dropdown/option-dropdown.stories.jsx +35 -0
  163. package/src/components/option-dropdown/option.jsx +13 -0
  164. package/src/components/pagination/pagination.jsx +139 -0
  165. package/src/components/pagination/pagination.module.less +11 -0
  166. package/src/components/pagination/pagination.stories.jsx +78 -0
  167. package/src/components/pagination/pagination.test.js +92 -0
  168. package/src/components/pagination/pagination.viewdata.js +66 -0
  169. package/src/components/pop-confirm/content.jsx +25 -0
  170. package/src/components/pop-confirm/pop-confirm.jsx +61 -0
  171. package/src/components/pop-confirm/pop-confirm.module.less +18 -0
  172. package/src/components/pop-confirm/pop-confirm.stories.jsx +53 -0
  173. package/src/components/popover/popover.jsx +112 -0
  174. package/src/components/popover/popover.module.less +22 -0
  175. package/src/components/popover/popover.stories.jsx +59 -0
  176. package/src/components/portal/portal.jsx +16 -0
  177. package/src/components/portal/portal.stories.jsx +69 -0
  178. package/src/components/progress-bar/progress-bar.jsx +64 -0
  179. package/src/components/progress-bar/progress-bar.module.less +64 -0
  180. package/src/components/progress-bar/progress-bar.stories.jsx +23 -0
  181. package/src/components/radio-button/radio-button.jsx +139 -0
  182. package/src/components/radio-button/radio-button.module.less +135 -0
  183. package/src/components/radio-button/radio-button.stories.jsx +37 -0
  184. package/src/components/radio-button/radio-input.jsx +52 -0
  185. package/src/components/select/custom-select/custom-select.jsx +440 -0
  186. package/src/components/select/custom-select/custom-select.module.less +123 -0
  187. package/src/components/select/custom-select/custom-select.reducer.js +157 -0
  188. package/src/components/select/custom-select/layer/heading.jsx +13 -0
  189. package/src/components/select/custom-select/layer/layer.jsx +73 -0
  190. package/src/components/select/custom-select/layer/option.jsx +54 -0
  191. package/src/components/select/custom-select/layer/placementOptions.js +7 -0
  192. package/src/components/select/custom-select/layer/section.jsx +35 -0
  193. package/src/components/select/custom-select/trigger/input.jsx +100 -0
  194. package/src/components/select/custom-select/trigger/trigger.jsx +155 -0
  195. package/src/components/select/custom-select/trigger/trigger.module.less +289 -0
  196. package/src/components/select/native-select/native-select.jsx +198 -0
  197. package/src/components/select/native-select/native-select.module.less +107 -0
  198. package/src/components/select/select.input.js +146 -0
  199. package/src/components/select/select.jsx +207 -0
  200. package/src/components/select/select.stories-data.jsx +92 -0
  201. package/src/components/select/select.stories.jsx +135 -0
  202. package/src/components/select/select.test.js +519 -0
  203. package/src/components/side-bar/container.module.less +29 -0
  204. package/src/components/side-bar/link.jsx +83 -0
  205. package/src/components/side-bar/sections.jsx +23 -0
  206. package/src/components/side-bar/side-bar.jsx +102 -0
  207. package/src/components/side-bar/side-bar.module.less +137 -0
  208. package/src/components/side-bar/side-bar.stories.jsx +101 -0
  209. package/src/components/slider/rc-slider.less +47 -0
  210. package/src/components/slider/slider-tooltip.jsx +20 -0
  211. package/src/components/slider/slider.jsx +233 -0
  212. package/src/components/slider/slider.module.less +40 -0
  213. package/src/components/slider/slider.stories.jsx +110 -0
  214. package/src/components/spinner/spinner.jsx +37 -0
  215. package/src/components/spinner/spinner.module.less +115 -0
  216. package/src/components/spinner/spinner.stories.jsx +24 -0
  217. package/src/components/table/cell/cell.jsx +614 -0
  218. package/src/components/table/cell/cell.module.less +152 -0
  219. package/src/components/table/footer/footer.jsx +66 -0
  220. package/src/components/table/footer/footer.module.less +14 -0
  221. package/src/components/table/helper.js +64 -0
  222. package/src/components/table/helper.test.js +166 -0
  223. package/src/components/table/icon/icon.module.less +31 -0
  224. package/src/components/table/row/expanded-content-row.jsx +16 -0
  225. package/src/components/table/row/row.jsx +253 -0
  226. package/src/components/table/row/row.module.less +62 -0
  227. package/src/components/table/table-scroll-wrapper.jsx +48 -0
  228. package/src/components/table/table.jsx +232 -0
  229. package/src/components/table/table.module.less +145 -0
  230. package/src/components/table/table.stories-data.jsx +752 -0
  231. package/src/components/table/table.stories.jsx +814 -0
  232. package/src/components/table/table.test.js +30 -0
  233. package/src/components/table/table.variables.less +19 -0
  234. package/src/components/table/table.viewdata.js +26 -0
  235. package/src/components/table/title/title.jsx +30 -0
  236. package/src/components/table/title/title.module.less +9 -0
  237. package/src/components/tabs/content.jsx +14 -0
  238. package/src/components/tabs/label.jsx +50 -0
  239. package/src/components/tabs/tabs.jsx +191 -0
  240. package/src/components/tabs/tabs.module.less +73 -0
  241. package/src/components/tabs/tabs.stories.jsx +110 -0
  242. package/src/components/text/text.jsx +64 -0
  243. package/src/components/text/text.module.less +45 -0
  244. package/src/components/text/text.stories.jsx +31 -0
  245. package/src/components/text-link/text-link.jsx +23 -0
  246. package/src/components/text-link/text-link.stories.jsx +20 -0
  247. package/src/components/textarea/textarea.jsx +126 -0
  248. package/src/components/textarea/textarea.module.less +55 -0
  249. package/src/components/textarea/textarea.stories.jsx +26 -0
  250. package/src/components/toaster/toaster.jsx +39 -0
  251. package/src/components/toaster/toaster.less +17 -0
  252. package/src/components/toaster/toaster.stories.jsx +116 -0
  253. package/src/components/toggle/toggle.jsx +65 -0
  254. package/src/components/toggle/toggle.module.less +139 -0
  255. package/src/components/toggle/toggle.stories.jsx +26 -0
  256. package/src/components/tooltip/tooltip-layer.jsx +72 -0
  257. package/src/components/tooltip/tooltip.jsx +108 -0
  258. package/src/components/tooltip/tooltip.module.less +28 -0
  259. package/src/components/tooltip/tooltip.stories.jsx +71 -0
  260. package/src/components/top-bar/element/element.jsx +72 -0
  261. package/src/components/top-bar/element/link.jsx +29 -0
  262. package/src/components/top-bar/title.jsx +24 -0
  263. package/src/components/top-bar/top-bar.jsx +79 -0
  264. package/src/components/top-bar/top-bar.module.less +191 -0
  265. package/src/components/top-bar/top-bar.stories.jsx +137 -0
  266. package/src/components/top-bar/warning.jsx +6 -0
  267. package/src/components/tree/tree-item.jsx +79 -0
  268. package/src/components/tree/tree-placeholder.jsx +6 -0
  269. package/src/components/tree/tree.jsx +129 -0
  270. package/src/components/tree/tree.module.less +33 -0
  271. package/src/components/tree/tree.stories-data.jsx +89 -0
  272. package/src/components/tree/tree.stories.jsx +106 -0
  273. package/src/docs/components/page/page.jsx +16 -0
  274. package/src/docs/config/config.js +1 -0
  275. package/src/docs/html/favicon.png +0 -0
  276. package/src/docs/html/index.html +11 -0
  277. package/src/docs/navigation/footer/footer.jsx +48 -0
  278. package/src/docs/navigation/header/header.jsx +39 -0
  279. package/src/docs/navigation/header/header.module.less +32 -0
  280. package/src/docs/navigation/routes/routes.jsx +16 -0
  281. package/src/docs/start.jsx +12 -0
  282. package/src/docs/views/main/main.jsx +209 -0
  283. package/src/docs/views/main/main.module.less +14 -0
  284. package/src/docs/views/not-found/not-found.jsx +5 -0
  285. package/src/helpers/disabled-context.js +8 -0
  286. package/src/helpers/styles.js +68 -0
  287. package/src/helpers/text.js +6 -0
  288. package/src/helpers/types.js +5 -0
  289. package/src/hooks/index.js +3 -0
  290. package/src/hooks/use-focus.js +11 -0
  291. package/src/hooks/use-keyboard-event.js +16 -0
  292. package/src/hooks/use-window-width.js +20 -0
  293. package/src/images/icons/icon-drop.png +0 -0
  294. package/src/images/icons/icon-share.png +0 -0
  295. package/src/images/icons/icons8-junction.svg +4 -0
  296. package/src/images/logo.png +0 -0
  297. package/src/images/logo.svg +13 -0
  298. package/src/images/oliasoft-logo.svg +1 -0
  299. package/src/style/colors.less +26 -0
  300. package/src/style/external.less +10 -0
  301. package/src/style/fonts/lato/Lato-Bold.woff2 +0 -0
  302. package/src/style/fonts/lato/Lato-BoldItalic.woff2 +0 -0
  303. package/src/style/fonts/lato/Lato-Italic.woff2 +0 -0
  304. package/src/style/fonts/lato/Lato-Regular.woff2 +0 -0
  305. package/src/style/fonts.less +27 -0
  306. package/src/style/global.less +51 -0
  307. package/src/style/mixins.less +67 -0
  308. package/src/style/reset/reset.less +34 -0
  309. package/src/style/shared.less +25 -0
  310. package/src/style/theme.dark.less +37 -0
  311. package/src/style/theme.default.less +74 -0
  312. package/src/style/variables.less +49 -0
  313. package/webpack/webpack.common.js +39 -0
  314. package/webpack/webpack.common.rules.js +102 -0
  315. package/webpack/webpack.dev.js +22 -0
  316. package/webpack/webpack.prod.js +23 -0
  317. package/webpack/webpack.resolve.js +22 -0
@@ -0,0 +1,28 @@
1
+ @import '../../style/variables.less';
2
+
3
+ .divider {
4
+ display: flex;
5
+ align-items: center;
6
+ text-align: center;
7
+ }
8
+
9
+ .divider::before,
10
+ .divider::after {
11
+ content: '';
12
+ flex: 1;
13
+ border-bottom: 1px solid var(--color);
14
+ }
15
+
16
+ .alignLeft::before {
17
+ flex-grow: 0.05;
18
+ }
19
+ .alignRight::after {
20
+ flex-grow: 0.05;
21
+ }
22
+
23
+ .divider:not(:empty)::before {
24
+ margin-right: 0.25em;
25
+ }
26
+ .divider:not(:empty)::after {
27
+ margin-left: 0.25em;
28
+ }
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import { Divider, Text } from '../../..';
3
+
4
+ export default {
5
+ title: 'Layout/Divider',
6
+ component: Divider,
7
+ argTypes: {
8
+ align: {
9
+ control: {
10
+ type: 'inline-radio',
11
+ },
12
+ options: ['left', 'center', 'right'],
13
+ },
14
+ },
15
+ decorators: [(story) => <>content{story()}more content</>],
16
+ parameters: {
17
+ docs: {
18
+ source: {
19
+ excludeDecorators: true,
20
+ },
21
+ },
22
+ },
23
+ };
24
+
25
+ const Template = (args) => (
26
+ <Divider
27
+ // eslint-disable-next-line react/jsx-props-no-spreading
28
+ {...args}
29
+ />
30
+ );
31
+
32
+ export const Default = Template.bind({});
33
+
34
+ export const WithText = Template.bind({});
35
+ WithText.args = {
36
+ children: 'Heading',
37
+ align: 'left',
38
+ };
39
+
40
+ export const Margin = Template.bind({});
41
+ Margin.args = {
42
+ margin: 0,
43
+ };
44
+
45
+ export const CustomColor = Template.bind({});
46
+ CustomColor.args = {
47
+ color: 'var(--color-text-success)',
48
+ children: <Text success>Colored text</Text>,
49
+ align: 'left',
50
+ };
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import cx from 'classnames';
3
+ import styles from './drawer.module.less';
4
+
5
+ export const DrawerTabs = ({
6
+ tabs,
7
+ activeTab,
8
+ background,
9
+ handleTabClick,
10
+ width,
11
+ testId,
12
+ }) => {
13
+ return (
14
+ <>
15
+ <div className={styles.tabs}>
16
+ {tabs.map((tab, index) => (
17
+ <div
18
+ key={index}
19
+ className={cx(styles.tab, activeTab === index && styles.active)}
20
+ style={{ background }}
21
+ onClick={() => handleTabClick(index)}
22
+ data-testid={testId && `${testId}-icon-${index}`}
23
+ >
24
+ {tab.icon}
25
+ </div>
26
+ ))}
27
+ </div>
28
+ {tabs.map((tab, index) => {
29
+ const active = activeTab === index;
30
+
31
+ return (
32
+ <div
33
+ style={{ width }}
34
+ key={index}
35
+ data-testid={testId && `${testId}-content-${index}`}
36
+ >
37
+ {active && tab.content}
38
+ </div>
39
+ );
40
+ })}
41
+ </>
42
+ );
43
+ };
@@ -0,0 +1,150 @@
1
+ import React, { isValidElement, useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import cx from 'classnames';
4
+ import { FaChevronLeft, FaChevronRight } from 'react-icons/fa';
5
+ import { Button } from '../button/button';
6
+ import { DrawerTabs } from './drawer-tabs';
7
+ import styles from './drawer.module.less';
8
+
9
+ export const Drawer = ({
10
+ background,
11
+ children,
12
+ fixed,
13
+ open: openProp,
14
+ right,
15
+ shadow,
16
+ top,
17
+ width,
18
+ closedWidth,
19
+ button,
20
+ buttonAnimate,
21
+ buttonPosition,
22
+ border,
23
+ tabs,
24
+ defaultTabIndex,
25
+ testId,
26
+ }) => {
27
+ const isStandardButton = button === true;
28
+ const isCustomButton = !isStandardButton && isValidElement(button);
29
+ const [open, setOpen] =
30
+ isStandardButton || tabs ? useState(openProp) : [openProp, null];
31
+ const [activeTab, setActiveTab] = useState(open ? defaultTabIndex : null);
32
+ const openWidth = Array.isArray(width) ? width[activeTab] : width;
33
+ const currentWidth = open ? openWidth : closedWidth;
34
+
35
+ const handleTabClick = (index) => {
36
+ if (activeTab === index) {
37
+ setActiveTab(null);
38
+ setOpen(false);
39
+ } else {
40
+ setActiveTab(index);
41
+ setOpen(true);
42
+ }
43
+ };
44
+
45
+ return (
46
+ <div
47
+ className={cx(
48
+ styles.drawer,
49
+ shadow ? styles.shadow : '',
50
+ fixed ? styles.fixed : styles.inline,
51
+ right ? styles.right : styles.left,
52
+ )}
53
+ style={{
54
+ top,
55
+ }}
56
+ >
57
+ <div
58
+ className={cx(styles.drawerContent, border && styles.border)}
59
+ style={{ background, borderColor: border, width: currentWidth }}
60
+ >
61
+ {tabs ? (
62
+ <DrawerTabs
63
+ width={openWidth}
64
+ testId={testId}
65
+ open={open}
66
+ tabs={tabs}
67
+ activeTab={activeTab}
68
+ background={background}
69
+ handleTabClick={handleTabClick}
70
+ />
71
+ ) : (
72
+ <div style={{ width: openWidth }}>{children}</div>
73
+ )}
74
+ </div>
75
+
76
+ {button && (
77
+ <span
78
+ className={cx(
79
+ styles.toggleButton,
80
+ open && (isStandardButton || (isCustomButton && buttonAnimate))
81
+ ? styles.toggleButtonOpen
82
+ : '',
83
+ buttonPosition === 'top' ? styles.top : styles.bottom,
84
+ )}
85
+ >
86
+ {isCustomButton ? (
87
+ button
88
+ ) : (
89
+ <Button
90
+ onClick={setOpen ? () => setOpen(!open) : null}
91
+ round
92
+ icon={right ? <FaChevronRight /> : <FaChevronLeft />}
93
+ />
94
+ )}
95
+ </span>
96
+ )}
97
+ </div>
98
+ );
99
+ };
100
+
101
+ Drawer.defaultProps = {
102
+ background: 'transparent',
103
+ fixed: false,
104
+ open: false,
105
+ right: false,
106
+ width: 400,
107
+ closedWidth: 0,
108
+ shadow: false,
109
+ top: 0,
110
+ button: null,
111
+ buttonAnimate: true,
112
+ buttonPosition: 'bottom',
113
+ border: false,
114
+ children: null,
115
+ tabs: null,
116
+ defaultTabIndex: 0,
117
+ testId: undefined,
118
+ };
119
+
120
+ Drawer.propTypes = {
121
+ background: PropTypes.string,
122
+ fixed: PropTypes.bool,
123
+ open: PropTypes.bool,
124
+ right: PropTypes.bool,
125
+ width: PropTypes.oneOfType([
126
+ PropTypes.string,
127
+ PropTypes.number,
128
+ PropTypes.arrayOf(
129
+ PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
130
+ ),
131
+ ]),
132
+ closedWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
133
+ children: PropTypes.node,
134
+ shadow: PropTypes.bool,
135
+ top: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
136
+ //button
137
+ button: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),
138
+ buttonAnimate: PropTypes.bool,
139
+ buttonPosition: PropTypes.oneOf(['top', 'bottom']),
140
+ border: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
141
+ // tabs
142
+ tabs: PropTypes.arrayOf(
143
+ PropTypes.shape({
144
+ icon: PropTypes.node,
145
+ content: PropTypes.node,
146
+ }),
147
+ ),
148
+ testId: PropTypes.string,
149
+ defaultTabIndex: PropTypes.number,
150
+ };
@@ -0,0 +1,167 @@
1
+ @import '../../style/variables.less';
2
+
3
+ :root {
4
+ --color-background-drawer-tab: #fff9f4;
5
+ --color-background-drawer-tab-hover: white;
6
+ --color-border-drawer-tab: #e4cbb7;
7
+ }
8
+
9
+ html[data-theme='dark'] {
10
+ --color-background-drawer-tab: var(--color-primary-muted-800);
11
+ --color-background-drawer-tab-hover: var(--color-primary-muted-700);
12
+ --color-border-drawer-tab: var(--color-border);
13
+ }
14
+
15
+ .inline {
16
+ position: relative;
17
+
18
+ &.left {
19
+ order: -1;
20
+ }
21
+
22
+ &.right {
23
+ order: 9999;
24
+ }
25
+ }
26
+
27
+ .fixed {
28
+ position: fixed;
29
+ top: 0;
30
+ bottom: 0;
31
+ z-index: @zindex_drawer;
32
+
33
+ &.left {
34
+ left: 0;
35
+ }
36
+
37
+ &.right {
38
+ right: 0;
39
+ }
40
+ }
41
+
42
+ .border {
43
+ .left & {
44
+ border-right: 1px solid var(--color-border);
45
+ }
46
+
47
+ .right & {
48
+ border-left: 1px solid var(--color-border);
49
+ }
50
+ }
51
+
52
+ .shadow {
53
+ box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
54
+ }
55
+
56
+ .drawerContent {
57
+ overflow-x: hidden;
58
+ overflow-y: auto;
59
+ max-height: 100%;
60
+ min-height: 100%;
61
+
62
+ transition: width 0.2s;
63
+
64
+ @media print {
65
+ background: transparent !important;
66
+ }
67
+
68
+ /* Hide scrollbar for Firefox */
69
+ scrollbar-width: none;
70
+ /* Hide scrollbar for IE 10+ */
71
+ -ms-overflow-style: none;
72
+
73
+ /* Hide scrollbar for Chrome, Safari and Opera */
74
+ &::-webkit-scrollbar {
75
+ display: none;
76
+ }
77
+ }
78
+
79
+ .toggleButton {
80
+ transition: transform 0.4s;
81
+ display: inline-block;
82
+ transform: rotate(180deg);
83
+ position: absolute;
84
+ z-index: 1;
85
+
86
+ .left & {
87
+ right: -19px;
88
+ }
89
+
90
+ .right & {
91
+ left: -19px;
92
+ }
93
+
94
+ &.top {
95
+ top: 20px;
96
+ }
97
+
98
+ &.bottom {
99
+ bottom: 20px;
100
+ }
101
+
102
+ &.toggleButtonOpen {
103
+ transform: rotate(0deg);
104
+ }
105
+ }
106
+
107
+ .tabs {
108
+ position: absolute;
109
+ top: 20px;
110
+ z-index: @zindex_drawer + 1;
111
+
112
+ .left & {
113
+ left: 100%;
114
+ margin-left: -1px;
115
+ }
116
+
117
+ .right & {
118
+ right: 100%;
119
+ margin-right: -1px;
120
+ }
121
+
122
+ .tab {
123
+ height: 40px;
124
+ width: 40px;
125
+ display: flex;
126
+ justify-content: center;
127
+ align-items: center;
128
+ margin-bottom: 1px;
129
+ border-radius: 4px;
130
+ cursor: pointer;
131
+ transition: color 0.3s, background-color 0.3s;
132
+ border: 1px solid var(--color-border-drawer-tab);
133
+
134
+ .left & {
135
+ border-top-left-radius: 0;
136
+ border-bottom-left-radius: 0;
137
+
138
+ &.active {
139
+ border-left-color: transparent;
140
+ }
141
+ }
142
+
143
+ .right & {
144
+ border-top-right-radius: 0;
145
+ border-bottom-right-radius: 0;
146
+
147
+ &.active {
148
+ border-right-color: transparent;
149
+ }
150
+ }
151
+
152
+ &:not(.active) {
153
+ color: var(--color-text-primary);
154
+ background-color: var(--color-background-drawer-tab) !important;
155
+
156
+ &:hover {
157
+ color: var(--color-text);
158
+ background-color: var(--color-background-drawer-tab-hover) !important;
159
+ }
160
+ }
161
+
162
+ &.active {
163
+ color: var(--color-text);
164
+ border-color: var(--color-border);
165
+ }
166
+ }
167
+ }
@@ -0,0 +1,156 @@
1
+ import React, { useState } from 'react';
2
+ import {
3
+ FaArrowLeft,
4
+ FaChevronLeft,
5
+ FaCogs,
6
+ FaPenAlt,
7
+ FaQuestion,
8
+ } from 'react-icons/fa';
9
+ import { Drawer, Button, List, Heading, Flex } from '../../..';
10
+ import { listSubheadingsBadges } from '../list/list.stories-data';
11
+
12
+ export default {
13
+ title: 'Layout/Drawer',
14
+ component: Drawer,
15
+ args: {
16
+ button: true,
17
+ open: true,
18
+ right: false,
19
+ border: true,
20
+ shadow: false,
21
+ width: '300px',
22
+ closedWidth: '50px',
23
+ top: undefined,
24
+ background: 'var(--color-background-raised)',
25
+ children: <div style={{ padding: 20 }}>Drawer content</div>,
26
+ },
27
+ argTypes: {
28
+ button: { table: { disable: true } },
29
+ },
30
+ decorators: [
31
+ (story) => (
32
+ <Flex height="400px">
33
+ <div
34
+ style={{
35
+ flexGrow: 1,
36
+ padding: 20,
37
+ background: 'var(--color-background)',
38
+ }}
39
+ >
40
+ Page content
41
+ </div>
42
+ {story()}
43
+ </Flex>
44
+ ),
45
+ ],
46
+ parameters: {
47
+ layout: 'fullscreen',
48
+ },
49
+ };
50
+
51
+ const Template = (args) => {
52
+ return (
53
+ <Drawer
54
+ // eslint-disable-next-line react/jsx-props-no-spreading
55
+ {...args}
56
+ />
57
+ );
58
+ };
59
+ export const Default = Template.bind({});
60
+
61
+ export const Right = Template.bind({});
62
+ Right.args = { right: true };
63
+
64
+ export const Fixed = Template.bind({});
65
+ Fixed.args = {
66
+ fixed: true,
67
+ };
68
+ Fixed.parameters = {
69
+ docs: {
70
+ inlineStories: false,
71
+ iframeHeight: '400px',
72
+ },
73
+ };
74
+
75
+ export const CustomButton = Template.bind({});
76
+ CustomButton.args = {
77
+ buttonType: 'custom',
78
+ button: <Button colored round icon={<FaArrowLeft />} />,
79
+ buttonAnimate: true,
80
+ };
81
+
82
+ export const WithList = () => {
83
+ const [open, setOpen] = useState(false);
84
+ return (
85
+ <Drawer
86
+ button={
87
+ <Button onClick={() => setOpen(!open)} round icon={<FaChevronLeft />} />
88
+ }
89
+ width="300px"
90
+ closedWidth="50px"
91
+ border
92
+ open={open}
93
+ >
94
+ <List
95
+ drawer
96
+ list={listSubheadingsBadges}
97
+ marginBottom={10}
98
+ narrow={!open}
99
+ />
100
+ </Drawer>
101
+ );
102
+ };
103
+ WithList.parameters = {
104
+ docs: {
105
+ description: {
106
+ story:
107
+ 'To hide `List` headings when the `Drawer` is closed, set the `narrow` prop on the `List`.',
108
+ },
109
+ },
110
+ };
111
+
112
+ export const Tabs = Template.bind({});
113
+ Tabs.args = {
114
+ right: true,
115
+ button: false,
116
+ closedWidth: 0,
117
+ width: ['200px', '300px', '400px'],
118
+ defaultTabIndex: 1,
119
+ tabs: [
120
+ {
121
+ icon: <FaQuestion />,
122
+ content: (
123
+ <div style={{ padding: 20 }}>
124
+ <Heading top>Help</Heading>
125
+ {'Example content goes here lorem ipsum. '.repeat(500)}
126
+ </div>
127
+ ),
128
+ },
129
+ {
130
+ icon: <FaCogs />,
131
+ content: (
132
+ <div style={{ padding: 20 }}>
133
+ <Heading top>Settings</Heading>
134
+ {'Example content goes here lorem ipsum. '.repeat(500)}
135
+ </div>
136
+ ),
137
+ },
138
+ {
139
+ icon: <FaPenAlt />,
140
+ content: (
141
+ <div style={{ padding: 20 }}>
142
+ <Heading top>Edit</Heading>
143
+ {'Example content goes here lorem ipsum. '.repeat(500)}
144
+ </div>
145
+ ),
146
+ },
147
+ ],
148
+ };
149
+ Tabs.parameters = {
150
+ docs: {
151
+ description: {
152
+ story:
153
+ 'The top tab will be open by default, but you can set `defaultTabIndex` if you need a different tab open. If you need different widths per tab, pass an array of widths to `width`.',
154
+ },
155
+ },
156
+ };
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Text } from '../text/text';
4
+ import styles from './empty.module.less';
5
+
6
+ export const Empty = ({ width, height, text, children }) => {
7
+ return (
8
+ <div className={styles.empty} style={{ width, height }}>
9
+ <svg xmlns="http://www.w3.org/2000/svg" width="64" height="41">
10
+ <g transform="translate(0 1)" fill="none" fillRule="evenodd">
11
+ <ellipse
12
+ cx="32"
13
+ cy="33"
14
+ rx="32"
15
+ ry="7"
16
+ fill="rgba(0,0,0,0.1)"
17
+ ></ellipse>
18
+ <g fillRule="nonzero" stroke="var(--color-text)" strokeOpacity="0.2">
19
+ <path
20
+ d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"
21
+ fill="rgba(0,0,0,0.05)"
22
+ ></path>
23
+ <path
24
+ d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z"
25
+ fill="var(--color-background-raised)"
26
+ ></path>
27
+ </g>
28
+ </g>
29
+ </svg>
30
+ {text !== '' && (
31
+ <div className={styles.text}>
32
+ <Text faint>{text}</Text>
33
+ </div>
34
+ )}
35
+ {children}
36
+ </div>
37
+ );
38
+ };
39
+
40
+ Empty.defaultProps = {
41
+ width: 'auto',
42
+ height: 'auto',
43
+ text: 'No data',
44
+ children: null,
45
+ };
46
+
47
+ Empty.propTypes = {
48
+ width: PropTypes.string,
49
+ height: PropTypes.string,
50
+ text: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
51
+ children: PropTypes.node,
52
+ };
@@ -0,0 +1,17 @@
1
+ @import '../../style/variables.less';
2
+
3
+ .empty {
4
+ position: relative;
5
+ border-radius: inherit;
6
+ display: inline-flex;
7
+ flex-direction: column;
8
+ align-items: center;
9
+ justify-content: center;
10
+ text-align: center;
11
+ gap: 10px;
12
+
13
+ .text {
14
+ max-width: 40ch;
15
+ margin-bottom: 3px;
16
+ }
17
+ }
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { Empty, Button } from '../../..';
3
+
4
+ export default {
5
+ title: 'Progress/Empty',
6
+ component: Empty,
7
+ args: {
8
+ text: 'No data',
9
+ width: '100%',
10
+ height: '100%',
11
+ },
12
+ };
13
+
14
+ const Template = (args) => (
15
+ <Empty
16
+ // eslint-disable-next-line react/jsx-props-no-spreading
17
+ {...args}
18
+ />
19
+ );
20
+ export const Default = Template.bind({});
21
+
22
+ export const WithButton = Template.bind({});
23
+ WithButton.args = {
24
+ text: 'Please apply at least one casing in Well Schematics to perform drilling mechanics',
25
+ children: <Button colored label="Add casing" />,
26
+ };