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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. package/CONTRIBUTING.md +7 -0
  2. package/README.md +15 -16
  3. package/dist/lib.development.js +271 -415
  4. package/dist/lib.js +1 -1
  5. package/package.json +11 -13
  6. package/src/lib/components/Alert/Alert.jsx +45 -44
  7. package/src/lib/components/Alert/Alert.scss +48 -48
  8. package/src/lib/components/Alert/README.mdx +2 -5
  9. package/src/lib/components/Alert/_settings.scss +4 -4
  10. package/src/lib/components/Alert/_theme.scss +50 -50
  11. package/src/lib/components/Alert/_tools.scss +6 -6
  12. package/src/lib/components/Badge/Badge.jsx +9 -11
  13. package/src/lib/components/Badge/Badge.scss +57 -57
  14. package/src/lib/components/Button/Button.jsx +14 -13
  15. package/src/lib/components/Button/Button.scss +2 -2
  16. package/src/lib/components/Button/README.mdx +11 -6
  17. package/src/lib/components/Button/_base.scss +69 -69
  18. package/src/lib/components/Button/_priorities.scss +49 -49
  19. package/src/lib/components/Button/_settings.scss +10 -10
  20. package/src/lib/components/Button/_theme.scss +18 -15
  21. package/src/lib/components/Button/_tools.scss +98 -100
  22. package/src/lib/components/Button/helpers/getRootLabelVisibilityClassName.js +4 -4
  23. package/src/lib/components/ButtonGroup/ButtonGroup.jsx +41 -25
  24. package/src/lib/components/ButtonGroup/ButtonGroup.scss +3 -3
  25. package/src/lib/components/ButtonGroup/README.mdx +1 -1
  26. package/src/lib/components/Card/Card.jsx +10 -9
  27. package/src/lib/components/Card/Card.scss +28 -28
  28. package/src/lib/components/Card/CardBody.jsx +17 -12
  29. package/src/lib/components/Card/CardFooter.jsx +22 -9
  30. package/src/lib/components/Card/_theme.scss +50 -50
  31. package/src/lib/components/Card/_tools.scss +6 -6
  32. package/src/lib/components/CheckboxField/CheckboxField.jsx +21 -20
  33. package/src/lib/components/CheckboxField/CheckboxField.scss +20 -20
  34. package/src/lib/components/CheckboxField/README.mdx +1 -1
  35. package/src/lib/components/FileInputField/FileInputField.jsx +16 -15
  36. package/src/lib/components/FileInputField/FileInputField.scss +19 -19
  37. package/src/lib/components/FileInputField/README.mdx +1 -1
  38. package/src/lib/components/FormLayout/FormLayout.jsx +19 -17
  39. package/src/lib/components/FormLayout/FormLayout.scss +17 -17
  40. package/src/lib/components/FormLayout/FormLayoutCustomField.jsx +18 -12
  41. package/src/lib/components/FormLayout/FormLayoutCustomField.scss +18 -18
  42. package/src/lib/components/FormLayout/README.mdx +26 -49
  43. package/src/lib/components/Grid/Grid.jsx +25 -24
  44. package/src/lib/components/Grid/Grid.scss +33 -29
  45. package/src/lib/components/Grid/GridSpan.jsx +11 -10
  46. package/src/lib/components/Grid/README.mdx +46 -20
  47. package/src/lib/components/Grid/{helpers → _helpers}/generateResponsiveCustomProperties.js +0 -2
  48. package/src/lib/components/Grid/_theme.scss +9 -9
  49. package/src/lib/components/Grid/_tools.scss +20 -20
  50. package/src/lib/components/Modal/Modal.jsx +38 -32
  51. package/src/lib/components/Modal/Modal.scss +73 -73
  52. package/src/lib/components/Modal/README.mdx +2 -5
  53. package/src/lib/components/Modal/_settings.scss +5 -5
  54. package/src/lib/components/Modal/_theme.scss +17 -17
  55. package/src/lib/components/Paper/Paper.jsx +9 -9
  56. package/src/lib/components/Paper/Paper.scss +8 -8
  57. package/src/lib/components/Popover/Popover.jsx +94 -0
  58. package/src/lib/components/Popover/Popover.scss +235 -0
  59. package/src/lib/components/Popover/PopoverWrapper.jsx +46 -0
  60. package/src/lib/components/Popover/README.mdx +333 -0
  61. package/src/lib/components/Popover/_helpers/getRootAlignmentClassName.js +13 -0
  62. package/src/lib/components/Popover/_helpers/getRootSideClassName.js +17 -0
  63. package/src/lib/components/Popover/_theme.scss +16 -0
  64. package/src/lib/components/Popover/index.js +2 -0
  65. package/src/lib/components/Radio/README.mdx +1 -1
  66. package/src/lib/components/Radio/Radio.jsx +15 -14
  67. package/src/lib/components/Radio/Radio.scss +26 -26
  68. package/src/lib/components/ScrollView/README.mdx +5 -5
  69. package/src/lib/components/ScrollView/ScrollView.jsx +22 -22
  70. package/src/lib/components/ScrollView/ScrollView.scss +113 -113
  71. package/src/lib/{services/elementPositionService.js → components/ScrollView/_helpers/getElementsPositionDifference.js} +0 -2
  72. package/src/lib/{hooks → components/ScrollView/_hooks}/useLoadResizeHook.js +1 -1
  73. package/src/lib/{hooks → components/ScrollView/_hooks}/useScrollPositionHook.js +1 -1
  74. package/src/lib/components/SelectField/README.mdx +1 -1
  75. package/src/lib/components/SelectField/SelectField.jsx +17 -16
  76. package/src/lib/components/SelectField/SelectField.scss +30 -30
  77. package/src/lib/components/Table/README.mdx +1 -1
  78. package/src/lib/components/Table/Table.jsx +3 -3
  79. package/src/lib/components/Table/Table.scss +28 -35
  80. package/src/lib/components/Table/_settings.scss +5 -5
  81. package/src/lib/components/Tabs/Tabs.jsx +4 -5
  82. package/src/lib/components/Tabs/Tabs.scss +21 -21
  83. package/src/lib/components/Tabs/TabsItem.jsx +7 -6
  84. package/src/lib/components/Tabs/TabsItem.scss +78 -78
  85. package/src/lib/components/Text/README.mdx +3 -3
  86. package/src/lib/components/Text/Text.jsx +16 -9
  87. package/src/lib/components/Text/Text.scss +23 -13
  88. package/src/lib/components/Text/_helpers/getRootClampClassName.js +11 -0
  89. package/src/lib/components/Text/{helpers → _helpers}/getRootHyphensClassName.js +1 -1
  90. package/src/lib/components/Text/{helpers → _helpers}/getRootWordWrappingClassName.js +1 -1
  91. package/src/lib/components/TextArea/README.mdx +1 -1
  92. package/src/lib/components/TextArea/TextArea.jsx +21 -17
  93. package/src/lib/components/TextArea/TextArea.scss +27 -27
  94. package/src/lib/components/TextField/README.mdx +1 -1
  95. package/src/lib/components/TextField/TextField.jsx +19 -18
  96. package/src/lib/components/TextField/TextField.scss +28 -28
  97. package/src/lib/components/TextLink/README.mdx +77 -0
  98. package/src/lib/components/TextLink/TextLink.jsx +44 -0
  99. package/src/lib/components/TextLink/TextLink.scss +11 -0
  100. package/src/lib/components/TextLink/_theme.scss +4 -0
  101. package/src/lib/components/TextLink/index.js +1 -0
  102. package/src/lib/components/Toggle/README.mdx +1 -1
  103. package/src/lib/components/Toggle/Toggle.jsx +21 -20
  104. package/src/lib/components/Toggle/Toggle.scss +20 -20
  105. package/src/lib/components/Toolbar/README.mdx +33 -5
  106. package/src/lib/components/Toolbar/Toolbar.jsx +33 -17
  107. package/src/lib/components/Toolbar/Toolbar.scss +29 -42
  108. package/src/lib/components/Toolbar/ToolbarGroup.jsx +28 -16
  109. package/src/lib/components/Toolbar/ToolbarItem.jsx +36 -10
  110. package/src/lib/{helpers → components/_helpers}/getRootColorClassName.js +1 -1
  111. package/src/lib/{helpers → components/_helpers}/getRootSizeClassName.js +1 -1
  112. package/src/lib/{helpers → components/_helpers}/getRootValidationStateClassName.js +1 -1
  113. package/src/lib/components/_helpers/isChildrenEmpty.js +3 -0
  114. package/src/lib/{helpers → components/_helpers}/resolveContextOrProp.js +0 -0
  115. package/src/lib/{utils → components/_helpers}/transferProps.js +1 -1
  116. package/src/lib/foundation.scss +11 -11
  117. package/src/lib/helpers.scss +2 -2
  118. package/src/lib/index.js +8 -17
  119. package/src/lib/provider/index.js +2 -1
  120. package/src/lib/provider/withGlobalProps.jsx +21 -0
  121. package/src/lib/styles/_utilities.scss +13 -13
  122. package/src/lib/styles/elements/_code.scss +7 -7
  123. package/src/lib/styles/elements/_links.scss +8 -8
  124. package/src/lib/styles/elements/_lists.scss +3 -3
  125. package/src/lib/styles/elements/_page.scss +14 -14
  126. package/src/lib/styles/elements/_rulers.scss +6 -6
  127. package/src/lib/styles/elements/_small.scss +2 -2
  128. package/src/lib/styles/generic/_box-sizing.scss +3 -2
  129. package/src/lib/styles/generic/_forms.scss +3 -3
  130. package/src/lib/styles/generic/_reset.scss +6 -6
  131. package/src/lib/styles/generic/_shared.scss +3 -3
  132. package/src/lib/styles/helpers/_animation.scss +8 -8
  133. package/src/lib/styles/settings/_breakpoints.scss +7 -7
  134. package/src/lib/styles/settings/_escaped-characters.scss +5 -5
  135. package/src/lib/styles/settings/_form-fields.scss +24 -24
  136. package/src/lib/styles/settings/_utilities.scss +112 -100
  137. package/src/lib/styles/theme/_colors.scss +50 -50
  138. package/src/lib/styles/theme/_form-fields.scss +32 -32
  139. package/src/lib/styles/theme/_spacing.scss +11 -11
  140. package/src/lib/styles/theme/_typography.scss +12 -11
  141. package/src/lib/styles/theme-constants/_breakpoints.scss +4 -4
  142. package/src/lib/styles/theme-constants/_colors.scss +2 -2
  143. package/src/lib/styles/theme-constants/_svg.scss +1 -2
  144. package/src/lib/styles/tools/_accessibility.scss +29 -29
  145. package/src/lib/styles/tools/_breakpoint.scss +11 -14
  146. package/src/lib/styles/tools/_caret.scss +8 -8
  147. package/src/lib/styles/tools/_colors.scss +3 -3
  148. package/src/lib/styles/tools/_reset.scss +24 -21
  149. package/src/lib/styles/tools/_scrollbar.scss +4 -4
  150. package/src/lib/styles/tools/_spacing.scss +14 -22
  151. package/src/lib/styles/tools/_string.scss +9 -9
  152. package/src/lib/styles/tools/_svg.scss +13 -16
  153. package/src/lib/styles/tools/_transition.scss +42 -44
  154. package/src/lib/styles/tools/_utilities.scss +19 -19
  155. package/src/lib/styles/tools/form-fields/_box-field-elements.scss +88 -88
  156. package/src/lib/styles/tools/form-fields/_box-field-layout.scss +147 -147
  157. package/src/lib/styles/tools/form-fields/_box-field-sizes.scss +13 -15
  158. package/src/lib/styles/tools/form-fields/_foundation.scss +12 -12
  159. package/src/lib/styles/tools/form-fields/_inline-field-elements.scss +82 -71
  160. package/src/lib/styles/tools/form-fields/_inline-field-layout.scss +88 -47
  161. package/src/lib/styles/tools/form-fields/_variants.scss +104 -106
  162. package/src/lib/theme.scss +959 -954
  163. package/src/lib/utils/classNames.js +8 -0
  164. package/src/lib/components/CTA/CTA.jsx +0 -60
  165. package/src/lib/components/CTA/CTA.scss +0 -71
  166. package/src/lib/components/CTA/CTACenter.jsx +0 -27
  167. package/src/lib/components/CTA/CTAEnd.jsx +0 -27
  168. package/src/lib/components/CTA/CTAStart.jsx +0 -27
  169. package/src/lib/components/CTA/README.mdx +0 -119
  170. package/src/lib/components/CTA/index.js +0 -4
  171. package/src/lib/components/Center/Center.jsx +0 -27
  172. package/src/lib/components/Center/Center.scss +0 -7
  173. package/src/lib/components/Center/README.mdx +0 -52
  174. package/src/lib/components/Center/index.js +0 -1
  175. package/src/lib/components/Link/Link.jsx +0 -45
  176. package/src/lib/components/Link/Link.scss +0 -11
  177. package/src/lib/components/Link/README.mdx +0 -85
  178. package/src/lib/components/Link/_theme.scss +0 -4
  179. package/src/lib/components/Link/index.js +0 -1
  180. package/src/lib/components/List/List.jsx +0 -71
  181. package/src/lib/components/List/List.scss +0 -53
  182. package/src/lib/components/List/ListItem.jsx +0 -31
  183. package/src/lib/components/List/README.mdx +0 -114
  184. package/src/lib/components/List/_theme.scss +0 -1
  185. package/src/lib/components/List/index.js +0 -2
  186. package/src/lib/components/Media/Media.jsx +0 -29
  187. package/src/lib/components/Media/Media.scss +0 -16
  188. package/src/lib/components/Media/MediaBody.jsx +0 -21
  189. package/src/lib/components/Media/MediaObject.jsx +0 -21
  190. package/src/lib/components/Media/README.mdx +0 -63
  191. package/src/lib/components/Media/index.js +0 -3
  192. package/src/lib/provider/withProviderContext.jsx +0 -32
