@khanacademy/wonder-blocks-cell 1.0.0
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 +17 -0
- package/dist/es/index.js +351 -0
- package/dist/index.js +577 -0
- package/dist/index.js.flow +2 -0
- package/package.json +33 -0
- package/src/components/__docs__/basic-cell.argtypes.js +178 -0
- package/src/components/__docs__/basic-cell.stories.js +302 -0
- package/src/components/__docs__/detail-cell.argtypes.js +28 -0
- package/src/components/__docs__/detail-cell.stories.js +154 -0
- package/src/components/__tests__/basic-cell.test.js +98 -0
- package/src/components/__tests__/detail-cell.test.js +103 -0
- package/src/components/basic-cell.js +40 -0
- package/src/components/detail-cell.js +100 -0
- package/src/components/internal/__tests__/cell-core.test.js +95 -0
- package/src/components/internal/__tests__/common.test.js +47 -0
- package/src/components/internal/cell-core.js +288 -0
- package/src/components/internal/common.js +73 -0
- package/src/index.js +5 -0
- package/src/util/types.js +129 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
module.exports =
|
|
2
|
+
/******/ (function(modules) { // webpackBootstrap
|
|
3
|
+
/******/ // The module cache
|
|
4
|
+
/******/ var installedModules = {};
|
|
5
|
+
/******/
|
|
6
|
+
/******/ // The require function
|
|
7
|
+
/******/ function __webpack_require__(moduleId) {
|
|
8
|
+
/******/
|
|
9
|
+
/******/ // Check if module is in cache
|
|
10
|
+
/******/ if(installedModules[moduleId]) {
|
|
11
|
+
/******/ return installedModules[moduleId].exports;
|
|
12
|
+
/******/ }
|
|
13
|
+
/******/ // Create a new module (and put it into the cache)
|
|
14
|
+
/******/ var module = installedModules[moduleId] = {
|
|
15
|
+
/******/ i: moduleId,
|
|
16
|
+
/******/ l: false,
|
|
17
|
+
/******/ exports: {}
|
|
18
|
+
/******/ };
|
|
19
|
+
/******/
|
|
20
|
+
/******/ // Execute the module function
|
|
21
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
22
|
+
/******/
|
|
23
|
+
/******/ // Flag the module as loaded
|
|
24
|
+
/******/ module.l = true;
|
|
25
|
+
/******/
|
|
26
|
+
/******/ // Return the exports of the module
|
|
27
|
+
/******/ return module.exports;
|
|
28
|
+
/******/ }
|
|
29
|
+
/******/
|
|
30
|
+
/******/
|
|
31
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
32
|
+
/******/ __webpack_require__.m = modules;
|
|
33
|
+
/******/
|
|
34
|
+
/******/ // expose the module cache
|
|
35
|
+
/******/ __webpack_require__.c = installedModules;
|
|
36
|
+
/******/
|
|
37
|
+
/******/ // define getter function for harmony exports
|
|
38
|
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
39
|
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
40
|
+
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
41
|
+
/******/ }
|
|
42
|
+
/******/ };
|
|
43
|
+
/******/
|
|
44
|
+
/******/ // define __esModule on exports
|
|
45
|
+
/******/ __webpack_require__.r = function(exports) {
|
|
46
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
47
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
48
|
+
/******/ }
|
|
49
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
50
|
+
/******/ };
|
|
51
|
+
/******/
|
|
52
|
+
/******/ // create a fake namespace object
|
|
53
|
+
/******/ // mode & 1: value is a module id, require it
|
|
54
|
+
/******/ // mode & 2: merge all properties of value into the ns
|
|
55
|
+
/******/ // mode & 4: return value when already ns object
|
|
56
|
+
/******/ // mode & 8|1: behave like require
|
|
57
|
+
/******/ __webpack_require__.t = function(value, mode) {
|
|
58
|
+
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
59
|
+
/******/ if(mode & 8) return value;
|
|
60
|
+
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
61
|
+
/******/ var ns = Object.create(null);
|
|
62
|
+
/******/ __webpack_require__.r(ns);
|
|
63
|
+
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
64
|
+
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
65
|
+
/******/ return ns;
|
|
66
|
+
/******/ };
|
|
67
|
+
/******/
|
|
68
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
69
|
+
/******/ __webpack_require__.n = function(module) {
|
|
70
|
+
/******/ var getter = module && module.__esModule ?
|
|
71
|
+
/******/ function getDefault() { return module['default']; } :
|
|
72
|
+
/******/ function getModuleExports() { return module; };
|
|
73
|
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
74
|
+
/******/ return getter;
|
|
75
|
+
/******/ };
|
|
76
|
+
/******/
|
|
77
|
+
/******/ // Object.prototype.hasOwnProperty.call
|
|
78
|
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
79
|
+
/******/
|
|
80
|
+
/******/ // __webpack_public_path__
|
|
81
|
+
/******/ __webpack_require__.p = "";
|
|
82
|
+
/******/
|
|
83
|
+
/******/
|
|
84
|
+
/******/ // Load entry module and return exports
|
|
85
|
+
/******/ return __webpack_require__(__webpack_require__.s = 12);
|
|
86
|
+
/******/ })
|
|
87
|
+
/************************************************************************/
|
|
88
|
+
/******/ ([
|
|
89
|
+
/* 0 */
|
|
90
|
+
/***/ (function(module, exports) {
|
|
91
|
+
|
|
92
|
+
module.exports = require("react");
|
|
93
|
+
|
|
94
|
+
/***/ }),
|
|
95
|
+
/* 1 */
|
|
96
|
+
/***/ (function(module, exports) {
|
|
97
|
+
|
|
98
|
+
module.exports = require("@khanacademy/wonder-blocks-color");
|
|
99
|
+
|
|
100
|
+
/***/ }),
|
|
101
|
+
/* 2 */
|
|
102
|
+
/***/ (function(module, exports) {
|
|
103
|
+
|
|
104
|
+
module.exports = require("@khanacademy/wonder-blocks-spacing");
|
|
105
|
+
|
|
106
|
+
/***/ }),
|
|
107
|
+
/* 3 */
|
|
108
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
109
|
+
|
|
110
|
+
"use strict";
|
|
111
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return CellMeasurements; });
|
|
112
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return getHorizontalRuleStyles; });
|
|
113
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
|
|
114
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_0__);
|
|
115
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
|
|
116
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_1__);
|
|
117
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
|
|
118
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2__);
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
const CellMeasurements = {
|
|
123
|
+
cellMinHeight: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2___default.a.xxLarge_48,
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The cell wrapper's gap.
|
|
127
|
+
*/
|
|
128
|
+
cellPadding: {
|
|
129
|
+
paddingVertical: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2___default.a.xSmall_8,
|
|
130
|
+
paddingHorizontal: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2___default.a.medium_16
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The extra vertical spacing added to the title/content wrapper.
|
|
135
|
+
*/
|
|
136
|
+
contentVerticalSpacing: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2___default.a.xxxSmall_4,
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The horizontal spacing between the left and right accessory.
|
|
140
|
+
*/
|
|
141
|
+
accessoryHorizontalSpacing: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2___default.a.medium_16
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Gets the horizontalRule style based on the variant.
|
|
145
|
+
* @param {HorizontalRuleVariant} horizontalRule The variant of the horizontal
|
|
146
|
+
* rule.
|
|
147
|
+
* @returns A styled horizontal rule.
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
const getHorizontalRuleStyles = horizontalRule => {
|
|
151
|
+
switch (horizontalRule) {
|
|
152
|
+
case "inset":
|
|
153
|
+
return [styles.horizontalRule, styles.horizontalRuleInset];
|
|
154
|
+
|
|
155
|
+
case "full-width":
|
|
156
|
+
return styles.horizontalRule;
|
|
157
|
+
|
|
158
|
+
case "none":
|
|
159
|
+
return {};
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const styles = aphrodite__WEBPACK_IMPORTED_MODULE_0__["StyleSheet"].create({
|
|
163
|
+
horizontalRule: {
|
|
164
|
+
position: "relative",
|
|
165
|
+
":after": {
|
|
166
|
+
width: "100%",
|
|
167
|
+
content: "''",
|
|
168
|
+
position: "absolute",
|
|
169
|
+
// align to the bottom of the cell
|
|
170
|
+
bottom: 0,
|
|
171
|
+
// align border to the right of the cell
|
|
172
|
+
right: 0,
|
|
173
|
+
height: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2___default.a.xxxxSmall_2,
|
|
174
|
+
boxShadow: `inset 0px -1px 0px ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_1___default.a.offBlack8}`
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
horizontalRuleInset: {
|
|
178
|
+
":after": {
|
|
179
|
+
// Inset doesn't include the left padding of the cell.
|
|
180
|
+
width: `calc(100% - ${CellMeasurements.cellPadding.paddingHorizontal}px)`
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
/***/ }),
|
|
186
|
+
/* 4 */
|
|
187
|
+
/***/ (function(module, exports) {
|
|
188
|
+
|
|
189
|
+
module.exports = require("aphrodite");
|
|
190
|
+
|
|
191
|
+
/***/ }),
|
|
192
|
+
/* 5 */
|
|
193
|
+
/***/ (function(module, exports) {
|
|
194
|
+
|
|
195
|
+
module.exports = require("@khanacademy/wonder-blocks-layout");
|
|
196
|
+
|
|
197
|
+
/***/ }),
|
|
198
|
+
/* 6 */
|
|
199
|
+
/***/ (function(module, exports) {
|
|
200
|
+
|
|
201
|
+
module.exports = require("@khanacademy/wonder-blocks-core");
|
|
202
|
+
|
|
203
|
+
/***/ }),
|
|
204
|
+
/* 7 */
|
|
205
|
+
/***/ (function(module, exports) {
|
|
206
|
+
|
|
207
|
+
module.exports = require("@khanacademy/wonder-blocks-typography");
|
|
208
|
+
|
|
209
|
+
/***/ }),
|
|
210
|
+
/* 8 */
|
|
211
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
212
|
+
|
|
213
|
+
"use strict";
|
|
214
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
215
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
216
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
217
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
218
|
+
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(11);
|
|
219
|
+
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_2__);
|
|
220
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6);
|
|
221
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__);
|
|
222
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1);
|
|
223
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4__);
|
|
224
|
+
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5);
|
|
225
|
+
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_5__);
|
|
226
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(2);
|
|
227
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6__);
|
|
228
|
+
/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(3);
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Left Accessories can be defined using WB components such as Icon, IconButton,
|
|
240
|
+
* or it can even be used for a custom node/component if needed.
|
|
241
|
+
*/
|
|
242
|
+
const LeftAccessory = ({
|
|
243
|
+
leftAccessory,
|
|
244
|
+
leftAccessoryStyle,
|
|
245
|
+
disabled
|
|
246
|
+
}) => {
|
|
247
|
+
if (!leftAccessory) {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
|
|
252
|
+
style: [styles.accessory, disabled && styles.accessoryDisabled, { ...leftAccessoryStyle
|
|
253
|
+
}]
|
|
254
|
+
}, leftAccessory), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_5__["Strut"], {
|
|
255
|
+
size: _common_js__WEBPACK_IMPORTED_MODULE_7__[/* CellMeasurements */ "a"].accessoryHorizontalSpacing
|
|
256
|
+
}));
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Right Accessories can be defined using WB components such as Icon,
|
|
261
|
+
* IconButton, or it can even be used for a custom node/component if needed.
|
|
262
|
+
*/
|
|
263
|
+
const RightAccessory = ({
|
|
264
|
+
rightAccessory,
|
|
265
|
+
rightAccessoryStyle,
|
|
266
|
+
active,
|
|
267
|
+
disabled
|
|
268
|
+
}) => {
|
|
269
|
+
if (!rightAccessory) {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_5__["Strut"], {
|
|
274
|
+
size: _common_js__WEBPACK_IMPORTED_MODULE_7__[/* CellMeasurements */ "a"].accessoryHorizontalSpacing
|
|
275
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
|
|
276
|
+
style: [styles.accessory, styles.accessoryRight, disabled && styles.accessoryDisabled, { ...rightAccessoryStyle
|
|
277
|
+
}, active && styles.accessoryActive]
|
|
278
|
+
}, rightAccessory));
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* CellCore is the base cell wrapper. It's used as the skeleton/layout that is
|
|
283
|
+
* used by BasicCell and DetailCell (and any other variants).
|
|
284
|
+
*
|
|
285
|
+
* Both variants share how they render their accessories, and the main
|
|
286
|
+
* responsibility of this component is to render the contents that are passed in
|
|
287
|
+
* (using the `children` prop).
|
|
288
|
+
*/
|
|
289
|
+
const CellCore = props => {
|
|
290
|
+
const {
|
|
291
|
+
active,
|
|
292
|
+
children,
|
|
293
|
+
disabled,
|
|
294
|
+
horizontalRule = "inset",
|
|
295
|
+
leftAccessory = undefined,
|
|
296
|
+
leftAccessoryStyle = undefined,
|
|
297
|
+
onClick,
|
|
298
|
+
rightAccessory = undefined,
|
|
299
|
+
rightAccessoryStyle = undefined,
|
|
300
|
+
style,
|
|
301
|
+
testId,
|
|
302
|
+
"aria-label": ariaLabel
|
|
303
|
+
} = props;
|
|
304
|
+
|
|
305
|
+
const renderCell = eventState => {
|
|
306
|
+
const horizontalRuleStyles = Object(_common_js__WEBPACK_IMPORTED_MODULE_7__[/* getHorizontalRuleStyles */ "b"])(horizontalRule);
|
|
307
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
|
|
308
|
+
style: [styles.wrapper, // focused applied to the main wrapper to make the border
|
|
309
|
+
// outline part of the wrapper
|
|
310
|
+
(eventState == null ? void 0 : eventState.focused) && styles.focused, // custom styles
|
|
311
|
+
style],
|
|
312
|
+
"aria-current": active ? "true" : undefined
|
|
313
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
|
|
314
|
+
style: [styles.innerWrapper, horizontalRuleStyles, disabled && styles.disabled, active && styles.active, // other states applied to the inner wrapper to blend
|
|
315
|
+
// the background color properly
|
|
316
|
+
!disabled && (eventState == null ? void 0 : eventState.hovered) && styles.hovered, // active + hovered
|
|
317
|
+
active && (eventState == null ? void 0 : eventState.hovered) && styles.activeHovered, !disabled && (eventState == null ? void 0 : eventState.pressed) && styles.pressed, // active + pressed
|
|
318
|
+
!disabled && active && (eventState == null ? void 0 : eventState.pressed) && styles.activePressed]
|
|
319
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](LeftAccessory, {
|
|
320
|
+
leftAccessory: leftAccessory,
|
|
321
|
+
leftAccessoryStyle: leftAccessoryStyle,
|
|
322
|
+
disabled: disabled
|
|
323
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
|
|
324
|
+
style: styles.content,
|
|
325
|
+
testId: testId
|
|
326
|
+
}, children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](RightAccessory, {
|
|
327
|
+
rightAccessory: rightAccessory,
|
|
328
|
+
rightAccessoryStyle: rightAccessoryStyle,
|
|
329
|
+
active: active,
|
|
330
|
+
disabled: disabled
|
|
331
|
+
})));
|
|
332
|
+
}; // Pressable cell.
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
if (onClick) {
|
|
336
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_2___default.a, {
|
|
337
|
+
disabled: disabled,
|
|
338
|
+
onClick: onClick,
|
|
339
|
+
hideDefaultFocusRing: true,
|
|
340
|
+
"aria-label": ariaLabel ? ariaLabel : undefined
|
|
341
|
+
}, eventState => renderCell(eventState));
|
|
342
|
+
} // No click event attached, so just render the cell as-is.
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
return renderCell();
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
349
|
+
wrapper: {
|
|
350
|
+
background: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default.a.white,
|
|
351
|
+
color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default.a.offBlack,
|
|
352
|
+
minHeight: _common_js__WEBPACK_IMPORTED_MODULE_7__[/* CellMeasurements */ "a"].cellMinHeight,
|
|
353
|
+
textAlign: "left"
|
|
354
|
+
},
|
|
355
|
+
innerWrapper: {
|
|
356
|
+
padding: `${_common_js__WEBPACK_IMPORTED_MODULE_7__[/* CellMeasurements */ "a"].cellPadding.paddingVertical}px ${_common_js__WEBPACK_IMPORTED_MODULE_7__[/* CellMeasurements */ "a"].cellPadding.paddingHorizontal}px`,
|
|
357
|
+
flexDirection: "row",
|
|
358
|
+
flex: 1
|
|
359
|
+
},
|
|
360
|
+
content: {
|
|
361
|
+
alignSelf: "center",
|
|
362
|
+
overflowWrap: "break-word",
|
|
363
|
+
padding: `${_common_js__WEBPACK_IMPORTED_MODULE_7__[/* CellMeasurements */ "a"].contentVerticalSpacing}px 0`
|
|
364
|
+
},
|
|
365
|
+
accessory: {
|
|
366
|
+
// Use content width by default.
|
|
367
|
+
minWidth: "auto",
|
|
368
|
+
// Horizontal alignment of the accessory.
|
|
369
|
+
alignItems: "center",
|
|
370
|
+
// Vertical alignment.
|
|
371
|
+
alignSelf: "center"
|
|
372
|
+
},
|
|
373
|
+
accessoryRight: {
|
|
374
|
+
// The right accessory will have this color by default. Unless the
|
|
375
|
+
// accessory element overrides that color internally.
|
|
376
|
+
color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default.a.offBlack64,
|
|
377
|
+
// Align the right accessory to the right side of the cell, so we can
|
|
378
|
+
// prevent the accessory from shifting left, if the content is too
|
|
379
|
+
// short.
|
|
380
|
+
marginLeft: "auto"
|
|
381
|
+
},
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* States
|
|
385
|
+
*/
|
|
386
|
+
hovered: {
|
|
387
|
+
background: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default.a.offBlack8
|
|
388
|
+
},
|
|
389
|
+
// Handling the focus ring internally because clickable doesn't support
|
|
390
|
+
// rounded focus ring.
|
|
391
|
+
focused: {
|
|
392
|
+
borderRadius: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6___default.a.xxxSmall_4,
|
|
393
|
+
outline: `solid ${_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6___default.a.xxxxSmall_2}px ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default.a.blue}`,
|
|
394
|
+
// The focus ring is not visible when there are stacked cells.
|
|
395
|
+
// Using outlineOffset to display the focus ring inside the cell.
|
|
396
|
+
outlineOffset: -_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6___default.a.xxxxSmall_2,
|
|
397
|
+
// To hide the internal corners of the cell.
|
|
398
|
+
overflow: "hidden"
|
|
399
|
+
},
|
|
400
|
+
pressed: {
|
|
401
|
+
background: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default.a.offBlack16
|
|
402
|
+
},
|
|
403
|
+
active: {
|
|
404
|
+
background: Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4__["fade"])(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default.a.blue, 0.08),
|
|
405
|
+
color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default.a.blue
|
|
406
|
+
},
|
|
407
|
+
activeHovered: {
|
|
408
|
+
background: Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4__["fade"])(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default.a.blue, 0.16)
|
|
409
|
+
},
|
|
410
|
+
activePressed: {
|
|
411
|
+
background: Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4__["fade"])(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default.a.blue, 0.24)
|
|
412
|
+
},
|
|
413
|
+
disabled: {
|
|
414
|
+
color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default.a.offBlack32
|
|
415
|
+
},
|
|
416
|
+
accessoryActive: {
|
|
417
|
+
color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default.a.blue
|
|
418
|
+
},
|
|
419
|
+
accessoryDisabled: {
|
|
420
|
+
color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default.a.offBlack,
|
|
421
|
+
opacity: 0.32
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
/* harmony default export */ __webpack_exports__["a"] = (CellCore);
|
|
425
|
+
|
|
426
|
+
/***/ }),
|
|
427
|
+
/* 9 */
|
|
428
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
429
|
+
|
|
430
|
+
"use strict";
|
|
431
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
432
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
433
|
+
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
|
|
434
|
+
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_1__);
|
|
435
|
+
/* harmony import */ var _internal_cell_core_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8);
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* BasicCell is the simplest form of the Cell. It is a compacted-height Cell
|
|
442
|
+
* with limited subviews and accessories, to be used for simple lists, like
|
|
443
|
+
* dropdown option items, navigation items, settings dialogs, etc.
|
|
444
|
+
*
|
|
445
|
+
* ### Usage
|
|
446
|
+
*
|
|
447
|
+
* ```jsx
|
|
448
|
+
* import {BasicCell} from "@khanacademy/wonder-blocks-cell";
|
|
449
|
+
*
|
|
450
|
+
* <BasicCell
|
|
451
|
+
* title="Basic cell"
|
|
452
|
+
* rightAccessory={<Icon icon={icons.caretRight} size="medium" />}
|
|
453
|
+
* />
|
|
454
|
+
* ```
|
|
455
|
+
*/
|
|
456
|
+
function BasicCell(props) {
|
|
457
|
+
const {
|
|
458
|
+
title,
|
|
459
|
+
...coreProps
|
|
460
|
+
} = props;
|
|
461
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_internal_cell_core_js__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"], coreProps, typeof title === "string" ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_1__["LabelMedium"], null, title) : title);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/* harmony default export */ __webpack_exports__["a"] = (BasicCell);
|
|
465
|
+
|
|
466
|
+
/***/ }),
|
|
467
|
+
/* 10 */
|
|
468
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
469
|
+
|
|
470
|
+
"use strict";
|
|
471
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
472
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
473
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
474
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
475
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
|
|
476
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__);
|
|
477
|
+
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5);
|
|
478
|
+
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_3__);
|
|
479
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2);
|
|
480
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4__);
|
|
481
|
+
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7);
|
|
482
|
+
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_5__);
|
|
483
|
+
/* harmony import */ var _internal_cell_core_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(8);
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
const Subtitle = ({
|
|
493
|
+
subtitle,
|
|
494
|
+
disabled
|
|
495
|
+
}) => {
|
|
496
|
+
if (!subtitle) {
|
|
497
|
+
return null;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
if (typeof subtitle === "string") {
|
|
501
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_5__["LabelSmall"], {
|
|
502
|
+
style: !disabled && styles.subtitle
|
|
503
|
+
}, subtitle);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
return subtitle;
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* This is a variant of BasicCell that allows adding subtitles, before and after
|
|
511
|
+
* the cell title.
|
|
512
|
+
*
|
|
513
|
+
* ### Usage
|
|
514
|
+
*
|
|
515
|
+
* ```jsx
|
|
516
|
+
* import {DetailCell} from "@khanacademy/wonder-blocks-cell";
|
|
517
|
+
*
|
|
518
|
+
* <DetailCell
|
|
519
|
+
* leftAccessory={<Icon icon={icons.contentVideo} size="medium" />}
|
|
520
|
+
* subtitle1="Subtitle 1"
|
|
521
|
+
* title="Detail cell"
|
|
522
|
+
* subtitle1="Subtitle 2"
|
|
523
|
+
* rightAccessory={<Icon icon={icons.caretRight} size="medium" />}
|
|
524
|
+
* />
|
|
525
|
+
* ```
|
|
526
|
+
*/
|
|
527
|
+
function DetailCell(props) {
|
|
528
|
+
const {
|
|
529
|
+
title,
|
|
530
|
+
subtitle1,
|
|
531
|
+
subtitle2,
|
|
532
|
+
...coreProps
|
|
533
|
+
} = props;
|
|
534
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_internal_cell_core_js__WEBPACK_IMPORTED_MODULE_6__[/* default */ "a"], coreProps, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](Subtitle, {
|
|
535
|
+
subtitle: subtitle1,
|
|
536
|
+
disabled: coreProps.disabled
|
|
537
|
+
}), subtitle1 && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_3__["Strut"], {
|
|
538
|
+
size: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default.a.xxxxSmall_2
|
|
539
|
+
}), typeof title === "string" ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_5__["LabelLarge"], null, title) : title, subtitle2 && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_3__["Strut"], {
|
|
540
|
+
size: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default.a.xxxxSmall_2
|
|
541
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](Subtitle, {
|
|
542
|
+
subtitle: subtitle2,
|
|
543
|
+
disabled: coreProps.disabled
|
|
544
|
+
}));
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
548
|
+
subtitle: {
|
|
549
|
+
color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack64
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
/* harmony default export */ __webpack_exports__["a"] = (DetailCell);
|
|
553
|
+
|
|
554
|
+
/***/ }),
|
|
555
|
+
/* 11 */
|
|
556
|
+
/***/ (function(module, exports) {
|
|
557
|
+
|
|
558
|
+
module.exports = require("@khanacademy/wonder-blocks-clickable");
|
|
559
|
+
|
|
560
|
+
/***/ }),
|
|
561
|
+
/* 12 */
|
|
562
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
563
|
+
|
|
564
|
+
"use strict";
|
|
565
|
+
__webpack_require__.r(__webpack_exports__);
|
|
566
|
+
/* harmony import */ var _components_basic_cell_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9);
|
|
567
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BasicCell", function() { return _components_basic_cell_js__WEBPACK_IMPORTED_MODULE_0__["a"]; });
|
|
568
|
+
|
|
569
|
+
/* harmony import */ var _components_detail_cell_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(10);
|
|
570
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DetailCell", function() { return _components_detail_cell_js__WEBPACK_IMPORTED_MODULE_1__["a"]; });
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
/***/ })
|
|
577
|
+
/******/ ]);
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@khanacademy/wonder-blocks-cell",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"design": "v1",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"description": "",
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"module": "dist/es/index.js",
|
|
11
|
+
"source": "src/index.js",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@babel/runtime": "^7.16.3",
|
|
17
|
+
"@khanacademy/wonder-blocks-clickable": "^2.2.1",
|
|
18
|
+
"@khanacademy/wonder-blocks-color": "^1.1.20",
|
|
19
|
+
"@khanacademy/wonder-blocks-core": "^4.2.0",
|
|
20
|
+
"@khanacademy/wonder-blocks-layout": "^1.4.6",
|
|
21
|
+
"@khanacademy/wonder-blocks-spacing": "^3.0.5",
|
|
22
|
+
"@khanacademy/wonder-blocks-typography": "^1.1.28"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"aphrodite": "^1.2.5",
|
|
26
|
+
"react": "16.14.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"wb-dev-build-settings": "^0.2.0"
|
|
30
|
+
},
|
|
31
|
+
"author": "",
|
|
32
|
+
"license": "MIT"
|
|
33
|
+
}
|