From 999f3d81946b7c0e30853931dc7e89cbf30cf83d Mon Sep 17 00:00:00 2001 From: Juan Andrade Date: Wed, 5 Jun 2024 13:37:02 -0400 Subject: [PATCH] Add panda support to Button (including theming) --- .changeset/spotty-rivers-admire.md | 5 + .../wonder-blocks-button/button.stories.tsx | 86 ++--- .../src/components/button-core.tsx | 328 +++++++++--------- .../src/themes/default.ts | 160 +++++---- .../src/themes/khanmigo.ts | 89 ++--- .../wonder-blocks-button/src/themes/theme.ts | 129 +++++++ .../src/themes/themed-button.tsx | 24 +- .../src/components/text.tsx | 19 +- panda.config.ts | 12 + 9 files changed, 495 insertions(+), 357 deletions(-) create mode 100644 .changeset/spotty-rivers-admire.md create mode 100644 packages/wonder-blocks-button/src/themes/theme.ts diff --git a/.changeset/spotty-rivers-admire.md b/.changeset/spotty-rivers-admire.md new file mode 100644 index 000000000..668a0cf9c --- /dev/null +++ b/.changeset/spotty-rivers-admire.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/wonder-blocks-button": major +--- + +Add panda support to Button (including theming) diff --git a/__docs__/wonder-blocks-button/button.stories.tsx b/__docs__/wonder-blocks-button/button.stories.tsx index 227f9a435..b8c9db025 100644 --- a/__docs__/wonder-blocks-button/button.stories.tsx +++ b/__docs__/wonder-blocks-button/button.stories.tsx @@ -1,11 +1,11 @@ import * as React from "react"; -import {StyleSheet} from "aphrodite"; +// import {StyleSheet} from "aphrodite"; import type {Meta, StoryObj} from "@storybook/react"; import {expect, fireEvent, userEvent, within} from "@storybook/test"; import {MemoryRouter, Route, Switch} from "react-router-dom"; -import type {StyleDeclaration} from "aphrodite"; +// import type {StyleDeclaration} from "aphrodite"; import pencilSimple from "@phosphor-icons/core/regular/pencil-simple.svg"; import pencilSimpleBold from "@phosphor-icons/core/bold/pencil-simple-bold.svg"; @@ -26,6 +26,8 @@ import ComponentInfo from "../../.storybook/components/component-info"; import ButtonArgTypes from "./button.argtypes"; import {ThemeSwitcherContext} from "@khanacademy/wonder-blocks-theming"; +import {SystemStyleObject} from "@/styled-system/types"; +import {css} from "@/styled-system/css"; /** * Reusable button component. @@ -132,35 +134,35 @@ export const Tertiary: StoryComponentType = { }, }; -export const styles: StyleDeclaration = StyleSheet.create({ - row: { +export const styles: Record = { + row: css.raw({ flexDirection: "row", alignItems: "center", - marginBottom: spacing.xSmall_8, - }, - button: { - marginRight: spacing.xSmall_8, - }, - truncatedButton: { + marginBottom: "xSmall_8", + }), + button: css.raw({ + marginRight: "xSmall_8", + }), + truncatedButton: css.raw({ maxWidth: 200, - marginBottom: spacing.medium_16, - }, - fillSpace: { + marginBottom: "medium_16", + }), + fillSpace: css.raw({ minWidth: 140, - }, - example: { - background: color.offWhite, - padding: spacing.medium_16, - }, - label: { - marginTop: spacing.large_24, - marginBottom: spacing.xSmall_8, - }, -}); + }), + example: css.raw({ + background: "offWhite", + padding: "medium_16", + }), + label: css.raw({ + marginTop: "large_24", + marginBottom: "xSmall_8", + }), +}; export const Variants: StoryComponentType = () => ( - - + + - + @@ -180,7 +182,7 @@ export const Variants: StoryComponentType = () => ( Hello, world! - + @@ -247,26 +249,28 @@ WithColor.parameters = { }; export const Dark: StoryComponentType = () => ( - - + + - - - - + - - - - + - -