@react-ui-org/react-ui 0.44.0 → 0.46.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. package/CONTRIBUTING.md +7 -0
  2. package/dist/lib.development.js +209 -305
  3. package/dist/lib.js +1 -1
  4. package/package.json +10 -13
  5. package/src/lib/components/Alert/Alert.jsx +4 -3
  6. package/src/lib/components/Alert/Alert.scss +48 -48
  7. package/src/lib/components/Alert/_settings.scss +4 -4
  8. package/src/lib/components/Alert/_theme.scss +50 -50
  9. package/src/lib/components/Alert/_tools.scss +6 -6
  10. package/src/lib/components/Badge/Badge.jsx +6 -8
  11. package/src/lib/components/Badge/Badge.scss +57 -57
  12. package/src/lib/components/Button/Button.jsx +10 -9
  13. package/src/lib/components/Button/Button.scss +2 -2
  14. package/src/lib/components/Button/README.mdx +8 -3
  15. package/src/lib/components/Button/_base.scss +65 -65
  16. package/src/lib/components/Button/_priorities.scss +49 -49
  17. package/src/lib/components/Button/_settings.scss +10 -10
  18. package/src/lib/components/Button/_theme.scss +18 -15
  19. package/src/lib/components/Button/_tools.scss +98 -100
  20. package/src/lib/components/ButtonGroup/ButtonGroup.jsx +31 -22
  21. package/src/lib/components/ButtonGroup/ButtonGroup.scss +3 -3
  22. package/src/lib/components/ButtonGroup/README.mdx +4 -4
  23. package/src/lib/components/Card/Card.jsx +7 -6
  24. package/src/lib/components/Card/Card.scss +28 -28
  25. package/src/lib/components/Card/CardBody.jsx +5 -11
  26. package/src/lib/components/Card/CardFooter.jsx +10 -5
  27. package/src/lib/components/Card/README.mdx +2 -2
  28. package/src/lib/components/Card/_theme.scss +50 -50
  29. package/src/lib/components/Card/_tools.scss +6 -6
  30. package/src/lib/components/CheckboxField/CheckboxField.jsx +18 -17
  31. package/src/lib/components/CheckboxField/CheckboxField.scss +20 -20
  32. package/src/lib/components/CheckboxField/README.mdx +3 -3
  33. package/src/lib/components/FileInputField/FileInputField.jsx +13 -12
  34. package/src/lib/components/FileInputField/FileInputField.scss +19 -19
  35. package/src/lib/components/FileInputField/README.mdx +1 -1
  36. package/src/lib/components/FormLayout/FormLayout.jsx +16 -14
  37. package/src/lib/components/FormLayout/FormLayout.scss +17 -17
  38. package/src/lib/components/FormLayout/FormLayoutCustomField.jsx +15 -9
  39. package/src/lib/components/FormLayout/FormLayoutCustomField.scss +18 -18
  40. package/src/lib/components/FormLayout/README.mdx +27 -49
  41. package/src/lib/components/Grid/Grid.jsx +4 -3
  42. package/src/lib/components/Grid/Grid.scss +32 -23
  43. package/src/lib/components/Grid/GridSpan.jsx +4 -3
  44. package/src/lib/components/Grid/{helpers → _helpers}/generateResponsiveCustomProperties.js +0 -2
  45. package/src/lib/components/Grid/_theme.scss +9 -9
  46. package/src/lib/components/Grid/_tools.scss +20 -20
  47. package/src/lib/components/List/List.jsx +14 -12
  48. package/src/lib/components/List/List.scss +21 -21
  49. package/src/lib/components/List/ListItem.jsx +3 -2
  50. package/src/lib/components/List/README.mdx +1 -1
  51. package/src/lib/components/Media/Media.jsx +12 -5
  52. package/src/lib/components/Media/Media.scss +6 -6
  53. package/src/lib/components/Media/MediaBody.jsx +18 -7
  54. package/src/lib/components/Media/MediaObject.jsx +18 -7
  55. package/src/lib/components/Modal/Modal.jsx +8 -6
  56. package/src/lib/components/Modal/Modal.scss +73 -73
  57. package/src/lib/components/Modal/README.mdx +2 -2
  58. package/src/lib/components/Modal/_settings.scss +5 -5
  59. package/src/lib/components/Modal/_theme.scss +17 -17
  60. package/src/lib/components/Paper/Paper.jsx +6 -6
  61. package/src/lib/components/Paper/Paper.scss +8 -8
  62. package/src/lib/components/Paper/README.mdx +1 -1
  63. package/src/lib/components/Radio/README.mdx +4 -4
  64. package/src/lib/components/Radio/Radio.jsx +12 -11
  65. package/src/lib/components/Radio/Radio.scss +26 -26
  66. package/src/lib/components/ScrollView/README.mdx +4 -1
  67. package/src/lib/components/ScrollView/ScrollView.jsx +11 -9
  68. package/src/lib/components/ScrollView/ScrollView.scss +113 -113
  69. package/src/lib/{services/elementPositionService.js → components/ScrollView/_helpers/getElementsPositionDifference.js} +0 -2
  70. package/src/lib/{hooks → components/ScrollView/_hooks}/useLoadResizeHook.js +1 -1
  71. package/src/lib/{hooks → components/ScrollView/_hooks}/useScrollPositionHook.js +1 -1
  72. package/src/lib/components/SelectField/README.mdx +4 -4
  73. package/src/lib/components/SelectField/SelectField.jsx +14 -13
  74. package/src/lib/components/SelectField/SelectField.scss +30 -30
  75. package/src/lib/components/Table/README.mdx +3 -3
  76. package/src/lib/components/Table/Table.scss +28 -35
  77. package/src/lib/components/Table/_settings.scss +5 -5
  78. package/src/lib/components/Tabs/README.mdx +1 -1
  79. package/src/lib/components/Tabs/Tabs.jsx +1 -2
  80. package/src/lib/components/Tabs/Tabs.scss +21 -21
  81. package/src/lib/components/Tabs/TabsItem.jsx +4 -3
  82. package/src/lib/components/Tabs/TabsItem.scss +78 -78
  83. package/src/lib/components/Text/README.mdx +1 -1
  84. package/src/lib/components/Text/Text.jsx +13 -6
  85. package/src/lib/components/Text/Text.scss +23 -13
  86. package/src/lib/components/Text/_helpers/getRootClampClassName.js +11 -0
  87. package/src/lib/components/Text/{helpers → _helpers}/getRootHyphensClassName.js +1 -1
  88. package/src/lib/components/Text/{helpers → _helpers}/getRootWordWrappingClassName.js +1 -1
  89. package/src/lib/components/TextArea/README.mdx +1 -1
  90. package/src/lib/components/TextArea/TextArea.jsx +18 -14
  91. package/src/lib/components/TextArea/TextArea.scss +27 -27
  92. package/src/lib/components/TextField/README.mdx +1 -1
  93. package/src/lib/components/TextField/TextField.jsx +16 -14
  94. package/src/lib/components/TextField/TextField.scss +28 -28
  95. package/src/lib/components/TextLink/README.mdx +77 -0
  96. package/src/lib/components/{Link/Link.jsx → TextLink/TextLink.jsx} +12 -13
  97. package/src/lib/components/TextLink/TextLink.scss +11 -0
  98. package/src/lib/components/TextLink/_theme.scss +4 -0
  99. package/src/lib/components/TextLink/index.js +1 -0
  100. package/src/lib/components/Toggle/README.mdx +3 -3
  101. package/src/lib/components/Toggle/Toggle.jsx +18 -17
  102. package/src/lib/components/Toggle/Toggle.scss +20 -20
  103. package/src/lib/components/Toolbar/README.mdx +19 -3
  104. package/src/lib/components/Toolbar/Toolbar.jsx +23 -14
  105. package/src/lib/components/Toolbar/Toolbar.scss +35 -30
  106. package/src/lib/components/Toolbar/ToolbarGroup.jsx +18 -13
  107. package/src/lib/components/Toolbar/ToolbarItem.jsx +26 -7
  108. package/src/lib/{helpers → components/_helpers}/getRootColorClassName.js +1 -1
  109. package/src/lib/{helpers → components/_helpers}/getRootSizeClassName.js +1 -1
  110. package/src/lib/{helpers → components/_helpers}/getRootValidationStateClassName.js +1 -1
  111. package/src/lib/components/_helpers/isChildrenEmpty.js +3 -0
  112. package/src/lib/{helpers → components/_helpers}/resolveContextOrProp.js +0 -0
  113. package/src/lib/{utils → components/_helpers}/transferProps.js +1 -1
  114. package/src/lib/foundation.scss +11 -11
  115. package/src/lib/helpers.scss +2 -2
  116. package/src/lib/index.js +4 -8
  117. package/src/lib/styles/_utilities.scss +13 -13
  118. package/src/lib/styles/elements/_code.scss +7 -7
  119. package/src/lib/styles/elements/_links.scss +8 -8
  120. package/src/lib/styles/elements/_lists.scss +3 -3
  121. package/src/lib/styles/elements/_page.scss +14 -14
  122. package/src/lib/styles/elements/_rulers.scss +6 -6
  123. package/src/lib/styles/elements/_small.scss +2 -2
  124. package/src/lib/styles/generic/_box-sizing.scss +3 -2
  125. package/src/lib/styles/generic/_forms.scss +3 -3
  126. package/src/lib/styles/generic/_reset.scss +6 -6
  127. package/src/lib/styles/generic/_shared.scss +3 -3
  128. package/src/lib/styles/helpers/_animation.scss +8 -8
  129. package/src/lib/styles/settings/_breakpoints.scss +7 -7
  130. package/src/lib/styles/settings/_escaped-characters.scss +5 -5
  131. package/src/lib/styles/settings/_form-fields.scss +24 -24
  132. package/src/lib/styles/settings/_utilities.scss +112 -100
  133. package/src/lib/styles/theme/_colors.scss +50 -50
  134. package/src/lib/styles/theme/_form-fields.scss +32 -32
  135. package/src/lib/styles/theme/_spacing.scss +11 -11
  136. package/src/lib/styles/theme/_typography.scss +12 -11
  137. package/src/lib/styles/theme-constants/_breakpoints.scss +2 -2
  138. package/src/lib/styles/theme-constants/_colors.scss +2 -2
  139. package/src/lib/styles/theme-constants/_svg.scss +1 -2
  140. package/src/lib/styles/tools/_accessibility.scss +29 -29
  141. package/src/lib/styles/tools/_breakpoint.scss +11 -14
  142. package/src/lib/styles/tools/_caret.scss +8 -8
  143. package/src/lib/styles/tools/_colors.scss +3 -3
  144. package/src/lib/styles/tools/_reset.scss +24 -21
  145. package/src/lib/styles/tools/_scrollbar.scss +4 -4
  146. package/src/lib/styles/tools/_spacing.scss +17 -21
  147. package/src/lib/styles/tools/_string.scss +9 -9
  148. package/src/lib/styles/tools/_svg.scss +13 -16
  149. package/src/lib/styles/tools/_transition.scss +42 -44
  150. package/src/lib/styles/tools/_utilities.scss +19 -19
  151. package/src/lib/styles/tools/form-fields/_box-field-elements.scss +88 -88
  152. package/src/lib/styles/tools/form-fields/_box-field-layout.scss +147 -147
  153. package/src/lib/styles/tools/form-fields/_box-field-sizes.scss +13 -15
  154. package/src/lib/styles/tools/form-fields/_foundation.scss +12 -12
  155. package/src/lib/styles/tools/form-fields/_inline-field-elements.scss +82 -71
  156. package/src/lib/styles/tools/form-fields/_inline-field-layout.scss +88 -47
  157. package/src/lib/styles/tools/form-fields/_variants.scss +104 -106
  158. package/src/lib/theme.scss +958 -954
  159. package/src/lib/utils/classNames.js +8 -0
  160. package/src/lib/components/CTA/CTA.jsx +0 -60
  161. package/src/lib/components/CTA/CTA.scss +0 -71
  162. package/src/lib/components/CTA/CTACenter.jsx +0 -27
  163. package/src/lib/components/CTA/CTAEnd.jsx +0 -27
  164. package/src/lib/components/CTA/CTAStart.jsx +0 -27
  165. package/src/lib/components/CTA/README.mdx +0 -119
  166. package/src/lib/components/CTA/index.js +0 -4
  167. package/src/lib/components/Center/Center.jsx +0 -27
  168. package/src/lib/components/Center/Center.scss +0 -7
  169. package/src/lib/components/Center/README.mdx +0 -52
  170. package/src/lib/components/Center/index.js +0 -1
  171. package/src/lib/components/Link/Link.scss +0 -11
  172. package/src/lib/components/Link/README.mdx +0 -85
  173. package/src/lib/components/Link/_theme.scss +0 -4
  174. package/src/lib/components/Link/index.js +0 -1
