@react-ui-org/react-ui 0.44.0 → 0.46.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 (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
@@ -0,0 +1,11 @@
1
+ export const getRootClampClassName = (lines, styles) => {
2
+ if (lines === 1) {
3
+ return styles.rootClampSingleLine;
4
+ }
5
+
6
+ if (lines > 1) {
7
+ return styles.rootClampMultiLine;
8
+ }
9
+
10
+ return null;
11
+ };
@@ -1,4 +1,4 @@
1
- export default (hyphens, styles) => {
1
+ export const getRootHyphensClassName = (hyphens, styles) => {
2
2
  if (hyphens === 'auto') {
3
3
  return styles.rootHyphensAuto;
4
4
  }
@@ -1,4 +1,4 @@
1
- export default (wordWrapping, styles) => {
1
+ export const getRootWordWrappingClassName = (wordWrapping, styles) => {
2
2
  if (wordWrapping === 'anywhere') {
3
3
  return styles.rootWordWrappingAnywhere;
4
4
  }
@@ -350,7 +350,7 @@ It's possible to disable the whole input.
350
350
 
351
351
  In addition to the options below, you can specify [React synthetic events] or
352
352
  any custom HTML attributes that do not interfere with the API, and they will be
353
- passed to the `textarea` HTML element. This enables making the component
353
+ passed to the `<textarea>` HTML element. This enables making the component
354
354
  interactive and helps improve its [accessibility](#forwarding-html-attributes).
355
355
 
356
356
  <Props table of={TextArea} />
@@ -1,10 +1,11 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
- import getRootSizeClassName from '../../helpers/getRootSizeClassName';
4
- import getRootValidationStateClassName from '../../helpers/getRootValidationStateClassName';
5
- import { resolveContextOrProp } from '../../helpers/resolveContextOrProp';
6
3
  import { withProviderContext } from '../../provider';
7
- import transferProps from '../../utils/transferProps';
4
+ import { classNames } from '../../utils/classNames';
5
+ import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
6
+ import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
7
+ import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
8
+ import { transferProps } from '../_helpers/transferProps';
8
9
  import { FormLayoutContext } from '../FormLayout';
9
10
  import withForwardedRef from '../withForwardedRef';
10
11
  import styles from './TextArea.scss';
@@ -33,27 +34,27 @@ export const TextArea = ({
33
34
 
34
35
  return (
35
36
  <label
36
- className={[
37
+ className={classNames(
37
38
  styles.root,
38
- fullWidth ? styles.isRootFullWidth : '',
39
- context ? styles.isRootInFormLayout : '',
39
+ fullWidth && styles.isRootFullWidth,
40
+ context && styles.isRootInFormLayout,
40
41
  resolveContextOrProp(context && context.layout, layout) === 'horizontal'
41
42
  ? styles.rootLayoutHorizontal
42
43
  : styles.rootLayoutVertical,
43
- disabled ? styles.isRootDisabled : '',
44
- required ? styles.isRootRequired : '',
44
+ disabled && styles.isRootDisabled,
45
+ required && styles.isRootRequired,
45
46
  getRootSizeClassName(size, styles),
46
47
  getRootValidationStateClassName(validationState, styles),
47
48
  variant === 'filled' ? styles.rootVariantFilled : styles.rootVariantOutline,
48
- ].join(' ')}
49
+ )}
49
50
  htmlFor={id}
50
51
  id={id && `${id}__label`}
51
52
  >
52
53
  <div
53
- className={[
54
+ className={classNames(
54
55
  styles.label,
55
- isLabelVisible ? '' : styles.isLabelHidden,
56
- ].join(' ')}
56
+ !isLabelVisible && styles.isLabelHidden,
57
+ )}
57
58
  id={id && `${id}__labelText`}
58
59
  >
59
60
  {label}
@@ -191,7 +192,10 @@ TextArea.propTypes = {
191
192
  /**
192
193
  * Value of the input.
193
194
  */
194
- value: PropTypes.string,
195
+ value: PropTypes.oneOfType([
196
+ PropTypes.string,
197
+ PropTypes.number,
198
+ ]),
195
199
  /**
196
200
  * Design variant of the field, further customizable with CSS custom properties.
197
201
  */
@@ -1,95 +1,95 @@
1
- @use '../../styles/tools/form-fields/box-field-elements';
2
- @use '../../styles/tools/form-fields/box-field-layout';
3
- @use '../../styles/tools/form-fields/box-field-sizes';
4
- @use '../../styles/tools/form-fields/foundation';
5
- @use '../../styles/tools/form-fields/variants';
6
- @use '../../styles/tools/accessibility';
1
+ @use "../../styles/tools/form-fields/box-field-elements";
2
+ @use "../../styles/tools/form-fields/box-field-layout";
3
+ @use "../../styles/tools/form-fields/box-field-sizes";
4
+ @use "../../styles/tools/form-fields/foundation";
5
+ @use "../../styles/tools/form-fields/variants";
6
+ @use "../../styles/tools/accessibility";
7
7
 
8
8
  // Foundation
9
9
  .root {
10
- @include foundation.root();
10
+ @include foundation.root();
11
11
  }
12
12
 
13
13
  .label {
14
- @include foundation.label();
14
+ @include foundation.label();
15
15
  }
16
16
 
17
17
  .inputContainer {
18
- @include box-field-elements.input-container();
18
+ @include box-field-elements.input-container();
19
19
  }
20
20
 
21
21
  .input {
22
- @include box-field-elements.input();
23
- @include box-field-elements.input-textarea();
22
+ @include box-field-elements.input();
23
+ @include box-field-elements.input-textarea();
24
24
  }
25
25
 
26
26
  .bottomLine {
27
- @include box-field-elements.bottom-line();
27
+ @include box-field-elements.bottom-line();
28
28
  }
29
29
 
30
30
  .helpText,
31
31
  .validationText {
32
- @include foundation.help-text();
32
+ @include foundation.help-text();
33
33
  }
34
34
 
35
35
  .isRootRequired .label {
36
- @include foundation.label-required();
36
+ @include foundation.label-required();
37
37
  }
38
38
 
39
39
  // Visual variants
40
40
  .rootVariantFilled {
41
- @include variants.visual(box, $variant: filled);
41
+ @include variants.visual(box, $variant: filled);
42
42
  }
43
43
 
44
44
  .rootVariantOutline {
45
- @include variants.visual(box, $variant: outline);
45
+ @include variants.visual(box, $variant: outline);
46
46
  }
47
47
 
48
48
  // States
49
49
  .isRootStateInvalid {
50
- @include variants.validation(invalid);
50
+ @include variants.validation(invalid);
51
51
  }
52
52
 
53
53
  .isRootStateValid {
54
- @include variants.validation(valid);
54
+ @include variants.validation(valid);
55
55
  }
56
56
 
57
57
  .isRootStateWarning {
58
- @include variants.validation(warning);
58
+ @include variants.validation(warning);
59
59
  }
60
60
 
61
61
  // Invisible label
62
62
  .isLabelHidden {
63
- @include accessibility.hide-text();
63
+ @include accessibility.hide-text();
64
64
  }
65
65
 
66
66
  // Layouts
67
67
  .rootLayoutVertical,
68
68
  .rootLayoutHorizontal {
69
- @include box-field-layout.vertical();
69
+ @include box-field-layout.vertical();
70
70
  }
71
71
 
72
72
  .rootLayoutHorizontal {
73
- @include box-field-layout.horizontal();
73
+ @include box-field-layout.horizontal();
74
74
  }
75
75
 
76
76
  .isRootFullWidth {
77
- @include box-field-layout.full-width();
77
+ @include box-field-layout.full-width();
78
78
  }
79
79
 
80
80
  .isRootInFormLayout {
81
- @include box-field-layout.in-form-layout();
81
+ @include box-field-layout.in-form-layout();
82
82
  }
83
83
 
84
84
  // Sizes
85
85
  .rootSizeSmall {
86
- @include box-field-sizes.size(small, $is-multiline: true);
86
+ @include box-field-sizes.size(small, $is-multiline: true);
87
87
  }
88
88
 
89
89
  .rootSizeMedium {
90
- @include box-field-sizes.size(medium, $is-multiline: true);
90
+ @include box-field-sizes.size(medium, $is-multiline: true);
91
91
  }
92
92
 
93
93
  .rootSizeLarge {
94
- @include box-field-sizes.size(large, $is-multiline: true);
94
+ @include box-field-sizes.size(large, $is-multiline: true);
95
95
  }
@@ -493,7 +493,7 @@ It's possible to disable the whole input.
493
493
 
494
494
  In addition to the options below, you can specify [React synthetic events] or
495
495
  any custom HTML attributes that do not interfere with the API, and they will be
496
- passed to the `input` HTML element. This enables making the component
496
+ passed to the `<input>` HTML element. This enables making the component
497
497
  interactive and helps improve its [accessibility](#forwarding-html-attributes).
498
498
 
499
499
  <Props table of={TextField} />
@@ -1,10 +1,11 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
- import getRootSizeClassName from '../../helpers/getRootSizeClassName';
4
- import getRootValidationStateClassName from '../../helpers/getRootValidationStateClassName';
5
- import { resolveContextOrProp } from '../../helpers/resolveContextOrProp';
6
3
  import { withProviderContext } from '../../provider';
7
- import transferProps from '../../utils/transferProps';
4
+ import { classNames } from '../../utils/classNames';
5
+ import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
6
+ import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
7
+ import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
8
+ import { transferProps } from '../_helpers/transferProps';
8
9
  import { FormLayoutContext } from '../FormLayout';
9
10
  import withForwardedRef from '../withForwardedRef';
10
11
  import styles from './TextField.scss';
@@ -36,29 +37,30 @@ export const TextField = ({
36
37
 
37
38
  return (
38
39
  <label
39
- className={[
40
+ className={classNames(
40
41
  styles.root,
41
- fullWidth ? styles.isRootFullWidth : '',
42
- hasSmallInput ? styles.hasRootSmallInput : '',
43
- context ? styles.isRootInFormLayout : '',
42
+ fullWidth && styles.isRootFullWidth,
43
+ hasSmallInput && styles.hasRootSmallInput,
44
+ inputSize && styles.hasRootCustomInputSize,
45
+ context && styles.isRootInFormLayout,
44
46
  resolveContextOrProp(context && context.layout, layout) === 'horizontal'
45
47
  ? styles.rootLayoutHorizontal
46
48
  : styles.rootLayoutVertical,
47
- disabled ? styles.isRootDisabled : '',
48
- required ? styles.isRootRequired : '',
49
+ disabled && styles.isRootDisabled,
50
+ required && styles.isRootRequired,
49
51
  getRootSizeClassName(size, styles),
50
52
  getRootValidationStateClassName(validationState, styles),
51
53
  variant === 'filled' ? styles.rootVariantFilled : styles.rootVariantOutline,
52
- ].join(' ')}
54
+ )}
53
55
  htmlFor={id}
54
56
  id={id && `${id}__label`}
55
57
  {...(inputSize ? { style: { '--rui-custom-input-size': inputSize } } : {})}
56
58
  >
57
59
  <div
58
- className={[
60
+ className={classNames(
59
61
  styles.label,
60
- isLabelVisible ? '' : styles.isLabelHidden,
61
- ].join(' ')}
62
+ !isLabelVisible && styles.isLabelHidden,
63
+ )}
62
64
  id={id && `${id}__labelText`}
63
65
  >
64
66
  {label}
@@ -1,102 +1,102 @@
1
- @use '../../styles/tools/form-fields/box-field-elements';
2
- @use '../../styles/tools/form-fields/box-field-layout';
3
- @use '../../styles/tools/form-fields/box-field-sizes';
4
- @use '../../styles/tools/form-fields/foundation';
5
- @use '../../styles/tools/form-fields/variants';
6
- @use '../../styles/tools/accessibility';
1
+ @use "../../styles/tools/form-fields/box-field-elements";
2
+ @use "../../styles/tools/form-fields/box-field-layout";
3
+ @use "../../styles/tools/form-fields/box-field-sizes";
4
+ @use "../../styles/tools/form-fields/foundation";
5
+ @use "../../styles/tools/form-fields/variants";
6
+ @use "../../styles/tools/accessibility";
7
7
 
8
8
  // Foundation
9
9
  .root {
10
- @include foundation.root();
10
+ @include foundation.root();
11
11
  }
12
12
 
13
13
  .label {
14
- @include foundation.label();
14
+ @include foundation.label();
15
15
  }
16
16
 
17
17
  .inputContainer {
18
- @include box-field-elements.input-container();
18
+ @include box-field-elements.input-container();
19
19
  }
20
20
 
21
21
  .input {
22
- @include box-field-elements.input();
22
+ @include box-field-elements.input();
23
23
  }
24
24
 
25
25
  .bottomLine {
26
- @include box-field-elements.bottom-line();
26
+ @include box-field-elements.bottom-line();
27
27
  }
28
28
 
29
29
  .helpText,
30
30
  .validationText {
31
- @include foundation.help-text();
31
+ @include foundation.help-text();
32
32
  }
33
33
 
34
34
  .hasRootCustomInputSize .input {
35
- @include box-field-elements.input-size();
35
+ @include box-field-elements.input-size();
36
36
  }
37
37
 
38
38
  .isRootRequired .label {
39
- @include foundation.label-required();
39
+ @include foundation.label-required();
40
40
  }
41
41
 
42
42
  // Variants
43
43
  .rootVariantFilled {
44
- @include variants.visual(box, $variant: filled);
44
+ @include variants.visual(box, $variant: filled);
45
45
  }
46
46
 
47
47
  .rootVariantOutline {
48
- @include variants.visual(box, $variant: outline);
48
+ @include variants.visual(box, $variant: outline);
49
49
  }
50
50
 
51
51
  // States
52
52
  .isRootStateInvalid {
53
- @include variants.validation(invalid);
53
+ @include variants.validation(invalid);
54
54
  }
55
55
 
56
56
  .isRootStateValid {
57
- @include variants.validation(valid);
57
+ @include variants.validation(valid);
58
58
  }
59
59
 
60
60
  .isRootStateWarning {
61
- @include variants.validation(warning);
61
+ @include variants.validation(warning);
62
62
  }
63
63
 
64
64
  // Invisible label
65
65
  .isLabelHidden {
66
- @include accessibility.hide-text();
66
+ @include accessibility.hide-text();
67
67
  }
68
68
 
69
69
  // Layouts
70
70
  .rootLayoutVertical,
71
71
  .rootLayoutHorizontal {
72
- @include box-field-layout.vertical();
72
+ @include box-field-layout.vertical();
73
73
  }
74
74
 
75
75
  .rootLayoutHorizontal {
76
- @include box-field-layout.horizontal();
76
+ @include box-field-layout.horizontal();
77
77
  }
78
78
 
79
79
  .isRootFullWidth {
80
- @include box-field-layout.full-width();
80
+ @include box-field-layout.full-width();
81
81
  }
82
82
 
83
83
  .isRootInFormLayout {
84
- @include box-field-layout.in-form-layout();
84
+ @include box-field-layout.in-form-layout();
85
85
  }
86
86
 
87
87
  .hasRootSmallInput.rootLayoutHorizontal {
88
- @include box-field-layout.horizontal-with-small-input();
88
+ @include box-field-layout.horizontal-with-small-input();
89
89
  }
90
90
 
91
91
  // Sizes
92
92
  .rootSizeSmall {
93
- @include box-field-sizes.size(small);
93
+ @include box-field-sizes.size(small);
94
94
  }
95
95
 
96
96
  .rootSizeMedium {
97
- @include box-field-sizes.size(medium);
97
+ @include box-field-sizes.size(medium);
98
98
  }
99
99
 
100
100
  .rootSizeLarge {
101
- @include box-field-sizes.size(large);
101
+ @include box-field-sizes.size(large);
102
102
  }
@@ -0,0 +1,77 @@
1
+ ---
2
+ name: TextLink
3
+ menu: 'Actions'
4
+ route: /components/text-link
5
+ ---
6
+
7
+ # TextLink
8
+
9
+ import {
10
+ Playground,
11
+ Props,
12
+ } from 'docz'
13
+ import { TextLink } from './TextLink'
14
+
15
+ TextLink allows users to follow navigation.
16
+
17
+ ## Basic Usage
18
+
19
+ To implement the TextLink component, you need to import it first:
20
+
21
+ ```js
22
+ import { TextLink } from '@react-ui-org/react-ui';
23
+ ```
24
+
25
+ And use it:
26
+
27
+ <Playground>
28
+ <TextLink
29
+ href="/contribute/guidelines"
30
+ label="How can I contribute to React UI?"
31
+ />
32
+ </Playground>
33
+
34
+ See [API](#api) for all available options.
35
+
36
+ ## General Guidelines
37
+
38
+ **Avoid using links for actions**, use a [Button](/components/button)
39
+ instead. This is because users expect navigation to happen when clicking on
40
+ something what looks like a link.
41
+
42
+ ## Custom Routing
43
+
44
+ It's common to use custom function for routing within SPAs. Use the
45
+ `onClick` option to provide such function.
46
+
47
+ <Playground>
48
+ <TextLink
49
+ href="/contribute/guidelines"
50
+ label="This link is controlled by custom function"
51
+ onClick={(event) => {
52
+ event.preventDefault();
53
+ alert('You will be redirected.')
54
+ window.location = event.currentTarget.getAttribute('href');
55
+ }}
56
+ />
57
+ </Playground>
58
+
59
+ ## API
60
+
61
+ In addition to the options below, you can specify [React synthetic events] or
62
+ any custom HTML attributes that do not interfere with the API, and they will be
63
+ passed to the `<a>` HTML element. This enables making the component interactive
64
+ and helps improve its accessibility.
65
+
66
+ <Props table of={TextLink} />
67
+
68
+ ## Theming
69
+
70
+ | Custom Property | Description |
71
+ |------------------------------------------|-----------------------------------|
72
+ | `--rui-TextLink__color` | Text color |
73
+ | `--rui-TextLink__text-decoration` | Text decoration, e.g. underline |
74
+ | `--rui-TextLink--hover__color` | Text color on hover |
75
+ | `--rui-TextLink--hover__text-decoration` | Text decoration on hover |
76
+
77
+ [React synthetic events]: https://reactjs.org/docs/events.html
@@ -1,13 +1,13 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import transferProps from '../../utils/transferProps';
4
3
  import { withProviderContext } from '../../provider';
5
- import styles from './Link.scss';
4
+ import { transferProps } from '../_helpers/transferProps';
5
+ import styles from './TextLink.scss';
6
6
 
7
- export const Link = ({
8
- children,
7
+ export const TextLink = ({
9
8
  href,
10
9
  id,
10
+ label,
11
11
  ...restProps
12
12
  }) => (
13
13
  <a
@@ -16,20 +16,15 @@ export const Link = ({
16
16
  className={styles.root}
17
17
  id={id}
18
18
  >
19
- {children}
19
+ {label}
20
20
  </a>
21
21
  );
22
22
 
23
- Link.defaultProps = {
24
- children: null,
23
+ TextLink.defaultProps = {
25
24
  id: undefined,
26
25
  };
27
26
 
28
- Link.propTypes = {
29
- /**
30
- * Content of the link.
31
- */
32
- children: PropTypes.node,
27
+ TextLink.propTypes = {
33
28
  /**
34
29
  * Link's `href` attribute.
35
30
  */
@@ -38,8 +33,12 @@ Link.propTypes = {
38
33
  * ID of the root HTML element.
39
34
  */
40
35
  id: PropTypes.string,
36
+ /**
37
+ * Link label.
38
+ */
39
+ label: PropTypes.string.isRequired,
41
40
  };
42
41
 
43
- export const LinkWithContext = withProviderContext(Link, 'Link');
42
+ export const LinkWithContext = withProviderContext(TextLink, 'Link');
44
43
 
45
44
  export default LinkWithContext;
@@ -0,0 +1,11 @@
1
+ @use "theme";
2
+
3
+ .root {
4
+ text-decoration: theme.$text-decoration;
5
+ color: theme.$color;
6
+
7
+ &:hover {
8
+ text-decoration: theme.$hover-text-decoration;
9
+ color: theme.$hover-color;
10
+ }
11
+ }
@@ -0,0 +1,4 @@
1
+ $color: var(--rui-TextLink__color);
2
+ $text-decoration: var(--rui-TextLink__text-decoration);
3
+ $hover-color: var(--rui-TextLink--hover__color);
4
+ $hover-text-decoration: var(--rui-TextLink--hover__text-decoration);
@@ -0,0 +1 @@
1
+ export { default } from './TextLink';
@@ -44,7 +44,7 @@ See [API](#api) for all available options.
44
44
  - Use the toggle only for boolean (true/false) input **with an immediate effect
45
45
  (without confirmation)**. To toggle things on or off in forms that require to
46
46
  be submitted by a button, use rather the
47
- [CheckboxField](/components/ui/checkbox-field) component.
47
+ [CheckboxField](/components/checkbox-field) component.
48
48
 
49
49
  - **Use positive wording for the toggle label,** so that it's clear what will
50
50
  happen when the user turns on the toggle. Avoid negations such as “Don't send
@@ -63,7 +63,7 @@ See [API](#api) for all available options.
63
63
  - The toggle is designed for **switching things on and off.** Don't use it to
64
64
  switch between two different things that cannot be described as on or off
65
65
  using a single label, e.g. different viewing modes. In such cases, consider
66
- using the [ButtonGroup](/components/ui/button-group) component.
66
+ using the [ButtonGroup](/components/button-group) component.
67
67
 
68
68
  ## Help Text
69
69
 
@@ -181,7 +181,7 @@ Disabled state makes the input unavailable.
181
181
 
182
182
  In addition to the options below, you can specify [React synthetic events] or
183
183
  any custom HTML attributes that do not interfere with the API, and they will be
184
- passed to the `input` HTML element. This enables making the component
184
+ passed to the `<input>` HTML element. This enables making the component
185
185
  interactive and helps improve its accessibility.
186
186
 
187
187
  <Props table of={Toggle} />
@@ -1,8 +1,9 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
- import getRootValidationStateClassName from '../../helpers/getRootValidationStateClassName';
4
3
  import { withProviderContext } from '../../provider';
5
- import transferProps from '../../utils/transferProps';
4
+ import { classNames } from '../../utils/classNames';
5
+ import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
6
+ import { transferProps } from '../_helpers/transferProps';
6
7
  import { FormLayoutContext } from '../FormLayout';
7
8
  import withForwardedRef from '../withForwardedRef';
8
9
  import styles from './Toggle.scss';
@@ -26,19 +27,28 @@ export const Toggle = ({
26
27
 
27
28
  return (
28
29
  <label
29
- className={[
30
+ className={classNames(
30
31
  styles.root,
31
- context ? styles.isRootInFormLayout : '',
32
+ context && styles.isRootInFormLayout,
32
33
  context && context.layout === 'horizontal' ? styles.rootLayoutHorizontal : styles.rootLayoutVertical,
33
- labelPosition === 'before' ? styles.hasRootLabelBefore : '',
34
- disabled ? styles.isRootDisabled : '',
35
- required ? styles.isRootRequired : '',
34
+ labelPosition === 'before' && styles.hasRootLabelBefore,
35
+ disabled && styles.isRootDisabled,
36
+ required && styles.isRootRequired,
36
37
  getRootValidationStateClassName(validationState, styles),
37
- ].join(' ')}
38
+ )}
38
39
  htmlFor={id}
39
40
  id={id && `${id}__label`}
40
41
  >
41
42
  <div className={styles.field}>
43
+ <div
44
+ className={classNames(
45
+ styles.label,
46
+ !isLabelVisible && styles.isLabelHidden,
47
+ )}
48
+ id={id && `${id}__labelText`}
49
+ >
50
+ {label}
51
+ </div>
42
52
  <input
43
53
  {...transferProps(restProps)}
44
54
  checked={checked}
@@ -51,15 +61,6 @@ export const Toggle = ({
51
61
  type="checkbox"
52
62
  value={value}
53
63
  />
54
- <div
55
- className={[
56
- styles.label,
57
- isLabelVisible ? '' : styles.isLabelHidden,
58
- ].join(' ')}
59
- id={id && `${id}__labelText`}
60
- >
61
- {label}
62
- </div>
63
64
  </div>
64
65
  {helpText && (
65
66
  <div