@instructure/ui-grid 8.33.1 → 8.33.2-snapshot-5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/es/Grid/index.js +9 -22
- package/es/Grid/props.js +1 -0
- package/es/Grid/styles.js +7 -7
- package/es/Grid/theme.js +3 -3
- package/es/GridCol/index.js +2 -16
- package/es/GridCol/props.js +1 -0
- package/es/GridCol/styles.js +19 -34
- package/es/GridCol/theme.js +3 -3
- package/es/GridRow/index.js +9 -22
- package/es/GridRow/props.js +1 -0
- package/es/GridRow/styles.js +14 -14
- package/es/GridRow/theme.js +3 -3
- package/lib/Grid/index.js +9 -36
- package/lib/Grid/props.js +1 -6
- package/lib/Grid/styles.js +7 -8
- package/lib/Grid/theme.js +3 -4
- package/lib/GridCol/index.js +2 -24
- package/lib/GridCol/props.js +1 -4
- package/lib/GridCol/styles.js +19 -35
- package/lib/GridCol/theme.js +3 -4
- package/lib/GridRow/index.js +9 -33
- package/lib/GridRow/props.js +1 -6
- package/lib/GridRow/styles.js +14 -15
- package/lib/GridRow/theme.js +3 -4
- package/lib/index.js +0 -1
- package/package.json +13 -13
- package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [8.33.2-snapshot-5](https://github.com/instructure/instructure-ui/compare/v8.33.1...v8.33.2-snapshot-5) (2023-01-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-grid
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [8.33.1](https://github.com/instructure/instructure-ui/compare/v8.33.0...v8.33.1) (2023-01-06)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @instructure/ui-grid
|
package/es/Grid/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
const _excluded = ["styles", "makeStyles"],
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
_excluded2 = ["styles"];
|
|
5
4
|
var _dec, _class, _class2;
|
|
6
|
-
|
|
7
5
|
/*
|
|
8
6
|
* The MIT License (MIT)
|
|
9
7
|
*
|
|
@@ -37,7 +35,6 @@ import { withStyle, jsx } from '@instructure/emotion';
|
|
|
37
35
|
import generateStyle from './styles';
|
|
38
36
|
import generateComponentTheme from './theme';
|
|
39
37
|
import { propTypes, allowedProps } from './props';
|
|
40
|
-
|
|
41
38
|
/**
|
|
42
39
|
---
|
|
43
40
|
category: components
|
|
@@ -48,37 +45,29 @@ let Grid = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class
|
|
|
48
45
|
constructor() {
|
|
49
46
|
super(...arguments);
|
|
50
47
|
this.ref = null;
|
|
51
|
-
|
|
52
48
|
this.handleRef = el => {
|
|
53
49
|
this.ref = el;
|
|
54
50
|
};
|
|
55
51
|
}
|
|
56
|
-
|
|
57
52
|
componentDidMount() {
|
|
58
53
|
var _this$props$makeStyle, _this$props;
|
|
59
|
-
|
|
60
54
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
61
55
|
}
|
|
62
|
-
|
|
63
56
|
componentDidUpdate() {
|
|
64
57
|
var _this$props$makeStyle2, _this$props2;
|
|
65
|
-
|
|
66
58
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
67
59
|
}
|
|
68
|
-
|
|
69
60
|
renderChildren() {
|
|
70
61
|
const _this$props3 = this.props,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
62
|
+
styles = _this$props3.styles,
|
|
63
|
+
makeStyles = _this$props3.makeStyles,
|
|
64
|
+
props = _objectWithoutProperties(_this$props3, _excluded);
|
|
75
65
|
const children = Children.toArray(this.props.children);
|
|
76
66
|
return children.map((child, index) => {
|
|
77
67
|
if (matchComponentTypes(child, [GridRow])) {
|
|
78
|
-
return safeCloneElement(child, {
|
|
79
|
-
...
|
|
80
|
-
/* child props should override parent
|
|
81
|
-
,
|
|
68
|
+
return safeCloneElement(child, {
|
|
69
|
+
...pickProps(props, Grid.allowedProps),
|
|
70
|
+
...child.props /* child props should override parent */,
|
|
82
71
|
isLastRow: index + 1 === children.length
|
|
83
72
|
});
|
|
84
73
|
} else {
|
|
@@ -89,16 +78,14 @@ let Grid = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class
|
|
|
89
78
|
|
|
90
79
|
render() {
|
|
91
80
|
const _this$props4 = this.props,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
81
|
+
styles = _this$props4.styles,
|
|
82
|
+
restProps = _objectWithoutProperties(_this$props4, _excluded2);
|
|
95
83
|
const props = omitProps(restProps, Grid.allowedProps);
|
|
96
84
|
return jsx("span", Object.assign({}, props, {
|
|
97
85
|
css: styles === null || styles === void 0 ? void 0 : styles.grid,
|
|
98
86
|
ref: this.handleRef
|
|
99
87
|
}), this.renderChildren());
|
|
100
88
|
}
|
|
101
|
-
|
|
102
89
|
}, _class2.displayName = "Grid", _class2.componentId = 'Grid', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
103
90
|
colSpacing: 'medium',
|
|
104
91
|
rowSpacing: 'medium',
|
package/es/Grid/props.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import PropTypes from 'prop-types';
|
|
25
26
|
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types';
|
|
26
27
|
import { ScreenReaderContent } from '@instructure/ui-a11y-content';
|
package/es/Grid/styles.js
CHANGED
|
@@ -34,22 +34,23 @@
|
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, props) => {
|
|
36
36
|
const startAt = props.startAt,
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
visualDebug = props.visualDebug;
|
|
39
38
|
const getStartAtVariants = breakpoint => !!startAt && startAt === breakpoint ? {
|
|
40
39
|
boxSizing: 'border-box'
|
|
41
40
|
} : {};
|
|
42
|
-
|
|
43
41
|
return {
|
|
44
42
|
grid: {
|
|
45
43
|
label: 'grid',
|
|
46
44
|
display: 'block',
|
|
47
45
|
...getStartAtVariants('small'),
|
|
48
|
-
[`@media screen and (${componentTheme.mediumMin})`]: {
|
|
46
|
+
[`@media screen and (${componentTheme.mediumMin})`]: {
|
|
47
|
+
...getStartAtVariants('medium')
|
|
49
48
|
},
|
|
50
|
-
[`@media screen and (${componentTheme.largeMin})`]: {
|
|
49
|
+
[`@media screen and (${componentTheme.largeMin})`]: {
|
|
50
|
+
...getStartAtVariants('large')
|
|
51
51
|
},
|
|
52
|
-
[`@media screen and (${componentTheme.xLargeMin})`]: {
|
|
52
|
+
[`@media screen and (${componentTheme.xLargeMin})`]: {
|
|
53
|
+
...getStartAtVariants('x-large')
|
|
53
54
|
},
|
|
54
55
|
...(visualDebug && {
|
|
55
56
|
outline: '0.0625rem dashed red'
|
|
@@ -57,5 +58,4 @@ const generateStyle = (componentTheme, props) => {
|
|
|
57
58
|
}
|
|
58
59
|
};
|
|
59
60
|
};
|
|
60
|
-
|
|
61
61
|
export default generateStyle;
|
package/es/Grid/theme.js
CHANGED
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
31
|
const spacing = theme.spacing,
|
|
32
|
-
|
|
32
|
+
media = theme.media;
|
|
33
33
|
const componentVariables = {
|
|
34
34
|
spacingSmall: spacing === null || spacing === void 0 ? void 0 : spacing.small,
|
|
35
35
|
spacingMedium: spacing === null || spacing === void 0 ? void 0 : spacing.medium,
|
|
36
36
|
spacingLarge: spacing === null || spacing === void 0 ? void 0 : spacing.large,
|
|
37
37
|
...media
|
|
38
38
|
};
|
|
39
|
-
return {
|
|
39
|
+
return {
|
|
40
|
+
...componentVariables
|
|
40
41
|
};
|
|
41
42
|
};
|
|
42
|
-
|
|
43
43
|
export default generateComponentTheme;
|
package/es/GridCol/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _dec, _class, _class2;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -32,7 +31,6 @@ import { logWarn as warn } from '@instructure/console';
|
|
|
32
31
|
import generateStyle from './styles';
|
|
33
32
|
import generateComponentTheme from './theme';
|
|
34
33
|
import { propTypes, allowedProps } from './props';
|
|
35
|
-
|
|
36
34
|
/**
|
|
37
35
|
---
|
|
38
36
|
parent: Grid
|
|
@@ -44,26 +42,21 @@ let GridCol = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_cl
|
|
|
44
42
|
constructor() {
|
|
45
43
|
super(...arguments);
|
|
46
44
|
this.ref = null;
|
|
47
|
-
|
|
48
45
|
this.handleRef = el => {
|
|
49
46
|
const elementRef = this.props.elementRef;
|
|
50
47
|
this.ref = el;
|
|
51
|
-
|
|
52
48
|
if (typeof elementRef === 'function') {
|
|
53
49
|
elementRef(el);
|
|
54
50
|
}
|
|
55
51
|
};
|
|
56
52
|
}
|
|
57
|
-
|
|
58
53
|
widthCheck() {
|
|
59
54
|
const width = this.props.width;
|
|
60
55
|
let shouldWarn = false;
|
|
61
|
-
|
|
62
56
|
if (width) {
|
|
63
57
|
if (typeof width === 'number' && width <= 0) {
|
|
64
58
|
shouldWarn = true;
|
|
65
59
|
}
|
|
66
|
-
|
|
67
60
|
if (typeof width === 'object') {
|
|
68
61
|
Object.keys(width).forEach(breakpoint => {
|
|
69
62
|
//@ts-expect-error Ts doesn't understand Object.keys properly
|
|
@@ -73,37 +66,30 @@ let GridCol = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_cl
|
|
|
73
66
|
});
|
|
74
67
|
}
|
|
75
68
|
}
|
|
76
|
-
|
|
77
69
|
if (shouldWarn) {
|
|
78
70
|
warn(false, 'Col width must be positive!');
|
|
79
71
|
}
|
|
80
72
|
}
|
|
81
|
-
|
|
82
73
|
componentDidMount() {
|
|
83
74
|
var _this$props$makeStyle, _this$props;
|
|
84
|
-
|
|
85
75
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
86
76
|
this.widthCheck();
|
|
87
77
|
}
|
|
88
|
-
|
|
89
78
|
componentDidUpdate() {
|
|
90
79
|
var _this$props$makeStyle2, _this$props2;
|
|
91
|
-
|
|
92
80
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
93
81
|
this.widthCheck();
|
|
94
82
|
}
|
|
95
|
-
|
|
96
83
|
render() {
|
|
97
84
|
const _this$props3 = this.props,
|
|
98
|
-
|
|
99
|
-
|
|
85
|
+
children = _this$props3.children,
|
|
86
|
+
styles = _this$props3.styles;
|
|
100
87
|
const props = omitProps(this.props, GridCol.allowedProps);
|
|
101
88
|
return jsx("span", Object.assign({}, props, {
|
|
102
89
|
ref: this.handleRef,
|
|
103
90
|
css: styles === null || styles === void 0 ? void 0 : styles.gridCol
|
|
104
91
|
}), children);
|
|
105
92
|
}
|
|
106
|
-
|
|
107
93
|
}, _class2.displayName = "GridCol", _class2.componentId = 'Grid.Col', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
108
94
|
textAlign: 'inherit',
|
|
109
95
|
children: null,
|
package/es/GridCol/props.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import PropTypes from 'prop-types';
|
|
25
26
|
// TODO: get numcols from theme config
|
|
26
27
|
const COL_WIDTHS = PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['auto'])]);
|
package/es/GridCol/styles.js
CHANGED
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, props) => {
|
|
36
36
|
const vAlign = props.vAlign,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
textAlign = props.textAlign,
|
|
38
|
+
rowSpacing = props.rowSpacing,
|
|
39
|
+
colSpacing = props.colSpacing,
|
|
40
|
+
isLastRow = props.isLastRow,
|
|
41
|
+
isLastCol = props.isLastCol,
|
|
42
|
+
startAt = props.startAt,
|
|
43
|
+
visualDebug = props.visualDebug;
|
|
44
44
|
const rowSpacingVariants = {
|
|
45
45
|
small: {
|
|
46
46
|
marginBottom: componentTheme.spacingSmall
|
|
@@ -55,7 +55,6 @@ const generateStyle = (componentTheme, props) => {
|
|
|
55
55
|
marginBottom: 0
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
-
|
|
59
58
|
const getStartGridColumnStyle = () => {
|
|
60
59
|
const colSpacingVariants = {
|
|
61
60
|
small: {
|
|
@@ -108,41 +107,31 @@ const generateStyle = (componentTheme, props) => {
|
|
|
108
107
|
...(textAlign && textAlignVariants[textAlign])
|
|
109
108
|
};
|
|
110
109
|
};
|
|
111
|
-
|
|
112
110
|
const enabledBreakpoints = () => {
|
|
113
111
|
const breakpoints = ['small', 'medium', 'large', 'x-large', null];
|
|
114
112
|
return breakpoints.slice(breakpoints.indexOf(startAt));
|
|
115
113
|
};
|
|
116
|
-
|
|
117
114
|
const breakpointIsEnabled = breakpoint => {
|
|
118
115
|
return enabledBreakpoints().includes(breakpoint);
|
|
119
116
|
};
|
|
120
|
-
|
|
121
117
|
const getColSize = breakpoint => {
|
|
122
118
|
let width = props.width;
|
|
123
119
|
if (!width) return;
|
|
124
|
-
|
|
125
120
|
if (width && typeof width === 'object') {
|
|
126
121
|
width = width[breakpoint === 'x-large' ? 'xLarge' : breakpoint];
|
|
127
122
|
}
|
|
128
|
-
|
|
129
123
|
return width;
|
|
130
124
|
};
|
|
131
|
-
|
|
132
125
|
const getColOffset = breakpoint => {
|
|
133
126
|
let offset = props.offset;
|
|
134
127
|
if (!offset) return;
|
|
135
|
-
|
|
136
128
|
if (offset && typeof offset === 'object') {
|
|
137
129
|
offset = offset[breakpoint === 'x-large' ? 'xLarge' : breakpoint];
|
|
138
130
|
}
|
|
139
|
-
|
|
140
131
|
return offset;
|
|
141
132
|
};
|
|
142
|
-
|
|
143
133
|
const getFlexColumnBySize = function () {
|
|
144
134
|
let size = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '1';
|
|
145
|
-
|
|
146
135
|
switch (size) {
|
|
147
136
|
case 'auto':
|
|
148
137
|
return {
|
|
@@ -150,12 +139,10 @@ const generateStyle = (componentTheme, props) => {
|
|
|
150
139
|
flexShrink: 0,
|
|
151
140
|
flexBasis: 'auto'
|
|
152
141
|
};
|
|
153
|
-
|
|
154
142
|
case 12:
|
|
155
143
|
return {
|
|
156
144
|
flex: '0 0 100%'
|
|
157
145
|
};
|
|
158
|
-
|
|
159
146
|
default:
|
|
160
147
|
return {
|
|
161
148
|
flexGrow: 0,
|
|
@@ -165,15 +152,12 @@ const generateStyle = (componentTheme, props) => {
|
|
|
165
152
|
};
|
|
166
153
|
}
|
|
167
154
|
};
|
|
168
|
-
|
|
169
155
|
const getColumnOffsetBySize = function () {
|
|
170
156
|
let size = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '1';
|
|
171
|
-
|
|
172
157
|
switch (size) {
|
|
173
158
|
case 'auto':
|
|
174
159
|
case 12:
|
|
175
160
|
return {};
|
|
176
|
-
|
|
177
161
|
default:
|
|
178
162
|
return {
|
|
179
163
|
marginInlineStart: `calc(${size} / 12 * 99.999%)`,
|
|
@@ -181,22 +165,21 @@ const generateStyle = (componentTheme, props) => {
|
|
|
181
165
|
};
|
|
182
166
|
}
|
|
183
167
|
};
|
|
184
|
-
|
|
185
|
-
|
|
168
|
+
const getStartAtVariants = breakpoint => !!startAt && startAt === breakpoint ? {
|
|
169
|
+
...getStartGridColumnStyle()
|
|
186
170
|
} : {};
|
|
187
|
-
|
|
188
171
|
const getGridColumnsForBreakpoint = breakpoint => {
|
|
189
172
|
const size = getColSize(breakpoint);
|
|
190
173
|
const offset = getColOffset(breakpoint);
|
|
191
|
-
return breakpointIsEnabled(breakpoint) ? {
|
|
174
|
+
return breakpointIsEnabled(breakpoint) ? {
|
|
175
|
+
...(size && getFlexColumnBySize(size)),
|
|
192
176
|
...(offset && getColumnOffsetBySize(size))
|
|
193
177
|
} : {};
|
|
194
178
|
};
|
|
195
|
-
|
|
196
|
-
|
|
179
|
+
const getBreakpointStyles = breakpoint => ({
|
|
180
|
+
...getStartAtVariants(breakpoint),
|
|
197
181
|
...getGridColumnsForBreakpoint(breakpoint)
|
|
198
182
|
});
|
|
199
|
-
|
|
200
183
|
return {
|
|
201
184
|
gridCol: {
|
|
202
185
|
label: 'gridCol',
|
|
@@ -209,11 +192,14 @@ const generateStyle = (componentTheme, props) => {
|
|
|
209
192
|
marginBottom: 0
|
|
210
193
|
}),
|
|
211
194
|
...getBreakpointStyles('small'),
|
|
212
|
-
[`@media screen and (${componentTheme.mediumMin})`]: {
|
|
195
|
+
[`@media screen and (${componentTheme.mediumMin})`]: {
|
|
196
|
+
...getBreakpointStyles('medium')
|
|
213
197
|
},
|
|
214
|
-
[`@media screen and (${componentTheme.largeMin})`]: {
|
|
198
|
+
[`@media screen and (${componentTheme.largeMin})`]: {
|
|
199
|
+
...getBreakpointStyles('large')
|
|
215
200
|
},
|
|
216
|
-
[`@media screen and (${componentTheme.xLargeMin})`]: {
|
|
201
|
+
[`@media screen and (${componentTheme.xLargeMin})`]: {
|
|
202
|
+
...getBreakpointStyles('x-large')
|
|
217
203
|
},
|
|
218
204
|
...(visualDebug && {
|
|
219
205
|
outline: '0.0625rem dashed red'
|
|
@@ -221,5 +207,4 @@ const generateStyle = (componentTheme, props) => {
|
|
|
221
207
|
}
|
|
222
208
|
};
|
|
223
209
|
};
|
|
224
|
-
|
|
225
210
|
export default generateStyle;
|
package/es/GridCol/theme.js
CHANGED
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
31
|
const spacing = theme.spacing,
|
|
32
|
-
|
|
32
|
+
media = theme.media;
|
|
33
33
|
const componentVariables = {
|
|
34
34
|
spacingSmall: spacing === null || spacing === void 0 ? void 0 : spacing.small,
|
|
35
35
|
spacingMedium: spacing === null || spacing === void 0 ? void 0 : spacing.medium,
|
|
36
36
|
spacingLarge: spacing === null || spacing === void 0 ? void 0 : spacing.large,
|
|
37
37
|
...media
|
|
38
38
|
};
|
|
39
|
-
return {
|
|
39
|
+
return {
|
|
40
|
+
...componentVariables
|
|
40
41
|
};
|
|
41
42
|
};
|
|
42
|
-
|
|
43
43
|
export default generateComponentTheme;
|
package/es/GridRow/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
const _excluded = ["styles", "makeStyles"],
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
_excluded2 = ["styles"];
|
|
5
4
|
var _dec, _class, _class2;
|
|
6
|
-
|
|
7
5
|
/*
|
|
8
6
|
* The MIT License (MIT)
|
|
9
7
|
*
|
|
@@ -36,7 +34,6 @@ import { withStyle, jsx } from '@instructure/emotion';
|
|
|
36
34
|
import generateStyle from './styles';
|
|
37
35
|
import generateComponentTheme from './theme';
|
|
38
36
|
import { propTypes, allowedProps } from './props';
|
|
39
|
-
|
|
40
37
|
/**
|
|
41
38
|
---
|
|
42
39
|
parent: Grid
|
|
@@ -48,36 +45,28 @@ let GridRow = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_cl
|
|
|
48
45
|
constructor() {
|
|
49
46
|
super(...arguments);
|
|
50
47
|
this.ref = null;
|
|
51
|
-
|
|
52
48
|
this.handleRef = el => {
|
|
53
49
|
this.ref = el;
|
|
54
50
|
};
|
|
55
51
|
}
|
|
56
|
-
|
|
57
52
|
componentDidMount() {
|
|
58
53
|
var _this$props$makeStyle, _this$props;
|
|
59
|
-
|
|
60
54
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
61
55
|
}
|
|
62
|
-
|
|
63
56
|
componentDidUpdate() {
|
|
64
57
|
var _this$props$makeStyle2, _this$props2;
|
|
65
|
-
|
|
66
58
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
67
59
|
}
|
|
68
|
-
|
|
69
60
|
renderChildren() {
|
|
70
61
|
const _this$props3 = this.props,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
62
|
+
styles = _this$props3.styles,
|
|
63
|
+
makeStyles = _this$props3.makeStyles,
|
|
64
|
+
props = _objectWithoutProperties(_this$props3, _excluded);
|
|
75
65
|
return Children.map(this.props.children, (child, index) => {
|
|
76
66
|
if (matchComponentTypes(child, [GridCol])) {
|
|
77
|
-
return safeCloneElement(child, {
|
|
78
|
-
...
|
|
79
|
-
/* child props should override parent
|
|
80
|
-
,
|
|
67
|
+
return safeCloneElement(child, {
|
|
68
|
+
...pickProps(props, GridRow.allowedProps),
|
|
69
|
+
...child.props /* child props should override parent */,
|
|
81
70
|
isLastRow: props.isLastRow,
|
|
82
71
|
isLastCol: index + 1 === Children.count(this.props.children)
|
|
83
72
|
});
|
|
@@ -89,16 +78,14 @@ let GridRow = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_cl
|
|
|
89
78
|
|
|
90
79
|
render() {
|
|
91
80
|
const _this$props4 = this.props,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
81
|
+
styles = _this$props4.styles,
|
|
82
|
+
restProps = _objectWithoutProperties(_this$props4, _excluded2);
|
|
95
83
|
const props = omitProps(restProps, GridRow.allowedProps);
|
|
96
84
|
return jsx("span", Object.assign({}, props, {
|
|
97
85
|
css: styles === null || styles === void 0 ? void 0 : styles.gridRow,
|
|
98
86
|
ref: this.handleRef
|
|
99
87
|
}), this.renderChildren());
|
|
100
88
|
}
|
|
101
|
-
|
|
102
89
|
}, _class2.displayName = "GridRow", _class2.componentId = 'Grid.Row', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
103
90
|
children: null,
|
|
104
91
|
isLastRow: false
|
package/es/GridRow/props.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import PropTypes from 'prop-types';
|
|
25
26
|
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types';
|
|
26
27
|
import { ScreenReaderContent } from '@instructure/ui-a11y-content';
|
package/es/GridRow/styles.js
CHANGED
|
@@ -34,13 +34,12 @@
|
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, props) => {
|
|
36
36
|
const hAlign = props.hAlign,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
vAlign = props.vAlign,
|
|
38
|
+
rowSpacing = props.rowSpacing,
|
|
39
|
+
colSpacing = props.colSpacing,
|
|
40
|
+
isLastRow = props.isLastRow,
|
|
41
|
+
startAt = props.startAt,
|
|
42
|
+
visualDebug = props.visualDebug;
|
|
44
43
|
const getGridRowStyle = () => {
|
|
45
44
|
const hAlignVariants = {
|
|
46
45
|
center: {
|
|
@@ -108,21 +107,23 @@ const generateStyle = (componentTheme, props) => {
|
|
|
108
107
|
})
|
|
109
108
|
};
|
|
110
109
|
};
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
const getStartAtVariants = breakpoint => !!startAt && startAt === breakpoint ? {
|
|
111
|
+
...getGridRowStyle()
|
|
113
112
|
} : {};
|
|
114
|
-
|
|
115
113
|
return {
|
|
116
114
|
gridRow: {
|
|
117
115
|
label: 'gridRow',
|
|
118
116
|
display: 'block',
|
|
119
117
|
boxSizing: 'border-box',
|
|
120
118
|
...getStartAtVariants('small'),
|
|
121
|
-
[`@media screen and (${componentTheme.mediumMin})`]: {
|
|
119
|
+
[`@media screen and (${componentTheme.mediumMin})`]: {
|
|
120
|
+
...getStartAtVariants('medium')
|
|
122
121
|
},
|
|
123
|
-
[`@media screen and (${componentTheme.largeMin})`]: {
|
|
122
|
+
[`@media screen and (${componentTheme.largeMin})`]: {
|
|
123
|
+
...getStartAtVariants('large')
|
|
124
124
|
},
|
|
125
|
-
[`@media screen and (${componentTheme.xLargeMin})`]: {
|
|
125
|
+
[`@media screen and (${componentTheme.xLargeMin})`]: {
|
|
126
|
+
...getStartAtVariants('x-large')
|
|
126
127
|
},
|
|
127
128
|
...(visualDebug && {
|
|
128
129
|
outline: '0.0625rem dashed blue'
|
|
@@ -130,5 +131,4 @@ const generateStyle = (componentTheme, props) => {
|
|
|
130
131
|
}
|
|
131
132
|
};
|
|
132
133
|
};
|
|
133
|
-
|
|
134
134
|
export default generateStyle;
|
package/es/GridRow/theme.js
CHANGED
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
31
|
const spacing = theme.spacing,
|
|
32
|
-
|
|
32
|
+
media = theme.media;
|
|
33
33
|
const componentVariables = {
|
|
34
34
|
spacingSmall: spacing === null || spacing === void 0 ? void 0 : spacing.small,
|
|
35
35
|
spacingMedium: spacing === null || spacing === void 0 ? void 0 : spacing.medium,
|
|
36
36
|
spacingLarge: spacing === null || spacing === void 0 ? void 0 : spacing.large,
|
|
37
37
|
...media
|
|
38
38
|
};
|
|
39
|
-
return {
|
|
39
|
+
return {
|
|
40
|
+
...componentVariables
|
|
40
41
|
};
|
|
41
42
|
};
|
|
42
|
-
|
|
43
43
|
export default generateComponentTheme;
|