@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
@@ -1,104 +1,104 @@
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-select();
24
- @include box-field-elements.input-select-option();
22
+ @include box-field-elements.input();
23
+ @include box-field-elements.input-select();
24
+ @include box-field-elements.input-select-option();
25
25
  }
26
26
 
27
27
  .caret {
28
- @include box-field-elements.caret();
28
+ @include box-field-elements.caret();
29
29
  }
30
30
 
31
31
  .caretIcon {
32
- @include box-field-elements.caret-icon();
32
+ @include box-field-elements.caret-icon();
33
33
  }
34
34
 
35
35
  .bottomLine {
36
- @include box-field-elements.bottom-line();
36
+ @include box-field-elements.bottom-line();
37
37
  }
38
38
 
39
39
  .helpText,
40
40
  .validationText {
41
- @include foundation.help-text();
41
+ @include foundation.help-text();
42
42
  }
43
43
 
44
44
  .isRootRequired .label {
45
- @include foundation.label-required();
45
+ @include foundation.label-required();
46
46
  }
47
47
 
48
48
  // Variants
49
49
  .rootVariantFilled {
50
- @include variants.visual(box, $variant: filled, $has-caret: true);
50
+ @include variants.visual(box, $variant: filled, $has-caret: true);
51
51
  }
52
52
 
53
53
  .rootVariantOutline {
54
- @include variants.visual(box, $variant: outline, $has-caret: true);
54
+ @include variants.visual(box, $variant: outline, $has-caret: true);
55
55
  }
56
56
 
57
57
  // States
58
58
  .isRootStateInvalid {
59
- @include variants.validation(invalid);
59
+ @include variants.validation(invalid);
60
60
  }
61
61
 
62
62
  .isRootStateValid {
63
- @include variants.validation(valid);
63
+ @include variants.validation(valid);
64
64
  }
65
65
 
66
66
  .isRootStateWarning {
67
- @include variants.validation(warning);
67
+ @include variants.validation(warning);
68
68
  }
69
69
 
70
70
  // Invisible label
71
71
  .isLabelHidden {
72
- @include accessibility.hide-text();
72
+ @include accessibility.hide-text();
73
73
  }
74
74
 
75
75
  // Layouts
76
76
  .rootLayoutVertical,
77
77
  .rootLayoutHorizontal {
78
- @include box-field-layout.vertical();
78
+ @include box-field-layout.vertical();
79
79
  }
80
80
 
81
81
  .rootLayoutHorizontal {
82
- @include box-field-layout.horizontal();
82
+ @include box-field-layout.horizontal();
83
83
  }
84
84
 
85
85
  .isRootFullWidth {
86
- @include box-field-layout.full-width();
86
+ @include box-field-layout.full-width();
87
87
  }
88
88
 
89
89
  .isRootInFormLayout {
90
- @include box-field-layout.in-form-layout();
90
+ @include box-field-layout.in-form-layout();
91
91
  }
92
92
 
93
93
  // Sizes
94
94
  .rootSizeSmall {
95
- @include box-field-sizes.size(small);
95
+ @include box-field-sizes.size(small);
96
96
  }
97
97
 
98
98
  .rootSizeMedium {
99
- @include box-field-sizes.size(medium);
99
+ @include box-field-sizes.size(medium);
100
100
  }
101
101
 
102
102
  .rootSizeLarge {
103
- @include box-field-sizes.size(large);
103
+ @include box-field-sizes.size(large);
104
104
  }