@@ -1,61 +1,61 @@
1
- @use '../../styles/tools/form-fields/foundation';
2
- @use '../../styles/tools/form-fields/inline-field-elements';
3
- @use '../../styles/tools/form-fields/inline-field-layout';
4
- @use '../../styles/tools/form-fields/variants';
5
- @use '../../styles/tools/accessibility';
1
+ @use "../../styles/tools/form-fields/foundation";
2
+ @use "../../styles/tools/form-fields/inline-field-elements";
3
+ @use "../../styles/tools/form-fields/inline-field-layout";
4
+ @use "../../styles/tools/form-fields/variants";
5
+ @use "../../styles/tools/accessibility";
6
6
 
7
7
  // Foundation
8
8
  .root {
9
- @include foundation.root();
10
- @include inline-field-layout.root();
11
- @include inline-field-elements.min-tap-target($type: toggle);
12
- @include variants.visual(check);
9
+ @include foundation.root();
10
+ @include inline-field-layout.root();
11
+ @include inline-field-elements.min-tap-target($type: toggle);
12
+ @include variants.visual(check);
13
13
  }
14
14
 
15
15
  .label {
16
- @include foundation.label();
16
+ @include foundation.label();
17
17
  }
18
18
 
19
19
  .field {
20
- @include inline-field-layout.field();
20
+ @include inline-field-layout.field($type: toggle);
21
21
  }
