@react-ui-org/react-ui 0.47.0 → 0.49.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/lib.development.js +465 -93
- package/dist/lib.js +1 -1
- package/package.json +1 -1
- package/src/lib/components/Alert/Alert.jsx +3 -0
- package/src/lib/components/Alert/Alert.scss +10 -10
- package/src/lib/components/Alert/README.mdx +18 -2
- package/src/lib/components/Alert/index.js +1 -1
- package/src/lib/components/Badge/Badge.jsx +4 -8
- package/src/lib/components/Badge/Badge.scss +21 -21
- package/src/lib/components/Badge/README.mdx +15 -1
- package/src/lib/components/Badge/index.js +1 -1
- package/src/lib/components/Button/Button.jsx +23 -34
- package/src/lib/components/Button/README.mdx +21 -7
- package/src/lib/components/Button/_base.scss +20 -20
- package/src/lib/components/Button/_priorities.scss +35 -35
- package/src/lib/components/Button/helpers/getRootLabelVisibilityClassName.js +7 -7
- package/src/lib/components/Button/helpers/getRootPriorityClassName.js +3 -3
- package/src/lib/components/Button/index.js +1 -1
- package/src/lib/components/ButtonGroup/ButtonGroup.jsx +2 -8
- package/src/lib/components/ButtonGroup/README.mdx +18 -2
- package/src/lib/components/Card/Card.jsx +6 -10
- package/src/lib/components/Card/Card.scss +13 -13
- package/src/lib/components/Card/CardBody.jsx +6 -10
- package/src/lib/components/Card/CardFooter.jsx +6 -7
- package/src/lib/components/Card/README.mdx +21 -5
- package/src/lib/components/CheckboxField/CheckboxField.jsx +17 -44
- package/src/lib/components/CheckboxField/README.mdx +18 -6
- package/src/lib/components/CheckboxField/index.js +1 -1
- package/src/lib/components/FileInputField/FileInputField.jsx +20 -29
- package/src/lib/components/FileInputField/FileInputField.scss +3 -3
- package/src/lib/components/FileInputField/README.mdx +30 -28
- package/src/lib/components/FileInputField/index.js +1 -1
- package/src/lib/components/FormLayout/FormLayout.jsx +5 -9
- package/src/lib/components/FormLayout/FormLayout.scss +3 -3
- package/src/lib/components/FormLayout/FormLayoutCustomField.jsx +4 -1
- package/src/lib/components/FormLayout/FormLayoutCustomField.scss +8 -8
- package/src/lib/components/FormLayout/README.mdx +28 -13
- package/src/lib/components/Grid/Grid.jsx +31 -35
- package/src/lib/components/Grid/Grid.scss +10 -15
- package/src/lib/components/Grid/GridSpan.jsx +5 -11
- package/src/lib/components/Grid/README.mdx +48 -36
- package/src/lib/components/Grid/_helpers/generateResponsiveCustomProperties.js +11 -3
- package/src/lib/components/Grid/_settings.scss +18 -0
- package/src/lib/components/Grid/_tools.scss +5 -5
- package/src/lib/components/Modal/Modal.jsx +147 -254
- package/src/lib/components/Modal/Modal.scss +7 -55
- package/src/lib/components/Modal/ModalBody.jsx +60 -0
- package/src/lib/components/Modal/ModalBody.scss +18 -0
- package/src/lib/components/Modal/ModalCloseButton.jsx +45 -0
- package/src/lib/components/Modal/ModalCloseButton.scss +18 -0
- package/src/lib/components/Modal/ModalContent.jsx +39 -0
- package/src/lib/components/Modal/ModalContent.scss +5 -0
- package/src/lib/components/Modal/ModalFooter.jsx +42 -0
- package/src/lib/components/Modal/ModalFooter.scss +35 -0
- package/src/lib/components/Modal/ModalHeader.jsx +44 -0
- package/src/lib/components/Modal/ModalHeader.scss +30 -0
- package/src/lib/components/Modal/ModalTitle.jsx +44 -0
- package/src/lib/components/Modal/ModalTitle.scss +10 -0
- package/src/lib/components/Modal/README.mdx +865 -195
- package/src/lib/components/Modal/_helpers/getJustifyClassName.js +19 -0
- package/src/lib/components/Modal/_helpers/getScrollingClassName.js +11 -0
- package/src/lib/components/Modal/_settings.scss +1 -5
- package/src/lib/components/Modal/_theme.scss +6 -0
- package/src/lib/components/Modal/index.js +7 -1
- package/src/lib/components/Paper/Paper.jsx +5 -9
- package/src/lib/components/Paper/Paper.scss +2 -2
- package/src/lib/components/Paper/README.mdx +15 -1
- package/src/lib/components/Paper/index.js +1 -1
- package/src/lib/components/Popover/Popover.jsx +14 -30
- package/src/lib/components/Popover/Popover.scss +7 -6
- package/src/lib/components/Popover/PopoverWrapper.jsx +5 -12
- package/src/lib/components/Popover/PopoverWrapper.scss +3 -0
- package/src/lib/components/Popover/README.mdx +32 -11
- package/src/lib/components/Popover/_theme.scss +1 -1
- package/src/lib/components/Radio/README.mdx +13 -6
- package/src/lib/components/Radio/Radio.jsx +39 -29
- package/src/lib/components/Radio/Radio.scss +3 -3
- package/src/lib/components/Radio/index.js +1 -1
- package/src/lib/components/ScrollView/README.mdx +165 -84
- package/src/lib/components/ScrollView/ScrollView.jsx +115 -117
- package/src/lib/components/ScrollView/ScrollView.scss +18 -16
- package/src/lib/components/ScrollView/index.js +1 -1
- package/src/lib/components/SelectField/README.mdx +83 -7
- package/src/lib/components/SelectField/SelectField.jsx +86 -61
- package/src/lib/components/SelectField/SelectField.scss +8 -8
- package/src/lib/components/SelectField/_components/Option/Option.jsx +46 -0
- package/src/lib/components/SelectField/_components/Option/index.js +1 -0
- package/src/lib/components/SelectField/index.js +1 -1
- package/src/lib/components/Table/README.mdx +25 -9
- package/src/lib/components/Table/Table.jsx +43 -101
- package/src/lib/components/Table/Table.scss +0 -24
- package/src/lib/components/Table/_components/TableBodyCell/TableBodyCell.jsx +46 -0
- package/src/lib/components/Table/_components/TableBodyCell/index.js +1 -0
- package/src/lib/components/Table/_components/TableCell.scss +25 -0
- package/src/lib/components/Table/_components/TableHeaderCell/TableHeaderCell.jsx +71 -0
- package/src/lib/components/Table/_components/TableHeaderCell/index.js +1 -0
- package/src/lib/components/Table/index.js +1 -1
- package/src/lib/components/Tabs/README.mdx +21 -3
- package/src/lib/components/Tabs/Tabs.jsx +6 -1
- package/src/lib/components/Tabs/TabsItem.jsx +3 -0
- package/src/lib/components/Tabs/TabsItem.scss +1 -2
- package/src/lib/components/Text/README.mdx +25 -7
- package/src/lib/components/Text/Text.jsx +3 -7
- package/src/lib/components/Text/Text.scss +6 -6
- package/src/lib/components/Text/_helpers/getRootClampClassName.js +2 -2
- package/src/lib/components/Text/_helpers/getRootHyphensClassName.js +2 -2
- package/src/lib/components/Text/_helpers/getRootWordWrappingClassName.js +2 -2
- package/src/lib/components/Text/index.js +1 -1
- package/src/lib/components/TextArea/README.mdx +34 -31
- package/src/lib/components/TextArea/TextArea.jsx +23 -63
- package/src/lib/components/TextArea/TextArea.scss +8 -8
- package/src/lib/components/TextArea/index.js +1 -1
- package/src/lib/components/TextField/README.mdx +56 -54
- package/src/lib/components/TextField/TextField.jsx +25 -52
- package/src/lib/components/TextField/TextField.scss +9 -9
- package/src/lib/components/TextField/index.js +1 -1
- package/src/lib/components/TextLink/README.mdx +13 -6
- package/src/lib/components/TextLink/TextLink.jsx +0 -10
- package/src/lib/components/TextLink/index.js +1 -1
- package/src/lib/components/Toggle/README.mdx +18 -6
- package/src/lib/components/Toggle/Toggle.jsx +18 -44
- package/src/lib/components/Toggle/index.js +1 -1
- package/src/lib/components/Toolbar/README.mdx +21 -6
- package/src/lib/components/Toolbar/Toolbar.jsx +9 -43
- package/src/lib/components/Toolbar/Toolbar.scss +24 -12
- package/src/lib/components/Toolbar/ToolbarGroup.jsx +7 -26
- package/src/lib/components/Toolbar/ToolbarItem.jsx +3 -7
- package/src/lib/components/Toolbar/_helpers/getAlignClassName.js +19 -0
- package/src/lib/components/Toolbar/_helpers/getJustifyClassName.js +16 -0
- package/src/lib/components/_helpers/getRootColorClassName.js +10 -10
- package/src/lib/components/_helpers/getRootSizeClassName.js +3 -3
- package/src/lib/components/_helpers/transferProps.js +1 -1
- package/src/lib/index.js +24 -16
- package/src/lib/provider/withGlobalProps.jsx +20 -3
- package/src/lib/styles/tools/form-fields/_box-field-layout.scss +15 -15
- package/src/lib/styles/tools/form-fields/_inline-field-elements.scss +1 -1
- package/src/lib/styles/tools/form-fields/_inline-field-layout.scss +9 -9
- package/src/lib/theme.scss +18 -26
- package/src/lib/translations/en.js +1 -1
- package/src/lib/components/Grid/_theme.scss +0 -11
- package/src/lib/components/ScrollView/_theme.scss +0 -2
- package/src/lib/components/withForwardedRef.jsx +0 -11
@@ -2,9 +2,12 @@ import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
3
3
|
import { withGlobalProps } from '../../provider';
|
4
4
|
import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
|
5
|
+
import { transferProps } from '../_helpers/transferProps';
|
5
6
|
import { generateResponsiveCustomProperties } from './_helpers/generateResponsiveCustomProperties';
|
6
7
|
import styles from './Grid.scss';
|
7
8
|
|
9
|
+
const SPACING_VALUES = [0, 1, 2, 3, 4, 5, 6, 7];
|
10
|
+
|
8
11
|
export const Grid = ({
|
9
12
|
alignContent,
|
10
13
|
alignItems,
|
@@ -12,13 +15,12 @@ export const Grid = ({
|
|
12
15
|
children,
|
13
16
|
columnGap,
|
14
17
|
columns,
|
15
|
-
id,
|
16
18
|
justifyContent,
|
17
19
|
justifyItems,
|
18
20
|
rowGap,
|
19
21
|
rows,
|
20
22
|
tag: Tag,
|
21
|
-
...
|
23
|
+
...restProps
|
22
24
|
}) => {
|
23
25
|
if (isChildrenEmpty(children)) {
|
24
26
|
return null;
|
@@ -26,20 +28,19 @@ export const Grid = ({
|
|
26
28
|
|
27
29
|
return (
|
28
30
|
<Tag
|
29
|
-
|
31
|
+
{...transferProps(restProps)}
|
30
32
|
className={styles.root}
|
31
33
|
style={{
|
32
34
|
...generateResponsiveCustomProperties(columns, 'columns'),
|
33
|
-
...generateResponsiveCustomProperties(columnGap, 'column-gap'),
|
35
|
+
...generateResponsiveCustomProperties(columnGap, 'column-gap', 'spacing'),
|
34
36
|
...generateResponsiveCustomProperties(rows, 'rows'),
|
35
|
-
...generateResponsiveCustomProperties(rowGap, 'row-gap'),
|
37
|
+
...generateResponsiveCustomProperties(rowGap, 'row-gap', 'spacing'),
|
36
38
|
...generateResponsiveCustomProperties(autoFlow, 'auto-flow'),
|
37
39
|
...generateResponsiveCustomProperties(alignContent, 'align-content'),
|
38
40
|
...generateResponsiveCustomProperties(alignItems, 'align-items'),
|
39
41
|
...generateResponsiveCustomProperties(justifyContent, 'justify-content'),
|
40
42
|
...generateResponsiveCustomProperties(justifyItems, 'justify-items'),
|
41
43
|
}}
|
42
|
-
{...other}
|
43
44
|
>
|
44
45
|
{children}
|
45
46
|
</Tag>
|
@@ -54,13 +55,12 @@ Grid.defaultProps = {
|
|
54
55
|
alignItems: undefined,
|
55
56
|
autoFlow: undefined,
|
56
57
|
children: null,
|
57
|
-
columnGap:
|
58
|
-
columns:
|
59
|
-
id: undefined,
|
58
|
+
columnGap: 4,
|
59
|
+
columns: '1fr',
|
60
60
|
justifyContent: undefined,
|
61
61
|
justifyItems: undefined,
|
62
|
-
rowGap:
|
63
|
-
rows:
|
62
|
+
rowGap: 4,
|
63
|
+
rows: 'auto',
|
64
64
|
tag: 'div',
|
65
65
|
};
|
66
66
|
|
@@ -118,19 +118,19 @@ Grid.propTypes = {
|
|
118
118
|
*/
|
119
119
|
children: PropTypes.node,
|
120
120
|
/**
|
121
|
-
* Gap between columns. Accepts any
|
122
|
-
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap) for more
|
121
|
+
* Gap between columns. Accepts any of [spacing values](/foundation/spacing-values) as number.
|
122
|
+
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap) for more about `column-gap`.
|
123
123
|
*/
|
124
124
|
columnGap: PropTypes.oneOfType([
|
125
|
-
PropTypes.
|
125
|
+
PropTypes.oneOf(SPACING_VALUES),
|
126
126
|
PropTypes.shape({
|
127
|
-
xs: PropTypes.
|
128
|
-
sm: PropTypes.
|
129
|
-
md: PropTypes.
|
130
|
-
lg: PropTypes.
|
131
|
-
xl: PropTypes.
|
132
|
-
x2l: PropTypes.
|
133
|
-
x3l: PropTypes.
|
127
|
+
xs: PropTypes.oneOf(SPACING_VALUES),
|
128
|
+
sm: PropTypes.oneOf(SPACING_VALUES),
|
129
|
+
md: PropTypes.oneOf(SPACING_VALUES),
|
130
|
+
lg: PropTypes.oneOf(SPACING_VALUES),
|
131
|
+
xl: PropTypes.oneOf(SPACING_VALUES),
|
132
|
+
x2l: PropTypes.oneOf(SPACING_VALUES),
|
133
|
+
x3l: PropTypes.oneOf(SPACING_VALUES),
|
134
134
|
}),
|
135
135
|
]),
|
136
136
|
/**
|
@@ -149,10 +149,6 @@ Grid.propTypes = {
|
|
149
149
|
x3l: PropTypes.string,
|
150
150
|
}),
|
151
151
|
]),
|
152
|
-
/**
|
153
|
-
* ID of the root HTML element.
|
154
|
-
*/
|
155
|
-
id: PropTypes.string,
|
156
152
|
/**
|
157
153
|
* Content justification. Accepts any valid value of `justify-content` CSS property.
|
158
154
|
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content) for more.
|
@@ -186,19 +182,19 @@ Grid.propTypes = {
|
|
186
182
|
}),
|
187
183
|
]),
|
188
184
|
/**
|
189
|
-
* Gap between rows. Accepts any
|
190
|
-
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap) for more
|
185
|
+
* Gap between rows. Accepts any of [spacing values](/foundation/spacing-values) as number.
|
186
|
+
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap) for more about `row-gap`.
|
191
187
|
*/
|
192
188
|
rowGap: PropTypes.oneOfType([
|
193
|
-
PropTypes.
|
189
|
+
PropTypes.oneOf(SPACING_VALUES),
|
194
190
|
PropTypes.shape({
|
195
|
-
xs: PropTypes.
|
196
|
-
sm: PropTypes.
|
197
|
-
md: PropTypes.
|
198
|
-
lg: PropTypes.
|
199
|
-
xl: PropTypes.
|
200
|
-
x2l: PropTypes.
|
201
|
-
x3l: PropTypes.
|
191
|
+
xs: PropTypes.oneOf(SPACING_VALUES),
|
192
|
+
sm: PropTypes.oneOf(SPACING_VALUES),
|
193
|
+
md: PropTypes.oneOf(SPACING_VALUES),
|
194
|
+
lg: PropTypes.oneOf(SPACING_VALUES),
|
195
|
+
xl: PropTypes.oneOf(SPACING_VALUES),
|
196
|
+
x2l: PropTypes.oneOf(SPACING_VALUES),
|
197
|
+
x3l: PropTypes.oneOf(SPACING_VALUES),
|
202
198
|
}),
|
203
199
|
]),
|
204
200
|
/**
|
@@ -22,22 +22,22 @@
|
|
22
22
|
|
23
23
|
@use "sass:map";
|
24
24
|
@use "../../styles/tools/spacing";
|
25
|
-
@use "
|
25
|
+
@use "settings";
|
26
26
|
@use "tools";
|
27
27
|
|
28
28
|
.root {
|
29
|
-
@include tools.assign-responsive-custom-properties(
|
29
|
+
@include tools.assign-responsive-custom-properties(settings.$grid-responsive-properties); // 1.
|
30
30
|
@include spacing.bottom(layouts);
|
31
31
|
|
32
32
|
display: grid;
|
33
33
|
grid-template-columns: var(--rui-local-columns); // 2.
|
34
34
|
grid-template-rows: var(--rui-local-rows); // 2.
|
35
|
-
grid-auto-flow: var(--rui-local-auto-flow
|
35
|
+
grid-auto-flow: var(--rui-local-auto-flow); // 2.
|
36
36
|
grid-gap: var(--rui-local-row-gap) var(--rui-local-column-gap); // 2.
|
37
|
-
align-content: var(--rui-local-align-content
|
38
|
-
align-items: var(--rui-local-align-items
|
39
|
-
justify-content: var(--rui-local-justify-content
|
40
|
-
justify-items: var(--rui-local-justify-items
|
37
|
+
align-content: var(--rui-local-align-content); // 2.
|
38
|
+
align-items: var(--rui-local-align-items); // 2.
|
39
|
+
justify-content: var(--rui-local-justify-content); // 2.
|
40
|
+
justify-items: var(--rui-local-justify-items); // 2.
|
41
41
|
}
|
42
42
|
|
43
43
|
// stylelint-disable-next-line selector-max-universal -- Reset any previously added margins.
|
@@ -46,15 +46,10 @@
|
|
46
46
|
}
|
47
47
|
|
48
48
|
.span {
|
49
|
-
|
50
|
-
column-span: 1,
|
51
|
-
row-span: 1,
|
52
|
-
);
|
49
|
+
@include tools.assign-responsive-custom-properties(settings.$grid-span-responsive-properties); // 1.
|
53
50
|
|
54
|
-
|
55
|
-
|
56
|
-
grid-column: span var(--rui-local-column-span, 1); // 2.
|
57
|
-
grid-row: span var(--rui-local-row-span, 1); // 2.
|
51
|
+
grid-column: span var(--rui-local-column-span); // 2.
|
52
|
+
grid-row: span var(--rui-local-row-span); // 2.
|
58
53
|
}
|
59
54
|
|
60
55
|
// stylelint-disable selector-no-qualifying-type
|
@@ -2,16 +2,16 @@ import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
3
3
|
import { withGlobalProps } from '../../provider';
|
4
4
|
import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
|
5
|
+
import { transferProps } from '../_helpers/transferProps';
|
5
6
|
import { generateResponsiveCustomProperties } from './_helpers/generateResponsiveCustomProperties';
|
6
7
|
import styles from './Grid.scss';
|
7
8
|
|
8
9
|
export const GridSpan = ({
|
9
10
|
children,
|
10
11
|
columns,
|
11
|
-
id,
|
12
12
|
rows,
|
13
13
|
tag: Tag,
|
14
|
-
...
|
14
|
+
...restProps
|
15
15
|
}) => {
|
16
16
|
if (isChildrenEmpty(children)) {
|
17
17
|
return null;
|
@@ -19,13 +19,12 @@ export const GridSpan = ({
|
|
19
19
|
|
20
20
|
return (
|
21
21
|
<Tag
|
22
|
-
|
22
|
+
{...transferProps(restProps)}
|
23
23
|
className={styles.span}
|
24
24
|
style={{
|
25
25
|
...generateResponsiveCustomProperties(columns, 'column-span'),
|
26
26
|
...generateResponsiveCustomProperties(rows, 'row-span'),
|
27
27
|
}}
|
28
|
-
{...other}
|
29
28
|
>
|
30
29
|
{children}
|
31
30
|
</Tag>
|
@@ -37,9 +36,8 @@ export const GridSpan = ({
|
|
37
36
|
|
38
37
|
GridSpan.defaultProps = {
|
39
38
|
children: null,
|
40
|
-
columns:
|
41
|
-
|
42
|
-
rows: undefined,
|
39
|
+
columns: 1,
|
40
|
+
rows: 1,
|
43
41
|
tag: 'div',
|
44
42
|
};
|
45
43
|
|
@@ -63,10 +61,6 @@ GridSpan.propTypes = {
|
|
63
61
|
x3l: PropTypes.number,
|
64
62
|
}),
|
65
63
|
]),
|
66
|
-
/**
|
67
|
-
* ID of the root HTML element.
|
68
|
-
*/
|
69
|
-
id: PropTypes.string,
|
70
64
|
/**
|
71
65
|
* Number of rows to span.
|
72
66
|
*/
|
@@ -11,8 +11,10 @@ import {
|
|
11
11
|
Props,
|
12
12
|
} from 'docz'
|
13
13
|
import { Placeholder } from '../../../docs/_components/Placeholder/Placeholder'
|
14
|
-
import {
|
15
|
-
|
14
|
+
import {
|
15
|
+
Grid,
|
16
|
+
GridSpan,
|
17
|
+
} from '../..'
|
16
18
|
|
17
19
|
The responsive Grid layout aligns content into an organized grid.
|
18
20
|
|
@@ -38,12 +40,11 @@ See [API](#api) for all available options.
|
|
38
40
|
|
39
41
|
## General Guidelines
|
40
42
|
|
41
|
-
- This component implements native [CSS grid layout][grid-layout], a
|
42
|
-
tool for two-dimensional layouts. You may use any value accepted by
|
43
|
-
[grid-template-columns], [grid-template-rows], [grid-
|
44
|
-
[
|
45
|
-
|
46
|
-
options of the component.
|
43
|
+
- This component implements the native [CSS grid layout][grid-layout], a
|
44
|
+
powerful tool for two-dimensional layouts. You may use any value accepted by
|
45
|
+
[grid-template-columns], [grid-template-rows], [grid-auto-flow],
|
46
|
+
[align-content], [align-items], [justify-content], [justify-items], and CSS
|
47
|
+
properties in corresponding API options of the component.
|
47
48
|
|
48
49
|
- To align your items in the grid, **simply wrap** them with the Grid
|
49
50
|
component. Unlike other grid frameworks and UI libraries, **no additional
|
@@ -62,7 +63,7 @@ See [API](#api) for all available options.
|
|
62
63
|
## Columns
|
63
64
|
|
64
65
|
Stack is the default outcome of Grid. Use the `columns` option to organize your
|
65
|
-
items into grid.
|
66
|
+
items into a grid.
|
66
67
|
|
67
68
|
<Playground>
|
68
69
|
<Grid columns="1fr 1fr 1fr">
|
@@ -89,7 +90,9 @@ You can use the [`repeat()`][repeat] function to specify a recurring pattern.
|
|
89
90
|
</Playground>
|
90
91
|
|
91
92
|
Combine `repeat()` with `auto-fit` and [`minmax()`][minmax] to build automatic
|
92
|
-
responsive layouts.
|
93
|
+
responsive layouts.
|
94
|
+
|
95
|
+
📐 Try resizing the playground to see it in action.
|
93
96
|
|
94
97
|
<Playground>
|
95
98
|
<Grid columns="repeat(auto-fit, minmax(200px, auto))">
|
@@ -102,8 +105,8 @@ responsive layouts. Resize the playground to see it in action.
|
|
102
105
|
</Grid>
|
103
106
|
</Playground>
|
104
107
|
|
105
|
-
👉 If you need your items to have **equal height** even with content of
|
106
|
-
|
108
|
+
👉 If you need your items to have **equal height** even with the content of
|
109
|
+
varying lengths, it may be necessary to set `height: 100%` on them.
|
107
110
|
|
108
111
|
## Rows
|
109
112
|
|
@@ -122,10 +125,11 @@ Use `columns` and `rows` to specify a more complicated grid layout.
|
|
122
125
|
|
123
126
|
## Gaps
|
124
127
|
|
125
|
-
Both column and row gaps can be customized.
|
128
|
+
Both column and row gaps can be customized. The value must correspond to any of
|
129
|
+
[available spacings](/foundation/spacing).
|
126
130
|
|
127
131
|
<Playground>
|
128
|
-
<Grid columns="repeat(3, 1fr)" columnGap=
|
132
|
+
<Grid columns="repeat(3, 1fr)" columnGap={2} rowGap={6}>
|
129
133
|
<Placeholder bordered>Grid item</Placeholder>
|
130
134
|
<Placeholder bordered>Grid item</Placeholder>
|
131
135
|
<Placeholder bordered>Grid item</Placeholder>
|
@@ -137,7 +141,7 @@ Both column and row gaps can be customized.
|
|
137
141
|
|
138
142
|
## Alignment
|
139
143
|
|
140
|
-
Individual items and the entire grid content can be aligned
|
144
|
+
Individual items and the entire grid content can be aligned along both axes.
|
141
145
|
|
142
146
|
<Playground>
|
143
147
|
<Grid
|
@@ -157,8 +161,8 @@ Individual items and the entire grid content can be aligned and along both axes.
|
|
157
161
|
|
158
162
|
## Custom HTML Tag
|
159
163
|
|
160
|
-
To render as list for example, just change the output `tag` to `ul` or `ol`
|
161
|
-
wrap your items with `<li>`.
|
164
|
+
To render as a list, for example, just change the output `tag` to `ul` or `ol`
|
165
|
+
and wrap your items with `<li>`.
|
162
166
|
|
163
167
|
<Playground>
|
164
168
|
<Grid tag="ul">
|
@@ -180,9 +184,11 @@ If you need to build more complicated layouts, you have full control over the
|
|
180
184
|
grid definition. Just specify your grid layout for
|
181
185
|
[breakpoints](/foundation/breakpoints) where a change of layout is needed.
|
182
186
|
The Grid component is written with the mobile-first approach so values for small
|
183
|
-
breakpoints are used until they're overridden by a bigger breakpoint.
|
184
|
-
|
185
|
-
|
187
|
+
breakpoints are used until they're overridden by a bigger breakpoint.
|
188
|
+
|
189
|
+
👉 With this syntax there are no defaults for individual breakpoints.
|
190
|
+
|
191
|
+
📐 Try resizing your browser to see how it works.
|
186
192
|
|
187
193
|
<Playground>
|
188
194
|
<Grid
|
@@ -191,16 +197,17 @@ works.
|
|
191
197
|
md: '1fr 2fr',
|
192
198
|
}}
|
193
199
|
columnGap={{
|
194
|
-
|
195
|
-
|
200
|
+
xs: 4,
|
201
|
+
md: 2,
|
202
|
+
lg: 4,
|
196
203
|
}}
|
197
204
|
rows={{
|
198
205
|
xs: 'auto auto 200px 200px',
|
199
206
|
md: 'auto 200px auto',
|
200
207
|
}}
|
201
208
|
rowGap={{
|
202
|
-
xs:
|
203
|
-
md:
|
209
|
+
xs: 3,
|
210
|
+
md: 4,
|
204
211
|
}}
|
205
212
|
>
|
206
213
|
<Placeholder bordered>Grid item</Placeholder>
|
@@ -214,9 +221,9 @@ works.
|
|
214
221
|
|
215
222
|
## Advanced Layouts
|
216
223
|
|
217
|
-
Wrap your content with GridSpan component to span it over multiple
|
218
|
-
rows. Use the `autoFlow` option to control the layout when combined
|
219
|
-
responsive columns and rows.
|
224
|
+
Wrap your content with the GridSpan component to span it over multiple
|
225
|
+
columns or rows. Use the `autoFlow` option to control the layout when combined
|
226
|
+
with responsive columns and rows.
|
220
227
|
|
221
228
|
<Playground>
|
222
229
|
<Grid
|
@@ -256,6 +263,17 @@ responsive columns and rows.
|
|
256
263
|
👉 `autoFlow` (used in the example above) implements the `grid-auto-flow` CSS
|
257
264
|
property. Check [MDN][grid-auto-flow] to fully understand available options.
|
258
265
|
|
266
|
+
## Forwarding HTML Attributes
|
267
|
+
|
268
|
+
In addition to the options below in the [component's API](#api) section, you
|
269
|
+
can specify [React synthetic events] or **any HTML attribute you like.** All
|
270
|
+
attributes that don't interfere with the API are forwarded to the HTML element
|
271
|
+
of your choice provided by `tag`, which is `<div>` by default. It enables making
|
272
|
+
the component interactive and helps to improve its accessibility.
|
273
|
+
|
274
|
+
👉 Refer to the MDN reference for the full list of supported attributes of the
|
275
|
+
[div] element or [any other][all-html-elements] element of your choice.
|
276
|
+
|
259
277
|
## API
|
260
278
|
|
261
279
|
<Props table of={Grid} />
|
@@ -266,18 +284,9 @@ Wrapper for content that should span multiple rows or columns.
|
|
266
284
|
|
267
285
|
<Props table of={GridSpan} />
|
268
286
|
|
269
|
-
## Theming
|
270
|
-
|
271
|
-
| Custom Property | Description |
|
272
|
-
|------------------------------------------------------|--------------------------------------------------------------|
|
273
|
-
| `--rui-Grid__column-gap` | Default column gap |
|
274
|
-
| `--rui-Grid__row-gap` | Default row gap |
|
275
|
-
|
276
287
|
[grid-layout]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout
|
277
288
|
[grid-template-columns]: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns
|
278
289
|
[grid-template-rows]: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows
|
279
|
-
[grid-column-gap]: https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap
|
280
|
-
[grid-row-gap]: https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap
|
281
290
|
[grid-auto-flow]: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow
|
282
291
|
[align-content]: https://developer.mozilla.org/en-US/docs/Web/CSS/align-content
|
283
292
|
[align-items]: https://developer.mozilla.org/en-US/docs/Web/CSS/align-items
|
@@ -285,3 +294,6 @@ Wrapper for content that should span multiple rows or columns.
|
|
285
294
|
[justify-items]: https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items
|
286
295
|
[repeat]: https://developer.mozilla.org/en-US/docs/Web/CSS/repeat
|
287
296
|
[minmax]: https://developer.mozilla.org/en-US/docs/Web/CSS/minmax
|
297
|
+
[React synthetic events]: https://reactjs.org/docs/events.html
|
298
|
+
[div]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div#attributes
|
299
|
+
[all-html-elements]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element
|
@@ -1,14 +1,22 @@
|
|
1
|
-
|
1
|
+
const prepareValueByType = (value, type) => {
|
2
|
+
if (type === 'spacing') {
|
3
|
+
return `var(--rui-spacing-${value})`;
|
4
|
+
}
|
5
|
+
|
6
|
+
return value;
|
7
|
+
};
|
8
|
+
|
9
|
+
export const generateResponsiveCustomProperties = (prop, infix, type = null) => {
|
2
10
|
if (typeof prop === 'undefined') {
|
3
11
|
return null;
|
4
12
|
}
|
5
13
|
|
6
14
|
if (typeof prop !== 'object') {
|
7
|
-
return { [`--rui-local-${infix}-xs`]: prop };
|
15
|
+
return { [`--rui-local-${infix}-xs`]: prepareValueByType(prop, type) };
|
8
16
|
}
|
9
17
|
|
10
18
|
return Object.keys(prop).reduce((acc, breakpoint) => ({
|
11
19
|
...acc,
|
12
|
-
[`--rui-local-${infix}-${breakpoint}`]: prop[breakpoint],
|
20
|
+
[`--rui-local-${infix}-${breakpoint}`]: prepareValueByType(prop[breakpoint], type),
|
13
21
|
}), {});
|
14
22
|
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
$grid-responsive-properties: [
|
2
|
+
columns,
|
3
|
+
column-gap,
|
4
|
+
rows,
|
5
|
+
row-gap,
|
6
|
+
auto-flow,
|
7
|
+
align-content,
|
8
|
+
align-items,
|
9
|
+
justify-content,
|
10
|
+
justify-items,
|
11
|
+
]; // stylelint-disable-line indentation -- Broken rule?
|
12
|
+
|
13
|
+
$grid-span-responsive-properties: [
|
14
|
+
column-span,
|
15
|
+
row-span,
|
16
|
+
]; // stylelint-disable-line indentation -- Broken rule?
|
17
|
+
|
18
|
+
$initial-fallback-value: initial;
|
@@ -1,14 +1,14 @@
|
|
1
1
|
@use "sass:map";
|
2
2
|
@use "../../styles/settings/breakpoints";
|
3
3
|
@use "../../styles/tools/breakpoint";
|
4
|
+
@use "settings";
|
4
5
|
|
5
6
|
// Generate fallback cascade using `var()` function fallbacks.
|
6
7
|
//
|
7
8
|
// $property-name: <string> Custom property name
|
8
|
-
// $initial-fallback: <string> Initial fallback value
|
9
9
|
// $current-breakpoint: <one of $breakpoint-values> Generate cascade for breakpoints smaller than this one
|
10
|
-
@function _generate-custom-property-fallback-cascade($property-name, $
|
11
|
-
$fallback-cascade:
|
10
|
+
@function _generate-custom-property-fallback-cascade($property-name, $current-breakpoint) {
|
11
|
+
$fallback-cascade: settings.$initial-fallback-value;
|
12
12
|
|
13
13
|
@each $breakpoint in map.keys(breakpoints.$values) {
|
14
14
|
@if $breakpoint == $current-breakpoint {
|
@@ -26,11 +26,11 @@
|
|
26
26
|
@mixin assign-responsive-custom-properties($properties) {
|
27
27
|
@each $breakpoint in map.keys(breakpoints.$values) {
|
28
28
|
@include breakpoint.up($breakpoint) {
|
29
|
-
@each $property-name
|
29
|
+
@each $property-name in $properties {
|
30
30
|
--rui-local-#{$property-name}:
|
31
31
|
var(
|
32
32
|
--rui-local-#{$property-name}-#{$breakpoint},
|
33
|
-
#{_generate-custom-property-fallback-cascade($property-name, $
|
33
|
+
#{_generate-custom-property-fallback-cascade($property-name, $breakpoint)}
|
34
34
|
);
|
35
35
|
}
|
36
36
|
}
|