@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.
- package/CONTRIBUTING.md +7 -0
- package/dist/lib.development.js +209 -305
- package/dist/lib.js +1 -1
- package/package.json +10 -13
- package/src/lib/components/Alert/Alert.jsx +4 -3
- package/src/lib/components/Alert/Alert.scss +48 -48
- package/src/lib/components/Alert/_settings.scss +4 -4
- package/src/lib/components/Alert/_theme.scss +50 -50
- package/src/lib/components/Alert/_tools.scss +6 -6
- package/src/lib/components/Badge/Badge.jsx +6 -8
- package/src/lib/components/Badge/Badge.scss +57 -57
- package/src/lib/components/Button/Button.jsx +10 -9
- package/src/lib/components/Button/Button.scss +2 -2
- package/src/lib/components/Button/README.mdx +8 -3
- package/src/lib/components/Button/_base.scss +65 -65
- package/src/lib/components/Button/_priorities.scss +49 -49
- package/src/lib/components/Button/_settings.scss +10 -10
- package/src/lib/components/Button/_theme.scss +18 -15
- package/src/lib/components/Button/_tools.scss +98 -100
- package/src/lib/components/ButtonGroup/ButtonGroup.jsx +31 -22
- package/src/lib/components/ButtonGroup/ButtonGroup.scss +3 -3
- package/src/lib/components/ButtonGroup/README.mdx +4 -4
- package/src/lib/components/Card/Card.jsx +7 -6
- package/src/lib/components/Card/Card.scss +28 -28
- package/src/lib/components/Card/CardBody.jsx +5 -11
- package/src/lib/components/Card/CardFooter.jsx +10 -5
- package/src/lib/components/Card/README.mdx +2 -2
- package/src/lib/components/Card/_theme.scss +50 -50
- package/src/lib/components/Card/_tools.scss +6 -6
- package/src/lib/components/CheckboxField/CheckboxField.jsx +18 -17
- package/src/lib/components/CheckboxField/CheckboxField.scss +20 -20
- package/src/lib/components/CheckboxField/README.mdx +3 -3
- package/src/lib/components/FileInputField/FileInputField.jsx +13 -12
- package/src/lib/components/FileInputField/FileInputField.scss +19 -19
- package/src/lib/components/FileInputField/README.mdx +1 -1
- package/src/lib/components/FormLayout/FormLayout.jsx +16 -14
- package/src/lib/components/FormLayout/FormLayout.scss +17 -17
- package/src/lib/components/FormLayout/FormLayoutCustomField.jsx +15 -9
- package/src/lib/components/FormLayout/FormLayoutCustomField.scss +18 -18
- package/src/lib/components/FormLayout/README.mdx +27 -49
- package/src/lib/components/Grid/Grid.jsx +4 -3
- package/src/lib/components/Grid/Grid.scss +32 -23
- package/src/lib/components/Grid/GridSpan.jsx +4 -3
- package/src/lib/components/Grid/{helpers → _helpers}/generateResponsiveCustomProperties.js +0 -2
- package/src/lib/components/Grid/_theme.scss +9 -9
- package/src/lib/components/Grid/_tools.scss +20 -20
- package/src/lib/components/List/List.jsx +14 -12
- package/src/lib/components/List/List.scss +21 -21
- package/src/lib/components/List/ListItem.jsx +3 -2
- package/src/lib/components/List/README.mdx +1 -1
- package/src/lib/components/Media/Media.jsx +12 -5
- package/src/lib/components/Media/Media.scss +6 -6
- package/src/lib/components/Media/MediaBody.jsx +18 -7
- package/src/lib/components/Media/MediaObject.jsx +18 -7
- package/src/lib/components/Modal/Modal.jsx +8 -6
- package/src/lib/components/Modal/Modal.scss +73 -73
- package/src/lib/components/Modal/README.mdx +2 -2
- package/src/lib/components/Modal/_settings.scss +5 -5
- package/src/lib/components/Modal/_theme.scss +17 -17
- package/src/lib/components/Paper/Paper.jsx +6 -6
- package/src/lib/components/Paper/Paper.scss +8 -8
- package/src/lib/components/Paper/README.mdx +1 -1
- package/src/lib/components/Radio/README.mdx +4 -4
- package/src/lib/components/Radio/Radio.jsx +12 -11
- package/src/lib/components/Radio/Radio.scss +26 -26
- package/src/lib/components/ScrollView/README.mdx +4 -1
- package/src/lib/components/ScrollView/ScrollView.jsx +11 -9
- package/src/lib/components/ScrollView/ScrollView.scss +113 -113
- package/src/lib/{services/elementPositionService.js → components/ScrollView/_helpers/getElementsPositionDifference.js} +0 -2
- package/src/lib/{hooks → components/ScrollView/_hooks}/useLoadResizeHook.js +1 -1
- package/src/lib/{hooks → components/ScrollView/_hooks}/useScrollPositionHook.js +1 -1
- package/src/lib/components/SelectField/README.mdx +4 -4
- package/src/lib/components/SelectField/SelectField.jsx +14 -13
- package/src/lib/components/SelectField/SelectField.scss +30 -30
- package/src/lib/components/Table/README.mdx +3 -3
- package/src/lib/components/Table/Table.scss +28 -35
- package/src/lib/components/Table/_settings.scss +5 -5
- package/src/lib/components/Tabs/README.mdx +1 -1
- package/src/lib/components/Tabs/Tabs.jsx +1 -2
- package/src/lib/components/Tabs/Tabs.scss +21 -21
- package/src/lib/components/Tabs/TabsItem.jsx +4 -3
- package/src/lib/components/Tabs/TabsItem.scss +78 -78
- package/src/lib/components/Text/README.mdx +1 -1
- package/src/lib/components/Text/Text.jsx +13 -6
- package/src/lib/components/Text/Text.scss +23 -13
- package/src/lib/components/Text/_helpers/getRootClampClassName.js +11 -0
- package/src/lib/components/Text/{helpers → _helpers}/getRootHyphensClassName.js +1 -1
- package/src/lib/components/Text/{helpers → _helpers}/getRootWordWrappingClassName.js +1 -1
- package/src/lib/components/TextArea/README.mdx +1 -1
- package/src/lib/components/TextArea/TextArea.jsx +18 -14
- package/src/lib/components/TextArea/TextArea.scss +27 -27
- package/src/lib/components/TextField/README.mdx +1 -1
- package/src/lib/components/TextField/TextField.jsx +16 -14
- package/src/lib/components/TextField/TextField.scss +28 -28
- package/src/lib/components/TextLink/README.mdx +77 -0
- package/src/lib/components/{Link/Link.jsx → TextLink/TextLink.jsx} +12 -13
- package/src/lib/components/TextLink/TextLink.scss +11 -0
- package/src/lib/components/TextLink/_theme.scss +4 -0
- package/src/lib/components/TextLink/index.js +1 -0
- package/src/lib/components/Toggle/README.mdx +3 -3
- package/src/lib/components/Toggle/Toggle.jsx +18 -17
- package/src/lib/components/Toggle/Toggle.scss +20 -20
- package/src/lib/components/Toolbar/README.mdx +19 -3
- package/src/lib/components/Toolbar/Toolbar.jsx +23 -14
- package/src/lib/components/Toolbar/Toolbar.scss +35 -30
- package/src/lib/components/Toolbar/ToolbarGroup.jsx +18 -13
- package/src/lib/components/Toolbar/ToolbarItem.jsx +26 -7
- package/src/lib/{helpers → components/_helpers}/getRootColorClassName.js +1 -1
- package/src/lib/{helpers → components/_helpers}/getRootSizeClassName.js +1 -1
- package/src/lib/{helpers → components/_helpers}/getRootValidationStateClassName.js +1 -1
- package/src/lib/components/_helpers/isChildrenEmpty.js +3 -0
- package/src/lib/{helpers → components/_helpers}/resolveContextOrProp.js +0 -0
- package/src/lib/{utils → components/_helpers}/transferProps.js +1 -1
- package/src/lib/foundation.scss +11 -11
- package/src/lib/helpers.scss +2 -2
- package/src/lib/index.js +4 -8
- package/src/lib/styles/_utilities.scss +13 -13
- package/src/lib/styles/elements/_code.scss +7 -7
- package/src/lib/styles/elements/_links.scss +8 -8
- package/src/lib/styles/elements/_lists.scss +3 -3
- package/src/lib/styles/elements/_page.scss +14 -14
- package/src/lib/styles/elements/_rulers.scss +6 -6
- package/src/lib/styles/elements/_small.scss +2 -2
- package/src/lib/styles/generic/_box-sizing.scss +3 -2
- package/src/lib/styles/generic/_forms.scss +3 -3
- package/src/lib/styles/generic/_reset.scss +6 -6
- package/src/lib/styles/generic/_shared.scss +3 -3
- package/src/lib/styles/helpers/_animation.scss +8 -8
- package/src/lib/styles/settings/_breakpoints.scss +7 -7
- package/src/lib/styles/settings/_escaped-characters.scss +5 -5
- package/src/lib/styles/settings/_form-fields.scss +24 -24
- package/src/lib/styles/settings/_utilities.scss +112 -100
- package/src/lib/styles/theme/_colors.scss +50 -50
- package/src/lib/styles/theme/_form-fields.scss +32 -32
- package/src/lib/styles/theme/_spacing.scss +11 -11
- package/src/lib/styles/theme/_typography.scss +12 -11
- package/src/lib/styles/theme-constants/_breakpoints.scss +2 -2
- package/src/lib/styles/theme-constants/_colors.scss +2 -2
- package/src/lib/styles/theme-constants/_svg.scss +1 -2
- package/src/lib/styles/tools/_accessibility.scss +29 -29
- package/src/lib/styles/tools/_breakpoint.scss +11 -14
- package/src/lib/styles/tools/_caret.scss +8 -8
- package/src/lib/styles/tools/_colors.scss +3 -3
- package/src/lib/styles/tools/_reset.scss +24 -21
- package/src/lib/styles/tools/_scrollbar.scss +4 -4
- package/src/lib/styles/tools/_spacing.scss +17 -21
- package/src/lib/styles/tools/_string.scss +9 -9
- package/src/lib/styles/tools/_svg.scss +13 -16
- package/src/lib/styles/tools/_transition.scss +42 -44
- package/src/lib/styles/tools/_utilities.scss +19 -19
- package/src/lib/styles/tools/form-fields/_box-field-elements.scss +88 -88
- package/src/lib/styles/tools/form-fields/_box-field-layout.scss +147 -147
- package/src/lib/styles/tools/form-fields/_box-field-sizes.scss +13 -15
- package/src/lib/styles/tools/form-fields/_foundation.scss +12 -12
- package/src/lib/styles/tools/form-fields/_inline-field-elements.scss +82 -71
- package/src/lib/styles/tools/form-fields/_inline-field-layout.scss +88 -47
- package/src/lib/styles/tools/form-fields/_variants.scss +104 -106
- package/src/lib/theme.scss +958 -954
- package/src/lib/utils/classNames.js +8 -0
- package/src/lib/components/CTA/CTA.jsx +0 -60
- package/src/lib/components/CTA/CTA.scss +0 -71
- package/src/lib/components/CTA/CTACenter.jsx +0 -27
- package/src/lib/components/CTA/CTAEnd.jsx +0 -27
- package/src/lib/components/CTA/CTAStart.jsx +0 -27
- package/src/lib/components/CTA/README.mdx +0 -119
- package/src/lib/components/CTA/index.js +0 -4
- package/src/lib/components/Center/Center.jsx +0 -27
- package/src/lib/components/Center/Center.scss +0 -7
- package/src/lib/components/Center/README.mdx +0 -52
- package/src/lib/components/Center/index.js +0 -1
- package/src/lib/components/Link/Link.scss +0 -11
- package/src/lib/components/Link/README.mdx +0 -85
- package/src/lib/components/Link/_theme.scss +0 -4
- package/src/lib/components/Link/index.js +0 -1
@@ -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
|
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
|
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
|
39
|
-
context
|
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
|
44
|
-
required
|
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
|
-
|
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
|
56
|
-
|
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.
|
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
|
2
|
-
@use
|
3
|
-
@use
|
4
|
-
@use
|
5
|
-
@use
|
6
|
-
@use
|
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
|
-
|
10
|
+
@include foundation.root();
|
11
11
|
}
|
12
12
|
|
13
13
|
.label {
|
14
|
-
|
14
|
+
@include foundation.label();
|
15
15
|
}
|
16
16
|
|
17
17
|
.inputContainer {
|
18
|
-
|
18
|
+
@include box-field-elements.input-container();
|
19
19
|
}
|
20
20
|
|
21
21
|
.input {
|
22
|
-
|
23
|
-
|
22
|
+
@include box-field-elements.input();
|
23
|
+
@include box-field-elements.input-textarea();
|
24
24
|
}
|
25
25
|
|
26
26
|
.bottomLine {
|
27
|
-
|
27
|
+
@include box-field-elements.bottom-line();
|
28
28
|
}
|
29
29
|
|
30
30
|
.helpText,
|
31
31
|
.validationText {
|
32
|
-
|
32
|
+
@include foundation.help-text();
|
33
33
|
}
|
34
34
|
|
35
35
|
.isRootRequired .label {
|
36
|
-
|
36
|
+
@include foundation.label-required();
|
37
37
|
}
|
38
38
|
|
39
39
|
// Visual variants
|
40
40
|
.rootVariantFilled {
|
41
|
-
|
41
|
+
@include variants.visual(box, $variant: filled);
|
42
42
|
}
|
43
43
|
|
44
44
|
.rootVariantOutline {
|
45
|
-
|
45
|
+
@include variants.visual(box, $variant: outline);
|
46
46
|
}
|
47
47
|
|
48
48
|
// States
|
49
49
|
.isRootStateInvalid {
|
50
|
-
|
50
|
+
@include variants.validation(invalid);
|
51
51
|
}
|
52
52
|
|
53
53
|
.isRootStateValid {
|
54
|
-
|
54
|
+
@include variants.validation(valid);
|
55
55
|
}
|
56
56
|
|
57
57
|
.isRootStateWarning {
|
58
|
-
|
58
|
+
@include variants.validation(warning);
|
59
59
|
}
|
60
60
|
|
61
61
|
// Invisible label
|
62
62
|
.isLabelHidden {
|
63
|
-
|
63
|
+
@include accessibility.hide-text();
|
64
64
|
}
|
65
65
|
|
66
66
|
// Layouts
|
67
67
|
.rootLayoutVertical,
|
68
68
|
.rootLayoutHorizontal {
|
69
|
-
|
69
|
+
@include box-field-layout.vertical();
|
70
70
|
}
|
71
71
|
|
72
72
|
.rootLayoutHorizontal {
|
73
|
-
|
73
|
+
@include box-field-layout.horizontal();
|
74
74
|
}
|
75
75
|
|
76
76
|
.isRootFullWidth {
|
77
|
-
|
77
|
+
@include box-field-layout.full-width();
|
78
78
|
}
|
79
79
|
|
80
80
|
.isRootInFormLayout {
|
81
|
-
|
81
|
+
@include box-field-layout.in-form-layout();
|
82
82
|
}
|
83
83
|
|
84
84
|
// Sizes
|
85
85
|
.rootSizeSmall {
|
86
|
-
|
86
|
+
@include box-field-sizes.size(small, $is-multiline: true);
|
87
87
|
}
|
88
88
|
|
89
89
|
.rootSizeMedium {
|
90
|
-
|
90
|
+
@include box-field-sizes.size(medium, $is-multiline: true);
|
91
91
|
}
|
92
92
|
|
93
93
|
.rootSizeLarge {
|
94
|
-
|
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
|
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
|
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
|
42
|
-
hasSmallInput
|
43
|
-
|
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
|
48
|
-
required
|
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
|
-
|
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
|
61
|
-
|
62
|
+
!isLabelVisible && styles.isLabelHidden,
|
63
|
+
)}
|
62
64
|
id={id && `${id}__labelText`}
|
63
65
|
>
|
64
66
|
{label}
|
@@ -1,102 +1,102 @@
|
|
1
|
-
@use
|
2
|
-
@use
|
3
|
-
@use
|
4
|
-
@use
|
5
|
-
@use
|
6
|
-
@use
|
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
|
-
|
10
|
+
@include foundation.root();
|
11
11
|
}
|
12
12
|
|
13
13
|
.label {
|
14
|
-
|
14
|
+
@include foundation.label();
|
15
15
|
}
|
16
16
|
|
17
17
|
.inputContainer {
|
18
|
-
|
18
|
+
@include box-field-elements.input-container();
|
19
19
|
}
|
20
20
|
|
21
21
|
.input {
|
22
|
-
|
22
|
+
@include box-field-elements.input();
|
23
23
|
}
|
24
24
|
|
25
25
|
.bottomLine {
|
26
|
-
|
26
|
+
@include box-field-elements.bottom-line();
|
27
27
|
}
|
28
28
|
|
29
29
|
.helpText,
|
30
30
|
.validationText {
|
31
|
-
|
31
|
+
@include foundation.help-text();
|
32
32
|
}
|
33
33
|
|
34
34
|
.hasRootCustomInputSize .input {
|
35
|
-
|
35
|
+
@include box-field-elements.input-size();
|
36
36
|
}
|
37
37
|
|
38
38
|
.isRootRequired .label {
|
39
|
-
|
39
|
+
@include foundation.label-required();
|
40
40
|
}
|
41
41
|
|
42
42
|
// Variants
|
43
43
|
.rootVariantFilled {
|
44
|
-
|
44
|
+
@include variants.visual(box, $variant: filled);
|
45
45
|
}
|
46
46
|
|
47
47
|
.rootVariantOutline {
|
48
|
-
|
48
|
+
@include variants.visual(box, $variant: outline);
|
49
49
|
}
|
50
50
|
|
51
51
|
// States
|
52
52
|
.isRootStateInvalid {
|
53
|
-
|
53
|
+
@include variants.validation(invalid);
|
54
54
|
}
|
55
55
|
|
56
56
|
.isRootStateValid {
|
57
|
-
|
57
|
+
@include variants.validation(valid);
|
58
58
|
}
|
59
59
|
|
60
60
|
.isRootStateWarning {
|
61
|
-
|
61
|
+
@include variants.validation(warning);
|
62
62
|
}
|
63
63
|
|
64
64
|
// Invisible label
|
65
65
|
.isLabelHidden {
|
66
|
-
|
66
|
+
@include accessibility.hide-text();
|
67
67
|
}
|
68
68
|
|
69
69
|
// Layouts
|
70
70
|
.rootLayoutVertical,
|
71
71
|
.rootLayoutHorizontal {
|
72
|
-
|
72
|
+
@include box-field-layout.vertical();
|
73
73
|
}
|
74
74
|
|
75
75
|
.rootLayoutHorizontal {
|
76
|
-
|
76
|
+
@include box-field-layout.horizontal();
|
77
77
|
}
|
78
78
|
|
79
79
|
.isRootFullWidth {
|
80
|
-
|
80
|
+
@include box-field-layout.full-width();
|
81
81
|
}
|
82
82
|
|
83
83
|
.isRootInFormLayout {
|
84
|
-
|
84
|
+
@include box-field-layout.in-form-layout();
|
85
85
|
}
|
86
86
|
|
87
87
|
.hasRootSmallInput.rootLayoutHorizontal {
|
88
|
-
|
88
|
+
@include box-field-layout.horizontal-with-small-input();
|
89
89
|
}
|
90
90
|
|
91
91
|
// Sizes
|
92
92
|
.rootSizeSmall {
|
93
|
-
|
93
|
+
@include box-field-sizes.size(small);
|
94
94
|
}
|
95
95
|
|
96
96
|
.rootSizeMedium {
|
97
|
-
|
97
|
+
@include box-field-sizes.size(medium);
|
98
98
|
}
|
99
99
|
|
100
100
|
.rootSizeLarge {
|
101
|
-
|
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
|
4
|
+
import { transferProps } from '../_helpers/transferProps';
|
5
|
+
import styles from './TextLink.scss';
|
6
6
|
|
7
|
-
export const
|
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
|
-
{
|
19
|
+
{label}
|
20
20
|
</a>
|
21
21
|
);
|
22
22
|
|
23
|
-
|
24
|
-
children: null,
|
23
|
+
TextLink.defaultProps = {
|
25
24
|
id: undefined,
|
26
25
|
};
|
27
26
|
|
28
|
-
|
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(
|
42
|
+
export const LinkWithContext = withProviderContext(TextLink, 'Link');
|
44
43
|
|
45
44
|
export default LinkWithContext;
|
@@ -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/
|
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/
|
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
|
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
|
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
|
32
|
+
context && styles.isRootInFormLayout,
|
32
33
|
context && context.layout === 'horizontal' ? styles.rootLayoutHorizontal : styles.rootLayoutVertical,
|
33
|
-
labelPosition === 'before'
|
34
|
-
disabled
|
35
|
-
required
|
34
|
+
labelPosition === 'before' && styles.hasRootLabelBefore,
|
35
|
+
disabled && styles.isRootDisabled,
|
36
|
+
required && styles.isRootRequired,
|
36
37
|
getRootValidationStateClassName(validationState, styles),
|
37
|
-
|
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
|