22
22
 
23
23
  .input {
24
- @include inline-field-elements.check-input($type: toggle);
24
+ @include inline-field-elements.check-input($type: toggle);
25
25
  }
26
26
 
27
27
  .helpText,
28
28
  .validationText {
29
- @include foundation.help-text();
29
+ @include foundation.help-text();
30
30
  }
31
31
 
32
32
  .isRootRequired .label {
33
- @include foundation.label-required();
33
+ @include foundation.label-required();
34
34
  }
35
35
 
36
36
  // States
37
37
  .isRootStateInvalid {
38
- @include variants.validation(invalid);
38
+ @include variants.validation(invalid);
39
39
  }
40
40
 
41
41
  .isRootStateValid {
42
- @include variants.validation(valid);
42
+ @include variants.validation(valid);
43
43
  }
44
44
 
45
45
  .isRootStateWarning {
46
- @include variants.validation(warning);
46
+ @include variants.validation(warning);
47
47
  }
48
48
 
49
49
  // Invisible label
50
50
  .isLabelHidden {
51
- @include accessibility.hide-text();
51
+ @include accessibility.hide-text();
52
52
  }
53
53
 
54
54
  // Layouts
55
55
  .hasRootLabelBefore {
56
- @include inline-field-layout.has-label-before();
56
+ @include inline-field-layout.has-label-before();
57
57
  }
