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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. package/CONTRIBUTING.md +7 -0
  2. package/README.md +15 -16
  3. package/dist/lib.development.js +271 -415
  4. package/dist/lib.js +1 -1
  5. package/package.json +11 -13
  6. package/src/lib/components/Alert/Alert.jsx +45 -44
  7. package/src/lib/components/Alert/Alert.scss +48 -48
  8. package/src/lib/components/Alert/README.mdx +2 -5
  9. package/src/lib/components/Alert/_settings.scss +4 -4
  10. package/src/lib/components/Alert/_theme.scss +50 -50
  11. package/src/lib/components/Alert/_tools.scss +6 -6
  12. package/src/lib/components/Badge/Badge.jsx +9 -11
  13. package/src/lib/components/Badge/Badge.scss +57 -57
  14. package/src/lib/components/Button/Button.jsx +14 -13
  15. package/src/lib/components/Button/Button.scss +2 -2
  16. package/src/lib/components/Button/README.mdx +11 -6
  17. package/src/lib/components/Button/_base.scss +69 -69
  18. package/src/lib/components/Button/_priorities.scss +49 -49
  19. package/src/lib/components/Button/_settings.scss +10 -10
  20. package/src/lib/components/Button/_theme.scss +18 -15
  21. package/src/lib/components/Button/_tools.scss +98 -100
  22. package/src/lib/components/Button/helpers/getRootLabelVisibilityClassName.js +4 -4
  23. package/src/lib/components/ButtonGroup/ButtonGroup.jsx +41 -25
  24. package/src/lib/components/ButtonGroup/ButtonGroup.scss +3 -3
  25. package/src/lib/components/ButtonGroup/README.mdx +1 -1
  26. package/src/lib/components/Card/Card.jsx +10 -9
  27. package/src/lib/components/Card/Card.scss +28 -28
  28. package/src/lib/components/Card/CardBody.jsx +17 -12
  29. package/src/lib/components/Card/CardFooter.jsx +22 -9
  30. package/src/lib/components/Card/_theme.scss +50 -50
  31. package/src/lib/components/Card/_tools.scss +6 -6
  32. package/src/lib/components/CheckboxField/CheckboxField.jsx +21 -20
  33. package/src/lib/components/CheckboxField/CheckboxField.scss +20 -20
  34. package/src/lib/components/CheckboxField/README.mdx +1 -1
  35. package/src/lib/components/FileInputField/FileInputField.jsx +16 -15
  36. package/src/lib/components/FileInputField/FileInputField.scss +19 -19
  37. package/src/lib/components/FileInputField/README.mdx +1 -1
  38. package/src/lib/components/FormLayout/FormLayout.jsx +19 -17
  39. package/src/lib/components/FormLayout/FormLayout.scss +17 -17
  40. package/src/lib/components/FormLayout/FormLayoutCustomField.jsx +18 -12
  41. package/src/lib/components/FormLayout/FormLayoutCustomField.scss +18 -18
  42. package/src/lib/components/FormLayout/README.mdx +26 -49
  43. package/src/lib/components/Grid/Grid.jsx +25 -24
  44. package/src/lib/components/Grid/Grid.scss +33 -29
  45. package/src/lib/components/Grid/GridSpan.jsx +11 -10
  46. package/src/lib/components/Grid/README.mdx +46 -20
  47. package/src/lib/components/Grid/{helpers → _helpers}/generateResponsiveCustomProperties.js +0 -2
  48. package/src/lib/components/Grid/_theme.scss +9 -9
  49. package/src/lib/components/Grid/_tools.scss +20 -20
  50. package/src/lib/components/Modal/Modal.jsx +38 -32
  51. package/src/lib/components/Modal/Modal.scss +73 -73
  52. package/src/lib/components/Modal/README.mdx +2 -5
  53. package/src/lib/components/Modal/_settings.scss +5 -5
  54. package/src/lib/components/Modal/_theme.scss +17 -17
  55. package/src/lib/components/Paper/Paper.jsx +9 -9
  56. package/src/lib/components/Paper/Paper.scss +8 -8
  57. package/src/lib/components/Popover/Popover.jsx +94 -0
  58. package/src/lib/components/Popover/Popover.scss +235 -0
  59. package/src/lib/components/Popover/PopoverWrapper.jsx +46 -0
  60. package/src/lib/components/Popover/README.mdx +333 -0
  61. package/src/lib/components/Popover/_helpers/getRootAlignmentClassName.js +13 -0
  62. package/src/lib/components/Popover/_helpers/getRootSideClassName.js +17 -0
  63. package/src/lib/components/Popover/_theme.scss +16 -0
  64. package/src/lib/components/Popover/index.js +2 -0
  65. package/src/lib/components/Radio/README.mdx +1 -1
  66. package/src/lib/components/Radio/Radio.jsx +15 -14
  67. package/src/lib/components/Radio/Radio.scss +26 -26
  68. package/src/lib/components/ScrollView/README.mdx +5 -5
  69. package/src/lib/components/ScrollView/ScrollView.jsx +22 -22
  70. package/src/lib/components/ScrollView/ScrollView.scss +113 -113
  71. package/src/lib/{services/elementPositionService.js → components/ScrollView/_helpers/getElementsPositionDifference.js} +0 -2
  72. package/src/lib/{hooks → components/ScrollView/_hooks}/useLoadResizeHook.js +1 -1
  73. package/src/lib/{hooks → components/ScrollView/_hooks}/useScrollPositionHook.js +1 -1
  74. package/src/lib/components/SelectField/README.mdx +1 -1
  75. package/src/lib/components/SelectField/SelectField.jsx +17 -16
  76. package/src/lib/components/SelectField/SelectField.scss +30 -30
  77. package/src/lib/components/Table/README.mdx +1 -1
  78. package/src/lib/components/Table/Table.jsx +3 -3
  79. package/src/lib/components/Table/Table.scss +28 -35
  80. package/src/lib/components/Table/_settings.scss +5 -5
  81. package/src/lib/components/Tabs/Tabs.jsx +4 -5
  82. package/src/lib/components/Tabs/Tabs.scss +21 -21
  83. package/src/lib/components/Tabs/TabsItem.jsx +7 -6
  84. package/src/lib/components/Tabs/TabsItem.scss +78 -78
  85. package/src/lib/components/Text/README.mdx +3 -3
  86. package/src/lib/components/Text/Text.jsx +16 -9
  87. package/src/lib/components/Text/Text.scss +23 -13
  88. package/src/lib/components/Text/_helpers/getRootClampClassName.js +11 -0
  89. package/src/lib/components/Text/{helpers → _helpers}/getRootHyphensClassName.js +1 -1
  90. package/src/lib/components/Text/{helpers → _helpers}/getRootWordWrappingClassName.js +1 -1
  91. package/src/lib/components/TextArea/README.mdx +1 -1
  92. package/src/lib/components/TextArea/TextArea.jsx +21 -17
  93. package/src/lib/components/TextArea/TextArea.scss +27 -27
  94. package/src/lib/components/TextField/README.mdx +1 -1
  95. package/src/lib/components/TextField/TextField.jsx +19 -18
  96. package/src/lib/components/TextField/TextField.scss +28 -28
  97. package/src/lib/components/TextLink/README.mdx +77 -0
  98. package/src/lib/components/TextLink/TextLink.jsx +44 -0
  99. package/src/lib/components/TextLink/TextLink.scss +11 -0
  100. package/src/lib/components/TextLink/_theme.scss +4 -0
  101. package/src/lib/components/TextLink/index.js +1 -0
  102. package/src/lib/components/Toggle/README.mdx +1 -1
  103. package/src/lib/components/Toggle/Toggle.jsx +21 -20
  104. package/src/lib/components/Toggle/Toggle.scss +20 -20
  105. package/src/lib/components/Toolbar/README.mdx +33 -5
  106. package/src/lib/components/Toolbar/Toolbar.jsx +33 -17
  107. package/src/lib/components/Toolbar/Toolbar.scss +29 -42
  108. package/src/lib/components/Toolbar/ToolbarGroup.jsx +28 -16
  109. package/src/lib/components/Toolbar/ToolbarItem.jsx +36 -10
  110. package/src/lib/{helpers → components/_helpers}/getRootColorClassName.js +1 -1
  111. package/src/lib/{helpers → components/_helpers}/getRootSizeClassName.js +1 -1
  112. package/src/lib/{helpers → components/_helpers}/getRootValidationStateClassName.js +1 -1
  113. package/src/lib/components/_helpers/isChildrenEmpty.js +3 -0
  114. package/src/lib/{helpers → components/_helpers}/resolveContextOrProp.js +0 -0
  115. package/src/lib/{utils → components/_helpers}/transferProps.js +1 -1
  116. package/src/lib/foundation.scss +11 -11
  117. package/src/lib/helpers.scss +2 -2
  118. package/src/lib/index.js +8 -17
  119. package/src/lib/provider/index.js +2 -1
  120. package/src/lib/provider/withGlobalProps.jsx +21 -0
  121. package/src/lib/styles/_utilities.scss +13 -13
  122. package/src/lib/styles/elements/_code.scss +7 -7
  123. package/src/lib/styles/elements/_links.scss +8 -8
  124. package/src/lib/styles/elements/_lists.scss +3 -3
  125. package/src/lib/styles/elements/_page.scss +14 -14
  126. package/src/lib/styles/elements/_rulers.scss +6 -6
  127. package/src/lib/styles/elements/_small.scss +2 -2
  128. package/src/lib/styles/generic/_box-sizing.scss +3 -2
  129. package/src/lib/styles/generic/_forms.scss +3 -3
  130. package/src/lib/styles/generic/_reset.scss +6 -6
  131. package/src/lib/styles/generic/_shared.scss +3 -3
  132. package/src/lib/styles/helpers/_animation.scss +8 -8
  133. package/src/lib/styles/settings/_breakpoints.scss +7 -7
  134. package/src/lib/styles/settings/_escaped-characters.scss +5 -5
  135. package/src/lib/styles/settings/_form-fields.scss +24 -24
  136. package/src/lib/styles/settings/_utilities.scss +112 -100
  137. package/src/lib/styles/theme/_colors.scss +50 -50
  138. package/src/lib/styles/theme/_form-fields.scss +32 -32
  139. package/src/lib/styles/theme/_spacing.scss +11 -11
  140. package/src/lib/styles/theme/_typography.scss +12 -11
  141. package/src/lib/styles/theme-constants/_breakpoints.scss +4 -4
  142. package/src/lib/styles/theme-constants/_colors.scss +2 -2
  143. package/src/lib/styles/theme-constants/_svg.scss +1 -2
  144. package/src/lib/styles/tools/_accessibility.scss +29 -29
  145. package/src/lib/styles/tools/_breakpoint.scss +11 -14
  146. package/src/lib/styles/tools/_caret.scss +8 -8
  147. package/src/lib/styles/tools/_colors.scss +3 -3
  148. package/src/lib/styles/tools/_reset.scss +24 -21
  149. package/src/lib/styles/tools/_scrollbar.scss +4 -4
  150. package/src/lib/styles/tools/_spacing.scss +14 -22
  151. package/src/lib/styles/tools/_string.scss +9 -9
  152. package/src/lib/styles/tools/_svg.scss +13 -16
  153. package/src/lib/styles/tools/_transition.scss +42 -44
  154. package/src/lib/styles/tools/_utilities.scss +19 -19
  155. package/src/lib/styles/tools/form-fields/_box-field-elements.scss +88 -88
  156. package/src/lib/styles/tools/form-fields/_box-field-layout.scss +147 -147
  157. package/src/lib/styles/tools/form-fields/_box-field-sizes.scss +13 -15
  158. package/src/lib/styles/tools/form-fields/_foundation.scss +12 -12
  159. package/src/lib/styles/tools/form-fields/_inline-field-elements.scss +82 -71
  160. package/src/lib/styles/tools/form-fields/_inline-field-layout.scss +88 -47
  161. package/src/lib/styles/tools/form-fields/_variants.scss +104 -106
  162. package/src/lib/theme.scss +959 -954
  163. package/src/lib/utils/classNames.js +8 -0
  164. package/src/lib/components/CTA/CTA.jsx +0 -60
  165. package/src/lib/components/CTA/CTA.scss +0 -71
  166. package/src/lib/components/CTA/CTACenter.jsx +0 -27
  167. package/src/lib/components/CTA/CTAEnd.jsx +0 -27
  168. package/src/lib/components/CTA/CTAStart.jsx +0 -27
  169. package/src/lib/components/CTA/README.mdx +0 -119
  170. package/src/lib/components/CTA/index.js +0 -4
  171. package/src/lib/components/Center/Center.jsx +0 -27
  172. package/src/lib/components/Center/Center.scss +0 -7
  173. package/src/lib/components/Center/README.mdx +0 -52
  174. package/src/lib/components/Center/index.js +0 -1
  175. package/src/lib/components/Link/Link.jsx +0 -45
  176. package/src/lib/components/Link/Link.scss +0 -11
  177. package/src/lib/components/Link/README.mdx +0 -85
  178. package/src/lib/components/Link/_theme.scss +0 -4
  179. package/src/lib/components/Link/index.js +0 -1
  180. package/src/lib/components/List/List.jsx +0 -71
  181. package/src/lib/components/List/List.scss +0 -53
  182. package/src/lib/components/List/ListItem.jsx +0 -31
  183. package/src/lib/components/List/README.mdx +0 -114
  184. package/src/lib/components/List/_theme.scss +0 -1
  185. package/src/lib/components/List/index.js +0 -2
  186. package/src/lib/components/Media/Media.jsx +0 -29
  187. package/src/lib/components/Media/Media.scss +0 -16
  188. package/src/lib/components/Media/MediaBody.jsx +0 -21
  189. package/src/lib/components/Media/MediaObject.jsx +0 -21
  190. package/src/lib/components/Media/README.mdx +0 -63
  191. package/src/lib/components/Media/index.js +0 -3
  192. package/src/lib/provider/withProviderContext.jsx +0 -32