@@ -15,142 +15,140 @@
15
15
  //
16
16
  // 5. Use original padding to restore square buttons back to their size.
17
17
 
18
- @use 'sass:list';
19
- @use 'sass:map';
20
- @use 'sass:math';
21
- @use '../../styles/tools/accessibility';
22
- @use '../../styles/tools/breakpoint';
23
- @use '../../styles/tools/transition';
24
- @use 'settings';
25
- @use 'theme';
18
+ @use "sass:list";
19
+ @use "sass:map";
20
+ @use "sass:math";
21
+ @use "../../styles/tools/accessibility";
22
+ @use "../../styles/tools/breakpoint";
23
+ @use "../../styles/tools/transition";
24
+ @use "settings";
25
+ @use "theme";
26
26
 
27
27
  // 1.
28
28
  @mixin _get-themeable-properties($priority, $color, $state) {
29
- @if (not list.index(map.keys(settings.$themeable-priority-properties), $priority)) {
30
- @error "Invalid priority specified! #{$priority} doesn't exist. "
31
- + "Choose one of #{settings.$themeable-priority-properties}.";
32
- }
33
-
34
- @if (not list.index(settings.$themeable-variants, $color)) {
35
- @error "Invalid variant specified! #{$color} doesn't exist. "
36
- + "Choose one of #{settings.$themeable-variants}.";
37
- }
38
-
39
- @if (not list.index(settings.$themeable-states, $state)) {
40
- @error "Invalid state specified! #{$state} doesn't exist. "
41
- + "Choose one of #{settings.$themeable-states}.";
42
- }
43
-
44
- $properties: map.get(settings.$themeable-priority-properties, $priority);
45
-
46
- // 2.
47
- @if ($state == 'disabled') {
48
- @each $property in $properties {
49
- --rui-local-#{$property}:
50
- var(
51
- --rui-Button--#{$priority}--#{$color}--#{$state}__#{$property},
52
- var(--rui-Button--#{$priority}--#{$color}--default__#{$property})
53
- );
29
+ @if not list.index(map.keys(settings.$themeable-priority-properties), $priority) {
30
+ @error "Invalid priority specified! #{$priority} doesn't exist. "
31
+ + "Choose one of #{settings.$themeable-priority-properties}.";
54
32
  }
55
- }
56
33
 
57
- @else {
58
- @each $property in $properties {
59
- --rui-local-#{$property}: var(--rui-Button--#{$priority}--#{$color}--#{$state}__#{$property});
34
+ @if not list.index(settings.$themeable-variants, $color) {
35
+ @error "Invalid variant specified! #{$color} doesn't exist. "
36
+ + "Choose one of #{settings.$themeable-variants}.";
37
+ }
38
+
39
+ @if not list.index(settings.$themeable-states, $state) {
40
+ @error "Invalid state specified! #{$state} doesn't exist. "
41
+ + "Choose one of #{settings.$themeable-states}.";
42
+ }
43
+
44
+ $properties: map.get(settings.$themeable-priority-properties, $priority);
45
+
46
+ // 2.
47
+ @if $state == "disabled" {
48
+ @each $property in $properties {
49
+ --rui-local-#{$property}:
50
+ var(
51
+ --rui-Button--#{$priority}--#{$color}--#{$state}__#{$property},
52
+ var(--rui-Button--#{$priority}--#{$color}--default__#{$property})
53
+ );
54
+ }
55
+ } @else {
56
+ @each $property in $properties {
57
+ --rui-local-#{$property}: var(--rui-Button--#{$priority}--#{$color}--#{$state}__#{$property});
58
+ }
60
59
  }
61
- }
62
60
  }
63
61
 
64
62
  // 4.
65
63
  @mixin _button-square() {
66
- --rui-local-padding: 0;
67
- --rui-local-width: var(--rui-local-height);
64
+ --rui-local-padding: 0;
65
+ --rui-local-width: var(--rui-local-height);
68
66
  }
69
67
 
70
68
  // 5.
71
69
  @mixin _button-size-restore() {
72
- --rui-local-padding: var(--rui-local-padding-original);
73
- --rui-local-width: unset;
70
+ --rui-local-padding: var(--rui-local-padding-original);
71
+ --rui-local-width: unset;
74
72
  }
75
73
 
76
74
  @mixin button() {
77
- @include transition.add((opacity, color, border-color, background-color, box-shadow));
78
-
79
- position: relative; // 3.
80
- display: inline-flex;
81
- column-gap: settings.$icon-spacing;
82
- align-items: center;
83
- justify-content: center;
84
- width: var(--rui-local-width, auto);
85
- height: var(--rui-local-height, auto);
86
- padding: var(--rui-local-padding);
87
- font: theme.$font-weight list.slash(var(--rui-local-font-size), settings.$line-height) settings.$font-family;
88
- letter-spacing: theme.$letter-spacing;
89
- text-align: center;
90
- text-decoration: none;
91
- text-transform: theme.$text-transform;
92
- vertical-align: middle;
93
- color: var(--rui-local-color);
94
- border: theme.$border-width solid var(--rui-local-border-color, transparent);
95
- border-radius: theme.$border-radius;
96
- background: var(--rui-local-background, transparent);
97
- box-shadow: var(--rui-local-box-shadow, none);
98
- user-select: none;
99
- cursor: pointer;
100
-
101
- &:hover,
102
- &:focus {
75
+ @include transition.add((opacity, color, border-color, background-color, box-shadow));
76
+
77
+ position: relative; // 3.
78
+ display: inline-flex;
79
+ column-gap: settings.$icon-spacing;
80
+ align-items: center;
81
+ justify-content: center;
82
+ width: var(--rui-local-width, auto);
83
+ min-height: var(--rui-local-height, auto);
84
+ padding: var(--rui-local-padding);
85
+ font: theme.$font-weight list.slash(var(--rui-local-font-size), settings.$line-height) settings.$font-family;
86
+ letter-spacing: theme.$letter-spacing;
87
+ text-align: center;
103
88
  text-decoration: none;
104
- }
89
+ text-transform: theme.$text-transform;
90
+ vertical-align: middle;
91
+ color: var(--rui-local-color);
92
+ border: theme.$border-width solid var(--rui-local-border-color, transparent);
93
+ border-radius: theme.$border-radius;
94
+ background: var(--rui-local-background, transparent);
95
+ box-shadow: var(--rui-local-box-shadow, none);
96
+ user-select: none;
97
+ cursor: pointer;
98
+
99
+ &:hover,
100
+ &:focus {
101
+ text-decoration: none;
102
+ }
105
103
 
106
- &:disabled {
107
- opacity: theme.$disabled-opacity;
108
- cursor: theme.$disabled-cursor;
109
- }
104
+ &:disabled {
105
+ opacity: theme.$disabled-opacity;
106
+ cursor: theme.$disabled-cursor;
107
+ }
110
108
 
111
- &:-moz-focusring {
112
- outline: 0;
113
- }
109
+ &:-moz-focusring {
110
+ outline: 0;
111
+ }
114
112
  }
115
113
 
116
114
  @mixin button-size($size) {
117
- $properties: map.get(theme.$sizes, $size);
115
+ $properties: map.get(theme.$sizes, $size);
118
116
 
119
- --rui-local-height: #{map.get($properties, height)};
120
- --rui-local-padding: 0 #{map.get($properties, padding-x)};
121
- --rui-local-padding-original: 0 #{map.get($properties, padding-x)}; // 5.
122
- --rui-local-font-size: #{map.get($properties, font-size)};
117
+ --rui-local-height: #{map.get($properties, height)};
118
+ --rui-local-padding: #{map.get($properties, padding-y)} #{map.get($properties, padding-x)};
119
+ --rui-local-padding-original: #{map.get($properties, padding-y)} #{map.get($properties, padding-x)}; // 5.
120
+ --rui-local-font-size: #{map.get($properties, font-size)};
123
121
  }
124
122
 
125
123
  @mixin button-color($priority, $color) {
126
- @include _get-themeable-properties($priority, $color, default);
124
+ @include _get-themeable-properties($priority, $color, default);
127
125
 
128
- &:disabled {
129
- @include _get-themeable-properties($priority, $color, disabled);
130
- }
126
+ &:disabled {
127
+ @include _get-themeable-properties($priority, $color, disabled);
128
+ }
131
129
 
132
- &:not(:disabled):hover,
133
- &:not(:disabled):focus {
134
- @include _get-themeable-properties($priority, $color, hover);
135
- }
130
+ &:not(:disabled):hover,
131
+ &:not(:disabled):focus {
132
+ @include _get-themeable-properties($priority, $color, hover);
133
+ }
136
134
 
137
- &:not(:disabled):active {
138
- @include _get-themeable-properties($priority, $color, active);
139
- }
135
+ &:not(:disabled):active {
136
+ @include _get-themeable-properties($priority, $color, active);
137
+ }
140
138
  }
141
139
 
142
140
  @mixin hide-label() {
143
- @include _button-square();
141
+ @include _button-square();
144
142
 
145
- .label {
146
- @include accessibility.hide-text();
147
- }
143
+ .label {
144
+ @include accessibility.hide-text();
145
+ }
148
146
  }
149
147
 
150
148
  @mixin show-label() {
151
- @include _button-size-restore();
149
+ @include _button-size-restore();
152
150
 
153
- .label {
154
- @include accessibility.unhide-text();
155
- }
151
+ .label {
152
+ @include accessibility.unhide-text();
153
+ }
156
154
  }
@@ -1,6 +1,8 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { withProviderContext } from '../../provider';
4
+ import { classNames } from '../../utils/classNames';
5
+ import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
4
6
  import styles from './ButtonGroup.scss';
5
7
  import { ButtonGroupContext } from './ButtonGroupContext';
6
8
 
@@ -11,30 +13,37 @@ export const ButtonGroup = ({
11
13
  priority,
12
14
  size,
13
15
  ...restProps
14
- }) => (
15
- <div
16
- className={[
17
- styles.root,
18
- block ? styles.isRootBlock : '',
19
- ].join(' ')}
20
- role="group"
21
- {...restProps}
22
- >
23
- <ButtonGroupContext.Provider
24
- value={{
25
- block,
26
- disabled,
27
- priority,
28
- size,
29
- }}
16
+ }) => {
17
+ if (isChildrenEmpty(children)) {
18
+ return null;
19
+ }
20
+
21
+ return (
22
+ <div
23
+ className={classNames(
24
+ styles.root,
25
+ block && styles.isRootBlock,
26
+ )}
27
+ role="group"
28
+ {...restProps}
30
29
  >
31
- {children}
32
- </ButtonGroupContext.Provider>
33
- </div>
34
- );
30
+ <ButtonGroupContext.Provider
31
+ value={{
32
+ block,
33
+ disabled,
34
+ priority,
35
+ size,
36
+ }}
37
+ >
38
+ {children}
39
+ </ButtonGroupContext.Provider>
40
+ </div>
41
+ );
42
+ };
35
43
 
36
44
  ButtonGroup.defaultProps = {
37
45
  block: false,
46
+ children: null,
38
47
  disabled: false,
39
48
  priority: 'filled',
40
49
  size: 'medium',
@@ -46,9 +55,9 @@ ButtonGroup.propTypes = {
46
55
  */
47
56
  block: PropTypes.bool,
48
57
  /**
49
- * Buttons to be grouped.
58
+ * Buttons to be grouped. If none are provided nothing is rendered.
50
59
  */
51
- children: PropTypes.node.isRequired,
60
+ children: PropTypes.node,
52
61
  /**
53
62
  * If `true`, all buttons inside the group will be disabled.
54
63
  */
@@ -1,8 +1,8 @@
1
1
  .root {
2
- display: inline-flex;
2
+ display: inline-flex;
3
3
  }
4
4
 
5
5
  .isRootBlock {
6
- display: flex;
7
- width: 100%;
6
+ display: flex;
7
+ width: 100%;
8
8
  }
@@ -44,11 +44,11 @@ See [API](#api) for all available options.
44
44
  - Use **short labels or icons** so the buttons can fit small screens.
45
45
 
46
46
  - For toggling between on/off states, use rather the
47
- [Toggle](/components/ui/toggle) component.
47
+ [Toggle](/components/toggle) component.
48
48
 
49
49
  - For switching between options in a form that needs to be submitted, use rather
50
- the [SelectField](/components/ui/select-field) or
51
- [Radio](/components/ui/radio) components.
50
+ the [SelectField](/components/select-field) or
51
+ [Radio](/components/radio) components.
52
52
 
53
53
  - Be careful with using `startCorner` and `endCorner` options for grouped
54
54
  buttons. Overflowing elements may cause undesired interaction problems.
@@ -65,7 +65,7 @@ different types or sizes.
65
65
  ## Priorities
66
66
 
67
67
  There are three **visual priorities** of buttons which exactly copy the
68
- priorities of the [Button](/components/ui/button) component:
68
+ priorities of the [Button](/components/button) component:
69
69
 
70
70
  1. filled
71
71
  2. outline
@@ -1,7 +1,8 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import getRootColorClassName from '../../helpers/getRootColorClassName';
4
3
  import { withProviderContext } from '../../provider';
4
+ import { classNames } from '../../utils/classNames';
5
+ import { getRootColorClassName } from '../_helpers/getRootColorClassName';
5
6
  import styles from './Card.scss';
6
7
 
7
8
  export const Card = ({
@@ -13,13 +14,13 @@ export const Card = ({
13
14
  color,
14
15
  }) => (
15
16
  <div
16
- className={[
17
+ className={classNames(
17
18
  styles.root,
18
19
  getRootColorClassName(color, styles),
19
- dense ? styles.rootDense : '',
20
- raised ? styles.rootRaised : '',
21
- disabled ? styles.isDisabled : '',
22
- ].join(' ')}
20
+ dense && styles.rootDense,
21
+ raised && styles.rootRaised,
22
+ disabled && styles.isDisabled,
23
+ )}
23
24
  id={id}
24
25
  >
25
26
  {children}
@@ -1,79 +1,79 @@
1
1
  // 1. Retain equal card widths in flex and grid layouts independently on their content.
2
2
 
3
- @use '../../styles/theme/colors';
4
- @use 'theme';
5
- @use 'tools';
3
+ @use "../../styles/theme/colors";
4
+ @use "theme";
5
+ @use "tools";
6
6
 
7
7
  .root {
8
- --rui-local-padding: #{theme.$padding};
8
+ --rui-local-padding: #{theme.$padding};
9
9
 
10
- display: flex;
11
- flex-direction: column;
12
- min-width: 0; // 1.
13
- color: var(--rui-local-color);
14
- border: theme.$border-width solid var(--rui-local-border-color);
15
- border-radius: theme.$border-radius;
16
- background-color: var(--rui-local-background-color);
10
+ display: flex;
11
+ flex-direction: column;
12
+ min-width: 0; // 1.
13
+ color: var(--rui-local-color);
14
+ border: theme.$border-width solid var(--rui-local-border-color);
15
+ border-radius: theme.$border-radius;
16
+ background-color: var(--rui-local-background-color);
17
17
  }
18
18
 
19
19
  .body {
20
- flex: 1 0 auto;
21
- padding: var(--rui-local-padding);
20
+ flex: 1 0 auto;
21
+ padding: var(--rui-local-padding);
22
22
  }
23
23
 
24
24
  .footer {
25
- padding: var(--rui-local-padding);
25
+ padding: var(--rui-local-padding);
26
26
  }
27
27
 
28
28
  .rootDense {
29
- --rui-local-padding: #{theme.$dense-padding};
29
+ --rui-local-padding: #{theme.$dense-padding};
30
30
  }
31
31
 
32
32
  .rootRaised {
33
- box-shadow: theme.$raised-box-shadow;
33
+ box-shadow: theme.$raised-box-shadow;
34
34
  }
35
35
 
36
36
  .rootColorPrimary {
37
- @include tools.color(primary);
37
+ @include tools.color(primary);
38
38
  }
39
39
 
40
40
  .rootColorSecondary {
41
- @include tools.color(secondary);
41
+ @include tools.color(secondary);
42
42
  }
43
43
 
44
44
  .rootColorSuccess {
45
- @include tools.color(success);
45
+ @include tools.color(success);
46
46
  }
47
47
 
48
48
  .rootColorWarning {
49
- @include tools.color(warning);
49
+ @include tools.color(warning);
50
50
  }
51
51
 
52
52
  .rootColorDanger {
53
- @include tools.color(danger);
53
+ @include tools.color(danger);
54
54
  }
55
55
 
56
56
  .rootColorHelp {
57
- @include tools.color(help);
57
+ @include tools.color(help);
58
58
  }
59
59
 
60
60
  .rootColorInfo {
61
- @include tools.color(info);
61
+ @include tools.color(info);
62
62
  }
63
63
 
64
64
  .rootColorNote {
65
- @include tools.color(note);
65
+ @include tools.color(note);
66
66
  }
67
67
 
68
68
  .rootColorLight {
69
- @include tools.color(light);
69
+ @include tools.color(light);
70
70
  }
71
71
 
72
72
  .rootColorDark {
73
- @include tools.color(dark);
73
+ @include tools.color(dark);
74
74
  }
75
75
 
76
76
  .isDisabled {
77
- background-color: theme.$disabled-background-color;
78
- opacity: theme.$disabled-opacity;
77
+ background-color: theme.$disabled-background-color;
78
+ opacity: theme.$disabled-opacity;
79
79
  }
@@ -3,17 +3,11 @@ import React from 'react';
3
3
  import { withProviderContext } from '../../provider';
4
4
  import styles from './Card.scss';
5
5
 
6
- export const CardBody = (props) => {
7
- const {
8
- children,
9
- } = props;
10
-
11
- return (
12
- <div className={styles.body}>
13
- {children}
14
- </div>
15
- );
16
- };
6
+ export const CardBody = ({ children }) => (
7
+ <div className={styles.body}>
8
+ {children}
9
+ </div>
10
+ );
17
11
 
18
12
  CardBody.propTypes = {
19
13
  /**
@@ -1,12 +1,13 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { withProviderContext } from '../../provider';
4
+ import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
4
5
  import styles from './Card.scss';
5
6
 
6
- export const CardFooter = (props) => {
7
- const {
8
- children,
9
- } = props;
7
+ export const CardFooter = ({ children }) => {
8
+ if (isChildrenEmpty(children)) {
9
+ return null;
10
+ }
10
11
 
11
12
  return (
12
13
  <div className={styles.footer}>
@@ -15,11 +16,15 @@ export const CardFooter = (props) => {
15
16
  );
16
17
  };
17
18
 
19
+ CardFooter.defaultProps = {
20
+ children: null,
21
+ };
22
+
18
23
  CardFooter.propTypes = {
19
24
  /**
20
25
  * Card actions, usually buttons.
21
26
  */
22
- children: PropTypes.node.isRequired,
27
+ children: PropTypes.node,
23
28
  };
24
29
 
25
30
  export const CardFooterWithContext = withProviderContext(CardFooter, 'CardFooter');
@@ -53,7 +53,7 @@ See [API](#api) for all available options.
53
53
  grid. It will help you keep the UI clean and easy to scan.
54
54
 
55
55
  - **Card, or Paper?** Card is a versatile surface for displaying content.
56
- However, there is also the [Paper](/components/ui/paper) component. While Card
56
+ However, there is also the [Paper](/components/paper) component. While Card
57
57
  is designed for displaying items (and also supports more visual options),
58
58
  Paper is usually used to hold larger content areas like lists, grids, or
59
59
  forms.
@@ -119,7 +119,7 @@ card should be also smaller to keep the card contained and easy to scan.
119
119
 
120
120
  ## Scrollable Card
121
121
 
122
- Combine Card with [ScrollView](/components/ui/scroll-view) to enable scrolling
122
+ Combine Card with [ScrollView](/components/scroll-view) to enable scrolling
123
123
  for card content.
124
124
 
125
125
  <Playground>