@khanacademy/wonder-blocks-cell 2.2.2 → 2.2.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 +27 -0
- package/dist/es/index.js +21 -123
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-cell
|
|
2
2
|
|
|
3
|
+
## 2.2.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [ee6fc773]
|
|
8
|
+
- @khanacademy/wonder-blocks-clickable@2.3.0
|
|
9
|
+
|
|
10
|
+
## 2.2.4
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [5f4a4297]
|
|
15
|
+
- Updated dependencies [2b96fd59]
|
|
16
|
+
- @khanacademy/wonder-blocks-core@4.3.2
|
|
17
|
+
- @khanacademy/wonder-blocks-clickable@2.2.7
|
|
18
|
+
- @khanacademy/wonder-blocks-layout@1.4.10
|
|
19
|
+
- @khanacademy/wonder-blocks-typography@1.1.32
|
|
20
|
+
|
|
21
|
+
## 2.2.3
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- @khanacademy/wonder-blocks-clickable@2.2.6
|
|
26
|
+
- @khanacademy/wonder-blocks-core@4.3.1
|
|
27
|
+
- @khanacademy/wonder-blocks-layout@1.4.9
|
|
28
|
+
- @khanacademy/wonder-blocks-typography@1.1.31
|
|
29
|
+
|
|
3
30
|
## 2.2.2
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/dist/es/index.js
CHANGED
|
@@ -11,35 +11,16 @@ import Spacing from '@khanacademy/wonder-blocks-spacing';
|
|
|
11
11
|
|
|
12
12
|
const CellMeasurements = {
|
|
13
13
|
cellMinHeight: Spacing.xxLarge_48,
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The cell wrapper's gap.
|
|
17
|
-
*/
|
|
18
14
|
cellPadding: {
|
|
19
15
|
paddingVertical: Spacing.small_12,
|
|
20
16
|
paddingHorizontal: Spacing.medium_16
|
|
21
17
|
},
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The DetailCell wrapper's gap.
|
|
25
|
-
*/
|
|
26
18
|
detailCellPadding: {
|
|
27
19
|
paddingVertical: Spacing.medium_16,
|
|
28
20
|
paddingHorizontal: Spacing.medium_16
|
|
29
21
|
},
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The horizontal spacing between the left and right accessory.
|
|
33
|
-
*/
|
|
34
22
|
accessoryHorizontalSpacing: Spacing.medium_16
|
|
35
23
|
};
|
|
36
|
-
/**
|
|
37
|
-
* Gets the horizontalRule style based on the variant.
|
|
38
|
-
* @param {HorizontalRuleVariant} horizontalRule The variant of the horizontal
|
|
39
|
-
* rule.
|
|
40
|
-
* @returns A styled horizontal rule.
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
24
|
const getHorizontalRuleStyles = horizontalRule => {
|
|
44
25
|
switch (horizontalRule) {
|
|
45
26
|
case "inset":
|
|
@@ -59,9 +40,7 @@ const styles$2 = StyleSheet.create({
|
|
|
59
40
|
width: "100%",
|
|
60
41
|
content: "''",
|
|
61
42
|
position: "absolute",
|
|
62
|
-
// align to the bottom of the cell
|
|
63
43
|
bottom: 0,
|
|
64
|
-
// align border to the right of the cell
|
|
65
44
|
right: 0,
|
|
66
45
|
height: Spacing.xxxxSmall_2,
|
|
67
46
|
boxShadow: `inset 0px -1px 0px ${Color.offBlack8}`
|
|
@@ -69,16 +48,11 @@ const styles$2 = StyleSheet.create({
|
|
|
69
48
|
},
|
|
70
49
|
horizontalRuleInset: {
|
|
71
50
|
":after": {
|
|
72
|
-
// Inset doesn't include the left padding of the cell.
|
|
73
51
|
width: `calc(100% - ${CellMeasurements.cellPadding.paddingHorizontal}px)`
|
|
74
52
|
}
|
|
75
53
|
}
|
|
76
54
|
});
|
|
77
55
|
|
|
78
|
-
/**
|
|
79
|
-
* Left Accessories can be defined using WB components such as Icon, IconButton,
|
|
80
|
-
* or it can even be used for a custom node/component if needed.
|
|
81
|
-
*/
|
|
82
56
|
const LeftAccessory = ({
|
|
83
57
|
leftAccessory,
|
|
84
58
|
leftAccessoryStyle,
|
|
@@ -88,17 +62,13 @@ const LeftAccessory = ({
|
|
|
88
62
|
return null;
|
|
89
63
|
}
|
|
90
64
|
|
|
91
|
-
return
|
|
65
|
+
return React.createElement(React.Fragment, null, React.createElement(View, {
|
|
92
66
|
style: [styles$1.accessory, disabled && styles$1.accessoryDisabled, _extends({}, leftAccessoryStyle)]
|
|
93
|
-
}, leftAccessory),
|
|
67
|
+
}, leftAccessory), React.createElement(Strut, {
|
|
94
68
|
size: CellMeasurements.accessoryHorizontalSpacing
|
|
95
69
|
}));
|
|
96
70
|
};
|
|
97
71
|
|
|
98
|
-
/**
|
|
99
|
-
* Right Accessories can be defined using WB components such as Icon,
|
|
100
|
-
* IconButton, or it can even be used for a custom node/component if needed.
|
|
101
|
-
*/
|
|
102
72
|
const RightAccessory = ({
|
|
103
73
|
rightAccessory,
|
|
104
74
|
rightAccessoryStyle,
|
|
@@ -109,21 +79,13 @@ const RightAccessory = ({
|
|
|
109
79
|
return null;
|
|
110
80
|
}
|
|
111
81
|
|
|
112
|
-
return
|
|
82
|
+
return React.createElement(React.Fragment, null, React.createElement(Strut, {
|
|
113
83
|
size: CellMeasurements.accessoryHorizontalSpacing
|
|
114
|
-
}),
|
|
84
|
+
}), React.createElement(View, {
|
|
115
85
|
style: [styles$1.accessory, styles$1.accessoryRight, disabled && styles$1.accessoryDisabled, _extends({}, rightAccessoryStyle), active && styles$1.accessoryActive]
|
|
116
86
|
}, rightAccessory));
|
|
117
87
|
};
|
|
118
88
|
|
|
119
|
-
/**
|
|
120
|
-
* CellCore is the base cell wrapper. It's used as the skeleton/layout that is
|
|
121
|
-
* used by CompactCell and DetailCell (and any other variants).
|
|
122
|
-
*
|
|
123
|
-
* Both variants share how they render their accessories, and the main
|
|
124
|
-
* responsibility of this component is to render the contents that are passed in
|
|
125
|
-
* (using the `children` prop).
|
|
126
|
-
*/
|
|
127
89
|
const CellCore = props => {
|
|
128
90
|
const {
|
|
129
91
|
active,
|
|
@@ -145,36 +107,28 @@ const CellCore = props => {
|
|
|
145
107
|
|
|
146
108
|
const renderCell = eventState => {
|
|
147
109
|
const horizontalRuleStyles = getHorizontalRuleStyles(horizontalRule);
|
|
148
|
-
return
|
|
149
|
-
style: [styles$1.wrapper,
|
|
150
|
-
// outline part of the wrapper
|
|
151
|
-
(eventState == null ? void 0 : eventState.focused) && styles$1.focused],
|
|
110
|
+
return React.createElement(View, {
|
|
111
|
+
style: [styles$1.wrapper, (eventState == null ? void 0 : eventState.focused) && styles$1.focused],
|
|
152
112
|
"aria-current": active ? "true" : undefined
|
|
153
|
-
},
|
|
154
|
-
style: [styles$1.innerWrapper, innerStyle,
|
|
155
|
-
|
|
156
|
-
// the background color properly
|
|
157
|
-
!disabled && (eventState == null ? void 0 : eventState.hovered) && styles$1.hovered, // active + hovered
|
|
158
|
-
active && (eventState == null ? void 0 : eventState.hovered) && styles$1.activeHovered, !disabled && (eventState == null ? void 0 : eventState.pressed) && styles$1.pressed, // active + pressed
|
|
159
|
-
!disabled && active && (eventState == null ? void 0 : eventState.pressed) && styles$1.activePressed]
|
|
160
|
-
}, /*#__PURE__*/React.createElement(LeftAccessory, {
|
|
113
|
+
}, React.createElement(View, {
|
|
114
|
+
style: [styles$1.innerWrapper, innerStyle, style, horizontalRuleStyles, disabled && styles$1.disabled, active && styles$1.active, !disabled && (eventState == null ? void 0 : eventState.hovered) && styles$1.hovered, active && (eventState == null ? void 0 : eventState.hovered) && styles$1.activeHovered, !disabled && (eventState == null ? void 0 : eventState.pressed) && styles$1.pressed, !disabled && active && (eventState == null ? void 0 : eventState.pressed) && styles$1.activePressed]
|
|
115
|
+
}, React.createElement(LeftAccessory, {
|
|
161
116
|
leftAccessory: leftAccessory,
|
|
162
117
|
leftAccessoryStyle: leftAccessoryStyle,
|
|
163
118
|
disabled: disabled
|
|
164
|
-
}),
|
|
119
|
+
}), React.createElement(View, {
|
|
165
120
|
style: styles$1.content,
|
|
166
121
|
testId: testId
|
|
167
|
-
}, children),
|
|
122
|
+
}, children), React.createElement(RightAccessory, {
|
|
168
123
|
rightAccessory: rightAccessory,
|
|
169
124
|
rightAccessoryStyle: rightAccessoryStyle,
|
|
170
125
|
active: active,
|
|
171
126
|
disabled: disabled
|
|
172
127
|
})));
|
|
173
|
-
};
|
|
174
|
-
|
|
128
|
+
};
|
|
175
129
|
|
|
176
130
|
if (onClick || href) {
|
|
177
|
-
return
|
|
131
|
+
return React.createElement(Clickable, {
|
|
178
132
|
disabled: disabled,
|
|
179
133
|
onClick: onClick,
|
|
180
134
|
href: href,
|
|
@@ -182,8 +136,7 @@ const CellCore = props => {
|
|
|
182
136
|
"aria-label": ariaLabel ? ariaLabel : undefined,
|
|
183
137
|
target: target
|
|
184
138
|
}, eventState => renderCell(eventState));
|
|
185
|
-
}
|
|
186
|
-
|
|
139
|
+
}
|
|
187
140
|
|
|
188
141
|
return renderCell();
|
|
189
142
|
};
|
|
@@ -202,39 +155,24 @@ const styles$1 = StyleSheet.create({
|
|
|
202
155
|
},
|
|
203
156
|
content: {
|
|
204
157
|
alignSelf: "center",
|
|
205
|
-
// Expand the content to fill the available space.
|
|
206
158
|
flex: 1,
|
|
207
159
|
overflowWrap: "break-word"
|
|
208
160
|
},
|
|
209
161
|
accessory: {
|
|
210
|
-
// Use content width by default.
|
|
211
162
|
minWidth: "auto",
|
|
212
|
-
// Horizontal alignment of the accessory.
|
|
213
163
|
alignItems: "center",
|
|
214
|
-
// Vertical alignment.
|
|
215
164
|
alignSelf: "center"
|
|
216
165
|
},
|
|
217
166
|
accessoryRight: {
|
|
218
|
-
// The right accessory will have this color by default. Unless the
|
|
219
|
-
// accessory element overrides that color internally.
|
|
220
167
|
color: Color.offBlack64
|
|
221
168
|
},
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* States
|
|
225
|
-
*/
|
|
226
169
|
hovered: {
|
|
227
170
|
background: Color.offBlack8
|
|
228
171
|
},
|
|
229
|
-
// Handling the focus ring internally because clickable doesn't support
|
|
230
|
-
// rounded focus ring.
|
|
231
172
|
focused: {
|
|
232
173
|
borderRadius: Spacing.xxxSmall_4,
|
|
233
174
|
outline: `solid ${Spacing.xxxxSmall_2}px ${Color.blue}`,
|
|
234
|
-
// The focus ring is not visible when there are stacked cells.
|
|
235
|
-
// Using outlineOffset to display the focus ring inside the cell.
|
|
236
175
|
outlineOffset: -Spacing.xxxxSmall_2,
|
|
237
|
-
// To hide the internal corners of the cell.
|
|
238
176
|
overflow: "hidden"
|
|
239
177
|
},
|
|
240
178
|
pressed: {
|
|
@@ -267,31 +205,13 @@ const styles$1 = StyleSheet.create({
|
|
|
267
205
|
|
|
268
206
|
const _excluded$1 = ["title"];
|
|
269
207
|
|
|
270
|
-
/**
|
|
271
|
-
* `CompactCell` is the simplest form of the Cell. It is a compacted-height Cell
|
|
272
|
-
* with limited subviews and accessories. Typically they represent additional
|
|
273
|
-
* info or selection lists. It has a minimum height of 48px and a non-bold
|
|
274
|
-
* title. It does not have subtitles or a progress bar, and in general it has
|
|
275
|
-
* less vertical space around text and accessories.
|
|
276
|
-
*
|
|
277
|
-
* ### Usage
|
|
278
|
-
*
|
|
279
|
-
* ```jsx
|
|
280
|
-
* import {CompactCell} from "@khanacademy/wonder-blocks-cell";
|
|
281
|
-
*
|
|
282
|
-
* <CompactCell
|
|
283
|
-
* title="Compact cell"
|
|
284
|
-
* rightAccessory={<Icon icon={icons.caretRight} size="medium" />}
|
|
285
|
-
* />
|
|
286
|
-
* ```
|
|
287
|
-
*/
|
|
288
208
|
function CompactCell(props) {
|
|
289
209
|
const {
|
|
290
210
|
title
|
|
291
211
|
} = props,
|
|
292
212
|
coreProps = _objectWithoutPropertiesLoose(props, _excluded$1);
|
|
293
213
|
|
|
294
|
-
return
|
|
214
|
+
return React.createElement(CellCore, coreProps, typeof title === "string" ? React.createElement(LabelMedium, null, title) : title);
|
|
295
215
|
}
|
|
296
216
|
|
|
297
217
|
const _excluded = ["title", "subtitle1", "subtitle2"];
|
|
@@ -305,7 +225,7 @@ const Subtitle = ({
|
|
|
305
225
|
}
|
|
306
226
|
|
|
307
227
|
if (typeof subtitle === "string") {
|
|
308
|
-
return
|
|
228
|
+
return React.createElement(LabelSmall, {
|
|
309
229
|
style: !disabled && styles.subtitle
|
|
310
230
|
}, subtitle);
|
|
311
231
|
}
|
|
@@ -313,27 +233,6 @@ const Subtitle = ({
|
|
|
313
233
|
return subtitle;
|
|
314
234
|
};
|
|
315
235
|
|
|
316
|
-
/**
|
|
317
|
-
* This is a variant of CompactCell that allows adding subtitles, before and
|
|
318
|
-
* after the cell title. They typically represent an item that can be
|
|
319
|
-
* clicked/tapped to view more complex details. They vary in height depending on
|
|
320
|
-
* the presence or absence of subtitles, and they allow for a wide range of
|
|
321
|
-
* functionality depending on which accessories are active.
|
|
322
|
-
*
|
|
323
|
-
* ### Usage
|
|
324
|
-
*
|
|
325
|
-
* ```jsx
|
|
326
|
-
* import {DetailCell} from "@khanacademy/wonder-blocks-cell";
|
|
327
|
-
*
|
|
328
|
-
* <DetailCell
|
|
329
|
-
* leftAccessory={<Icon icon={icons.contentVideo} size="medium" />}
|
|
330
|
-
* subtitle1="Subtitle 1"
|
|
331
|
-
* title="Detail cell"
|
|
332
|
-
* subtitle1="Subtitle 2"
|
|
333
|
-
* rightAccessory={<Icon icon={icons.caretRight} size="medium" />}
|
|
334
|
-
* />
|
|
335
|
-
* ```
|
|
336
|
-
*/
|
|
337
236
|
function DetailCell(props) {
|
|
338
237
|
const {
|
|
339
238
|
title,
|
|
@@ -342,16 +241,16 @@ function DetailCell(props) {
|
|
|
342
241
|
} = props,
|
|
343
242
|
coreProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
344
243
|
|
|
345
|
-
return
|
|
244
|
+
return React.createElement(CellCore, _extends({}, coreProps, {
|
|
346
245
|
innerStyle: styles.innerWrapper
|
|
347
|
-
}),
|
|
246
|
+
}), React.createElement(Subtitle, {
|
|
348
247
|
subtitle: subtitle1,
|
|
349
248
|
disabled: coreProps.disabled
|
|
350
|
-
}), subtitle1 &&
|
|
249
|
+
}), subtitle1 && React.createElement(Strut, {
|
|
351
250
|
size: Spacing.xxxxSmall_2
|
|
352
|
-
}), typeof title === "string" ?
|
|
251
|
+
}), typeof title === "string" ? React.createElement(LabelMedium, null, title) : title, subtitle2 && React.createElement(Strut, {
|
|
353
252
|
size: Spacing.xxxxSmall_2
|
|
354
|
-
}),
|
|
253
|
+
}), React.createElement(Subtitle, {
|
|
355
254
|
subtitle: subtitle2,
|
|
356
255
|
disabled: coreProps.disabled
|
|
357
256
|
}));
|
|
@@ -361,7 +260,6 @@ const styles = StyleSheet.create({
|
|
|
361
260
|
subtitle: {
|
|
362
261
|
color: Color.offBlack64
|
|
363
262
|
},
|
|
364
|
-
// This is to override the default padding of the CellCore innerWrapper.
|
|
365
263
|
innerWrapper: {
|
|
366
264
|
padding: `${CellMeasurements.detailCellPadding.paddingVertical}px ${CellMeasurements.detailCellPadding.paddingHorizontal}px`
|
|
367
265
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-cell",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.5",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -13,20 +13,20 @@
|
|
|
13
13
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@babel/runtime": "^7.
|
|
17
|
-
"@khanacademy/wonder-blocks-clickable": "^2.
|
|
16
|
+
"@babel/runtime": "^7.18.6",
|
|
17
|
+
"@khanacademy/wonder-blocks-clickable": "^2.3.0",
|
|
18
18
|
"@khanacademy/wonder-blocks-color": "^1.1.20",
|
|
19
|
-
"@khanacademy/wonder-blocks-core": "^4.3.
|
|
20
|
-
"@khanacademy/wonder-blocks-layout": "^1.4.
|
|
19
|
+
"@khanacademy/wonder-blocks-core": "^4.3.2",
|
|
20
|
+
"@khanacademy/wonder-blocks-layout": "^1.4.10",
|
|
21
21
|
"@khanacademy/wonder-blocks-spacing": "^3.0.5",
|
|
22
|
-
"@khanacademy/wonder-blocks-typography": "^1.1.
|
|
22
|
+
"@khanacademy/wonder-blocks-typography": "^1.1.32"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"aphrodite": "^1.2.5",
|
|
26
26
|
"react": "16.14.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"wb-dev-build-settings": "^0.
|
|
29
|
+
"wb-dev-build-settings": "^0.4.0"
|
|
30
30
|
},
|
|
31
31
|
"author": "",
|
|
32
32
|
"license": "MIT"
|