Skip to content

Commit c1f420a

Browse files
authored
[WB-1814.5] Refactor IconButton to use semantic colors (#2449)
## Summary: Next step is to refactor the `IconButton` component to use semantic colors. Besides the migration, this PR also includes the following changes: - Reworked the theme structure to make it closer to the semanticColor structure. - Moved all the color-related CSS properties to a separate function (`getStylesByKind`). - Added `border` to all the states to prepare the work for Polaris as these icon buttons will look similar to the Button ones. ### Implementation plan: 1. #2439 2. #2440 3. #2441 4. #2446 5. IconButton (current PR) 6. Clickable, Link 7. Modal 8. Popover, Tooltip 9. Pill, Toolbar Issue: WB-1814 ## Test plan: Verify that the Chromatic snapshots are unchanged. URL: `/?path=/story/packages-iconbutton-all-variants--default` Author: jandrade Reviewers: jandrade, marcysutton, beaesguerra Required Reviewers: Approved By: marcysutton, beaesguerra Checks: ✅ Chromatic - Get results on regular PRs (ubuntu-latest, 20.x), ✅ Test / Test (ubuntu-latest, 20.x, 2/2), ✅ Test / Test (ubuntu-latest, 20.x, 1/2), ✅ Lint / Lint (ubuntu-latest, 20.x), ✅ Check build sizes (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Chromatic - Build and test on regular PRs / chromatic (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ⏭️ Chromatic - Skip on Release PR (changesets), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ✅ gerald, ⏭️ dependabot Pull Request URL: #2449
1 parent 7057fa7 commit c1f420a

File tree

8 files changed

+329
-763
lines changed

8 files changed

+329
-763
lines changed

.changeset/sixty-jars-guess.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@khanacademy/wonder-blocks-icon-button": patch
3+
---
4+
5+
Migrate to semanticColor tokens

__docs__/wonder-blocks-icon-button/icon-button-variants.stories.tsx

+13-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {Meta, StoryObj} from "@storybook/react";
66
import paperPlaneIcon from "@phosphor-icons/core/fill/paper-plane-tilt-fill.svg";
77
import {View} from "@khanacademy/wonder-blocks-core";
88
import {ThemeSwitcherContext} from "@khanacademy/wonder-blocks-theming";
9-
import {color, spacing} from "@khanacademy/wonder-blocks-tokens";
9+
import {semanticColor, spacing} from "@khanacademy/wonder-blocks-tokens";
1010
import {HeadingLarge, LabelMedium} from "@khanacademy/wonder-blocks-typography";
1111
import IconButton from "@khanacademy/wonder-blocks-icon-button";
1212

@@ -16,11 +16,7 @@ import IconButton from "@khanacademy/wonder-blocks-icon-button";
1616
*/
1717
export default {
1818
title: "Packages / IconButton / All Variants",
19-
parameters: {
20-
docs: {
21-
autodocs: false,
22-
},
23-
},
19+
tags: ["!autodocs"],
2420
} as Meta;
2521

2622
type StoryComponentType = StoryObj<typeof IconButton>;
@@ -52,7 +48,9 @@ const KindVariants = ({
5248
: styles.darkDefault),
5349
]}
5450
>
55-
<LabelMedium style={light && {color: color.white}}>
51+
<LabelMedium
52+
style={light && {color: semanticColor.text.inverse}}
53+
>
5654
{kind}-default
5755
</LabelMedium>
5856
<View style={[styles.iconButtons]}>
@@ -79,7 +77,9 @@ const KindVariants = ({
7977
: styles.darkDefault),
8078
]}
8179
>
82-
<LabelMedium style={light && {color: color.white}}>
80+
<LabelMedium
81+
style={light && {color: semanticColor.text.inverse}}
82+
>
8383
{kind}-destructive
8484
</LabelMedium>
8585
<View style={[styles.iconButtons]}>
@@ -106,7 +106,9 @@ const KindVariants = ({
106106
: styles.darkDefault),
107107
]}
108108
>
109-
<LabelMedium style={light && {color: color.white}}>
109+
<LabelMedium
110+
style={light && {color: semanticColor.text.inverse}}
111+
>
110112
{kind}-disabled
111113
</LabelMedium>
112114
<View style={[styles.iconButtons]}>
@@ -178,10 +180,10 @@ export const Active: StoryComponentType = {
178180

179181
const styles = StyleSheet.create({
180182
darkDefault: {
181-
backgroundColor: color.darkBlue,
183+
backgroundColor: semanticColor.surface.inverse,
182184
},
183185
darkKhanmigo: {
184-
backgroundColor: color.eggplant,
186+
backgroundColor: semanticColor.khanmigo.primary,
185187
},
186188
grid: {
187189
display: "grid",

__docs__/wonder-blocks-icon-button/icon-button.stories.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {MemoryRouter, Route, Switch} from "react-router";
1616
import {View} from "@khanacademy/wonder-blocks-core";
1717
import {LabelMedium} from "@khanacademy/wonder-blocks-typography";
1818
import IconButton from "@khanacademy/wonder-blocks-icon-button";
19-
import {color, spacing} from "@khanacademy/wonder-blocks-tokens";
19+
import {semanticColor, spacing} from "@khanacademy/wonder-blocks-tokens";
2020

2121
import ComponentInfo from "../components/component-info";
2222
import packageConfig from "../../packages/wonder-blocks-icon-button/package.json";
@@ -397,7 +397,7 @@ export const SubmittingForms: StoryComponentType = {
397397

398398
const styles = StyleSheet.create({
399399
dark: {
400-
backgroundColor: color.darkBlue,
400+
backgroundColor: semanticColor.surface.inverse,
401401
padding: spacing.medium_16,
402402
},
403403
arrowsWrapper: {

0 commit comments

Comments
 (0)