@khanacademy/wonder-blocks-cell 4.1.2 → 4.1.3

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 CHANGED
@@ -1,5 +1,32 @@
1
1
  # @khanacademy/wonder-blocks-cell
2
2
 
3
+ ## 4.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 1e98035: Use semantic color tokens in CellCore
8
+ - 507cf2f: DetailCell and CompactCell: update styling to address accessibility issues (color contrast and using color as the only visual indicator). Updated styles include:
9
+
10
+ - General:
11
+ - Changing the grey used for subtitles
12
+ - Using `icon.primary` for the right accessory
13
+ - Press state:
14
+ - Changing the background to `fadedBlue8`
15
+ - Adding a thin left border when clickable cells are pressed
16
+ - Hover state:
17
+ - Changing the background to `fadedBlue8`
18
+ - Disabled state:
19
+ - Changing the focus outline to `action.disabled.default`
20
+ - Selected state (cells with `active=true`):
21
+ - Adding a thick left border
22
+ - Changing the text color to `activeBlue`
23
+ - The styling no longer changes when a selected cell is hovered or pressed on
24
+
25
+ - Updated dependencies [507cf2f]
26
+ - @khanacademy/wonder-blocks-tokens@5.1.0
27
+ - @khanacademy/wonder-blocks-clickable@6.1.3
28
+ - @khanacademy/wonder-blocks-layout@3.1.3
29
+
3
30
  ## 4.1.2
4
31
 
5
32
  ### Patch Changes
package/dist/es/index.js CHANGED
@@ -6,7 +6,7 @@ import { StyleSheet } from 'aphrodite';
6
6
  import Clickable from '@khanacademy/wonder-blocks-clickable';
7
7
  import { View } from '@khanacademy/wonder-blocks-core';
8
8
  import { Strut } from '@khanacademy/wonder-blocks-layout';
9
- import { spacing, color } from '@khanacademy/wonder-blocks-tokens';
9
+ import { spacing, color, semanticColor, border } from '@khanacademy/wonder-blocks-tokens';
10
10
 
