Skip to content

Commit 69c12a0

Browse files
authored
Wonder Blocks: Updates WB Button instances to match new API (color -> actionType) (#2491)
## Summary: Integrates Khan/wonder-blocks#2594 in Perseus. Matches the recent WB release: https://khanacademy.slack.com/archives/C4PE1QM5Y/p1747321594567069 ### Wonder Blocks changes: #### Major changes: - `Button`: Renames color prop to actionType and changes default to progressive. - `Button`: Updates Button default theme to simplify its use and have more consistency with the IconButton styles. Also makes some changes to get this button closer to the design specs. - `IconButton`: removes the internal use of the Khanmigo theme (not used in Perseus). #### Perseus changes: - `Button`: Updates all instances of Button in Perseus to use actionType instead of color. Issue: "none" ## Test plan: Verify that all the checks pass and that the Button component works as expected in Perseus. Author: jandrade Reviewers: ivyolamit, catandthemachines, jeremywiebe Required Reviewers: Approved By: catandthemachines, ivyolamit, jeremywiebe Checks: ✅ 12 checks were successful, ⏹️ 1 check was cancelled Pull Request URL: #2491
1 parent 998d121 commit 69c12a0

File tree

18 files changed

+461
-381
lines changed

18 files changed

+461
-381
lines changed

.changeset/ten-lobsters-lie.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@khanacademy/perseus": patch
3+
"@khanacademy/perseus-editor": patch
4+
---
5+
6+
Updates WB Button instances to match new API (color -> actionType)

packages/perseus-editor/src/widgets/expression-editor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ class AnswerOption extends React.Component<
524524
<Button
525525
size="small"
526526
onClick={this.handleImSure}
527-
color="destructive"
527+
actionType="destructive"
528528
>
529529
I&apos;m sure!
530530
</Button>
@@ -541,7 +541,7 @@ class AnswerOption extends React.Component<
541541
<Button
542542
size="small"
543543
onClick={this.handleDelete}
544-
color="destructive"
544+
actionType="destructive"
545545
kind="tertiary"
546546
style={styles.deleteButton}
547547
>

packages/perseus-editor/src/widgets/free-response-editor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ const CriterionEditor = function (props: {
209209
<View style={styles.deleteButtonContainer}>
210210
<Button
211211
aria-label={`Delete criterion ${props.index + 1}`}
212-
color="destructive"
212+
actionType="destructive"
213213
disabled={!props.isDeletable}
214214
kind="tertiary"
215215
onClick={() => props.onDelete(props.index)}

packages/perseus/src/__tests__/__snapshots__/renderer.test.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ exports[`renderer snapshots correct answer: correct answer 1`] = `
364364
aria-haspopup="listbox"
365365
aria-invalid="false"
366366
aria-label="Test ARIA label"
367-
class="button_vr44p2-o_O-shared_4y4ff7-o_O-default_qr7vlu"
367+
class="button_vr44p2-o_O-shared_4y4ff7-o_O-default_bvghof"
368368
id=":r3:"
369369
role="combobox"
370370
type="button"
@@ -449,7 +449,7 @@ exports[`renderer snapshots incorrect answer: incorrect answer 1`] = `
449449
aria-haspopup="listbox"
450450
aria-invalid="false"
451451
aria-label="Test ARIA label"
452-
class="button_vr44p2-o_O-shared_4y4ff7-o_O-default_qr7vlu"
452+
class="button_vr44p2-o_O-shared_4y4ff7-o_O-default_bvghof"
453453
id=":r6:"
454454
role="combobox"
455455
type="button"
@@ -534,7 +534,7 @@ exports[`renderer snapshots initial render: initial render 1`] = `
534534
aria-haspopup="listbox"
535535
aria-invalid="false"
536536
aria-label="Test ARIA label"
537-
class="button_vr44p2-o_O-shared_4y4ff7-o_O-default_qr7vlu"
537+
class="button_vr44p2-o_O-shared_4y4ff7-o_O-default_bvghof"
538538
id=":r0:"
539539
role="combobox"
540540
type="button"

packages/perseus/src/__tests__/__snapshots__/server-item-renderer.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ exports[`server item renderer should snapshot: initial render 1`] = `
4646
aria-invalid="false"
4747
aria-label="Mock Widget"
4848
aria-required="false"
49-
class="input_a5n1n-o_O-LabelMedium_1voxh4u-o_O-default_1elaks2-o_O-defaultFocus_drkasj"
49+
class="input_a5n1n-o_O-LabelMedium_1voxh4u-o_O-default_1kavdzs-o_O-defaultFocus_drkasj"
5050
id="mock-widget 1"
5151
role="textbox"
5252
type="text"

packages/perseus/src/widgets/dropdown/__snapshots__/dropdown.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ exports[`Dropdown widget should snapshot when opened: dropdown open 1`] = `
2929
aria-haspopup="listbox"
3030
aria-invalid="false"
3131
aria-label="Select an answer"
32-
class="button_vr44p2-o_O-shared_4y4ff7-o_O-default_qr7vlu"
32+
class="button_vr44p2-o_O-shared_4y4ff7-o_O-default_bvghof"
3333
id=":r3:"
3434
role="combobox"
3535
type="button"
@@ -108,7 +108,7 @@ exports[`Dropdown widget should snapshot: initial render 1`] = `
108108
aria-haspopup="listbox"
109109
aria-invalid="false"
110110
aria-label="Select an answer"
111-
class="button_vr44p2-o_O-shared_4y4ff7-o_O-default_qr7vlu"
111+
class="button_vr44p2-o_O-shared_4y4ff7-o_O-default_bvghof"
112112
id=":r0:"
113113
role="combobox"
114114
type="button"

packages/perseus/src/widgets/explanation/__snapshots__/explanation.test.ts.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ exports[`Explanation should snapshot when expanded: expanded 1`] = `
2121
aria-controls=":r1:"
2222
aria-disabled="false"
2323
aria-expanded="true"
24-
class="button_vr44p2-o_O-shared_11fo0od-o_O-default_1t67lz5-o_O-small_1rcykji-o_O-inlineStyles_1s8anjv"
24+
class="button_vr44p2-o_O-reset_1ck4g21-o_O-shared_1v12k51-o_O-default_y5mm15-o_O-small_oliyv9-o_O-inlineStyles_1s8anjv"
2525
role="button"
2626
type="button"
2727
>
2828
<span
29-
class="text_f1191h-o_O-LabelSmall_b0rx6x-o_O-text_1s96g1x-o_O-smallText_9bce1o-o_O-textWithFocus_e296pg-o_O-inlineStyles_egvfd8"
29+
class="text_f1191h-o_O-LabelSmall_b0rx6x-o_O-text_1s96g1x-o_O-smallText_9bce1o-o_O-inlineStyles_egvfd8"
3030
>
3131
Hide explanation!
3232
</span>
3333
<div
34-
class="default_xu2jcg-o_O-iconWrapper_h4cn9t-o_O-endIconWrapper_l32m71-o_O-endIconWrapperTertiary_10fyztj"
34+
class="default_xu2jcg-o_O-iconWrapper_3ynivu-o_O-endIconWrapper_1mx094c-o_O-endIconWrapperTertiary_9p0zpt-o_O-iconWrapperHovered_3hmsj"
3535
>
3636
<span
3737
aria-hidden="true"
@@ -94,17 +94,17 @@ exports[`Explanation should snapshot: initial render 1`] = `
9494
aria-controls=":r0:"
9595
aria-disabled="false"
9696
aria-expanded="false"
97-
class="button_vr44p2-o_O-shared_11fo0od-o_O-default_1t67lz5-o_O-small_1rcykji-o_O-inlineStyles_1s8anjv"
97+
class="button_vr44p2-o_O-reset_1ck4g21-o_O-shared_1v12k51-o_O-default_y5mm15-o_O-small_oliyv9-o_O-inlineStyles_1s8anjv"
9898
role="button"
9999
type="button"
100100
>
101101
<span
102-
class="text_f1191h-o_O-LabelSmall_b0rx6x-o_O-text_1s96g1x-o_O-smallText_9bce1o-o_O-textWithFocus_e296pg-o_O-inlineStyles_egvfd8"
102+
class="text_f1191h-o_O-LabelSmall_b0rx6x-o_O-text_1s96g1x-o_O-smallText_9bce1o-o_O-inlineStyles_egvfd8"
103103
>
104104
Explanation
105105
</span>
106106
<div
107-
class="default_xu2jcg-o_O-iconWrapper_h4cn9t-o_O-endIconWrapper_l32m71-o_O-endIconWrapperTertiary_10fyztj"
107+
class="default_xu2jcg-o_O-iconWrapper_3ynivu-o_O-endIconWrapper_1mx094c-o_O-endIconWrapperTertiary_9p0zpt"
108108
>
109109
<span
110110
aria-hidden="true"

packages/perseus/src/widgets/free-response/__snapshots__/free-response.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ exports[`free-response widget should snapshot on mobile: first mobile render 1`]
5252
aria-describedby=""
5353
aria-invalid="false"
5454
aria-required="false"
55-
class="textarea_6p4mp0-o_O-LabelMedium_1voxh4u-o_O-default_1elaks2-o_O-defaultFocus_drkasj-o_O-textarea_1x0fg6n"
55+
class="textarea_6p4mp0-o_O-LabelMedium_1voxh4u-o_O-default_1kavdzs-o_O-defaultFocus_drkasj-o_O-textarea_1x0fg6n"
5656
id=":r2:-labeled-field-field"
5757
placeholder="test-placeholder"
5858
/>
@@ -134,7 +134,7 @@ exports[`free-response widget should snapshot: first render 1`] = `
134134
aria-describedby=""
135135
aria-invalid="false"
136136
aria-required="false"
137-
class="textarea_6p4mp0-o_O-LabelMedium_1voxh4u-o_O-default_1elaks2-o_O-defaultFocus_drkasj-o_O-textarea_1x0fg6n"
137+
class="textarea_6p4mp0-o_O-LabelMedium_1voxh4u-o_O-default_1kavdzs-o_O-defaultFocus_drkasj-o_O-textarea_1x0fg6n"
138138
id=":r0:-labeled-field-field"
139139
placeholder="test-placeholder"
140140
/>

packages/perseus/src/widgets/graded-group-set/__snapshots__/graded-group-set-jipt.test.ts.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ exports[`graded-group-set should render all graded groups 1`] = `
6666
autocapitalize="off"
6767
autocomplete="off"
6868
autocorrect="off"
69-
class="input_a5n1n-o_O-LabelMedium_1voxh4u-o_O-default_1elaks2-o_O-defaultFocus_drkasj-o_O-inputWithExamples_1y6ajxo"
69+
class="input_a5n1n-o_O-LabelMedium_1voxh4u-o_O-default_1kavdzs-o_O-defaultFocus_drkasj-o_O-inputWithExamples_1y6ajxo"
7070
data-testid="input-with-examples"
7171
id=":r0:"
7272
tabindex="0"
@@ -87,7 +87,7 @@ exports[`graded-group-set should render all graded groups 1`] = `
8787
/>
8888
<button
8989
aria-disabled="false"
90-
class="button_vr44p2-o_O-shared_11fo0od-o_O-default_hrw3a6"
90+
class="button_vr44p2-o_O-reset_1ck4g21-o_O-shared_1v12k51-o_O-default_1xd28xe"
9191
role="button"
9292
type="button"
9393
>
@@ -144,7 +144,7 @@ exports[`graded-group-set should render all graded groups 1`] = `
144144
autocapitalize="off"
145145
autocomplete="off"
146146
autocorrect="off"
147-
class="input_a5n1n-o_O-LabelMedium_1voxh4u-o_O-default_1elaks2-o_O-defaultFocus_drkasj-o_O-inputWithExamples_1y6ajxo"
147+
class="input_a5n1n-o_O-LabelMedium_1voxh4u-o_O-default_1kavdzs-o_O-defaultFocus_drkasj-o_O-inputWithExamples_1y6ajxo"
148148
data-testid="input-with-examples"
149149
id=":r3:"
150150
tabindex="0"
@@ -165,7 +165,7 @@ exports[`graded-group-set should render all graded groups 1`] = `
165165
/>
166166
<button
167167
aria-disabled="false"
168-
class="button_vr44p2-o_O-shared_11fo0od-o_O-default_hrw3a6"
168+
class="button_vr44p2-o_O-reset_1ck4g21-o_O-shared_1v12k51-o_O-default_1xd28xe"
169169
role="button"
170170
type="button"
171171
>
@@ -222,7 +222,7 @@ exports[`graded-group-set should render all graded groups 1`] = `
222222
autocapitalize="off"
223223
autocomplete="off"
224224
autocorrect="off"
225-
class="input_a5n1n-o_O-LabelMedium_1voxh4u-o_O-default_1elaks2-o_O-defaultFocus_drkasj-o_O-inputWithExamples_1y6ajxo"
225+
class="input_a5n1n-o_O-LabelMedium_1voxh4u-o_O-default_1kavdzs-o_O-defaultFocus_drkasj-o_O-inputWithExamples_1y6ajxo"
226226
data-testid="input-with-examples"
227227
id=":r6:"
228228
tabindex="0"
@@ -243,7 +243,7 @@ exports[`graded-group-set should render all graded groups 1`] = `
243243
/>
244244
<button
245245
aria-disabled="false"
246-
class="button_vr44p2-o_O-shared_11fo0od-o_O-default_hrw3a6"
246+
class="button_vr44p2-o_O-reset_1ck4g21-o_O-shared_1v12k51-o_O-default_1xd28xe"
247247
role="button"
248248
type="button"
249249
>

packages/perseus/src/widgets/graded-group-set/__snapshots__/graded-group-set.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ exports[`graded group widget should snapshot 1`] = `
132132
autocapitalize="off"
133133
autocomplete="off"
134134
autocorrect="off"
135-
class="input_a5n1n-o_O-LabelMedium_1voxh4u-o_O-default_1elaks2-o_O-defaultFocus_drkasj-o_O-inputWithExamples_1y6ajxo"
135+
class="input_a5n1n-o_O-LabelMedium_1voxh4u-o_O-default_1kavdzs-o_O-defaultFocus_drkasj-o_O-inputWithExamples_1y6ajxo"
136136
data-testid="input-with-examples"
137137
id=":r0:"
138138
tabindex="0"
@@ -153,7 +153,7 @@ exports[`graded group widget should snapshot 1`] = `
153153
/>
154154
<button
155155
aria-disabled="false"
156-
class="button_vr44p2-o_O-shared_11fo0od-o_O-default_hrw3a6"
156+
class="button_vr44p2-o_O-reset_1ck4g21-o_O-shared_1v12k51-o_O-default_1xd28xe"
157157
role="button"
158158
type="button"
159159
>

packages/perseus/src/widgets/graded-group/__snapshots__/graded-group.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ exports[`graded-group should snapshot: initial render (mobile: false) 1`] = `
408408
/>
409409
<button
410410
aria-disabled="false"
411-
class="button_vr44p2-o_O-shared_11fo0od-o_O-default_hrw3a6"
411+
class="button_vr44p2-o_O-reset_1ck4g21-o_O-shared_1v12k51-o_O-default_1xd28xe"
412412
role="button"
413413
type="button"
414414
>

packages/perseus/src/widgets/group/__snapshots__/group.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ exports[`group widget should snapshot: initial render 1`] = `
755755
autocapitalize="off"
756756
autocomplete="off"
757757
autocorrect="off"
758-
class="input_a5n1n-o_O-LabelMedium_1voxh4u-o_O-default_1elaks2-o_O-defaultFocus_drkasj-o_O-inputWithExamples_1y6ajxo"
758+
class="input_a5n1n-o_O-LabelMedium_1voxh4u-o_O-default_1kavdzs-o_O-defaultFocus_drkasj-o_O-inputWithExamples_1y6ajxo"
759759
data-testid="input-with-examples"
760760
id=":r0:"
761761
tabindex="0"
@@ -812,7 +812,7 @@ exports[`group widget should snapshot: initial render 1`] = `
812812
autocapitalize="off"
813813
autocomplete="off"
814814
autocorrect="off"
815-
class="input_a5n1n-o_O-LabelMedium_1voxh4u-o_O-default_1elaks2-o_O-defaultFocus_drkasj-o_O-inputWithExamples_1y6ajxo"
815+
class="input_a5n1n-o_O-LabelMedium_1voxh4u-o_O-default_1kavdzs-o_O-defaultFocus_drkasj-o_O-inputWithExamples_1y6ajxo"
816816
data-testid="input-with-examples"
817817
id=":r3:"
818818
tabindex="0"

packages/perseus/src/widgets/interactive-graphs/__snapshots__/interactive-graph.test.tsx.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,7 +2134,7 @@ exports[`Interactive Graph question Should render predictably: after interaction
21342134
>
21352135
<button
21362136
aria-disabled="false"
2137-
class="button_vr44p2-o_O-shared_11fo0od-o_O-default_yxotth-o_O-inlineStyles_16y2sco"
2137+
class="button_vr44p2-o_O-reset_1ck4g21-o_O-shared_1v12k51-o_O-default_1mug5fd-o_O-inlineStyles_16y2sco"
21382138
id="perseus_mafs_remove_button"
21392139
role="button"
21402140
tabindex="-1"
@@ -2400,7 +2400,7 @@ exports[`Interactive Graph question Should render predictably: after interaction
24002400
>
24012401
<button
24022402
aria-disabled="true"
2403-
class="button_vr44p2-o_O-shared_11fo0od-o_O-disabled_mqm918-o_O-default_yxotth-o_O-disabled_vmsefw-o_O-inlineStyles_1kc2paq"
2403+
class="button_vr44p2-o_O-reset_1ck4g21-o_O-shared_1v12k51-o_O-default_1mug5fd-o_O-disabled_5vgqwg-o_O-inlineStyles_1kc2paq"
24042404
id="perseus_mafs_remove_button"
24052405
role="button"
24062406
tabindex="-1"
@@ -2414,7 +2414,7 @@ exports[`Interactive Graph question Should render predictably: after interaction
24142414
</button>
24152415
<button
24162416
aria-disabled="true"
2417-
class="button_vr44p2-o_O-shared_11fo0od-o_O-disabled_mqm918-o_O-default_hrw3a6-o_O-disabled_ebci8n-o_O-inlineStyles_1kc2paq"
2417+
class="button_vr44p2-o_O-reset_1ck4g21-o_O-shared_1v12k51-o_O-default_1xd28xe-o_O-disabled_5vgqwg-o_O-inlineStyles_1kc2paq"
24182418
role="button"
24192419
tabindex="-1"
24202420
type="button"
@@ -3526,7 +3526,7 @@ exports[`Interactive Graph question Should render predictably: first render 3`]
35263526
>
35273527
<button
35283528
aria-disabled="false"
3529-
class="button_vr44p2-o_O-shared_11fo0od-o_O-default_yxotth-o_O-inlineStyles_16y2sco"
3529+
class="button_vr44p2-o_O-reset_1ck4g21-o_O-shared_1v12k51-o_O-default_1mug5fd-o_O-inlineStyles_16y2sco"
35303530
id="perseus_mafs_remove_button"
35313531
role="button"
35323532
tabindex="-1"
@@ -3792,7 +3792,7 @@ exports[`Interactive Graph question Should render predictably: first render 4`]
37923792
>
37933793
<button
37943794
aria-disabled="true"
3795-
class="button_vr44p2-o_O-shared_11fo0od-o_O-disabled_mqm918-o_O-default_yxotth-o_O-disabled_vmsefw-o_O-inlineStyles_1kc2paq"
3795+
class="button_vr44p2-o_O-reset_1ck4g21-o_O-shared_1v12k51-o_O-default_1mug5fd-o_O-disabled_5vgqwg-o_O-inlineStyles_1kc2paq"
37963796
id="perseus_mafs_remove_button"
37973797
role="button"
37983798
tabindex="-1"
@@ -3806,7 +3806,7 @@ exports[`Interactive Graph question Should render predictably: first render 4`]
38063806
</button>
38073807
<button
38083808
aria-disabled="true"
3809-
class="button_vr44p2-o_O-shared_11fo0od-o_O-disabled_mqm918-o_O-default_hrw3a6-o_O-disabled_ebci8n-o_O-inlineStyles_1kc2paq"
3809+
class="button_vr44p2-o_O-reset_1ck4g21-o_O-shared_1v12k51-o_O-default_1xd28xe-o_O-disabled_5vgqwg-o_O-inlineStyles_1kc2paq"
38103810
role="button"
38113811
tabindex="-1"
38123812
type="button"

packages/perseus/src/widgets/interactive-graphs/mafs-graph.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ const renderPointGraphControls = (props: {
427427
<Button
428428
id={REMOVE_BUTTON_ID}
429429
kind="secondary"
430-
color="destructive"
430+
actionType="destructive"
431431
// This button is meant to be interacted with by the mouse only
432432
// Never allow learners to tab to this button
433433
tabIndex={-1}
@@ -547,7 +547,7 @@ const renderPolygonGraphControls = (props: {
547547
<Button
548548
id={REMOVE_BUTTON_ID}
549549
kind="secondary"
550-
color="destructive"
550+
actionType="destructive"
551551
// Disable button when polygon is closed.
552552
disabled={closedPolygon || !shouldShowRemoveButton}
553553
// This button is meant to be interacted with by the mouse only

0 commit comments

Comments
 (0)