@react-ui-org/react-ui 0.42.1 → 0.44.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. package/CONTRIBUTING.md +44 -25
  2. package/README.md +1 -1
  3. package/dist/lib.development.js +1597 -651
  4. package/dist/lib.js +1 -9
  5. package/package.json +47 -46
  6. package/src/lib/components/{ui/Alert → Alert}/Alert.jsx +17 -14
  7. package/src/lib/components/{ui/Alert → Alert}/Alert.scss +3 -3
  8. package/src/lib/components/{ui/Alert → Alert}/README.mdx +6 -6
  9. package/src/lib/components/{ui/Alert → Alert}/_settings.scss +1 -1
  10. package/src/lib/components/{ui/Alert → Alert}/_theme.scss +0 -0
  11. package/src/lib/components/{ui/Alert → Alert}/_tools.scss +0 -0
  12. package/src/lib/components/{ui/Alert → Alert}/index.js +0 -0
  13. package/src/lib/components/{ui/Badge → Badge}/Badge.jsx +2 -2
  14. package/src/lib/components/{ui/Badge → Badge}/Badge.scss +3 -3
  15. package/src/lib/components/{ui/Badge → Badge}/README.mdx +3 -3
  16. package/src/lib/components/{ui/Badge → Badge}/index.js +0 -0
  17. package/src/lib/components/Button/Button.jsx +198 -0
  18. package/src/lib/components/{ui/Button → Button}/Button.scss +0 -0
  19. package/src/lib/components/{ui/Button → Button}/README.mdx +161 -76
  20. package/src/lib/components/Button/_base.scss +148 -0
  21. package/src/lib/components/{ui/Button → Button}/_priorities.scss +0 -4
  22. package/src/lib/components/{ui/Button → Button}/_settings.scss +2 -3
  23. package/src/lib/components/{ui/Button → Button}/_theme.scss +3 -11
  24. package/src/lib/components/{ui/Button → Button}/_tools.scss +27 -44
  25. package/src/lib/components/Button/helpers/getRootLabelVisibilityClassName.js +33 -0
  26. package/src/lib/components/{ui/Button → Button}/helpers/getRootPriorityClassName.js +0 -4
  27. package/src/lib/components/{ui/Button → Button}/index.js +0 -0
  28. package/src/lib/components/{ui/ButtonGroup → ButtonGroup}/ButtonGroup.jsx +9 -11
  29. package/src/lib/components/{ui/ButtonGroup → ButtonGroup}/ButtonGroup.scss +0 -0
  30. package/src/lib/components/ButtonGroup/ButtonGroupContext.js +3 -0
  31. package/src/lib/components/{ui/ButtonGroup → ButtonGroup}/README.mdx +30 -6
  32. package/src/lib/components/ButtonGroup/index.js +2 -0
  33. package/src/lib/components/{layout/CTA → CTA}/CTA.jsx +5 -2
  34. package/src/lib/components/{layout/CTA → CTA}/CTA.scss +2 -2
  35. package/src/lib/components/{layout/CTA → CTA}/CTACenter.jsx +1 -1
  36. package/src/lib/components/{layout/CTA → CTA}/CTAEnd.jsx +1 -1
  37. package/src/lib/components/{layout/CTA → CTA}/CTAStart.jsx +1 -1
  38. package/src/lib/components/{layout/CTA → CTA}/README.mdx +4 -4
  39. package/src/lib/components/{layout/CTA → CTA}/index.js +0 -0
  40. package/src/lib/components/{ui/Card → Card}/Card.jsx +6 -4
  41. package/src/lib/components/{ui/Card → Card}/Card.scss +1 -1
  42. package/src/lib/components/{ui/Card → Card}/CardBody.jsx +1 -1
  43. package/src/lib/components/{ui/Card → Card}/CardFooter.jsx +1 -1
  44. package/src/lib/components/{ui/Card → Card}/README.mdx +4 -4
  45. package/src/lib/components/{ui/Card → Card}/_theme.scss +0 -0
  46. package/src/lib/components/{ui/Card → Card}/_tools.scss +0 -0
  47. package/src/lib/components/{ui/Card → Card}/index.js +0 -0
  48. package/src/lib/components/{layout/Center → Center}/Center.jsx +1 -1
  49. package/src/lib/components/{layout/Center → Center}/Center.scss +0 -0
  50. package/src/lib/components/{layout/Center → Center}/README.mdx +2 -2
  51. package/src/lib/components/{layout/Center → Center}/index.js +0 -0
  52. package/src/lib/components/CheckboxField/CheckboxField.jsx +164 -0
  53. package/src/lib/components/{ui/CheckboxField → CheckboxField}/CheckboxField.scss +5 -5
  54. package/src/lib/components/{ui/CheckboxField → CheckboxField}/README.mdx +17 -14
  55. package/src/lib/components/{ui/CheckboxField → CheckboxField}/index.js +0 -0
  56. package/src/lib/components/FileInputField/FileInputField.jsx +162 -0
  57. package/src/lib/components/{ui/FileInputField → FileInputField}/FileInputField.scss +5 -5
  58. package/src/lib/components/{ui/FileInputField → FileInputField}/README.mdx +8 -6
  59. package/src/lib/components/{ui/FileInputField → FileInputField}/index.js +0 -0
  60. package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayout.jsx +16 -18
  61. package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayout.scss +3 -3
  62. package/src/lib/components/FormLayout/FormLayoutContext.js +3 -0
  63. package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayoutCustomField.jsx +33 -30
  64. package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayoutCustomField.scss +4 -4
  65. package/src/lib/components/{layout/FormLayout → FormLayout}/README.mdx +37 -47
  66. package/src/lib/components/{layout/FormLayout → FormLayout}/_theme.scss +0 -0
  67. package/src/lib/components/{layout/FormLayout → FormLayout}/index.js +1 -0
  68. package/src/lib/components/{layout/Grid → Grid}/Grid.jsx +23 -5
  69. package/src/lib/components/{layout/Grid → Grid}/Grid.scss +13 -4
  70. package/src/lib/components/{layout/Grid → Grid}/GridSpan.jsx +10 -3
  71. package/src/lib/components/{layout/Grid → Grid}/README.mdx +42 -38
  72. package/src/lib/components/{layout/Grid → Grid}/_theme.scss +1 -2
  73. package/src/lib/components/{layout/Grid → Grid}/_tools.scss +2 -2
  74. package/src/lib/components/{layout/Grid → Grid}/helpers/generateResponsiveCustomProperties.js +0 -0
  75. package/src/lib/components/{layout/Grid → Grid}/index.js +0 -0
  76. package/src/lib/components/Link/Link.jsx +45 -0
  77. package/src/lib/components/Link/Link.scss +11 -0
  78. package/src/lib/components/Link/README.mdx +85 -0
  79. package/src/lib/components/Link/_theme.scss +4 -0
  80. package/src/lib/components/Link/index.js +1 -0
  81. package/src/lib/components/{layout/List → List}/List.jsx +1 -1
  82. package/src/lib/components/{layout/List → List}/List.scss +2 -2
  83. package/src/lib/components/{layout/List → List}/ListItem.jsx +1 -1
  84. package/src/lib/components/{layout/List → List}/README.mdx +3 -3
  85. package/src/lib/components/{layout/List → List}/_theme.scss +0 -0
  86. package/src/lib/components/{layout/List → List}/index.js +0 -0
  87. package/src/lib/components/{layout/Media → Media}/Media.jsx +4 -2
  88. package/src/lib/components/{layout/Media → Media}/Media.scss +1 -1
  89. package/src/lib/components/{layout/Media → Media}/MediaBody.jsx +1 -1
  90. package/src/lib/components/{layout/Media → Media}/MediaObject.jsx +1 -1
  91. package/src/lib/components/{layout/Media → Media}/README.mdx +2 -2
  92. package/src/lib/components/{layout/Media → Media}/index.js +0 -0
  93. package/src/lib/components/{ui/Modal → Modal}/Modal.jsx +28 -27
  94. package/src/lib/components/{ui/Modal → Modal}/Modal.scss +5 -5
  95. package/src/lib/components/{ui/Modal → Modal}/README.mdx +42 -42
  96. package/src/lib/components/{ui/Modal → Modal}/_settings.scss +4 -4
  97. package/src/lib/components/{ui/Modal → Modal}/_theme.scss +0 -0
  98. package/src/lib/components/{ui/Modal → Modal}/index.js +0 -0
  99. package/src/lib/components/{ui/Paper → Paper}/Paper.jsx +8 -1
  100. package/src/lib/components/{ui/Paper → Paper}/Paper.scss +5 -0
  101. package/src/lib/components/{ui/Paper → Paper}/README.mdx +15 -3
  102. package/src/lib/components/{ui/Paper → Paper}/_theme.scss +2 -0
  103. package/src/lib/components/{ui/Paper → Paper}/index.js +0 -0
  104. package/src/lib/components/{ui/Radio → Radio}/README.mdx +20 -17
  105. package/src/lib/components/Radio/Radio.jsx +188 -0
  106. package/src/lib/components/{ui/Radio → Radio}/Radio.scss +9 -9
  107. package/src/lib/components/{ui/Radio → Radio}/index.js +0 -0
  108. package/src/lib/components/{ui/ScrollView → ScrollView}/README.mdx +11 -11
  109. package/src/lib/components/{ui/ScrollView → ScrollView}/ScrollView.jsx +9 -10
  110. package/src/lib/components/{ui/ScrollView → ScrollView}/ScrollView.scss +6 -6
  111. package/src/lib/components/{ui/ScrollView → ScrollView}/_theme.scss +0 -0
  112. package/src/lib/components/{ui/ScrollView → ScrollView}/index.js +0 -0
  113. package/src/lib/components/{ui/SelectField → SelectField}/README.mdx +47 -44
  114. package/src/lib/components/SelectField/SelectField.jsx +219 -0
  115. package/src/lib/components/{ui/SelectField → SelectField}/SelectField.scss +6 -6
  116. package/src/lib/components/{ui/SelectField → SelectField}/index.js +0 -0
  117. package/src/lib/components/{ui/Table → Table}/README.mdx +10 -10
  118. package/src/lib/components/{ui/Table → Table}/Table.jsx +9 -13
  119. package/src/lib/components/{ui/Table → Table}/Table.scss +1 -1
  120. package/src/lib/components/{ui/Table → Table}/_settings.scss +4 -4
  121. package/src/lib/components/{ui/Table → Table}/index.js +0 -0
  122. package/src/lib/components/{ui/Tabs → Tabs}/README.mdx +4 -4
  123. package/src/lib/components/{ui/Tabs → Tabs}/Tabs.jsx +4 -4
  124. package/src/lib/components/{ui/Tabs → Tabs}/Tabs.scss +1 -1
  125. package/src/lib/components/{ui/Tabs → Tabs}/TabsItem.jsx +4 -3
  126. package/src/lib/components/{ui/Tabs → Tabs}/TabsItem.scss +3 -3
  127. package/src/lib/components/{ui/Tabs → Tabs}/_theme.scss +0 -0
  128. package/src/lib/components/{ui/Tabs → Tabs}/index.js +0 -0
  129. package/src/lib/components/{ui/Text → Text}/README.mdx +19 -19
  130. package/src/lib/components/{ui/Text → Text}/Text.jsx +1 -1
  131. package/src/lib/components/{ui/Text → Text}/Text.scss +0 -0
  132. package/src/lib/components/{ui/Text → Text}/helpers/getRootHyphensClassName.js +0 -0
  133. package/src/lib/components/{ui/Text → Text}/helpers/getRootWordWrappingClassName.js +0 -0
  134. package/src/lib/components/{ui/Text → Text}/index.js +0 -0
  135. package/src/lib/components/{ui/TextArea → TextArea}/README.mdx +8 -6
  136. package/src/lib/components/{ui/TextArea → TextArea}/TextArea.jsx +78 -78
  137. package/src/lib/components/{ui/TextArea → TextArea}/TextArea.scss +6 -6
  138. package/src/lib/components/{ui/TextArea → TextArea}/index.js +0 -0
  139. package/src/lib/components/{ui/TextField → TextField}/README.mdx +7 -6
  140. package/src/lib/components/{ui/TextField → TextField}/TextField.jsx +20 -22
  141. package/src/lib/components/{ui/TextField → TextField}/TextField.scss +6 -6
  142. package/src/lib/components/{ui/TextField → TextField}/index.js +0 -0
  143. package/src/lib/components/{ui/Toggle → Toggle}/README.mdx +17 -14
  144. package/src/lib/components/Toggle/Toggle.jsx +163 -0
  145. package/src/lib/components/{ui/Toggle → Toggle}/Toggle.scss +5 -5
  146. package/src/lib/components/{ui/Toggle → Toggle}/index.js +0 -0
  147. package/src/lib/components/{layout/Toolbar → Toolbar}/README.mdx +29 -29
  148. package/src/lib/components/{layout/Toolbar → Toolbar}/Toolbar.jsx +1 -1
  149. package/src/lib/components/{layout/Toolbar → Toolbar}/Toolbar.scss +1 -1
  150. package/src/lib/components/{layout/Toolbar → Toolbar}/ToolbarGroup.jsx +1 -1
  151. package/src/lib/components/{layout/Toolbar → Toolbar}/ToolbarItem.jsx +1 -1
  152. package/src/lib/components/{layout/Toolbar → Toolbar}/_theme.scss +0 -0
  153. package/src/lib/components/{layout/Toolbar → Toolbar}/index.js +0 -0
  154. package/src/lib/components/{ui/withForwardedRef.jsx → withForwardedRef.jsx} +0 -0
  155. package/src/lib/helpers/resolveContextOrProp.js +7 -0
  156. package/src/lib/index.js +34 -35
  157. package/src/lib/styles/tools/_accessibility.scss +9 -0
  158. package/src/lib/theme.scss +25 -7
  159. package/src/lib/components/ui/Button/Button.jsx +0 -191
  160. package/src/lib/components/ui/Button/_base.scss +0 -154
  161. package/src/lib/components/ui/Button/helpers/getRootLabelVisibilityClassName.js +0 -11
  162. package/src/lib/components/ui/ButtonGroup/index.js +0 -1
  163. package/src/lib/components/ui/CheckboxField/CheckboxField.jsx +0 -173
  164. package/src/lib/components/ui/FileInputField/FileInputField.jsx +0 -158
  165. package/src/lib/components/ui/Radio/Radio.jsx +0 -179
  166. package/src/lib/components/ui/SelectField/SelectField.jsx +0 -214
  167. package/src/lib/components/ui/Toggle/Toggle.jsx +0 -174