11
11
  const CellMeasurements = {
12
12
  cellMinHeight: spacing.xxLarge_48,
@@ -96,7 +96,8 @@ function CellInner(props) {
96
96
  } = props;
97
97
  const horizontalRuleStyles = getHorizontalRuleStyles(horizontalRule);
98
98
  return React.createElement(View, {
99
- style: [styles$1.innerWrapper, innerStyle, style, horizontalRuleStyles]
99
+ style: [styles$1.innerWrapper, innerStyle, style, horizontalRuleStyles, active && styles$1.activeInnerWrapper],
100
+ className: "inner-wrapper"
100
101
  }, React.createElement(LeftAccessory, {
101
102
  leftAccessory: leftAccessory,
102
103
  leftAccessoryStyle: leftAccessoryStyle,
@@ -146,10 +147,48 @@ const CellCore = props => {
146
147
  role: role
147
148
  }, React.createElement(CellInner, props));
148
149
  };
150
+ const cellTokens = {
151
+ root: {
152
+ default: {
153
+ background: semanticColor.surface.primary,
154
+ foreground: semanticColor.text.primary
155
+ },
156
+ hover: {
157
+ background: color.fadedBlue8
158
+ },
159
+ press: {
160
+ background: color.fadedBlue8,
161
+ border: semanticColor.surface.emphasis
162
+ },
163
+ selected: {
164
+ background: color.fadedBlue8,
165
+ foreground: color.activeBlue,
166
+ border: semanticColor.surface.emphasis
167
+ },
168
+ focus: {
169
+ border: semanticColor.focus.outer
170
+ },
171
+ disabled: {
172
+ foreground: semanticColor.text.disabled,
173
+ border: semanticColor.focus.outer
174
+ }
175
+ },
176
+ accessory: {
177
+ default: {
178
+ foreground: semanticColor.icon.primary
179
+ },
180
+ selected: {
181
+ foreground: semanticColor.icon.action
182
+ },
183
+ disabled: {
184
+ foreground: semanticColor.icon.secondary
185
+ }
186
+ }
187
+ };
149
188
  const styles$1 = StyleSheet.create({
150
189
  wrapper: {
151
- background: color.white,
152
- color: color.offBlack,
190
+ background: cellTokens.root.default.background,
191
+ color: cellTokens.root.default.foreground,
153
192
  display: "flex",
154
193
  minHeight: CellMeasurements.cellMinHeight,
155
194
  textAlign: "left",
@@ -160,10 +199,25 @@ const styles$1 = StyleSheet.create({
160
199
  padding: `${CellMeasurements.cellPadding.paddingVertical}px ${CellMeasurements.cellPadding.paddingHorizontal}px`,
161
200
  flexDirection: "row",
162
201
  flex: 1,
202
+ borderRadius: "inherit",
203
+ overflow: "hidden",
204
+ height: "100%",
163
205
  ":focus-visible": {
164
206
  padding: `${CellMeasurements.cellPadding.paddingVertical - 2}px ${CellMeasurements.cellPadding.paddingHorizontal - 2}px`
165
207
  }
166
208
  },
209
+ activeInnerWrapper: {
210
+ position: "relative",
211
+ ":before": {
212
+ content: "''",
213
+ position: "absolute",
214
+ top: 0,
215
+ left: 0,
216
+ bottom: 0,
217
+ width: border.width.thick,
218
+ backgroundColor: cellTokens.root.selected.border
219
+ }
220
+ },
167
221
  content: {
168
222
  alignSelf: "center",
169
223
  flex: 1,
@@ -175,7 +229,7 @@ const styles$1 = StyleSheet.create({
175
229
  alignSelf: "center"
176
230
  },
177
231
  accessoryRight: {
178
- color: color.offBlack64
232
+ color: cellTokens.accessory.default.foreground
179
233
  },
180
234
  clickable: {
181
235
  outline: "none",
@@ -195,37 +249,47 @@ const styles$1 = StyleSheet.create({
195
249
  zIndex: 1,
196
250
  width: `calc(100% - ${spacing.xxxSmall_4}px)`,
197
251
  height: `calc(100% - ${spacing.xxxSmall_4}px)`,
198
- border: `${spacing.xxxxSmall_2}px solid ${color.blue}`,
252
+ border: `${spacing.xxxxSmall_2}px solid ${cellTokens.root.focus.border}`,
199
253
  borderRadius: spacing.xxxSmall_4
200
254
  },
255
+ [":focus-visible[aria-disabled=true]:after"]: {
256
+ borderColor: cellTokens.root.disabled.border
257
+ },
201
258
  [":hover[aria-disabled=false]"]: {
202
- background: color.offBlack8
259
+ background: cellTokens.root.hover.background
203
260
  },
204
261
  [":active[aria-disabled=false]"]: {
205
- background: color.offBlack16
262
+ background: cellTokens.root.press.background
263
+ },
264
+ [":active[aria-disabled=false]:not([aria-current=true]) .inner-wrapper"]: {
265
+ position: "relative",
266
+ ":before": {
267
+ content: "''",
268
+ position: "absolute",
269
+ top: 0,
270
+ left: 0,
271
+ bottom: 0,
272
+ width: border.width.thin,
273
+ backgroundColor: semanticColor.surface.emphasis
274
+ }
206
275
  }
207
276
  },
208
277
  active: {
209
- background: color.fadedBlue8,
210
- color: color.blue,
211
- [":hover[aria-disabled=false]"]: {
212
- background: color.fadedBlue16
213
- },
214
- [":active[aria-disabled=false]"]: {
215
- background: color.fadedBlue24
216
- }
278
+ background: cellTokens.root.selected.background,
279
+ color: cellTokens.root.selected.foreground,
280
+ cursor: "default"
217
281
  },
218
282
  disabled: {
219
- color: color.offBlack32,
283
+ color: cellTokens.root.disabled.foreground,
220
284
  ":focus-visible": {
221
285
  outline: "none"
222
286
  }
223
287
  },
224
288
  accessoryActive: {
225
- color: color.blue
289
+ color: cellTokens.accessory.selected.foreground
226
290
  },
227
291
  accessoryDisabled: {
228
- color: color.offBlack,
292
+ color: cellTokens.accessory.disabled.foreground,
229
293
  opacity: 0.32
230
294
  }
231
295
  });
@@ -277,7 +341,7 @@ const DetailCell = function DetailCell(props) {
277
341
  };
278
342
  const styles = StyleSheet.create({
279
343
  subtitle: {
280
- color: color.offBlack64
344
+ color: semanticColor.text.secondary
281
345
  },
282
346
  innerWrapper: {
283
347
  padding: `${CellMeasurements.detailCellPadding.paddingVertical}px ${CellMeasurements.detailCellPadding.paddingHorizontal}px`
package/dist/index.js CHANGED
@@ -125,7 +125,8 @@ function CellInner(props) {
125
125
  } = props;
126
126
  const horizontalRuleStyles = getHorizontalRuleStyles(horizontalRule);
127
127
  return React__namespace.createElement(wonderBlocksCore.View, {
128
- style: [styles$1.innerWrapper, innerStyle, style, horizontalRuleStyles]
128
+ style: [styles$1.innerWrapper, innerStyle, style, horizontalRuleStyles, active && styles$1.activeInnerWrapper],
129
+ className: "inner-wrapper"
129
130
  }, React__namespace.createElement(LeftAccessory, {
130
131
  leftAccessory: leftAccessory,
131
132
  leftAccessoryStyle: leftAccessoryStyle,
@@ -175,10 +176,48 @@ const CellCore = props => {
175
176
  role: role
176
177
  }, React__namespace.createElement(CellInner, props));
177
178
  };
179
+ const cellTokens = {
180
+ root: {
181
+ default: {
182
+ background: wonderBlocksTokens.semanticColor.surface.primary,
183
+ foreground: wonderBlocksTokens.semanticColor.text.primary
184
+ },
185
+ hover: {
186
+ background: wonderBlocksTokens.color.fadedBlue8
187
+ },
188
+ press: {
189
+ background: wonderBlocksTokens.color.fadedBlue8,
190
+ border: wonderBlocksTokens.semanticColor.surface.emphasis
191
+ },
192
+ selected: {
193
+ background: wonderBlocksTokens.color.fadedBlue8,
194
+ foreground: wonderBlocksTokens.color.activeBlue,
195
+ border: wonderBlocksTokens.semanticColor.surface.emphasis
196
+ },
197
+ focus: {
198
+ border: wonderBlocksTokens.semanticColor.focus.outer
199
+ },
200
+ disabled: {
201
+ foreground: wonderBlocksTokens.semanticColor.text.disabled,
202
+ border: wonderBlocksTokens.semanticColor.focus.outer
203
+ }
204
+ },
205
+ accessory: {
206
+ default: {
207
+ foreground: wonderBlocksTokens.semanticColor.icon.primary
208
+ },
209
+ selected: {
210
+ foreground: wonderBlocksTokens.semanticColor.icon.action
211
+ },
212
+ disabled: {
213
+ foreground: wonderBlocksTokens.semanticColor.icon.secondary
214
+ }
215
+ }
216
+ };
178
217
  const styles$1 = aphrodite.StyleSheet.create({
179
218
  wrapper: {
180
- background: wonderBlocksTokens.color.white,
181
- color: wonderBlocksTokens.color.offBlack,
219
+ background: cellTokens.root.default.background,
220
+ color: cellTokens.root.default.foreground,
182
221
  display: "flex",
183
222
  minHeight: CellMeasurements.cellMinHeight,
184
223
  textAlign: "left",
@@ -189,10 +228,25 @@ const styles$1 = aphrodite.StyleSheet.create({
189
228
  padding: `${CellMeasurements.cellPadding.paddingVertical}px ${CellMeasurements.cellPadding.paddingHorizontal}px`,
190
229
  flexDirection: "row",
191
230
  flex: 1,
231
+ borderRadius: "inherit",
232
+ overflow: "hidden",
233
+ height: "100%",
192
234
  ":focus-visible": {
193
235
  padding: `${CellMeasurements.cellPadding.paddingVertical - 2}px ${CellMeasurements.cellPadding.paddingHorizontal - 2}px`
194
236
  }
195
237
  },
238
+ activeInnerWrapper: {
239
+ position: "relative",
240
+ ":before": {
241
+ content: "''",
242
+ position: "absolute",
243
+ top: 0,
244
+ left: 0,
245
+ bottom: 0,
246
+ width: wonderBlocksTokens.border.width.thick,
247
+ backgroundColor: cellTokens.root.selected.border
248
+ }
249
+ },
196
250
  content: {
197
251
  alignSelf: "center",
198
252
  flex: 1,
@@ -204,7 +258,7 @@ const styles$1 = aphrodite.StyleSheet.create({
204
258
  alignSelf: "center"
205
259
  },
206
260
  accessoryRight: {
207
- color: wonderBlocksTokens.color.offBlack64
261
+ color: cellTokens.accessory.default.foreground
208
262
  },
209
263
  clickable: {
210
264
  outline: "none",
@@ -224,37 +278,47 @@ const styles$1 = aphrodite.StyleSheet.create({
224
278
  zIndex: 1,
225
279
  width: `calc(100% - ${wonderBlocksTokens.spacing.xxxSmall_4}px)`,
226
280
  height: `calc(100% - ${wonderBlocksTokens.spacing.xxxSmall_4}px)`,
227
- border: `${wonderBlocksTokens.spacing.xxxxSmall_2}px solid ${wonderBlocksTokens.color.blue}`,
281
+ border: `${wonderBlocksTokens.spacing.xxxxSmall_2}px solid ${cellTokens.root.focus.border}`,
228
282
  borderRadius: wonderBlocksTokens.spacing.xxxSmall_4
229
283
  },
284
+ [":focus-visible[aria-disabled=true]:after"]: {
285
+ borderColor: cellTokens.root.disabled.border
286
+ },
230
287
  [":hover[aria-disabled=false]"]: {
231
- background: wonderBlocksTokens.color.offBlack8
288
+ background: cellTokens.root.hover.background
232
289
  },
233
290
  [":active[aria-disabled=false]"]: {
234
- background: wonderBlocksTokens.color.offBlack16
291
+ background: cellTokens.root.press.background
292
+ },
293
+ [":active[aria-disabled=false]:not([aria-current=true]) .inner-wrapper"]: {
294
+ position: "relative",
295
+ ":before": {
296
+ content: "''",
297
+ position: "absolute",
298
+ top: 0,
299
+ left: 0,
300
+ bottom: 0,
301
+ width: wonderBlocksTokens.border.width.thin,
302
+ backgroundColor: wonderBlocksTokens.semanticColor.surface.emphasis
303
+ }
235
304
  }
236
305
  },
237
306
  active: {
238
- background: wonderBlocksTokens.color.fadedBlue8,
239
- color: wonderBlocksTokens.color.blue,
240
- [":hover[aria-disabled=false]"]: {
241
- background: wonderBlocksTokens.color.fadedBlue16
242
- },
243
- [":active[aria-disabled=false]"]: {
244
- background: wonderBlocksTokens.color.fadedBlue24
245
- }
307
+ background: cellTokens.root.selected.background,
308
+ color: cellTokens.root.selected.foreground,
309
+ cursor: "default"
246
310
  },
247
311
  disabled: {
248
- color: wonderBlocksTokens.color.offBlack32,
312
+ color: cellTokens.root.disabled.foreground,
249
313
  ":focus-visible": {
250
314
  outline: "none"
251
315
  }
252
316
  },
253
317
  accessoryActive: {
254
- color: wonderBlocksTokens.color.blue
318
+ color: cellTokens.accessory.selected.foreground
255
319
  },
256
320
  accessoryDisabled: {
257
- color: wonderBlocksTokens.color.offBlack,
321
+ color: cellTokens.accessory.disabled.foreground,
258
322
  opacity: 0.32
259
323
  }
260
324
  });
@@ -306,7 +370,7 @@ const DetailCell = function DetailCell(props) {
306
370
  };
307
371
  const styles = aphrodite.StyleSheet.create({
308
372
  subtitle: {
309
- color: wonderBlocksTokens.color.offBlack64
373
+ color: wonderBlocksTokens.semanticColor.text.secondary
310
374
  },
311
375
  innerWrapper: {
312
376
  padding: `${CellMeasurements.detailCellPadding.paddingVertical}px ${CellMeasurements.detailCellPadding.paddingHorizontal}px`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-cell",
3
- "version": "4.1.2",
3
+ "version": "4.1.3",
4
4
  "design": "v1",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -11,10 +11,10 @@
11
11
  "types": "dist/index.d.ts",
12
12
  "dependencies": {
13
13
  "@babel/runtime": "^7.24.5",
14
- "@khanacademy/wonder-blocks-clickable": "6.1.2",
14
+ "@khanacademy/wonder-blocks-clickable": "6.1.3",
15
15
  "@khanacademy/wonder-blocks-core": "12.2.0",
16
- "@khanacademy/wonder-blocks-layout": "3.1.2",
17
- "@khanacademy/wonder-blocks-tokens": "5.0.0",
16
+ "@khanacademy/wonder-blocks-layout": "3.1.3",
17
+ "@khanacademy/wonder-blocks-tokens": "5.1.0",
18
18
  "@khanacademy/wonder-blocks-typography": "3.1.2"
19
19
  },
20
20
  "peerDependencies": {