@khanacademy/wonder-blocks-layout 1.4.3 → 1.4.7
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 +6 -0
- package/dist/es/index.js +10 -10
- package/dist/index.js +126 -101
- package/package.json +7 -8
- package/src/__tests__/__snapshots__/generated-snapshot.test.js.snap +5 -5
- package/src/components/__tests__/media-layout-context.test.js +1 -0
- package/src/components/__tests__/media-layout.test.js +1 -0
- package/src/components/media-layout.js +2 -3
- package/src/components/spring.stories.js +10 -14
- package/src/components/strut.stories.js +10 -14
- package/LICENSE +0 -21
package/CHANGELOG.md
ADDED
package/dist/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from '@babel/runtime/helpers/extends';
|
|
2
|
-
import
|
|
2
|
+
import * as React from 'react';
|
|
3
3
|
import Spacing from '@khanacademy/wonder-blocks-spacing';
|
|
4
4
|
import { StyleSheet } from 'aphrodite';
|
|
5
5
|
import { View } from '@khanacademy/wonder-blocks-core';
|
|
@@ -59,7 +59,7 @@ const defaultContext = {
|
|
|
59
59
|
ssrSize: "large",
|
|
60
60
|
mediaSpec: MEDIA_DEFAULT_SPEC
|
|
61
61
|
};
|
|
62
|
-
var MediaLayoutContext = /*#__PURE__*/createContext(defaultContext);
|
|
62
|
+
var MediaLayoutContext = /*#__PURE__*/React.createContext(defaultContext);
|
|
63
63
|
|
|
64
64
|
const queries = [].concat(Object.values(MEDIA_DEFAULT_SPEC).map(spec => spec.query), Object.values(MEDIA_INTERNAL_SPEC).map(spec => spec.query), Object.values(MEDIA_MODAL_SPEC).map(spec => spec.query));
|
|
65
65
|
const mediaQueryLists = {}; // eslint-disable-next-line flowtype/require-exact-type
|
|
@@ -74,7 +74,7 @@ const DEFAULT_SIZE = "large";
|
|
|
74
74
|
* to specify different breakpoint configurations. By default it uses
|
|
75
75
|
* `MEDIA_DEFAULT_SPEC`. See media-layout-context.js for additiional options.
|
|
76
76
|
*/
|
|
77
|
-
class MediaLayoutInternal extends Component {
|
|
77
|
+
class MediaLayoutInternal extends React.Component {
|
|
78
78
|
// A collection of thunks that's used to clean up event listeners
|
|
79
79
|
// when the component is unmounted.
|
|
80
80
|
constructor(props) {
|
|
@@ -217,16 +217,16 @@ class MediaLayoutInternal extends Component {
|
|
|
217
217
|
} // gen-snapshot-tests.js only understands `export default class ...`
|
|
218
218
|
|
|
219
219
|
|
|
220
|
-
class MediaLayout extends Component {
|
|
220
|
+
class MediaLayout extends React.Component {
|
|
221
221
|
render() {
|
|
222
222
|
// We listen to the MediaLayoutContext to see what defaults we're
|
|
223
223
|
// being given (this can be overriden by wrapping this component in
|
|
224
224
|
// a MediaLayoutContext.Consumer).
|
|
225
|
-
return /*#__PURE__*/createElement(MediaLayoutContext.Consumer, null, ({
|
|
225
|
+
return /*#__PURE__*/React.createElement(MediaLayoutContext.Consumer, null, ({
|
|
226
226
|
overrideSize,
|
|
227
227
|
ssrSize,
|
|
228
228
|
mediaSpec
|
|
229
|
-
}) => /*#__PURE__*/createElement(MediaLayoutInternal, _extends({}, this.props, {
|
|
229
|
+
}) => /*#__PURE__*/React.createElement(MediaLayoutInternal, _extends({}, this.props, {
|
|
230
230
|
overrideSize: overrideSize,
|
|
231
231
|
ssrSize: ssrSize,
|
|
232
232
|
mediaSpec: mediaSpec
|
|
@@ -240,12 +240,12 @@ class MediaLayout extends Component {
|
|
|
240
240
|
*
|
|
241
241
|
* Assumes parent is a View.
|
|
242
242
|
*/
|
|
243
|
-
class Spring extends Component {
|
|
243
|
+
class Spring extends React.Component {
|
|
244
244
|
render() {
|
|
245
245
|
const {
|
|
246
246
|
style
|
|
247
247
|
} = this.props;
|
|
248
|
-
return /*#__PURE__*/createElement(View, {
|
|
248
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
249
249
|
"aria-hidden": "true",
|
|
250
250
|
style: [styles.grow, style]
|
|
251
251
|
});
|
|
@@ -263,13 +263,13 @@ const styles = StyleSheet.create({
|
|
|
263
263
|
*
|
|
264
264
|
* Assumes parent is a View.
|
|
265
265
|
*/
|
|
266
|
-
class Strut extends Component {
|
|
266
|
+
class Strut extends React.Component {
|
|
267
267
|
render() {
|
|
268
268
|
const {
|
|
269
269
|
size,
|
|
270
270
|
style
|
|
271
271
|
} = this.props;
|
|
272
|
-
return /*#__PURE__*/createElement(View, {
|
|
272
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
273
273
|
"aria-hidden": "true",
|
|
274
274
|
style: [strutStyle(size), style]
|
|
275
275
|
});
|
package/dist/index.js
CHANGED
|
@@ -82,7 +82,7 @@ module.exports =
|
|
|
82
82
|
/******/
|
|
83
83
|
/******/
|
|
84
84
|
/******/ // Load entry module and return exports
|
|
85
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
|
85
|
+
/******/ return __webpack_require__(__webpack_require__.s = 10);
|
|
86
86
|
/******/ })
|
|
87
87
|
/************************************************************************/
|
|
88
88
|
/******/ ([
|
|
@@ -99,96 +99,38 @@ module.exports = require("@khanacademy/wonder-blocks-spacing");
|
|
|
99
99
|
|
|
100
100
|
/***/ }),
|
|
101
101
|
/* 2 */
|
|
102
|
-
/***/ (function(module, exports) {
|
|
103
|
-
|
|
104
|
-
module.exports = require("@khanacademy/wonder-blocks-core");
|
|
105
|
-
|
|
106
|
-
/***/ }),
|
|
107
|
-
/* 3 */
|
|
108
|
-
/***/ (function(module, exports) {
|
|
109
|
-
|
|
110
|
-
function _extends() {
|
|
111
|
-
module.exports = _extends = Object.assign || function (target) {
|
|
112
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
113
|
-
var source = arguments[i];
|
|
114
|
-
|
|
115
|
-
for (var key in source) {
|
|
116
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
117
|
-
target[key] = source[key];
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return target;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
module.exports["default"] = module.exports, module.exports.__esModule = true;
|
|
126
|
-
return _extends.apply(this, arguments);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
module.exports = _extends;
|
|
130
|
-
module.exports["default"] = module.exports, module.exports.__esModule = true;
|
|
131
|
-
|
|
132
|
-
/***/ }),
|
|
133
|
-
/* 4 */
|
|
134
|
-
/***/ (function(module, exports) {
|
|
135
|
-
|
|
136
|
-
module.exports = require("aphrodite");
|
|
137
|
-
|
|
138
|
-
/***/ }),
|
|
139
|
-
/* 5 */
|
|
140
102
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
141
103
|
|
|
142
104
|
"use strict";
|
|
143
|
-
|
|
144
|
-
__webpack_require__.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
__webpack_require__.d(__webpack_exports__, "Spring", function() { return /* reexport */ spring_Spring; });
|
|
150
|
-
__webpack_require__.d(__webpack_exports__, "Strut", function() { return /* reexport */ strut_Strut; });
|
|
151
|
-
__webpack_require__.d(__webpack_exports__, "VALID_MEDIA_SIZES", function() { return /* reexport */ VALID_MEDIA_SIZES; });
|
|
152
|
-
__webpack_require__.d(__webpack_exports__, "MEDIA_DEFAULT_SPEC", function() { return /* reexport */ MEDIA_DEFAULT_SPEC; });
|
|
153
|
-
__webpack_require__.d(__webpack_exports__, "MEDIA_INTERNAL_SPEC", function() { return /* reexport */ MEDIA_INTERNAL_SPEC; });
|
|
154
|
-
__webpack_require__.d(__webpack_exports__, "MEDIA_MODAL_SPEC", function() { return /* reexport */ MEDIA_MODAL_SPEC; });
|
|
155
|
-
__webpack_require__.d(__webpack_exports__, "queryMatchesSize", function() { return /* reexport */ queryMatchesSize; });
|
|
156
|
-
|
|
157
|
-
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/extends.js
|
|
158
|
-
var helpers_extends = __webpack_require__(3);
|
|
159
|
-
var extends_default = /*#__PURE__*/__webpack_require__.n(helpers_extends);
|
|
160
|
-
|
|
161
|
-
// EXTERNAL MODULE: external "react"
|
|
162
|
-
var external_react_ = __webpack_require__(0);
|
|
163
|
-
|
|
164
|
-
// EXTERNAL MODULE: external "@khanacademy/wonder-blocks-spacing"
|
|
165
|
-
var wonder_blocks_spacing_ = __webpack_require__(1);
|
|
166
|
-
var wonder_blocks_spacing_default = /*#__PURE__*/__webpack_require__.n(wonder_blocks_spacing_);
|
|
167
|
-
|
|
168
|
-
// CONCATENATED MODULE: ./packages/wonder-blocks-layout/src/util/specs.js
|
|
105
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return VALID_MEDIA_SIZES; });
|
|
106
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return MEDIA_DEFAULT_SPEC; });
|
|
107
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return MEDIA_INTERNAL_SPEC; });
|
|
108
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return MEDIA_MODAL_SPEC; });
|
|
109
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
|
|
110
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_0__);
|
|
169
111
|
|
|
170
112
|
// All possible valid media sizes
|
|
171
113
|
const VALID_MEDIA_SIZES = ["small", "medium", "large"];
|
|
172
|
-
const mediaDefaultSpecLargeMarginWidth =
|
|
114
|
+
const mediaDefaultSpecLargeMarginWidth = _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_0___default.a.large_24; // The default spec for media layout, currently available in
|
|
173
115
|
// three different settings (roughly mobile, tablet, and desktop).
|
|
174
116
|
|
|
175
117
|
const MEDIA_DEFAULT_SPEC = {
|
|
176
118
|
small: {
|
|
177
119
|
query: "(max-width: 767px)",
|
|
178
120
|
totalColumns: 4,
|
|
179
|
-
gutterWidth:
|
|
180
|
-
marginWidth:
|
|
121
|
+
gutterWidth: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_0___default.a.medium_16,
|
|
122
|
+
marginWidth: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_0___default.a.medium_16
|
|
181
123
|
},
|
|
182
124
|
medium: {
|
|
183
125
|
query: "(min-width: 768px) and (max-width: 1023px)",
|
|
184
126
|
totalColumns: 8,
|
|
185
|
-
gutterWidth:
|
|
186
|
-
marginWidth:
|
|
127
|
+
gutterWidth: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_0___default.a.xLarge_32,
|
|
128
|
+
marginWidth: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_0___default.a.large_24
|
|
187
129
|
},
|
|
188
130
|
large: {
|
|
189
131
|
query: "(min-width: 1024px)",
|
|
190
132
|
totalColumns: 12,
|
|
191
|
-
gutterWidth:
|
|
133
|
+
gutterWidth: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_0___default.a.xLarge_32,
|
|
192
134
|
marginWidth: mediaDefaultSpecLargeMarginWidth,
|
|
193
135
|
maxWidth: 1120 + mediaDefaultSpecLargeMarginWidth * 2
|
|
194
136
|
}
|
|
@@ -198,8 +140,8 @@ const MEDIA_INTERNAL_SPEC = {
|
|
|
198
140
|
large: {
|
|
199
141
|
query: "(min-width: 1px)",
|
|
200
142
|
totalColumns: 12,
|
|
201
|
-
gutterWidth:
|
|
202
|
-
marginWidth:
|
|
143
|
+
gutterWidth: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_0___default.a.xLarge_32,
|
|
144
|
+
marginWidth: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_0___default.a.medium_16
|
|
203
145
|
}
|
|
204
146
|
}; // The default used for modals
|
|
205
147
|
|
|
@@ -207,30 +149,55 @@ const MEDIA_MODAL_SPEC = {
|
|
|
207
149
|
small: {
|
|
208
150
|
query: "(max-width: 767px)",
|
|
209
151
|
totalColumns: 4,
|
|
210
|
-
gutterWidth:
|
|
211
|
-
marginWidth:
|
|
152
|
+
gutterWidth: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_0___default.a.medium_16,
|
|
153
|
+
marginWidth: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_0___default.a.medium_16
|
|
212
154
|
},
|
|
213
155
|
large: {
|
|
214
156
|
query: "(min-width: 768px)",
|
|
215
157
|
totalColumns: 12,
|
|
216
|
-
gutterWidth:
|
|
217
|
-
marginWidth:
|
|
158
|
+
gutterWidth: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_0___default.a.xLarge_32,
|
|
159
|
+
marginWidth: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_0___default.a.xxLarge_48
|
|
218
160
|
}
|
|
219
161
|
};
|
|
220
|
-
|
|
162
|
+
|
|
163
|
+
/***/ }),
|
|
164
|
+
/* 3 */
|
|
165
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
166
|
+
|
|
167
|
+
"use strict";
|
|
168
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
169
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
170
|
+
/* harmony import */ var _util_specs_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
|
|
221
171
|
|
|
222
172
|
|
|
223
173
|
const defaultContext = {
|
|
224
174
|
ssrSize: "large",
|
|
225
|
-
mediaSpec: MEDIA_DEFAULT_SPEC
|
|
175
|
+
mediaSpec: _util_specs_js__WEBPACK_IMPORTED_MODULE_1__[/* MEDIA_DEFAULT_SPEC */ "a"]
|
|
226
176
|
};
|
|
227
|
-
/* harmony default export */
|
|
228
|
-
// CONCATENATED MODULE: ./packages/wonder-blocks-layout/src/components/media-layout.js
|
|
177
|
+
/* harmony default export */ __webpack_exports__["a"] = (/*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createContext"](defaultContext));
|
|
229
178
|
|
|
179
|
+
/***/ }),
|
|
180
|
+
/* 4 */
|
|
181
|
+
/***/ (function(module, exports) {
|
|
230
182
|
|
|
183
|
+
module.exports = require("@khanacademy/wonder-blocks-core");
|
|
184
|
+
|
|
185
|
+
/***/ }),
|
|
186
|
+
/* 5 */
|
|
187
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
188
|
+
|
|
189
|
+
"use strict";
|
|
190
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return MediaLayout; });
|
|
191
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
192
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
193
|
+
/* harmony import */ var _media_layout_context_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
|
|
194
|
+
/* harmony import */ var _util_specs_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
|
|
195
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
231
196
|
|
|
232
197
|
|
|
233
|
-
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
const queries = [].concat(Object.values(_util_specs_js__WEBPACK_IMPORTED_MODULE_2__[/* MEDIA_DEFAULT_SPEC */ "a"]).map(spec => spec.query), Object.values(_util_specs_js__WEBPACK_IMPORTED_MODULE_2__[/* MEDIA_INTERNAL_SPEC */ "b"]).map(spec => spec.query), Object.values(_util_specs_js__WEBPACK_IMPORTED_MODULE_2__[/* MEDIA_MODAL_SPEC */ "c"]).map(spec => spec.query));
|
|
234
201
|
const mediaQueryLists = {}; // eslint-disable-next-line flowtype/require-exact-type
|
|
235
202
|
|
|
236
203
|
// If for some reason we're not able to resolve the current media size we
|
|
@@ -243,7 +210,7 @@ const DEFAULT_SIZE = "large";
|
|
|
243
210
|
* to specify different breakpoint configurations. By default it uses
|
|
244
211
|
* `MEDIA_DEFAULT_SPEC`. See media-layout-context.js for additiional options.
|
|
245
212
|
*/
|
|
246
|
-
class
|
|
213
|
+
class MediaLayoutInternal extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
247
214
|
// A collection of thunks that's used to clean up event listeners
|
|
248
215
|
// when the component is unmounted.
|
|
249
216
|
constructor(props) {
|
|
@@ -292,8 +259,8 @@ class media_layout_MediaLayoutInternal extends external_react_["Component"] {
|
|
|
292
259
|
} else {
|
|
293
260
|
const entries = Object.entries(this.props.mediaSpec);
|
|
294
261
|
|
|
295
|
-
for (const [size,
|
|
296
|
-
const mql = mediaQueryLists[
|
|
262
|
+
for (const [size, spec] of entries) {
|
|
263
|
+
const mql = mediaQueryLists[spec.query];
|
|
297
264
|
|
|
298
265
|
if (mql.matches) {
|
|
299
266
|
return size;
|
|
@@ -386,16 +353,16 @@ class media_layout_MediaLayoutInternal extends external_react_["Component"] {
|
|
|
386
353
|
} // gen-snapshot-tests.js only understands `export default class ...`
|
|
387
354
|
|
|
388
355
|
|
|
389
|
-
class
|
|
356
|
+
class MediaLayout extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
390
357
|
render() {
|
|
391
358
|
// We listen to the MediaLayoutContext to see what defaults we're
|
|
392
359
|
// being given (this can be overriden by wrapping this component in
|
|
393
360
|
// a MediaLayoutContext.Consumer).
|
|
394
|
-
return /*#__PURE__*/
|
|
361
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_media_layout_context_js__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].Consumer, null, ({
|
|
395
362
|
overrideSize,
|
|
396
363
|
ssrSize,
|
|
397
364
|
mediaSpec
|
|
398
|
-
}) => /*#__PURE__*/
|
|
365
|
+
}) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](MediaLayoutInternal, _extends({}, this.props, {
|
|
399
366
|
overrideSize: overrideSize,
|
|
400
367
|
ssrSize: ssrSize,
|
|
401
368
|
mediaSpec: mediaSpec
|
|
@@ -403,13 +370,19 @@ class media_layout_MediaLayout extends external_react_["Component"] {
|
|
|
403
370
|
}
|
|
404
371
|
|
|
405
372
|
}
|
|
406
|
-
// EXTERNAL MODULE: external "aphrodite"
|
|
407
|
-
var external_aphrodite_ = __webpack_require__(4);
|
|
408
373
|
|
|
409
|
-
|
|
410
|
-
|
|
374
|
+
/***/ }),
|
|
375
|
+
/* 6 */
|
|
376
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
411
377
|
|
|
412
|
-
|
|
378
|
+
"use strict";
|
|
379
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Spring; });
|
|
380
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
381
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
382
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9);
|
|
383
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
384
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
|
|
385
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2__);
|
|
413
386
|
|
|
414
387
|
|
|
415
388
|
|
|
@@ -419,24 +392,34 @@ var wonder_blocks_core_ = __webpack_require__(2);
|
|
|
419
392
|
*
|
|
420
393
|
* Assumes parent is a View.
|
|
421
394
|
*/
|
|
422
|
-
class
|
|
395
|
+
class Spring extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
423
396
|
render() {
|
|
424
397
|
const {
|
|
425
398
|
style
|
|
426
399
|
} = this.props;
|
|
427
|
-
return /*#__PURE__*/
|
|
400
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2__["View"], {
|
|
428
401
|
"aria-hidden": "true",
|
|
429
402
|
style: [styles.grow, style]
|
|
430
403
|
});
|
|
431
404
|
}
|
|
432
405
|
|
|
433
406
|
}
|
|
434
|
-
const styles =
|
|
407
|
+
const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
435
408
|
grow: {
|
|
436
409
|
flexGrow: 1
|
|
437
410
|
}
|
|
438
411
|
});
|
|
439
|
-
|
|
412
|
+
|
|
413
|
+
/***/ }),
|
|
414
|
+
/* 7 */
|
|
415
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
416
|
+
|
|
417
|
+
"use strict";
|
|
418
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Strut; });
|
|
419
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
420
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
421
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
422
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__);
|
|
440
423
|
|
|
441
424
|
|
|
442
425
|
|
|
@@ -445,13 +428,13 @@ const styles = external_aphrodite_["StyleSheet"].create({
|
|
|
445
428
|
*
|
|
446
429
|
* Assumes parent is a View.
|
|
447
430
|
*/
|
|
448
|
-
class
|
|
431
|
+
class Strut extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
449
432
|
render() {
|
|
450
433
|
const {
|
|
451
434
|
size,
|
|
452
435
|
style
|
|
453
436
|
} = this.props;
|
|
454
|
-
return /*#__PURE__*/
|
|
437
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__["View"], {
|
|
455
438
|
"aria-hidden": "true",
|
|
456
439
|
style: [strutStyle(size), style]
|
|
457
440
|
});
|
|
@@ -469,7 +452,13 @@ const strutStyle = size => {
|
|
|
469
452
|
flexShrink: 0
|
|
470
453
|
};
|
|
471
454
|
};
|
|
472
|
-
|
|
455
|
+
|
|
456
|
+
/***/ }),
|
|
457
|
+
/* 8 */
|
|
458
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
459
|
+
|
|
460
|
+
"use strict";
|
|
461
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return queryMatchesSize; });
|
|
473
462
|
/**
|
|
474
463
|
* Return where a media size matches a media query.
|
|
475
464
|
*
|
|
@@ -504,7 +493,43 @@ const queryMatchesSize = (mediaQuery, mediaSize) => {
|
|
|
504
493
|
throw new Error(`Unsupported mediaSize: ${mediaSize}`);
|
|
505
494
|
}
|
|
506
495
|
};
|
|
507
|
-
|
|
496
|
+
|
|
497
|
+
/***/ }),
|
|
498
|
+
/* 9 */
|
|
499
|
+
/***/ (function(module, exports) {
|
|
500
|
+
|
|
501
|
+
module.exports = require("aphrodite");
|
|
502
|
+
|
|
503
|
+
/***/ }),
|
|
504
|
+
/* 10 */
|
|
505
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
506
|
+
|
|
507
|
+
"use strict";
|
|
508
|
+
__webpack_require__.r(__webpack_exports__);
|
|
509
|
+
/* harmony import */ var _components_media_layout_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
|
|
510
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MediaLayout", function() { return _components_media_layout_js__WEBPACK_IMPORTED_MODULE_0__["a"]; });
|
|
511
|
+
|
|
512
|
+
/* harmony import */ var _components_media_layout_context_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
|
|
513
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MediaLayoutContext", function() { return _components_media_layout_context_js__WEBPACK_IMPORTED_MODULE_1__["a"]; });
|
|
514
|
+
|
|
515
|
+
/* harmony import */ var _components_spring_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
|
|
516
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Spring", function() { return _components_spring_js__WEBPACK_IMPORTED_MODULE_2__["a"]; });
|
|
517
|
+
|
|
518
|
+
/* harmony import */ var _components_strut_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7);
|
|
519
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Strut", function() { return _components_strut_js__WEBPACK_IMPORTED_MODULE_3__["a"]; });
|
|
520
|
+
|
|
521
|
+
/* harmony import */ var _util_specs_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2);
|
|
522
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VALID_MEDIA_SIZES", function() { return _util_specs_js__WEBPACK_IMPORTED_MODULE_4__["d"]; });
|
|
523
|
+
|
|
524
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MEDIA_DEFAULT_SPEC", function() { return _util_specs_js__WEBPACK_IMPORTED_MODULE_4__["a"]; });
|
|
525
|
+
|
|
526
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MEDIA_INTERNAL_SPEC", function() { return _util_specs_js__WEBPACK_IMPORTED_MODULE_4__["b"]; });
|
|
527
|
+
|
|
528
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MEDIA_MODAL_SPEC", function() { return _util_specs_js__WEBPACK_IMPORTED_MODULE_4__["c"]; });
|
|
529
|
+
|
|
530
|
+
/* harmony import */ var _util_util_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8);
|
|
531
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "queryMatchesSize", function() { return _util_util_js__WEBPACK_IMPORTED_MODULE_5__["a"]; });
|
|
532
|
+
|
|
508
533
|
|
|
509
534
|
|
|
510
535
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-layout",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.7",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -13,18 +13,17 @@
|
|
|
13
13
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@babel/runtime": "^7.
|
|
17
|
-
"@khanacademy/wonder-blocks-core": "^
|
|
18
|
-
"@khanacademy/wonder-blocks-spacing": "^3.0.
|
|
16
|
+
"@babel/runtime": "^7.16.3",
|
|
17
|
+
"@khanacademy/wonder-blocks-core": "^4.2.1",
|
|
18
|
+
"@khanacademy/wonder-blocks-spacing": "^3.0.5"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"wb-dev-build-settings": "^0.
|
|
21
|
+
"wb-dev-build-settings": "^0.3.0"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"aphrodite": "^1.2.5",
|
|
25
|
-
"react": "
|
|
25
|
+
"react": "16.14.0"
|
|
26
26
|
},
|
|
27
27
|
"author": "",
|
|
28
|
-
"license": "MIT"
|
|
29
|
-
"gitHead": "8022bb419eed74be37f71f71c7621854794a731c"
|
|
28
|
+
"license": "MIT"
|
|
30
29
|
}
|
|
@@ -22,8 +22,8 @@ exports[`wonder-blocks-layout example 1 1`] = `
|
|
|
22
22
|
}
|
|
23
23
|
>
|
|
24
24
|
<button
|
|
25
|
+
aria-disabled={false}
|
|
25
26
|
className=""
|
|
26
|
-
disabled={false}
|
|
27
27
|
onBlur={[Function]}
|
|
28
28
|
onClick={[Function]}
|
|
29
29
|
onDragStart={[Function]}
|
|
@@ -121,8 +121,8 @@ exports[`wonder-blocks-layout example 1 1`] = `
|
|
|
121
121
|
}
|
|
122
122
|
/>
|
|
123
123
|
<button
|
|
124
|
+
aria-disabled={false}
|
|
124
125
|
className=""
|
|
125
|
-
disabled={false}
|
|
126
126
|
onBlur={[Function]}
|
|
127
127
|
onClick={[Function]}
|
|
128
128
|
onDragStart={[Function]}
|
|
@@ -220,8 +220,8 @@ exports[`wonder-blocks-layout example 1 1`] = `
|
|
|
220
220
|
}
|
|
221
221
|
/>
|
|
222
222
|
<button
|
|
223
|
+
aria-disabled={false}
|
|
223
224
|
className=""
|
|
224
|
-
disabled={false}
|
|
225
225
|
onBlur={[Function]}
|
|
226
226
|
onClick={[Function]}
|
|
227
227
|
onDragStart={[Function]}
|
|
@@ -314,8 +314,8 @@ exports[`wonder-blocks-layout example 1 1`] = `
|
|
|
314
314
|
}
|
|
315
315
|
/>
|
|
316
316
|
<button
|
|
317
|
+
aria-disabled={false}
|
|
317
318
|
className=""
|
|
318
|
-
disabled={false}
|
|
319
319
|
onBlur={[Function]}
|
|
320
320
|
onClick={[Function]}
|
|
321
321
|
onDragStart={[Function]}
|
|
@@ -413,8 +413,8 @@ exports[`wonder-blocks-layout example 1 1`] = `
|
|
|
413
413
|
}
|
|
414
414
|
/>
|
|
415
415
|
<button
|
|
416
|
+
aria-disabled={false}
|
|
416
417
|
className=""
|
|
417
|
-
disabled={false}
|
|
418
418
|
onBlur={[Function]}
|
|
419
419
|
onClick={[Function]}
|
|
420
420
|
onDragStart={[Function]}
|
|
@@ -3,6 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
import {StyleSheet} from "aphrodite";
|
|
4
4
|
import {View} from "@khanacademy/wonder-blocks-core";
|
|
5
5
|
import {mount} from "enzyme";
|
|
6
|
+
import "jest-enzyme";
|
|
6
7
|
|
|
7
8
|
import MediaLayout from "../media-layout.js";
|
|
8
9
|
import {resizeWindow, matchMedia} from "../../util/test-util.js";
|
|
@@ -121,9 +121,8 @@ class MediaLayoutInternal extends React.Component<CombinedProps, State> {
|
|
|
121
121
|
if (this.state.size) {
|
|
122
122
|
return this.state.size;
|
|
123
123
|
} else {
|
|
124
|
-
const entries: Array<
|
|
125
|
-
|
|
126
|
-
> = (Object.entries(this.props.mediaSpec): any);
|
|
124
|
+
const entries: Array<[MediaSize, {|query: string|}]> =
|
|
125
|
+
(Object.entries(this.props.mediaSpec): any);
|
|
127
126
|
|
|
128
127
|
for (const [size, spec] of entries) {
|
|
129
128
|
const mql = mediaQueryLists[spec.query];
|
|
@@ -32,7 +32,7 @@ const styles = StyleSheet.create({
|
|
|
32
32
|
},
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
export const
|
|
35
|
+
export const Simple: StoryComponentType = () => (
|
|
36
36
|
<View style={styles.column}>
|
|
37
37
|
<View style={styles.row}>
|
|
38
38
|
<Button>Hello, world!</Button>
|
|
@@ -48,7 +48,7 @@ export const simple: StoryComponentType = () => (
|
|
|
48
48
|
</View>
|
|
49
49
|
);
|
|
50
50
|
|
|
51
|
-
export const
|
|
51
|
+
export const WithStyle: StoryComponentType = () => (
|
|
52
52
|
<View style={styles.column}>
|
|
53
53
|
<View style={styles.row}>
|
|
54
54
|
<Button>Hello, world!</Button>
|
|
@@ -68,20 +68,16 @@ export const withStyle: StoryComponentType = () => (
|
|
|
68
68
|
</View>
|
|
69
69
|
);
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
disable: true,
|
|
76
|
-
},
|
|
71
|
+
Simple.parameters = {
|
|
72
|
+
chromatic: {
|
|
73
|
+
// we don't need screenshots because this story only tests behavior.
|
|
74
|
+
disableSnapshot: true,
|
|
77
75
|
},
|
|
78
76
|
};
|
|
79
77
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
disable: true,
|
|
85
|
-
},
|
|
78
|
+
WithStyle.parameters = {
|
|
79
|
+
chromatic: {
|
|
80
|
+
// we don't need screenshots because this story only tests behavior.
|
|
81
|
+
disableSnapshot: true,
|
|
86
82
|
},
|
|
87
83
|
};
|
|
@@ -36,7 +36,7 @@ const styles = StyleSheet.create({
|
|
|
36
36
|
const smallSize = Spacing.medium_16;
|
|
37
37
|
const largeSize = Spacing.xxxLarge_64;
|
|
38
38
|
|
|
39
|
-
export const
|
|
39
|
+
export const Simple: StoryComponentType = () => (
|
|
40
40
|
<View style={styles.column}>
|
|
41
41
|
<View style={styles.row}>
|
|
42
42
|
<Button>Hello, world!</Button>
|
|
@@ -59,7 +59,7 @@ export const simple: StoryComponentType = () => (
|
|
|
59
59
|
</View>
|
|
60
60
|
);
|
|
61
61
|
|
|
62
|
-
export const
|
|
62
|
+
export const WithStyle: StoryComponentType = () => (
|
|
63
63
|
<View style={styles.column}>
|
|
64
64
|
<View style={styles.row}>
|
|
65
65
|
<Button>Hello, world!</Button>
|
|
@@ -83,20 +83,16 @@ export const withStyle: StoryComponentType = () => (
|
|
|
83
83
|
</View>
|
|
84
84
|
);
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
disable: true,
|
|
91
|
-
},
|
|
86
|
+
Simple.parameters = {
|
|
87
|
+
chromatic: {
|
|
88
|
+
// we don't need screenshots because this story only tests behavior.
|
|
89
|
+
disableSnapshot: true,
|
|
92
90
|
},
|
|
93
91
|
};
|
|
94
92
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
disable: true,
|
|
100
|
-
},
|
|
93
|
+
WithStyle.parameters = {
|
|
94
|
+
chromatic: {
|
|
95
|
+
// we don't need screenshots because this story only tests behavior.
|
|
96
|
+
disableSnapshot: true,
|
|
101
97
|
},
|
|
102
98
|
};
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 Khan Academy
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|