package/src/lib/index.js CHANGED
@@ -1,60 +1,59 @@
1
- // Layout components
2
- export { default as Center } from './components/layout/Center';
1
+ // Components
2
+ export { default as Alert } from './components/Alert';
3
+ export { default as Badge } from './components/Badge';
4
+ export { default as Button } from './components/Button';
5
+ export { ButtonGroup } from './components/ButtonGroup';
6
+ export {
7
+ Card,
8
+ CardBody,
9
+ CardFooter,
10
+ } from './components/Card';
11
+ export { default as Center } from './components/Center';
12
+ export { default as CheckboxField } from './components/CheckboxField';
3
13
  export {
4
14
  CTA,
5
15
  CTACenter,
6
16
  CTAEnd,
7
17
  CTAStart,
8
- } from './components/layout/CTA';
18
+ } from './components/CTA';
19
+ export { default as FileInputField } from './components/FileInputField';
9
20
  export {
10
21
  FormLayout,
11
22
  FormLayoutCustomField,
12
- } from './components/layout/FormLayout';
23
+ } from './components/FormLayout';
13
24
  export {
14
25
  Grid,
15
26
  GridSpan,
16
- } from './components/layout/Grid';
27
+ } from './components/Grid';
28
+ export { default as Link } from './components/Link';
17
29
  export {
18
30
  List,
19
31
  ListItem,
20
- } from './components/layout/List';
32
+ } from './components/List';
21
33
  export {
22
34
  Media,
23
35
  MediaBody,
24
36
  MediaObject,
25
- } from './components/layout/Media';
37
+ } from './components/Media';
38
+ export { default as Modal } from './components/Modal';
39
+ export { default as Paper } from './components/Paper';
40
+ export { default as Radio } from './components/Radio';
41
+ export { default as ScrollView } from './components/ScrollView';
42
+ export { default as SelectField } from './components/SelectField';
43
+ export {
44
+ Tabs,
45
+ TabsItem,
46
+ } from './components/Tabs';
47
+ export { default as Table } from './components/Table';
48
+ export { default as Text } from './components/Text';
49
+ export { default as TextArea } from './components/TextArea';
50
+ export { default as TextField } from './components/TextField';
51
+ export { default as Toggle } from './components/Toggle';
26
52
  export {
27
53
  Toolbar,
28
54
  ToolbarGroup,
29
55
  ToolbarItem,
30
- } from './components/layout/Toolbar';
31
-
32
- // UI components
33
- export { default as Alert } from './components/ui/Alert';
34
- export { default as Badge } from './components/ui/Badge';
35
- export { default as Button } from './components/ui/Button';
36
- export { default as ButtonGroup } from './components/ui/ButtonGroup';
37
- export {
38
- Card,
39
- CardBody,
40
- CardFooter,
41
- } from './components/ui/Card';
42
- export { default as CheckboxField } from './components/ui/CheckboxField';
43
- export { default as FileInputField } from './components/ui/FileInputField';
44
- export { default as Modal } from './components/ui/Modal';
45
- export { default as Paper } from './components/ui/Paper';
46
- export { default as Radio } from './components/ui/Radio';
47
- export { default as ScrollView } from './components/ui/ScrollView';
48
- export { default as SelectField } from './components/ui/SelectField';
49
- export {
50
- Tabs,
51
- TabsItem,
52
- } from './components/ui/Tabs';
53
- export { default as Table } from './components/ui/Table';
54
- export { default as Text } from './components/ui/Text';
55
- export { default as TextArea } from './components/ui/TextArea';
56
- export { default as TextField } from './components/ui/TextField';
57
- export { default as Toggle } from './components/ui/Toggle';
56
+ } from './components/Toolbar';
58
57
 
