diff --git a/.changeset/blue-cows-clap.md b/.changeset/blue-cows-clap.md
new file mode 100644
index 000000000..e841bb18f
--- /dev/null
+++ b/.changeset/blue-cows-clap.md
@@ -0,0 +1,5 @@
+---
+"@khanacademy/wonder-blocks-switch": patch
+---
+
+Add PhosphorIcon support to `Switch`
diff --git a/__docs__/wonder-blocks-switch/switch.argtypes.tsx b/__docs__/wonder-blocks-switch/switch.argtypes.tsx
index 3dc26caa0..29f54d91d 100644
--- a/__docs__/wonder-blocks-switch/switch.argtypes.tsx
+++ b/__docs__/wonder-blocks-switch/switch.argtypes.tsx
@@ -67,7 +67,7 @@ export default {
mapping: iconsMap,
table: {
type: {
- summary: "Icon",
+ summary: "PhosphorIcon",
},
},
},
diff --git a/__docs__/wonder-blocks-switch/switch.stories.tsx b/__docs__/wonder-blocks-switch/switch.stories.tsx
index 8a0dd3c7b..82890be69 100644
--- a/__docs__/wonder-blocks-switch/switch.stories.tsx
+++ b/__docs__/wonder-blocks-switch/switch.stories.tsx
@@ -3,10 +3,11 @@ import type {Meta, StoryObj} from "@storybook/react";
import {StyleSheet} from "aphrodite";
import {expect} from "@storybook/jest";
import {userEvent, within} from "@storybook/testing-library";
+import magnifyingGlassIcon from "@phosphor-icons/core/bold/magnifying-glass-bold.svg";
import Switch from "@khanacademy/wonder-blocks-switch";
import {PropsFor, View} from "@khanacademy/wonder-blocks-core";
-import Icon, {icons} from "@khanacademy/wonder-blocks-icon";
+import {PhosphorIcon} from "@khanacademy/wonder-blocks-icon";
import {ThemeSwitcherContext, tokens} from "@khanacademy/wonder-blocks-theming";
import {LabelMedium} from "@khanacademy/wonder-blocks-typography";
@@ -94,7 +95,7 @@ export const Controlled: StoryComponentType = () => {
aria-label="test switch"
checked={checkedTwo}
onChange={setCheckedTwo}
- icon={}
+ icon={}
/>
);
@@ -136,27 +137,34 @@ export const Disabled: StoryComponentType = {
}
+ icon={}
/>
}
+ icon={}
/>
),
};
/**
- * The switch can take an `Icon` element which will be rendered inside the slider.
+ * The switch can take a `PhosphorIcon` element which will be rendered inside
+ * the slider.
*/
export const WithIcon: StoryComponentType = {
render: () => {
return (
- } />
-
- } />
+ }
+ />
+
+ }
+ />
);
},
@@ -186,21 +194,21 @@ export const KhanmigoTheme = () => {
}
+ icon={}
/>
}
+ icon={}
/>
}
+ icon={}
/>
}
+ icon={}
/>
diff --git a/packages/wonder-blocks-switch/src/components/__tests__/switch.test.tsx b/packages/wonder-blocks-switch/src/components/__tests__/switch.test.tsx
index e411c4450..ad3175e62 100644
--- a/packages/wonder-blocks-switch/src/components/__tests__/switch.test.tsx
+++ b/packages/wonder-blocks-switch/src/components/__tests__/switch.test.tsx
@@ -2,8 +2,9 @@ import * as React from "react";
import {render, screen} from "@testing-library/react";
import userEvent from "@testing-library/user-event";
-import Icon, {icons} from "@khanacademy/wonder-blocks-icon";
+import {PhosphorIcon} from "@khanacademy/wonder-blocks-icon";
import {RenderStateRoot} from "@khanacademy/wonder-blocks-core";
+import magnifyingGlassIcon from "@phosphor-icons/core/bold/magnifying-glass-bold.svg";
import Switch from "../switch";
describe("Switch", () => {
@@ -114,7 +115,12 @@ describe("Switch", () => {
}
+ icon={
+
+ }
/>
,
);
diff --git a/packages/wonder-blocks-switch/src/components/switch.tsx b/packages/wonder-blocks-switch/src/components/switch.tsx
index c5e5d7f53..2ad36405f 100644
--- a/packages/wonder-blocks-switch/src/components/switch.tsx
+++ b/packages/wonder-blocks-switch/src/components/switch.tsx
@@ -7,7 +7,7 @@ import {
addStyle,
useUniqueIdWithMock,
} from "@khanacademy/wonder-blocks-core";
-import Icon from "@khanacademy/wonder-blocks-icon";
+import {PhosphorIcon} from "@khanacademy/wonder-blocks-icon";
import {
ThemedStylesFn,
useScopedTheme,
@@ -33,7 +33,7 @@ type Props = Pick<
/**
* Optional icon to display on the slider.
*/
- icon?: React.ReactElement;
+ icon?: React.ReactElement>;
/**
* The unique identifier for the switch.
*/
@@ -90,13 +90,15 @@ const SwitchCore = React.forwardRef(function SwitchCore(
themeName,
);
- let styledIcon: React.ReactElement | undefined;
+ let styledIcon:
+ | React.ReactElement>
+ | undefined;
if (icon) {
styledIcon = React.cloneElement(icon, {
size: "small",
style: [sharedStyles.icon, stateStyles.icon],
"aria-hidden": true,
- } as Partial>);
+ } as Partial>);
}
return (