@khanacademy/wonder-blocks-cell 2.1.0 → 2.2.2
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 +18 -0
- package/dist/es/index.js +10 -16
- package/dist/index.js +10 -16
- package/package.json +1 -1
- package/src/components/__docs__/detail-cell.stories.js +6 -4
- package/src/components/internal/cell-core.js +4 -5
- package/src/components/internal/common.js +2 -7
- package/src/util/types.js +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-cell
|
|
2
2
|
|
|
3
|
+
## 2.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f74b7379: Fixes `CellCore` to set the styles properly (removed `marginLeft: auto` from accessory and expanded the content wrapper).
|
|
8
|
+
|
|
9
|
+
## 2.2.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- eadd9c0d: Fix top vertical alignment between accessories and content
|
|
14
|
+
|
|
15
|
+
## 2.2.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 35b9ef9c: Add target prop to cell.
|
|
20
|
+
|
|
3
21
|
## 2.1.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/dist/es/index.js
CHANGED
|
@@ -16,7 +16,7 @@ const CellMeasurements = {
|
|
|
16
16
|
* The cell wrapper's gap.
|
|
17
17
|
*/
|
|
18
18
|
cellPadding: {
|
|
19
|
-
paddingVertical: Spacing.
|
|
19
|
+
paddingVertical: Spacing.small_12,
|
|
20
20
|
paddingHorizontal: Spacing.medium_16
|
|
21
21
|
},
|
|
22
22
|
|
|
@@ -24,15 +24,10 @@ const CellMeasurements = {
|
|
|
24
24
|
* The DetailCell wrapper's gap.
|
|
25
25
|
*/
|
|
26
26
|
detailCellPadding: {
|
|
27
|
-
paddingVertical: Spacing.
|
|
27
|
+
paddingVertical: Spacing.medium_16,
|
|
28
28
|
paddingHorizontal: Spacing.medium_16
|
|
29
29
|
},
|
|
30
30
|
|
|
31
|
-
/**
|
|
32
|
-
* The extra vertical spacing added to the title/content wrapper.
|
|
33
|
-
*/
|
|
34
|
-
contentVerticalSpacing: Spacing.xxxSmall_4,
|
|
35
|
-
|
|
36
31
|
/**
|
|
37
32
|
* The horizontal spacing between the left and right accessory.
|
|
38
33
|
*/
|
|
@@ -144,7 +139,8 @@ const CellCore = props => {
|
|
|
144
139
|
style,
|
|
145
140
|
testId,
|
|
146
141
|
"aria-label": ariaLabel,
|
|
147
|
-
innerStyle
|
|
142
|
+
innerStyle,
|
|
143
|
+
target
|
|
148
144
|
} = props;
|
|
149
145
|
|
|
150
146
|
const renderCell = eventState => {
|
|
@@ -183,7 +179,8 @@ const CellCore = props => {
|
|
|
183
179
|
onClick: onClick,
|
|
184
180
|
href: href,
|
|
185
181
|
hideDefaultFocusRing: true,
|
|
186
|
-
"aria-label": ariaLabel ? ariaLabel : undefined
|
|
182
|
+
"aria-label": ariaLabel ? ariaLabel : undefined,
|
|
183
|
+
target: target
|
|
187
184
|
}, eventState => renderCell(eventState));
|
|
188
185
|
} // No click event attached, so just render the cell as-is.
|
|
189
186
|
|
|
@@ -205,8 +202,9 @@ const styles$1 = StyleSheet.create({
|
|
|
205
202
|
},
|
|
206
203
|
content: {
|
|
207
204
|
alignSelf: "center",
|
|
208
|
-
|
|
209
|
-
|
|
205
|
+
// Expand the content to fill the available space.
|
|
206
|
+
flex: 1,
|
|
207
|
+
overflowWrap: "break-word"
|
|
210
208
|
},
|
|
211
209
|
accessory: {
|
|
212
210
|
// Use content width by default.
|
|
@@ -219,11 +217,7 @@ const styles$1 = StyleSheet.create({
|
|
|
219
217
|
accessoryRight: {
|
|
220
218
|
// The right accessory will have this color by default. Unless the
|
|
221
219
|
// accessory element overrides that color internally.
|
|
222
|
-
color: Color.offBlack64
|
|
223
|
-
// Align the right accessory to the right side of the cell, so we can
|
|
224
|
-
// prevent the accessory from shifting left, if the content is too
|
|
225
|
-
// short.
|
|
226
|
-
marginLeft: "auto"
|
|
220
|
+
color: Color.offBlack64
|
|
227
221
|
},
|
|
228
222
|
|
|
229
223
|
/**
|
package/dist/index.js
CHANGED
|
@@ -126,7 +126,7 @@ const CellMeasurements = {
|
|
|
126
126
|
* The cell wrapper's gap.
|
|
127
127
|
*/
|
|
128
128
|
cellPadding: {
|
|
129
|
-
paddingVertical: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2___default.a.
|
|
129
|
+
paddingVertical: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2___default.a.small_12,
|
|
130
130
|
paddingHorizontal: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2___default.a.medium_16
|
|
131
131
|
},
|
|
132
132
|
|
|
@@ -134,15 +134,10 @@ const CellMeasurements = {
|
|
|
134
134
|
* The DetailCell wrapper's gap.
|
|
135
135
|
*/
|
|
136
136
|
detailCellPadding: {
|
|
137
|
-
paddingVertical: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2___default.a.
|
|
137
|
+
paddingVertical: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2___default.a.medium_16,
|
|
138
138
|
paddingHorizontal: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2___default.a.medium_16
|
|
139
139
|
},
|
|
140
140
|
|
|
141
|
-
/**
|
|
142
|
-
* The extra vertical spacing added to the title/content wrapper.
|
|
143
|
-
*/
|
|
144
|
-
contentVerticalSpacing: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2___default.a.xxxSmall_4,
|
|
145
|
-
|
|
146
141
|
/**
|
|
147
142
|
* The horizontal spacing between the left and right accessory.
|
|
148
143
|
*/
|
|
@@ -309,7 +304,8 @@ const CellCore = props => {
|
|
|
309
304
|
style,
|
|
310
305
|
testId,
|
|
311
306
|
"aria-label": ariaLabel,
|
|
312
|
-
innerStyle
|
|
307
|
+
innerStyle,
|
|
308
|
+
target
|
|
313
309
|
} = props;
|
|
314
310
|
|
|
315
311
|
const renderCell = eventState => {
|
|
@@ -348,7 +344,8 @@ const CellCore = props => {
|
|
|
348
344
|
onClick: onClick,
|
|
349
345
|
href: href,
|
|
350
346
|
hideDefaultFocusRing: true,
|
|
351
|
-
"aria-label": ariaLabel ? ariaLabel : undefined
|
|
347
|
+
"aria-label": ariaLabel ? ariaLabel : undefined,
|
|
348
|
+
target: target
|
|
352
349
|
}, eventState => renderCell(eventState));
|
|
353
350
|
} // No click event attached, so just render the cell as-is.
|
|
354
351
|
|
|
@@ -370,8 +367,9 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
|
370
367
|
},
|
|
371
368
|
content: {
|
|
372
369
|
alignSelf: "center",
|
|
373
|
-
|
|
374
|
-
|
|
370
|
+
// Expand the content to fill the available space.
|
|
371
|
+
flex: 1,
|
|
372
|
+
overflowWrap: "break-word"
|
|
375
373
|
},
|
|
376
374
|
accessory: {
|
|
377
375
|
// Use content width by default.
|
|
@@ -384,11 +382,7 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
|
384
382
|
accessoryRight: {
|
|
385
383
|
// The right accessory will have this color by default. Unless the
|
|
386
384
|
// accessory element overrides that color internally.
|
|
387
|
-
color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default.a.offBlack64
|
|
388
|
-
// Align the right accessory to the right side of the cell, so we can
|
|
389
|
-
// prevent the accessory from shifting left, if the content is too
|
|
390
|
-
// short.
|
|
391
|
-
marginLeft: "auto"
|
|
385
|
+
color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default.a.offBlack64
|
|
392
386
|
},
|
|
393
387
|
|
|
394
388
|
/**
|
package/package.json
CHANGED
|
@@ -107,14 +107,16 @@ export const DetailCellWithCustomStyles: StoryComponentType = () => (
|
|
|
107
107
|
title="Title for article item"
|
|
108
108
|
subtitle1="Subtitle for article item"
|
|
109
109
|
subtitle2="Subtitle for article item"
|
|
110
|
-
leftAccessory={<Icon icon={icons.
|
|
110
|
+
leftAccessory={<Icon icon={icons.caretLeft} size="small" />}
|
|
111
111
|
leftAccessoryStyle={{
|
|
112
|
-
|
|
112
|
+
alignSelf: "flex-start",
|
|
113
113
|
}}
|
|
114
114
|
rightAccessory={<Icon icon={icons.caretRight} size="small" />}
|
|
115
115
|
rightAccessoryStyle={{
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
alignSelf: "flex-start",
|
|
117
|
+
}}
|
|
118
|
+
style={{
|
|
119
|
+
textAlign: "center",
|
|
118
120
|
}}
|
|
119
121
|
/>
|
|
120
122
|
);
|
|
@@ -130,6 +130,7 @@ const CellCore = (props: CellCoreProps): React.Node => {
|
|
|
130
130
|
testId,
|
|
131
131
|
"aria-label": ariaLabel,
|
|
132
132
|
innerStyle,
|
|
133
|
+
target,
|
|
133
134
|
} = props;
|
|
134
135
|
|
|
135
136
|
const renderCell = (eventState?: ClickableState): React.Node => {
|
|
@@ -200,6 +201,7 @@ const CellCore = (props: CellCoreProps): React.Node => {
|
|
|
200
201
|
href={href}
|
|
201
202
|
hideDefaultFocusRing={true}
|
|
202
203
|
aria-label={ariaLabel ? ariaLabel : undefined}
|
|
204
|
+
target={target}
|
|
203
205
|
>
|
|
204
206
|
{(eventState) => renderCell(eventState)}
|
|
205
207
|
</Clickable>
|
|
@@ -226,8 +228,9 @@ const styles = StyleSheet.create({
|
|
|
226
228
|
|
|
227
229
|
content: {
|
|
228
230
|
alignSelf: "center",
|
|
231
|
+
// Expand the content to fill the available space.
|
|
232
|
+
flex: 1,
|
|
229
233
|
overflowWrap: "break-word",
|
|
230
|
-
padding: `${CellMeasurements.contentVerticalSpacing}px 0`,
|
|
231
234
|
},
|
|
232
235
|
|
|
233
236
|
accessory: {
|
|
@@ -243,10 +246,6 @@ const styles = StyleSheet.create({
|
|
|
243
246
|
// The right accessory will have this color by default. Unless the
|
|
244
247
|
// accessory element overrides that color internally.
|
|
245
248
|
color: Color.offBlack64,
|
|
246
|
-
// Align the right accessory to the right side of the cell, so we can
|
|
247
|
-
// prevent the accessory from shifting left, if the content is too
|
|
248
|
-
// short.
|
|
249
|
-
marginLeft: "auto",
|
|
250
249
|
},
|
|
251
250
|
|
|
252
251
|
/**
|
|
@@ -14,7 +14,7 @@ export const CellMeasurements = {
|
|
|
14
14
|
* The cell wrapper's gap.
|
|
15
15
|
*/
|
|
16
16
|
cellPadding: {
|
|
17
|
-
paddingVertical: Spacing.
|
|
17
|
+
paddingVertical: Spacing.small_12,
|
|
18
18
|
paddingHorizontal: Spacing.medium_16,
|
|
19
19
|
},
|
|
20
20
|
|
|
@@ -22,15 +22,10 @@ export const CellMeasurements = {
|
|
|
22
22
|
* The DetailCell wrapper's gap.
|
|
23
23
|
*/
|
|
24
24
|
detailCellPadding: {
|
|
25
|
-
paddingVertical: Spacing.
|
|
25
|
+
paddingVertical: Spacing.medium_16,
|
|
26
26
|
paddingHorizontal: Spacing.medium_16,
|
|
27
27
|
},
|
|
28
28
|
|
|
29
|
-
/**
|
|
30
|
-
* The extra vertical spacing added to the title/content wrapper.
|
|
31
|
-
*/
|
|
32
|
-
contentVerticalSpacing: Spacing.xxxSmall_4,
|
|
33
|
-
|
|
34
29
|
/**
|
|
35
30
|
* The horizontal spacing between the left and right accessory.
|
|
36
31
|
*/
|
package/src/util/types.js
CHANGED
|
@@ -132,4 +132,12 @@ export type CellProps = {|
|
|
|
132
132
|
* by default if react-router is present.
|
|
133
133
|
*/
|
|
134
134
|
href?: string,
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* A target destination window for a link to open in. Should only be used
|
|
138
|
+
* when `href` is specified.
|
|
139
|
+
*
|
|
140
|
+
* TODO(WB-1262): only allow this prop when `href` is also set.t
|
|
141
|
+
*/
|
|
142
|
+
target?: "_blank",
|
|
135
143
|
|};
|