@@ -1,6 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import { withProviderContext } from '../../provider';
3
+ import { withGlobalProps } from '../../provider';
4
4
  import Button from '../Button';
5
5
  import styles from './Table.scss';
6
6
 
@@ -145,6 +145,6 @@ Table.propTypes = {
145
145
  }),
146
146
  };
147
147
 
148
- export const TableWithContext = withProviderContext(Table, 'Table');
148
+ export const TableWithGlobalProps = withGlobalProps(Table, 'Table');
149
149
 
150
- export default TableWithContext;
150
+ export default TableWithGlobalProps;
@@ -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);
@@ -1,6 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import { withProviderContext } from '../../provider';
3
+ import { withGlobalProps } from '../../provider';
4
4
  import styles from './Tabs.scss';
5
5
 
6
6
  export const Tabs = ({
@@ -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`
@@ -34,6 +33,6 @@ Tabs.propTypes = {
34
33
  id: PropTypes.string,
35
34
  };
36
35
 
37
- export const TabsWithContext = withProviderContext(Tabs, 'Tabs');
36
+ export const TabsWithGlobalProps = withGlobalProps(Tabs, 'Tabs');
38
37
 
39
- export default TabsWithContext;
38
+ export default TabsWithGlobalProps;
@@ -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
- import { withProviderContext } from '../../provider';
3
+ import { withGlobalProps } 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
  >
@@ -82,6 +83,6 @@ TabsItem.propTypes = {
82
83
  onClick: PropTypes.func,
83
84
  };
84
85
 
85
- export const TabsItemWithContext = withProviderContext(TabsItem, 'TabsItem');
86
+ export const TabsItemWithGlobalProps = withGlobalProps(TabsItem, 'TabsItem');
86
87
 
87
- export default TabsItemWithContext;
88
+ export default TabsItemWithGlobalProps;
@@ -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
  />
@@ -154,7 +154,7 @@ will override automatic break point selection in `auto` mode when present.
154
154
  <span id="word-wrapping-options-label">Word wrapping:</span>
155
155
  </ToolbarItem>
156
156
  <ToolbarItem>
157
- <ButtonGroup aria-labelledby="#word-wrapping-options-label">
157
+ <ButtonGroup aria-labelledby="word-wrapping-options-label">
158
158
  <Button
159
159
  color={wordWrapping === 'normal' ? 'dark' : 'primary'}
160
160
  label="normal"
@@ -178,7 +178,7 @@ will override automatic break point selection in `auto` mode when present.
178
178
  <span id="hyphens-options-label">Hyphens:</span>
179
179
  </ToolbarItem>
180
180
  <ToolbarItem>
181
- <ButtonGroup aria-labelledby="#hyphens-options-label">
181
+ <ButtonGroup aria-labelledby="hyphens-options-label">
182
182
  <Button
183
183
  color={hyphens === 'none' ? 'dark' : 'primary'}
184
184
  label="none"
@@ -1,8 +1,11 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import { withProviderContext } from '../../provider';
4
- import getRootHyphensClassName from './helpers/getRootHyphensClassName';
5
- import getRootWordWrappingClassName from './helpers/getRootWordWrappingClassName';
3
+ import { withGlobalProps } from '../../provider';
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>
@@ -68,6 +75,6 @@ Text.propTypes = {
68
75
  wordWrapping: PropTypes.oneOf(['normal', 'long-words', 'anywhere']),
69
76
  };
70
77
 
71
- export const TextWithContext = withProviderContext(Text, 'Text');
78
+ export const TextWithGlobalProps = withGlobalProps(Text, 'Text');
72
79
 
73
- export default TextWithContext;
80
+ export default TextWithGlobalProps;
@@ -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
  }
@@ -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} />