59
58
  // Provider
60
59
  export { RUIProvider } from './provider';
@@ -17,6 +17,15 @@
17
17
  border: 0;
18
18
  }
19
19
 
20
+ @mixin unhide-text() {
21
+ position: unset;
22
+ width: unset;
23
+ height: unset;
24
+ overflow: unset;
25
+ clip: unset;
26
+ white-space: unset;
27
+ }
28
+
20
29
  // 2.
21
30
  @mixin min-tap-target($size: theme.$tap-target-size, $center: true) {
22
31
  position: relative;
@@ -155,6 +155,11 @@
155
155
  --rui-spacing-bottom-headings: var(--rui-spacing-5);
156
156
  --rui-spacing-bottom-layouts: var(--rui-spacing-5);
157
157
 
158
+ // Disabled state
159
+ --rui-disabled-background-color: var(--rui-color-gray-50);
160
+ --rui-disabled-opacity: 0.5;
161
+ --rui-disabled-cursor: not-allowed;
162
+
158
163
  //
159
164
  // Elements
160
165
  // ========
@@ -193,11 +198,11 @@
193
198
  // Grid
194
199
  // ====
195
200
 
196
- --rui-Grid__auto-flow: initial;
197
201
  --rui-Grid__columns: 1fr;
198
202
  --rui-Grid__column-gap: var(--rui-spacing-4);
199
203
  --rui-Grid__rows: auto;
200
204
  --rui-Grid__row-gap: var(--rui-spacing-4);
205
+ --rui-Grid__auto-flow: initial;
201
206
  --rui-Grid__align-content: initial;
202
207
  --rui-Grid__align-items: initial;
203
208
  --rui-Grid__justify-content: initial;
@@ -292,8 +297,10 @@
292
297
  --rui-Button__text-transform: none;
293
298
  --rui-Button__border-width: var(--rui-border-width);
294
299
  --rui-Button__border-radius: var(--rui-border-radius);
295
- --rui-Button--disabled__opacity: 0.5;
296
- --rui-Button--disabled__cursor: not-allowed;
300
+ --rui-Button--disabled__opacity: var(--rui-disabled-opacity);
301
+ --rui-Button--disabled__cursor: var(--rui-disabled-cursor);
302
+ --rui-Button--feedback__opacity: 1;
303
+ --rui-Button--feedback__cursor: var(--rui-disabled-cursor);
297
304
 
298
305
  // Buttons: filled priority
299
306
 
@@ -674,8 +681,8 @@
674
681
  --rui-Card__border-radius: var(--rui-border-radius);
675
682
  --rui-Card--dense__padding: var(--rui-spacing-2);
676
683
  --rui-Card--raised__box-shadow: var(--rui-elevation-1);
677
- --rui-Card--disabled__background-color: var(--rui-color-gray-50);
678
- --rui-Card--disabled__opacity: 0.6;
684
+ --rui-Card--disabled__background-color: var(--rui-disabled-background-color);
685
+ --rui-Card--disabled__opacity: var(--rui-disabled-opacity);
679
686
 
680
687
  // Card: variant: primary
681
688
  --rui-Card--primary__color: var(--rui-page-color);
@@ -758,8 +765,8 @@
758
765
  --rui-FormField--horizontal--full-width__label__width: fit-content(50%);
759
766
 
760
767
  // Forms fields: disabled state
761
- --rui-FormField--disabled__cursor: not-allowed;
762
- --rui-FormField--disabled__opacity: 0.5;
768
+ --rui-FormField--disabled__cursor: var(--rui-disabled-cursor);
769
+ --rui-FormField--disabled__opacity: var(--rui-disabled-opacity);
763
770
 
764
771
  // Form fields: validation states: invalid
765
772
  --rui-FormField--invalid--default__border-color: var(--rui-color-danger);
@@ -851,6 +858,15 @@
851
858
  --rui-FormField--check--checked__border-color: var(--rui-color-active);
852
859
  --rui-FormField--check--checked__check-background-color: var(--rui-color-active);
853
860
 
861
+ //
862
+ // Link
863
+ // ====
864
+
865
+ --rui-Link__color: var(--rui-link-color);
866
+ --rui-Link__text-decoration: var(--rui-link-decoration);
867
+ --rui-Link--hover__color: var(--rui-link-hover-color);
868
+ --rui-Link--hover__text-decoration: var(--rui-link-hover-decoration);
869
+
854
870
  //
855
871
  // Modal
856
872
  // =====
@@ -878,6 +894,8 @@
878
894
  --rui-Paper__border-color: transparent;
879
895
  --rui-Paper__border-radius: var(--rui-border-radius);
880
896
  --rui-Paper__background-color: var(--rui-color-white);
897
+ --rui-Paper--muted__background-color: var(--rui-disabled-background-color);
898
+ --rui-Paper--muted__opacity: var(--rui-disabled-opacity);
881
899
  --rui-Paper--raised__box-shadow: var(--rui-elevation-1);
882
900
 
883
901
  //
@@ -1,191 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React from 'react';
3
- import getRootSizeClassName from '../../../helpers/getRootSizeClassName';
4
- import getRootColorClassName from '../../../helpers/getRootColorClassName';
5
- import { withProviderContext } from '../../../provider';
6
- import transferProps from '../../../utils/transferProps';
7
- import withForwardedRef from '../withForwardedRef';
8
- import getRootLabelVisibilityClassName from './helpers/getRootLabelVisibilityClassName';
9
- import getRootPriorityClassName from './helpers/getRootPriorityClassName';
10
- import styles from './Button.scss';
11
-
12
- export const Button = ({
13
- afterLabel,
14
- beforeLabel,
15
- block,
16
- clickHandler,
17
- disabled,
18
- endCorner,
19
- forwardedRef,
20
- grouped,
21
- id,
22
- label,
23
- labelVisibility,
24
- loadingIcon,
25
- priority,
26
- size,
27
- startCorner,
28
- type,
29
- color,
30
- ...restProps
31
- }) => (
32
- /* No worries, `type` is always assigned correctly through props. */
33
- /* eslint-disable react/button-has-type */
34
- <button
35
- {...transferProps(restProps)}
36
- className={
37
- priority === 'link'
38
- ? [
39
- styles.root,
40
- getRootPriorityClassName(priority, styles),
41
- ].join(' ')
42
- : [
43
- styles.root,
44
- getRootPriorityClassName(priority, styles),
45
- getRootColorClassName(color, styles),
46
- getRootSizeClassName(size, styles),
47
- getRootLabelVisibilityClassName(labelVisibility, styles),
48
- block ? styles.rootBlock : '',
49
- grouped ? styles.rootGrouped : '',
50
- loadingIcon ? styles.isRootLoading : '',
51
- ].join(' ')
52
- }
53
- disabled={disabled || !!loadingIcon}
54
- id={id}
55
- onClick={clickHandler}
56
- ref={forwardedRef}
57
- type={type}
58
- >
59
- {priority !== 'link' && startCorner && (
60
- <span className={styles.startCorner}>
61
- {startCorner}
62
- </span>
63
- )}
64
- {beforeLabel && (
65
- <span className={styles.beforeLabel}>
66
- {beforeLabel}
67
- </span>
68
- )}
69
- <span
70
- className={styles.label}
71
- {...(id && { id: `${id}__labelText` })}
72
- >
73
- {label}
74
- </span>
75
- {afterLabel && (
76
- <span className={styles.afterLabel}>
77
- {afterLabel}
78
- </span>
79
- )}
80
- {priority !== 'link' && endCorner && (
81
- <span className={styles.endCorner}>
82
- {endCorner}
83
- </span>
84
- )}
85
- {priority !== 'link' && loadingIcon && (
86
- <span className={styles.loadingIcon}>
87
- {loadingIcon}
88
- </span>
89
- )}
90
- </button>
91
- /* eslint-enable react/button-has-type */
92
- );
93
-
94
- Button.defaultProps = {
95
- afterLabel: null,
96
- beforeLabel: null,
97
- block: false,
98
- clickHandler: null,
99
- color: 'primary',
100
- disabled: false,
101
- endCorner: null,
102
- forwardedRef: undefined,
103
- grouped: false,
104
- id: undefined,
105
- labelVisibility: 'all',
106
- loadingIcon: null,
107
- priority: 'filled',
108
- size: 'medium',
109
- startCorner: null,
110
- type: 'button',
111
- };
112
-
113
- Button.propTypes = {
114
- /**
115
- * Element to be displayed after label, eg. an icon.
116
- */
117
- afterLabel: PropTypes.node,
118
- /**
119
- * Element to be displayed before label, eg. an icon.
120
- */
121
- beforeLabel: PropTypes.node,
122
- /**
123
- * If `true`, the button will span the full width of its parent.
124
- */
125
- block: PropTypes.bool,
126
- /**
127
- * Function to call when the button is clicked.
128
- */
129
- clickHandler: PropTypes.func,
130
- /**
131
- * [Color variant](/foundation/colors#component-colors) to clarify importance and meaning of the button.
132
- */
133
- color: PropTypes.oneOf(['primary', 'secondary', 'success', 'warning', 'danger', 'help', 'info', 'note', 'light', 'dark']),
134
- /**
135
- * If `true`, the button will be disabled.
136
- */
137
- disabled: PropTypes.bool,
138
- /**
139
- * Element to be displayed in the top right corner.
140
- */
141
- endCorner: PropTypes.node,
142
- /**
143
- * Reference forwarded to the `button` element.
144
- */
145
- forwardedRef: PropTypes.oneOfType([
146
- PropTypes.func,
147
- // eslint-disable-next-line react/forbid-prop-types
148
- PropTypes.shape({ current: PropTypes.any }),
149
- ]),
150
- /**
151
- * Treat button differently when it's inside `ButtonGroup`. Do not set manually!
152
- */
153
- grouped: PropTypes.bool,
154
- /**
155
- * ID of the root HTML element.
156
- */
157
- id: PropTypes.string,
158
- /**
159
- * Button label.
160
- */
161
- label: PropTypes.string.isRequired,
162
- /**
163
- * Defines when the button label should be visible.
164
- */
165
- labelVisibility: PropTypes.oneOf(['all', 'desktop', 'none']),
166
- /**
167
- * Element to be displayed as a loading icon. When defined, it implies the button is in the
168
- * loading state.
169
- */
170
- loadingIcon: PropTypes.node,
171
- /**
172
- * Visual priority to highlight or suppress the button.
173
- */
174
- priority: PropTypes.oneOf(['filled', 'outline', 'flat', 'link']),
175
- /**
176
- * Size of the button.
177
- */
178
- size: PropTypes.oneOf(['small', 'medium', 'large']),
179
- /**
180
- * Element to be displayed in the top left corner.
181
- */
182
- startCorner: PropTypes.node,
183
- /**
184
- * Set the HTML `type` attribute of the `button` element.
185
- */
186
- type: PropTypes.oneOf(['button', 'submit']),
187
- };
188
-
189
- export const ButtonWithContext = withForwardedRef(withProviderContext(Button, 'Button'));
190
-
191
- export default ButtonWithContext;
@@ -1,154 +0,0 @@
1
- @use 'sass:map';
2
- @use '../../../styles/tools/accessibility';
3
- @use '../../../styles/tools/breakpoint';
4
- @use 'settings';
5
- @use 'theme';
6
- @use 'tools';
7
-
8
- .root {
9
- @include tools.button();
10
- }
11
-
12
- .label {
13
- display: block;
14
- }
15
-
16
- .beforeLabel,
17
- .afterLabel,
18
- .startCorner,
19
- .endCorner,
20
- .loadingIcon {
21
- display: flex;
22
- align-items: baseline;
23
- justify-content: center;
24
- }
25
-
26
- .beforeLabel {
27
- margin-right: settings.$icon-spacing;
28
- }
29
-
30
- .afterLabel,
31
- .loadingIcon {
32
- margin-left: settings.$icon-spacing;
33
- }
34
-
35
- .startCorner,
36
- .endCorner {
37
- position: absolute;
38
- top: -0.35rem;
39
- }
40
-
41
- .startCorner {
42
- left: 0;
43
- margin-left: -0.35rem;
44
- }
45
-
46
- .endCorner {
47
- right: 0;
48
- margin-right: -0.35rem;
49
- }
50
-
51
- .rootSizeSmall {
52
- @include tools.button-size(small);
53
- }
54
-
55
- .rootSizeMedium {
56
- @include tools.button-size(medium);
57
- }
58
-
59
- .rootSizeLarge {
60
- @include tools.button-size(large);
61
- }
62
-
63
- .rootBlock {
64
- width: 100%;
65
- }
66
-
67
- .rootBlock.withLabelHiddenMobile {
68
- @include breakpoint.up(settings.$breakpoint) {
69
- width: 100%;
70
- }
71
- }
72
-
73
- .rootGrouped {
74
- z-index: map.get(settings.$group-z-indexes, button);
75
-
76
- &:not(:first-child) {
77
- margin-left: var(--local-gap);
78
- border-top-left-radius: 0;
79
- border-bottom-left-radius: 0;
80
- }
81
-
82
- &:not(:last-child) {
83
- border-top-right-radius: 0;
84
- border-bottom-right-radius: 0;
85
- }
86
-
87
- &:focus,
88
- &:not(:disabled):hover {
89
- z-index: map.get(settings.$group-z-indexes, button-hover);
90
- }
91
- }
92
-
93
- .rootGrouped .startCorner,
94
- .rootGrouped .endCorner {
95
- z-index: map.get(settings.$group-z-indexes, button-overflowing-elements);
96
- }
97
-
98
- .withLabelHidden .label,
99
- .withLabelHiddenMobile .label {
100
- @include accessibility.hide-text();
101
- }
102
-
103
- .withLabelHiddenMobile .label {
104
- @include breakpoint.up(settings.$breakpoint) {
105
- position: relative;
106
- width: auto;
107
- height: auto;
108
- }
109
- }
110
-
111
- .withLabelHidden .beforeLabel,
112
- .withLabelHidden .afterLabel,
113
- .withLabelHiddenMobile .beforeLabel,
114
- .withLabelHiddenMobile .afterLabel {
115
- margin-right: 0;
116
- margin-left: 0;
117
- }
118
-
119
- .withLabelHiddenMobile .beforeLabel {
120
- @include breakpoint.up(settings.$breakpoint) {
121
- margin-right: settings.$icon-spacing;
122
- }
123
- }
124
-
125
- .withLabelHiddenMobile .afterLabel {
126
- @include breakpoint.up(settings.$breakpoint) {
127
- margin-left: settings.$icon-spacing;
128
- }
129
- }
130
-
131
- .withLabelHidden.isRootLoading .loadingIcon,
132
- .withLabelHiddenMobile.isRootLoading .loadingIcon {
133
- margin-left: 0;
134
- }
135
-
136
- .withLabelHidden.isRootLoading .beforeLabel,
137
- .withLabelHidden.isRootLoading .afterLabel,
138
- .withLabelHiddenMobile.isRootLoading .beforeLabel,
139
- .withLabelHiddenMobile.isRootLoading .afterLabel {
140
- display: none;
141
- }
142
-
143
- .withLabelHiddenMobile.isRootLoading .beforeLabel,
144
- .withLabelHiddenMobile.isRootLoading .afterLabel {
145
- @include breakpoint.up(settings.$breakpoint) {
146
- display: flex;
147
- }
148
- }
149
-
150
- .withLabelHiddenMobile.isRootLoading .loadingIcon {
151
- @include breakpoint.up(settings.$breakpoint) {
152
- margin-left: settings.$icon-spacing;
153
- }
154
- }
@@ -1,11 +0,0 @@
1
- export default (labelVisibility, styles) => {
2
- if (labelVisibility === 'desktop') {
3
- return styles.withLabelHiddenMobile;
4
- }
5
-
6
- if (labelVisibility === 'none') {
7
- return styles.withLabelHidden;
8
- }
9
-
10
- return null;
11
- };
@@ -1 +0,0 @@
1
- export { default } from './ButtonGroup';