58
58
 
59
59
  .isRootInFormLayout {
60
- @include inline-field-layout.in-form-layout();
60
+ @include inline-field-layout.in-form-layout();
61
61
  }
@@ -50,8 +50,8 @@ See [API](#api) for all available options.
50
50
  ## General Guidelines
51
51
 
52
52
  - **Toolbar is great for flexible inline layouts.** For stacking your content
53
- vertically, use the [List][list] layout. For two-dimensional layouts head to
54
- the [Grid][grid] layout.
53
+ vertically or building two-dimensional layouts head to the [Grid][grid]
54
+ layout.
55
55
 
56
56
  - **Wrap your items** into the ToolbarItem component. This ensures your content
57
57
  is properly spaced and aligned with other Toolbar elements. Do **not** try to
@@ -88,7 +88,7 @@ of `right`.
88
88
  <span id="alignment-label">Alignment:</span>
89
89
  </ToolbarItem>
90
90
  <ToolbarItem>
91
- <ButtonGroup aria-labelledby="#alignment-label">
91
+ <ButtonGroup aria-labelledby="alignment-label">
92
92
  <Button
93
93
  color={alignment === 'top' ? 'dark' : 'primary'}
94
94
  label="top"
@@ -117,7 +117,7 @@ of `right`.
117
117
  <span id="justification-label">Justification:</span>
118
118
  </ToolbarItem>
119
119
  <ToolbarItem>
120
- <ButtonGroup aria-labelledby="#justification-label">
120
+ <ButtonGroup aria-labelledby="justification-label">
121
121
  <Button
122
122
  color={justification === 'start' ? 'dark' : 'primary'}
123
123
  label="start"
@@ -304,6 +304,35 @@ Toolbar.
304
304
  content placed within Toolbar. The [Text][text] component is designed
305
305
  specifically for this kind of job.
306
306
 
307
+ ## Flexible Items
308
+
309
+ Toolbar items can be made flexible to grow and shrink according to the available
310
+ space. This is useful e.g. when you need to combine text with an action:
311
+
312
+ <Playground>
313
+ <Toolbar>
314
+ <ToolbarItem flexible>
315
+ <Placeholder bordered>My Headline</Placeholder>
316
+ </ToolbarItem>
317
+ <ToolbarItem>
318
+ <Placeholder bordered>Action</Placeholder>
319
+ </ToolbarItem>
320
+ </Toolbar>
321
+ </Playground>
322
+
323
+ Or to build a classic media layout with image on the left and text on the right:
324
+
325
+ <Playground>
326
+ <Toolbar>
327
+ <ToolbarItem>
328
+ <Placeholder bordered>Media object</Placeholder>
329
+ </ToolbarItem>
330
+ <ToolbarItem flexible>
331
+ <Placeholder bordered>Media body</Placeholder>
332
+ </ToolbarItem>
333
+ </Toolbar>
334
+ </Playground>
335
+
307
336
  ## API
308
337
 
309
338
  <Props table of={Toolbar} />
@@ -330,6 +359,5 @@ A wrapper for individual toolbar items.
330
359
  [inline-elements]: https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
331
360
  [block-elements]: https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
332
361
  [grid]: /components/grid
333
- [list]: /components/list
334
362
  [spacing]: /css-helpers/spacing
335
363
  [text]: /components/text
@@ -1,16 +1,21 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import { withProviderContext } from '../../provider';
3
+ import { withGlobalProps } from '../../provider';
4
+ import { classNames } from '../../utils/classNames';
5
+ import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
4
6
  import styles from './Toolbar.scss';
5
7
 
6
- export const Toolbar = (props) => {
7
- const {
8
- align,
9
- children,
10
- dense,
11
- justify,
12
- nowrap,
13
- } = props;
8
+ export const Toolbar = ({
9
+ align,
10
+ children,
11
+ dense,
12
+ id,
13
+ justify,
14
+ nowrap,
15
+ }) => {
16
+ if (isChildrenEmpty(children)) {
17
+ return null;
18
+ }
14
19
 
15
20
  const alignClass = (value) => {
16
21
  if (value === 'top') {
@@ -46,13 +51,14 @@ export const Toolbar = (props) => {
46
51
 
47
52
  return (
48
53
  <div
49
- className={[
54
+ className={classNames(
50
55
  styles.toolbar,
51
- dense ? styles.isDense : null,
52
- nowrap ? styles.isNowrap : null,
56
+ dense && styles.isDense,
57
+ nowrap && styles.isNowrap,
53
58
  alignClass(align),
54
59
  justifyClass(justify),
55
- ].join(' ')}
60
+ )}
61
+ id={id}
56
62
  >
57
63
  {children}
58
64
  </div>
@@ -61,7 +67,9 @@ export const Toolbar = (props) => {
61
67
 
62
68
  Toolbar.defaultProps = {
63
69
  align: 'top',
70
+ children: null,
64
71
  dense: false,
72
+ id: undefined,
65
73
  justify: 'start',
66
74
  nowrap: false,
67
75
  };
@@ -72,13 +80,21 @@ Toolbar.propTypes = {
72
80
  */
73
81
  align: PropTypes.oneOf(['top', 'middle', 'bottom', 'baseline']),
74
82
  /**
75
- * Individual ToolbarItems and ToolbarGroups.
83
+ * Nested elements. Supported types are:
84
+ * * `ToolbarItems`
85
+ * * `ToolbarGroups`
86
+ *
87
+ * If none are provided nothing is rendered.
76
88
  */
77
- children: PropTypes.node.isRequired,
89
+ children: PropTypes.node,
78
90
  /**
79
91
  * If `true`, spacing of all toolbar items in the toolbar will be reduced.
80
92
  */
81
93
  dense: PropTypes.bool,
94
+ /**
95
+ * ID of the root HTML element.
96
+ */
97
+ id: PropTypes.string,
82
98
  /**
83
99
  * Horizontal alignment (distribution) of toolbar items and groups.
84
100
  */
@@ -89,6 +105,6 @@ Toolbar.propTypes = {
89
105
  nowrap: PropTypes.bool,
90
106
  };
91
107
 
92
- export const ToolbarWithContext = withProviderContext(Toolbar, 'Toolbar');
108
+ export const ToolbarWithGlobalProps = withGlobalProps(Toolbar, 'Toolbar');
93
109
 
94
- export default ToolbarWithContext;
110
+ export default ToolbarWithGlobalProps;
@@ -1,84 +1,71 @@
1
1
  // 1. Get rid of unwanted spacing of inline elements by invocation of flex layout.
2
2
 
3
- @use '../../styles/tools/spacing';
4
- @use 'theme';
3
+ @use "../../styles/tools/spacing";
4
+ @use "theme";
5
5
 
6
6
  .toolbar,
7
7
  .group {
8
- display: flex;
9
- flex-wrap: wrap;
8
+ display: flex;
9
+ flex-wrap: wrap;
10
+ gap: theme.$gap;
10
11
  }
11
12
 
12
13
  .toolbar {
13
- @include spacing.bottom(layouts, $compensation: theme.$gap);
14
-
15
- margin: calc(-1 * #{theme.$gap});
14
+ @include spacing.bottom(layouts);
16
15
  }
17
16
 
18
17
  .item {
19
- display: flex; // 1.
20
- flex: none;
21
- flex-direction: column; // 1.
22
- margin: theme.$gap;
18
+ display: flex; // 1.
19
+ flex: none;
20
+ flex-direction: column; // 1.
21
+ }
22
+
23
+ .isItemFlexible {
24
+ flex: 1;
25
+ min-width: 0;
23
26
  }
24
27
 
25
28
  .isAlignedToTop {
26
- align-items: flex-start;
29
+ align-items: flex-start;
27
30
  }
28
31
 
29
32
  .isAlignedToMiddle {
30
- align-items: center;
33
+ align-items: center;
31
34
  }
32
35
 
33
36
  .isAlignedToBottom {
34
- align-items: flex-end;
37
+ align-items: flex-end;
35
38
  }
36
39
 
37
40
  .isAlignedToBaseline {
38
- align-items: baseline;
41
+ align-items: baseline;
39
42
  }
40
43
 
41
44
  .isJustifiedToStart {
42
- justify-content: flex-start;
45
+ justify-content: flex-start;
43
46
  }
44
47
 
45
48
  .isJustifiedToCenter {
46
- justify-content: center;
49
+ justify-content: center;
47
50
  }
48
51
 
49
52
  .isJustifiedToEnd {
50
- justify-content: flex-end;
53
+ justify-content: flex-end;
51
54
  }
52
55
 
53
56
  .isJustifiedToSpaceBetween {
54
- justify-content: space-between;
57
+ justify-content: space-between;
55
58
  }
56
59
 
57
- .isNowrap {
58
- flex-wrap: nowrap;
60
+ .isDense,
61
+ .isDense .group {
62
+ gap: theme.$gap-dense;
59
63
  }
60
64
 
61
- .isNowrap > .item {
62
- flex: 0 1 auto;
63
- }
64
-
65
- .isDense {
66
- margin: calc(-1 * #{theme.$gap-dense});
67
- }
68
-
69
- .isDense .item {
70
- margin: theme.$gap-dense;
71
- }
72
-
73
- .isDense > .isDense {
74
- margin: 0;
75
- }
76
-
77
- .toolbar.isDense {
78
- @include spacing.bottom(layouts, $compensation: theme.$gap-dense);
65
+ .isNowrap {
66
+ flex-wrap: nowrap;
79
67
  }
80
68
 
81
- .toolbar:not(.isDense) > .isDense,
82
- .group:not(.isDense) > .isDense {
83
- margin: theme.$gap-dense;
69
+ .isNowrap > .item:not(.isItemFlexible) {
70
+ flex: 0 1 auto;
84
71
  }
@@ -1,15 +1,20 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import { withProviderContext } from '../../provider';
3
+ import { withGlobalProps } from '../../provider';
4
+ import { classNames } from '../../utils/classNames';
5
+ import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
4
6
  import styles from './Toolbar.scss';
5
7
 
6
- export const ToolbarGroup = (props) => {
7
- const {
8
- align,
9
- children,
10
- dense,
11
- nowrap,
12
- } = props;
8
+ export const ToolbarGroup = ({
9
+ align,
10
+ children,
11
+ dense,
12
+ id,
13
+ nowrap,
14
+ }) => {
15
+ if (isChildrenEmpty(children)) {
16
+ return null;
17
+ }
13
18
 
14
19
  const alignClass = (value) => {
15
20
  if (value === 'top') {
@@ -29,12 +34,13 @@ export const ToolbarGroup = (props) => {
29
34
 
30
35
  return (
31
36
  <div
32
- className={[
37
+ className={classNames(
33
38
  styles.group,
34
- dense ? styles.isDense : null,
35
- nowrap ? styles.isNowrap : null,
39
+ dense && styles.isDense,
40
+ nowrap && styles.isNowrap,
36
41
  alignClass(align),
37
- ].join(' ')}
42
+ )}
43
+ id={id}
38
44
  >
39
45
  {children}
40
46
  </div>
@@ -43,7 +49,9 @@ export const ToolbarGroup = (props) => {
43
49
 
44
50
  ToolbarGroup.defaultProps = {
45
51
  align: 'top',
52
+ children: null,
46
53
  dense: false,
54
+ id: undefined,
47
55
  nowrap: false,
48
56
  };
49
57
 
@@ -53,19 +61,23 @@ ToolbarGroup.propTypes = {
53
61
  */
54
62
  align: PropTypes.oneOf(['top', 'middle', 'bottom', 'baseline']),
55
63
  /**
56
- * Grouped ToolbarItems.
64
+ * Grouped ToolbarItems. If none are provided nothing is rendered.
57
65
  */
58
- children: PropTypes.node.isRequired,
66
+ children: PropTypes.node,
59
67
  /**
60
68
  * If `true`, spacing of toolbar items in the group will be reduced.
61
69
  */
62
70
  dense: PropTypes.bool,
71
+ /**
72
+ * ID of the root HTML element.
73
+ */
74
+ id: PropTypes.string,
63
75
  /**
64
76
  * If set, the toolbar group will not wrap.
65
77
  */
66
78
  nowrap: PropTypes.bool,
67
79
  };
68
80
 
69
- export const ToolbarGroupWithContext = withProviderContext(ToolbarGroup, 'ToolbarGroup');
81
+ export const ToolbarGroupWithGlobalProps = withGlobalProps(ToolbarGroup, 'ToolbarGroup');
70
82
 
71
- export default ToolbarGroupWithContext;
83
+ export default ToolbarGroupWithGlobalProps;
@@ -1,27 +1,53 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import { withProviderContext } from '../../provider';
3
+ import { classNames } from '../../utils/classNames';
4
+ import { withGlobalProps } from '../../provider';
5
+ import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
4
6
  import styles from './Toolbar.scss';
5
7
 
6
- export const ToolbarItem = (props) => {
7
- const {
8
- children,
9
- } = props;
8
+ export const ToolbarItem = ({
9
+ children,
10
+ flexible,
11
+ id,
12
+ }) => {
13
+ if (isChildrenEmpty(children)) {
14
+ return null;
15
+ }
10
16
 
11
17
  return (
12
- <div className={styles.item}>
18
+ <div
19
+ className={classNames(
20
+ styles.item,
21
+ flexible && styles.isItemFlexible,
22
+ )}
23
+ id={id}
24
+ >
13
25
  {children}
14
26
  </div>
15
27
  );
16
28
  };
17
29
 
30
+ ToolbarItem.defaultProps = {
31
+ children: null,
32
+ flexible: false,
33
+ id: undefined,
34
+ };
35
+
18
36
  ToolbarItem.propTypes = {
19
37
  /**
20
- * Content of the toolbar item.
38
+ * Content of the toolbar item. If none are provided nothing is rendered.
39
+ */
40
+ children: PropTypes.node,
41
+ /**
42
+ * Allow item to grow and shrink if needed.
43
+ */
44
+ flexible: PropTypes.bool,
45
+ /**
46
+ * ID of the root HTML element.
21
47
  */
22
- children: PropTypes.node.isRequired,
48
+ id: PropTypes.string,
23
49
  };
24
50
 
25
- export const ToolbarItemWithContext = withProviderContext(ToolbarItem, 'ToolbarItem');
51
+ export const ToolbarItemWithGlobalProps = withGlobalProps(ToolbarItem, 'ToolbarItem');
26
52
 
27
- export default ToolbarItemWithContext;
53
+ export default ToolbarItemWithGlobalProps;
@@ -1,4 +1,4 @@
1
- export default (variant, styles) => {
1
+ export const getRootColorClassName = (variant, styles) => {
2
2
  if (variant === 'primary') {
3
3
  return styles.rootColorPrimary;
4
4
  }
@@ -1,4 +1,4 @@
1
- export default (size, styles) => {
1
+ export const getRootSizeClassName = (size, styles) => {
2
2
  if (size === 'small') {
3
3
  return styles.rootSizeSmall;
4
4
  }
@@ -1,4 +1,4 @@
1
- export default (validationState, styles) => {
1
+ export const getRootValidationStateClassName = (validationState, styles) => {
2
2
  if (validationState === 'invalid') {
3
3
  return styles.isRootStateInvalid;
4
4
  }
@@ -0,0 +1,3 @@
1
+ export const isChildrenEmpty = (children) => children == null
2
+ || children === false
3
+ || (Array.isArray(children) && children.length === 0);
@@ -1,4 +1,4 @@
1
- export default ({
1
+ export const transferProps = ({
2
2
  children,
3
3
  className,
4
4
  forwardedRef,
@@ -7,11 +7,11 @@
7
7
  //
8
8
  // Ground-zero styles.
9
9
 
10
- @use 'styles/generic/box-sizing';
11
- @use 'normalize.css/normalize.css';
12
- @use 'styles/generic/forms';
13
- @use 'styles/generic/reset';
14
- @use 'styles/generic/shared';
10
+ @use "styles/generic/box-sizing";
11
+ @use "normalize.css/normalize.css";
12
+ @use "styles/generic/forms";
13
+ @use "styles/generic/reset";
14
+ @use "styles/generic/shared";
15
15
 
16
16
  //
17
17
  // 2. Elements
@@ -19,9 +19,9 @@
19
19
  //
20
20
  // Unclassed HTML elements (type selectors).
21
21
 
22
- @use 'styles/elements/code';
23
- @use 'styles/elements/links';
24
- @use 'styles/elements/lists';
25
- @use 'styles/elements/page';
26
- @use 'styles/elements/rulers';
27
- @use 'styles/elements/small';
22
+ @use "styles/elements/code";
23
+ @use "styles/elements/links";
24
+ @use "styles/elements/lists";
25
+ @use "styles/elements/page";
26
+ @use "styles/elements/rulers";
27
+ @use "styles/elements/small";
@@ -9,7 +9,7 @@
9
9
  // General purpose helpers for common situations. They can compose multiple CSS rules to do a bit
10
10
  // more complicated tasks.
11
11
 
12
- @use 'styles/helpers/animation';
12
+ @use "styles/helpers/animation";
13
13
 
14
14
  //
15
15
  // 2. Utilities
@@ -19,4 +19,4 @@
19
19
  // thing: they set a single CSS rule and use the otherwise disallowed `!important` to enforce it.
20
20
  // Also they are often responsive (can be adjusted for individual breakpoints).
21
21
 
22
- @use 'styles/utilities';
22
+ @use "styles/utilities";
package/src/lib/index.js CHANGED
@@ -8,14 +8,7 @@ export {
8
8
  CardBody,
9
9
  CardFooter,
10
10
  } from './components/Card';
11
- export { default as Center } from './components/Center';
12
11
  export { default as CheckboxField } from './components/CheckboxField';
13
- export {
14
- CTA,
15
- CTACenter,
16
- CTAEnd,
17
- CTAStart,
18
- } from './components/CTA';
19
12
  export { default as FileInputField } from './components/FileInputField';
20
13
  export {
21
14
  FormLayout,
@@ -25,18 +18,12 @@ export {
25
18
  Grid,
26
19
  GridSpan,
27
20
  } from './components/Grid';
28
- export { default as Link } from './components/Link';
29
- export {
30
- List,
31
- ListItem,
32
- } from './components/List';
33
- export {
34
- Media,
35
- MediaBody,
36
- MediaObject,
37
- } from './components/Media';
38
21
  export { default as Modal } from './components/Modal';
39
22
  export { default as Paper } from './components/Paper';
23
+ export {
24
+ Popover,
25
+ PopoverWrapper,
26
+ } from './components/Popover';
40
27
  export { default as Radio } from './components/Radio';
41
28
  export { default as ScrollView } from './components/ScrollView';
42
29
  export { default as SelectField } from './components/SelectField';
@@ -48,6 +35,7 @@ export { default as Table } from './components/Table';
48
35
  export { default as Text } from './components/Text';
49
36
  export { default as TextArea } from './components/TextArea';
50
37
  export { default as TextField } from './components/TextField';
38
+ export { default as TextLink } from './components/TextLink';
51
39
  export { default as Toggle } from './components/Toggle';
52
40
  export {
53
41
  Toolbar,
@@ -57,3 +45,6 @@ export {
57
45
 
58
46
  // Provider
59
47
  export { RUIProvider } from './provider';
48
+
49
+ // Utils
50
+ export { classNames } from './utils/classNames';
@@ -1,2 +1,3 @@
1
1
  export { default as RUIProvider } from './RUIProvider';
2
- export { default as withProviderContext } from './withProviderContext';
2
+ export { default as RUIContext } from './RUIContext';
3
+ export { default as withGlobalProps } from './withGlobalProps';
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import RUIContext from './RUIContext';
3
+
4
+ export default (Component, componentName) => {
5
+ const WithGlobalPropsComponent = (props) => (
6
+ <RUIContext.Consumer>
7
+ {({ globalProps }) => {
8
+ const contextGlobalProps = globalProps ? globalProps[componentName] : null;
9
+
10
+ return (
11
+ <Component
12
+ {...contextGlobalProps}
13
+ {...props}
14
+ />
15
+ );
16
+ }}
17
+ </RUIContext.Consumer>
18
+ );
19
+
20
+ return WithGlobalPropsComponent;
21
+ };