@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.
- package/CONTRIBUTING.md +7 -0
- package/README.md +15 -16
- package/dist/lib.development.js +271 -415
- package/dist/lib.js +1 -1
- package/package.json +11 -13
- package/src/lib/components/Alert/Alert.jsx +45 -44
- package/src/lib/components/Alert/Alert.scss +48 -48
- package/src/lib/components/Alert/README.mdx +2 -5
- 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 +9 -11
- package/src/lib/components/Badge/Badge.scss +57 -57
- package/src/lib/components/Button/Button.jsx +14 -13
- package/src/lib/components/Button/Button.scss +2 -2
- package/src/lib/components/Button/README.mdx +11 -6
- package/src/lib/components/Button/_base.scss +69 -69
- 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/Button/helpers/getRootLabelVisibilityClassName.js +4 -4
- package/src/lib/components/ButtonGroup/ButtonGroup.jsx +41 -25
- package/src/lib/components/ButtonGroup/ButtonGroup.scss +3 -3
- package/src/lib/components/ButtonGroup/README.mdx +1 -1
- package/src/lib/components/Card/Card.jsx +10 -9
- package/src/lib/components/Card/Card.scss +28 -28
- package/src/lib/components/Card/CardBody.jsx +17 -12
- package/src/lib/components/Card/CardFooter.jsx +22 -9
- 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 +21 -20
- package/src/lib/components/CheckboxField/CheckboxField.scss +20 -20
- package/src/lib/components/CheckboxField/README.mdx +1 -1
- package/src/lib/components/FileInputField/FileInputField.jsx +16 -15
- 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 +19 -17
- package/src/lib/components/FormLayout/FormLayout.scss +17 -17
- package/src/lib/components/FormLayout/FormLayoutCustomField.jsx +18 -12
- package/src/lib/components/FormLayout/FormLayoutCustomField.scss +18 -18
- package/src/lib/components/FormLayout/README.mdx +26 -49
- package/src/lib/components/Grid/Grid.jsx +25 -24
- package/src/lib/components/Grid/Grid.scss +33 -29
- package/src/lib/components/Grid/GridSpan.jsx +11 -10
- package/src/lib/components/Grid/README.mdx +46 -20
- 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/Modal/Modal.jsx +38 -32
- package/src/lib/components/Modal/Modal.scss +73 -73
- package/src/lib/components/Modal/README.mdx +2 -5
- 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 +9 -9
- package/src/lib/components/Paper/Paper.scss +8 -8
- package/src/lib/components/Popover/Popover.jsx +94 -0
- package/src/lib/components/Popover/Popover.scss +235 -0
- package/src/lib/components/Popover/PopoverWrapper.jsx +46 -0
- package/src/lib/components/Popover/README.mdx +333 -0
- package/src/lib/components/Popover/_helpers/getRootAlignmentClassName.js +13 -0
- package/src/lib/components/Popover/_helpers/getRootSideClassName.js +17 -0
- package/src/lib/components/Popover/_theme.scss +16 -0
- package/src/lib/components/Popover/index.js +2 -0
- package/src/lib/components/Radio/README.mdx +1 -1
- package/src/lib/components/Radio/Radio.jsx +15 -14
- package/src/lib/components/Radio/Radio.scss +26 -26
- package/src/lib/components/ScrollView/README.mdx +5 -5
- package/src/lib/components/ScrollView/ScrollView.jsx +22 -22
- 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 +1 -1
- package/src/lib/components/SelectField/SelectField.jsx +17 -16
- package/src/lib/components/SelectField/SelectField.scss +30 -30
- package/src/lib/components/Table/README.mdx +1 -1
- package/src/lib/components/Table/Table.jsx +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/Tabs.jsx +4 -5
- package/src/lib/components/Tabs/Tabs.scss +21 -21
- package/src/lib/components/Tabs/TabsItem.jsx +7 -6
- package/src/lib/components/Tabs/TabsItem.scss +78 -78
- package/src/lib/components/Text/README.mdx +3 -3
- package/src/lib/components/Text/Text.jsx +16 -9
- 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 +21 -17
- 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 +19 -18
- package/src/lib/components/TextField/TextField.scss +28 -28
- package/src/lib/components/TextLink/README.mdx +77 -0
- package/src/lib/components/TextLink/TextLink.jsx +44 -0
- 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 +1 -1
- package/src/lib/components/Toggle/Toggle.jsx +21 -20
- package/src/lib/components/Toggle/Toggle.scss +20 -20
- package/src/lib/components/Toolbar/README.mdx +33 -5
- package/src/lib/components/Toolbar/Toolbar.jsx +33 -17
- package/src/lib/components/Toolbar/Toolbar.scss +29 -42
- package/src/lib/components/Toolbar/ToolbarGroup.jsx +28 -16
- package/src/lib/components/Toolbar/ToolbarItem.jsx +36 -10
- 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 +8 -17
- package/src/lib/provider/index.js +2 -1
- package/src/lib/provider/withGlobalProps.jsx +21 -0
- 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 +4 -4
- 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 +14 -22
- 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 +959 -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.jsx +0 -45
- 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
- package/src/lib/components/List/List.jsx +0 -71
- package/src/lib/components/List/List.scss +0 -53
- package/src/lib/components/List/ListItem.jsx +0 -31
- package/src/lib/components/List/README.mdx +0 -114
- package/src/lib/components/List/_theme.scss +0 -1
- package/src/lib/components/List/index.js +0 -2
- package/src/lib/components/Media/Media.jsx +0 -29
- package/src/lib/components/Media/Media.scss +0 -16
- package/src/lib/components/Media/MediaBody.jsx +0 -21
- package/src/lib/components/Media/MediaObject.jsx +0 -21
- package/src/lib/components/Media/README.mdx +0 -63
- package/src/lib/components/Media/index.js +0 -3
- package/src/lib/provider/withProviderContext.jsx +0 -32
@@ -1,10 +1,11 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React, { useContext } from 'react';
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import
|
3
|
+
import { withGlobalProps } from '../../provider';
|
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,13 +192,16 @@ 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
|
*/
|
198
202
|
variant: PropTypes.oneOf(['filled', 'outline']),
|
199
203
|
};
|
200
204
|
|
201
|
-
export const
|
205
|
+
export const TextAreaWithGlobalProps = withForwardedRef(withGlobalProps(TextArea, 'TextArea'));
|
202
206
|
|
203
|
-
export default
|
207
|
+
export default TextAreaWithGlobalProps;
|
@@ -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
|
4
|
-
import
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import
|
3
|
+
import { withGlobalProps } from '../../provider';
|
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,30 +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
|
-
inputSize
|
44
|
-
context
|
42
|
+
fullWidth && styles.isRootFullWidth,
|
43
|
+
hasSmallInput && styles.hasRootSmallInput,
|
44
|
+
inputSize && styles.hasRootCustomInputSize,
|
45
|
+
context && styles.isRootInFormLayout,
|
45
46
|
resolveContextOrProp(context && context.layout, layout) === 'horizontal'
|
46
47
|
? styles.rootLayoutHorizontal
|
47
48
|
: styles.rootLayoutVertical,
|
48
|
-
disabled
|
49
|
-
required
|
49
|
+
disabled && styles.isRootDisabled,
|
50
|
+
required && styles.isRootRequired,
|
50
51
|
getRootSizeClassName(size, styles),
|
51
52
|
getRootValidationStateClassName(validationState, styles),
|
52
53
|
variant === 'filled' ? styles.rootVariantFilled : styles.rootVariantOutline,
|
53
|
-
|
54
|
+
)}
|
54
55
|
htmlFor={id}
|
55
56
|
id={id && `${id}__label`}
|
56
57
|
{...(inputSize ? { style: { '--rui-custom-input-size': inputSize } } : {})}
|
57
58
|
>
|
58
59
|
<div
|
59
|
-
className={
|
60
|
+
className={classNames(
|
60
61
|
styles.label,
|
61
|
-
isLabelVisible
|
62
|
-
|
62
|
+
!isLabelVisible && styles.isLabelHidden,
|
63
|
+
)}
|
63
64
|
id={id && `${id}__labelText`}
|
64
65
|
>
|
65
66
|
{label}
|
@@ -208,6 +209,6 @@ TextField.propTypes = {
|
|
208
209
|
variant: PropTypes.oneOf(['filled', 'outline']),
|
209
210
|
};
|
210
211
|
|
211
|
-
export const
|
212
|
+
export const TextFieldWithGlobalProps = withForwardedRef(withGlobalProps(TextField, 'TextField'));
|
212
213
|
|
213
|
-
export default
|
214
|
+
export default TextFieldWithGlobalProps;
|
@@ -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
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import PropTypes from 'prop-types';
|
2
|
+
import React from 'react';
|
3
|
+
import { withGlobalProps } from '../../provider';
|
4
|
+
import { transferProps } from '../_helpers/transferProps';
|
5
|
+
import styles from './TextLink.scss';
|
6
|
+
|
7
|
+
export const TextLink = ({
|
8
|
+
href,
|
9
|
+
id,
|
10
|
+
label,
|
11
|
+
...restProps
|
12
|
+
}) => (
|
13
|
+
<a
|
14
|
+
{...transferProps(restProps)}
|
15
|
+
href={href}
|
16
|
+
className={styles.root}
|
17
|
+
id={id}
|
18
|
+
>
|
19
|
+
{label}
|
20
|
+
</a>
|
21
|
+
);
|
22
|
+
|
23
|
+
TextLink.defaultProps = {
|
24
|
+
id: undefined,
|
25
|
+
};
|
26
|
+
|
27
|
+
TextLink.propTypes = {
|
28
|
+
/**
|
29
|
+
* Link's `href` attribute.
|
30
|
+
*/
|
31
|
+
href: PropTypes.string.isRequired,
|
32
|
+
/**
|
33
|
+
* ID of the root HTML element.
|
34
|
+
*/
|
35
|
+
id: PropTypes.string,
|
36
|
+
/**
|
37
|
+
* Link label.
|
38
|
+
*/
|
39
|
+
label: PropTypes.string.isRequired,
|
40
|
+
};
|
41
|
+
|
42
|
+
export const LinkWithGlobalProps = withGlobalProps(TextLink, 'TextLink');
|
43
|
+
|
44
|
+
export default LinkWithGlobalProps;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './TextLink';
|
@@ -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
|
4
|
-
import {
|
5
|
-
import
|
3
|
+
import { withGlobalProps } from '../../provider';
|
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
|
@@ -158,6 +159,6 @@ Toggle.propTypes = {
|
|
158
159
|
]),
|
159
160
|
};
|
160
161
|
|
161
|
-
export const
|
162
|
+
export const ToggleWithGlobalProps = withForwardedRef(withGlobalProps(Toggle, 'Toggle'));
|
162
163
|
|
163
|
-
export default
|
164
|
+
export default ToggleWithGlobalProps;
|