@@ -77,16 +77,16 @@ See [API](#api) for all available options.
77
77
 
78
78
  - Tables are **good for displaying complex tabular data.** For simpler data sets
79
79
  or even plain key-value pairs, consider using the
80
- [List](/components/layout/list) component.
80
+ [List](/components/list) component.
81
81
 
82
82
  - Tables make **lots of information easier to scan and compare.** If you have
83
83
  fewer sections and want to emphasize each group more, consider using
84
- [Cards](/components/ui/card).
84
+ [Cards](/components/card).
85
85
 
86
86
  ## Responsive Tables
87
87
 
88
88
  The easiest way to make tables responsive is to wrap them with the
89
- [ScrollView](/components/ui/scroll-view) component in the horizontal mode.
89
+ [ScrollView](/components/scroll-view) component in the horizontal mode.
90
90
 
91
91
  <Playground>
92
92
  <ScrollView direction="horizontal" shadowSize="100px">
@@ -1,59 +1,52 @@
1
- @use '../../styles/tools/transition';
2
- @use 'settings';
3
-
4
- // Ignore pascalCase values of `composes` property:
5
- // stylelint-disable value-keyword-case
1
+ @use "../../styles/tools/transition";
2
+ @use "settings";
6
3
 
7
4
  .table {
8
- width: 100%;
9
- border-collapse: collapse;
5
+ width: 100%;
6
+ border-collapse: collapse;
10
7
  }
11
8
 
12
- .tableRow {
13
- @include transition.add((background-color));
9
+ .tableRow,
10
+ .tableHeadRow {
11
+ @include transition.add((background-color));
12
+ }
14
13
 
15
- background-color: settings.$background-color;
14
+ .tableRow {
15
+ background-color: settings.$background-color;
16
16
 
17
- &:hover {
18
- background-color: settings.$hover-background-color;
19
- }
17
+ &:hover {
18
+ background-color: settings.$hover-background-color;
19
+ }
20
20
  }
21
21
 
22
22
  .tableHeadRow {
23
- composes: tableRow;
24
- background-color: settings.$head-background-color;
25
-
26
- &:hover {
27
23
  background-color: settings.$head-background-color;
28
- }
29
- }
30
-
31
- .tableCell {
32
- padding: settings.$cell-padding-y settings.$cell-padding-x;
33
- text-align: left;
34
- border-bottom: settings.$border-width solid settings.$border-color;
35
- }
36
24
 
37
- .tableHeadCell {
38
- composes: tableCell;
39
- font-weight: settings.$head-font-weight;
40
- border-bottom-width: 2px;
25
+ &:hover {
26
+ background-color: settings.$head-background-color;
27
+ }
41
28
  }
42
29
 
30
+ .tableCell,
31
+ .tableHeadCell,
43
32
  .isTableCellSortingActive,
44
33
  .isTableHeadCellSortingActive {
45
- background-color: settings.$sorted-background-color;
34
+ padding: settings.$cell-padding-y settings.$cell-padding-x;
35
+ text-align: left;
36
+ border-bottom: settings.$border-width solid settings.$border-color;
46
37
  }
47
38
 
48
- .isTableCellSortingActive {
49
- composes: tableCell;
39
+ .tableHeadCell {
40
+ font-weight: settings.$head-font-weight;
41
+ border-bottom-width: 2px;
50
42
  }
51
43
 
44
+ .isTableCellSortingActive,
52
45
  .isTableHeadCellSortingActive {
53
- composes: tableHeadCell;
46
+ background-color: settings.$sorted-background-color;
54
47
  }
55
48
 
56
49
  .sortButton {
57
- display: inline-block;
58
- margin-right: settings.$cell-padding-x;
50
+ display: inline-block;
51
+ margin-right: settings.$cell-padding-x;
59
52
  }
@@ -1,8 +1,8 @@
1
- @use 'sass:map';
2
- @use '../../styles/theme/borders';
3
- @use '../../styles/theme/colors';
4
- @use '../../styles/theme/typography';
5
- @use '../../styles/tools/spacing';
1
+ @use "sass:map";
2
+ @use "../../styles/theme/borders";
3
+ @use "../../styles/theme/colors";
4
+ @use "../../styles/theme/typography";
5
+ @use "../../styles/tools/spacing";
6
6
 
7
7
  $cell-padding-x: spacing.of(3);
8
8
  $cell-padding-y: spacing.of(1);
@@ -119,7 +119,7 @@ for each tab and don't leave some tabs without an icon.
119
119
 
120
120
  If you have more than a few tabs, you may need to make sure they will be all
121
121
  accessible no matter the space they have around. Wrap Tabs into
122
- [ScrollView](/components/ui/scroll-view) to make them scrollable if necessary.
122
+ [ScrollView](/components/scroll-view) to make them scrollable if necessary.
123
123
 
124
124
  <Playground>
125
125
  {() => {
@@ -18,7 +18,6 @@ export const Tabs = ({
18
18
  );
19
19
 
20
20
  Tabs.defaultProps = {
21
- children: null,
22
21
  id: undefined,
23
22
  };
24
23
 
@@ -26,7 +25,7 @@ Tabs.propTypes = {
26
25
  /**
27
26
  * Nested `TabsItem` elements.
28
27
  */
29
- children: PropTypes.node,
28
+ children: PropTypes.node.isRequired,
30
29
  /**
31
30
  * ID of the root HTML element. It also serves as base for nested element:
32
31
  * * `<ID>__list`
@@ -1,28 +1,28 @@
1
1
  // 1. Decorative bottom border.
2
2
 
3
- @use '../../styles/tools/reset';
4
- @use 'theme';
3
+ @use "../../styles/tools/reset";
4
+ @use "theme";
5
5
 
6
6
  .list {
7
- @include reset.list();
7
+ @include reset.list();
8
8
 
9
- position: relative;
10
- display: inline-flex;
11
- min-width: 100%;
12
- padding-right: theme.$padding-x;
13
- padding-left: theme.$padding-x;
14
- overflow-y: hidden;
15
- white-space: nowrap;
9
+ position: relative;
10
+ display: inline-flex;
11
+ min-width: 100%;
12
+ padding-right: theme.$padding-x;
13
+ padding-left: theme.$padding-x;
14
+ overflow-y: hidden;
15
+ white-space: nowrap;
16
16
 
17
- // 1.
18
- &::after {
19
- content: '';
20
- position: absolute;
21
- right: 0;
22
- bottom: 0;
23
- left: 0;
24
- z-index: 1;
25
- height: theme.$border-bottom-width;
26
- background-color: theme.$border-bottom-color;
27
- }
17
+ // 1.
18
+ &::after {
19
+ content: "";
20
+ position: absolute;
21
+ right: 0;
22
+ bottom: 0;
23
+ left: 0;
24
+ z-index: 1;
25
+ height: theme.$border-bottom-width;
26
+ background-color: theme.$border-bottom-color;
27
+ }
28
28
  }
@@ -1,6 +1,7 @@
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';
4
5
  import styles from './TabsItem.scss';
5
6
 
6
7
  export const TabsItem = ({
@@ -13,10 +14,10 @@ export const TabsItem = ({
13
14
  onClick,
14
15
  }) => (
15
16
  <li
16
- className={[
17
+ className={classNames(
17
18
  styles.root,
18
- isActive ? styles.isRootActive : null,
19
- ].join(' ')}
19
+ isActive && styles.isRootActive,
20
+ )}
20
21
  id={id}
21
22
  key={href}
22
23
  >
@@ -1,118 +1,118 @@
1
1
  // 1. Keep inactive items under Tabs' decorative bottom border and pop active ones above it.
2
2
 
3
- @use '../../styles/tools/breakpoint';
4
- @use '../../styles/tools/reset';
5
- @use '../../styles/tools/transition';
6
- @use 'theme';
3
+ @use "../../styles/tools/breakpoint";
4
+ @use "../../styles/tools/reset";
5
+ @use "../../styles/tools/transition";
6
+ @use "theme";
7
7
 
8
8
  .root {
9
- @include transition.add(transform);
10
-
11
- position: relative; // 1.
12
- z-index: 1; // 1.
13
- flex: none;
14
- padding-top: calc(-1 * #{theme.$item-active-shift-y});
15
- margin-bottom: theme.$item-active-shift-y;
16
- transform: translateY(0);
17
-
18
- &:hover,
19
- &:focus-within {
20
- transform: translateY(theme.$item-hover-shift-y);
21
- }
22
-
23
- &:not(:last-child) {
24
- margin-right: theme.$gap-xs;
25
- }
9
+ @include transition.add(transform);
10
+
11
+ position: relative; // 1.
12
+ z-index: 1; // 1.
13
+ flex: none;
14
+ padding-top: calc(-1 * #{theme.$item-active-shift-y});
15
+ margin-bottom: theme.$item-active-shift-y;
16
+ transform: translateY(0);
17
+
18
+ &:hover,
19
+ &:focus-within {
20
+ transform: translateY(theme.$item-hover-shift-y);
21
+ }
26
22
 
27
- @include breakpoint.up(sm) {
28
23
  &:not(:last-child) {
29
- margin-right: theme.$gap-sm;
24
+ margin-right: theme.$gap-xs;
30
25
  }
31
- }
32
26
 
33
- @include breakpoint.up(md) {
34
- &:not(:last-child) {
35
- margin-right: theme.$gap-md;
27
+ @include breakpoint.up(sm) {
28
+ &:not(:last-child) {
29
+ margin-right: theme.$gap-sm;
30
+ }
31
+ }
32
+
33
+ @include breakpoint.up(md) {
34
+ &:not(:last-child) {
35
+ margin-right: theme.$gap-md;
36
+ }
36
37
  }
37
- }
38
38
  }
39
39
 
40
40
  .link {
41
- @include reset.link();
42
- @include transition.add((color, border-color, background-color, box-shadow));
43
-
44
- display: block;
45
- padding: theme.$item-padding-xs;
46
- font-weight: theme.$item-font-weight;
47
- line-height: 1;
48
- text-decoration: none;
49
- color: theme.$item-color;
50
- border-width: theme.$item-border-width;
51
- border-style: solid;
52
- border-color: theme.$item-border-color;
53
- border-top-left-radius: theme.$item-border-radius;
54
- border-top-right-radius: theme.$item-border-radius;
55
- background-color: theme.$item-background-color;
56
- box-shadow: theme.$item-box-shadow;
57
-
58
- &:hover,
59
- &:focus {
60
- font-weight: theme.$item-hover-font-weight;
61
- color: theme.$item-hover-color;
62
- border-width: theme.$item-hover-border-width;
63
- border-color: theme.$item-hover-border-color;
64
- background-color: theme.$item-hover-background-color;
65
- box-shadow: theme.$item-hover-box-shadow;
66
- }
67
-
68
- @include breakpoint.up(sm) {
69
- padding: theme.$item-padding-sm;
70
- }
71
-
72
- @include breakpoint.up(md) {
73
- padding: theme.$item-padding-md;
74
- }
41
+ @include reset.link();
42
+ @include transition.add((color, border-color, background-color, box-shadow));
43
+
44
+ display: block;
45
+ padding: theme.$item-padding-xs;
46
+ font-weight: theme.$item-font-weight;
47
+ line-height: 1;
48
+ text-decoration: none;
49
+ color: theme.$item-color;
50
+ border-width: theme.$item-border-width;
51
+ border-style: solid;
52
+ border-color: theme.$item-border-color;
53
+ border-top-left-radius: theme.$item-border-radius;
54
+ border-top-right-radius: theme.$item-border-radius;
55
+ background-color: theme.$item-background-color;
56
+ box-shadow: theme.$item-box-shadow;
57
+
58
+ &:hover,
59
+ &:focus {
60
+ font-weight: theme.$item-hover-font-weight;
61
+ color: theme.$item-hover-color;
62
+ border-width: theme.$item-hover-border-width;
63
+ border-color: theme.$item-hover-border-color;
64
+ background-color: theme.$item-hover-background-color;
65
+ box-shadow: theme.$item-hover-box-shadow;
66
+ }
67
+
68
+ @include breakpoint.up(sm) {
69
+ padding: theme.$item-padding-sm;
70
+ }
71
+
72
+ @include breakpoint.up(md) {
73
+ padding: theme.$item-padding-md;
74
+ }
75
75
  }
76
76
 
77
77
  .linkContent {
78
- @include transition.add(transform);
78
+ @include transition.add(transform);
79
79
 
80
- display: flex;
81
- align-items: center;
82
- transform: translateY(0);
80
+ display: flex;
81
+ align-items: center;
82
+ transform: translateY(0);
83
83
  }
84
84
 
85
85
  .label:not(:first-child) {
86
- margin-left: theme.$item-icon-gap;
86
+ margin-left: theme.$item-icon-gap;
87
87
  }
88
88
 
89
89
  .label:not(:last-child) {
90
- margin-right: theme.$item-icon-gap;
90
+ margin-right: theme.$item-icon-gap;
91
91
  }
92
92
 
93
93
  .isRootActive,
94
94
  .isRootActive:hover,
95
95
  .isRootActive:focus-within {
96
- z-index: 2; // 1.
97
- transform: translateY(theme.$item-active-shift-y);
96
+ z-index: 2; // 1.
97
+ transform: translateY(theme.$item-active-shift-y);
98
98
  }
99
99
 
100
100
  .isRootActive .link {
101
- font-weight: theme.$item-active-font-weight;
102
- color: theme.$item-active-color;
103
- border-width: theme.$item-active-border-width;
104
- border-color: theme.$item-active-border-color;
105
- background-color: theme.$item-active-background-color;
106
- box-shadow: theme.$item-active-box-shadow;
101
+ font-weight: theme.$item-active-font-weight;
102
+ color: theme.$item-active-color;
103
+ border-width: theme.$item-active-border-width;
104
+ border-color: theme.$item-active-border-color;
105
+ background-color: theme.$item-active-background-color;
106
+ box-shadow: theme.$item-active-box-shadow;
107
107
  }
108
108
 
109
109
  .link:hover .linkContent,
110
110
  .link:focus .linkContent {
111
- transform: translateY(theme.$item-hover-label-shift-y);
111
+ transform: translateY(theme.$item-hover-label-shift-y);
112
112
  }
113
113
 
114
114
  .isRootActive .link .linkContent,
115
115
  .isRootActive .link:hover .linkContent,
116
116
  .isRootActive .link:focus .linkContent {
117
- transform: translateY(theme.$item-active-label-shift-y);
117
+ transform: translateY(theme.$item-active-label-shift-y);
118
118
  }
@@ -81,7 +81,7 @@ appended by an ellipsis (`…`).
81
81
  label="Number of lines"
82
82
  min={1}
83
83
  max={100}
84
- onChange={(e) => setLines(e.target.value)}
84
+ onChange={(e) => setLines(Number(e.target.value))}
85
85
  type="number"
86
86
  value={lines}
87
87
  />
@@ -1,8 +1,11 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { withProviderContext } from '../../provider';
4
- import getRootHyphensClassName from './helpers/getRootHyphensClassName';
5
- import getRootWordWrappingClassName from './helpers/getRootWordWrappingClassName';
4
+ import { classNames } from '../../utils/classNames';
5
+ import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
6
+ import { getRootClampClassName } from './_helpers/getRootClampClassName';
7
+ import { getRootHyphensClassName } from './_helpers/getRootHyphensClassName';
8
+ import { getRootWordWrappingClassName } from './_helpers/getRootWordWrappingClassName';
6
9
  import styles from './Text.scss';
7
10
 
8
11
  export const Text = ({
@@ -13,19 +16,23 @@ export const Text = ({
13
16
  lines,
14
17
  wordWrapping,
15
18
  }) => {
19
+ if (isChildrenEmpty(children)) {
20
+ return null;
21
+ }
22
+
16
23
  const HtmlElement = blockLevel ? 'div' : 'span';
17
24
 
18
25
  return (
19
26
  <HtmlElement
20
27
  className={(hyphens !== 'none' || lines > 0 || wordWrapping !== 'normal')
21
- ? [
22
- (lines > 0) ? styles.rootClampLines : '',
28
+ ? classNames(
29
+ getRootClampClassName(lines, styles),
23
30
  getRootHyphensClassName(hyphens, styles),
24
31
  getRootWordWrappingClassName(wordWrapping, styles),
25
- ].join(' ')
32
+ )
26
33
  : undefined}
27
34
  id={id}
28
- style={(lines > 0) ? { '--rui-custom-lines': lines } : undefined}
35
+ style={(lines > 1) ? { '--rui-custom-lines': lines } : undefined}
29
36
  >
30
37
  {children}
31
38
  </HtmlElement>
@@ -1,30 +1,40 @@
1
1
  // 1. `word-break: break-word` is deprecated in favour of `overflow-wrap: anywhere`, but it's still
2
2
  // required for Safari.
3
3
  // https://caniuse.com/mdn-css_properties_overflow-wrap_anywhere
4
+ //
5
+ // 2. Different approaches are used for single and multiline texts because the latter approach
6
+ // doesn't always work for single-line texts.
4
7
 
5
- /* stylelint-disable property-no-vendor-prefix, value-no-vendor-prefix */
6
- .rootClampLines {
7
- display: -webkit-box;
8
- -webkit-line-clamp: var(--rui-custom-lines);
9
- -webkit-box-orient: vertical;
10
- overflow: hidden;
11
- text-overflow: ellipsis;
8
+ .rootClampSingleLine {
9
+ display: block; // 2.
10
+ overflow: hidden;
11
+ text-overflow: ellipsis;
12
+ white-space: nowrap;
12
13
  }
13
- /* stylelint-enable property-no-vendor-prefix, value-no-vendor-prefix */
14
+
15
+ // stylelint-disable property-no-vendor-prefix, value-no-vendor-prefix
16
+ .rootClampMultiLine {
17
+ display: -webkit-box; // 2.
18
+ -webkit-line-clamp: var(--rui-custom-lines);
19
+ -webkit-box-orient: vertical;
20
+ overflow: hidden;
21
+ text-overflow: ellipsis;
22
+ }
23
+ // stylelint-enable property-no-vendor-prefix, value-no-vendor-prefix
14
24
 
15
25
  .rootHyphensAuto {
16
- hyphens: auto;
26
+ hyphens: auto;
17
27
  }
18
28
 
19
29
  .rootHyphensManual {
20
- hyphens: manual;
30
+ hyphens: manual;
21
31
  }
22
32
 
23
33
  .rootWordWrappingAnywhere {
24
- word-break: break-all;
34
+ word-break: break-all;
25
35
  }
26
36
 
27
37
  .rootWordWrappingLongWords {
28
- word-break: break-word; // 1.
29
- overflow-wrap: anywhere;
38
+ word-break: break-word; // 1.
39
+ overflow-wrap: anywhere;
30
40
  }