Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WB-1641.2: Move tokens.ts to wb-tokens package #2170

Merged
merged 8 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/blue-vans-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/wonder-blocks-theming": major
---

Move tokens export to wb-tokens
5 changes: 5 additions & 0 deletions .changeset/perfect-meals-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/wonder-blocks-tokens": minor
---

Move tokens from wb-theming to wb-tokens and split token categories into separate objects/files
11 changes: 11 additions & 0 deletions .changeset/slimy-socks-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@khanacademy/wonder-blocks-icon-button": patch
"@khanacademy/wonder-blocks-accordion": patch
"@khanacademy/wonder-blocks-dropdown": patch
"@khanacademy/wonder-blocks-button": patch
"@khanacademy/wonder-blocks-switch": patch
"@khanacademy/wonder-blocks-modal": patch
"@khanacademy/wonder-blocks-pill": patch
---

Replace theming.tokens with wb-tokens and update callsites to use the new export
8 changes: 4 additions & 4 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from "react";

Check warning on line 1 in .storybook/preview.tsx

View workflow job for this annotation

GitHub Actions / Lint (ubuntu-latest, 20.x)

File ignored by default.
import wonderBlocksTheme from "./wonder-blocks-theme";
import {configure} from "@storybook/testing-library";

import {tokens} from "@khanacademy/wonder-blocks-theming";
import {color} from "@khanacademy/wonder-blocks-tokens";
import Link from "@khanacademy/wonder-blocks-link";
import {ThemeSwitcherContext} from "@khanacademy/wonder-blocks-theming";
import {RenderStateRoot} from "../packages/wonder-blocks-core/src";
Expand Down Expand Up @@ -55,15 +55,15 @@
values: [
{
name: "light",
value: tokens.color.white,
value: color.white,
},
{
name: "darkBlue",
value: tokens.color.darkBlue,
value: color.darkBlue,
},
{
name: "khanmigo",
value: tokens.color.eggplant,
value: color.eggplant,
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion __docs__/components/gallery/component-tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import externalLinkIcon from "@phosphor-icons/core/bold/arrow-square-out-bold.sv
import Clickable from "@khanacademy/wonder-blocks-clickable";
import {View} from "@khanacademy/wonder-blocks-core";
import {PhosphorIcon} from "@khanacademy/wonder-blocks-icon";
import {tokens} from "@khanacademy/wonder-blocks-theming";
import * as tokens from "@khanacademy/wonder-blocks-tokens";
import {Body, HeadingMedium} from "@khanacademy/wonder-blocks-typography";

type Props = {
Expand Down
4 changes: 2 additions & 2 deletions __docs__/components/gallery/sections/button-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";
import {StyleSheet} from "aphrodite";

import Button from "@khanacademy/wonder-blocks-button";
import {tokens} from "@khanacademy/wonder-blocks-theming";
import {spacing} from "@khanacademy/wonder-blocks-tokens";
import {HeadingLarge} from "@khanacademy/wonder-blocks-typography";

import ComponentTile from "../component-tile";
Expand Down Expand Up @@ -43,6 +43,6 @@ export default function BannerSection() {

const localStyles = StyleSheet.create({
button: {
marginBottom: tokens.spacing.small_12,
marginBottom: spacing.small_12,
},
});
2 changes: 1 addition & 1 deletion __docs__/components/gallery/sections/cell-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {StyleSheet} from "aphrodite";
import {CompactCell, DetailCell} from "@khanacademy/wonder-blocks-cell";
import {View} from "@khanacademy/wonder-blocks-core";
import {PhosphorIcon} from "@khanacademy/wonder-blocks-icon";
import {tokens} from "@khanacademy/wonder-blocks-theming";
import * as tokens from "@khanacademy/wonder-blocks-tokens";
import {HeadingLarge} from "@khanacademy/wonder-blocks-typography";
import {IconMappings} from "../../../wonder-blocks-icon/phosphor-icon.argtypes";

Expand Down
4 changes: 2 additions & 2 deletions __docs__/components/gallery/sections/icon-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import magnifyingGlass from "@phosphor-icons/core/regular/magnifying-glass.svg";
import magnifyingGlassBold from "@phosphor-icons/core/bold/magnifying-glass-bold.svg";
import {View} from "@khanacademy/wonder-blocks-core";
import {PhosphorIcon} from "@khanacademy/wonder-blocks-icon";
import {tokens} from "@khanacademy/wonder-blocks-theming";
import {spacing} from "@khanacademy/wonder-blocks-tokens";
import {HeadingLarge} from "@khanacademy/wonder-blocks-typography";

import ComponentTile from "../component-tile";
Expand Down Expand Up @@ -59,6 +59,6 @@ const localStyles = StyleSheet.create({
alignItems: "end",
},
icon: {
marginRight: tokens.spacing.medium_16,
marginRight: spacing.medium_16,
},
});
4 changes: 2 additions & 2 deletions __docs__/components/gallery/sections/pill-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {StyleSheet} from "aphrodite";

import {View} from "@khanacademy/wonder-blocks-core";
import Pill from "@khanacademy/wonder-blocks-pill";
import {tokens} from "@khanacademy/wonder-blocks-theming";
import {spacing} from "@khanacademy/wonder-blocks-tokens";
import {HeadingLarge} from "@khanacademy/wonder-blocks-typography";

import ComponentTile from "../component-tile";
Expand Down Expand Up @@ -66,7 +66,7 @@ const localStyles = StyleSheet.create({
display: "grid",
gridTemplateColumns: "repeat(2, 1fr)",
gridTemplateRows: "repeat(2, 1fr)",
columnGap: tokens.spacing.large_24,
columnGap: spacing.large_24,
width: "fit-content",
},
});
6 changes: 3 additions & 3 deletions __docs__/components/gallery/styles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {StyleSheet} from "aphrodite";

import {tokens} from "@khanacademy/wonder-blocks-theming";
import {spacing} from "@khanacademy/wonder-blocks-tokens";

export const styles = StyleSheet.create({
section: {
Expand All @@ -9,8 +9,8 @@ export const styles = StyleSheet.create({
flexWrap: "wrap",
},
sectionLabel: {
marginTop: tokens.spacing.xLarge_32,
marginBottom: tokens.spacing.large_24,
marginTop: spacing.xLarge_32,
marginBottom: spacing.large_24,
},
centerContent: {
width: "fit-content",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {DetailCell} from "@khanacademy/wonder-blocks-cell";
import {View} from "@khanacademy/wonder-blocks-core";
import {PhosphorIcon} from "@khanacademy/wonder-blocks-icon";
import {Strut} from "@khanacademy/wonder-blocks-layout";
import {tokens} from "@khanacademy/wonder-blocks-theming";
import * as tokens from "@khanacademy/wonder-blocks-tokens";
import {HeadingSmall, LabelLarge} from "@khanacademy/wonder-blocks-typography";

import ComponentInfo from "../../.storybook/components/component-info";
Expand Down
2 changes: 1 addition & 1 deletion __docs__/wonder-blocks-accordion/accordion.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import Button from "@khanacademy/wonder-blocks-button";
import {View} from "@khanacademy/wonder-blocks-core";
import {Strut} from "@khanacademy/wonder-blocks-layout";
import {tokens} from "@khanacademy/wonder-blocks-theming";
import * as tokens from "@khanacademy/wonder-blocks-tokens";
import {LabelLarge} from "@khanacademy/wonder-blocks-typography";
import {
MultiSelect,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import type {Meta, StoryObj} from "@storybook/react";
import paperPlaneIcon from "@phosphor-icons/core/fill/paper-plane-tilt-fill.svg";
import {View} from "@khanacademy/wonder-blocks-core";
import Spacing from "@khanacademy/wonder-blocks-spacing";
import {ThemeSwitcherContext, tokens} from "@khanacademy/wonder-blocks-theming";
import {ThemeSwitcherContext} from "@khanacademy/wonder-blocks-theming";
import * as tokens from "@khanacademy/wonder-blocks-tokens";
import {HeadingLarge, LabelMedium} from "@khanacademy/wonder-blocks-typography";
import IconButton from "@khanacademy/wonder-blocks-icon-button";

Expand Down
4 changes: 2 additions & 2 deletions __docs__/wonder-blocks-icon-button/icon-button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {View} from "@khanacademy/wonder-blocks-core";
import {LabelMedium} from "@khanacademy/wonder-blocks-typography";
import Spacing from "@khanacademy/wonder-blocks-spacing";
import IconButton from "@khanacademy/wonder-blocks-icon-button";
import {tokens} from "@khanacademy/wonder-blocks-theming";
import {color} from "@khanacademy/wonder-blocks-tokens";

import ComponentInfo from "../../.storybook/components/component-info";
import packageConfig from "../../packages/wonder-blocks-icon-button/package.json";
Expand Down Expand Up @@ -346,7 +346,7 @@ export const WithRouter: StoryComponentType = {

const styles = StyleSheet.create({
dark: {
backgroundColor: tokens.color.darkBlue,
backgroundColor: color.darkBlue,
padding: Spacing.medium_16,
},
arrowsWrapper: {
Expand Down
6 changes: 3 additions & 3 deletions __docs__/wonder-blocks-icon/phosphor-icon.argtypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import playCircle from "@phosphor-icons/core/regular/play-circle.svg";
import playCircleBold from "@phosphor-icons/core/bold/play-circle-bold.svg";
import gear from "@phosphor-icons/core/regular/gear.svg";

import {tokens} from "@khanacademy/wonder-blocks-theming";
import {color} from "@khanacademy/wonder-blocks-tokens";

/**
* Some pre-defined icon examples to use in our stories.
Expand Down Expand Up @@ -127,8 +127,8 @@ export default {
color: {
description:
"The color of the icon. Will default to `currentColor`, which means that it will take on the CSS `color` value from the parent element.",
options: Object.keys(tokens.color),
mapping: tokens.color,
options: Object.keys(color),
mapping: color,
control: {
type: "select",
},
Expand Down
2 changes: 1 addition & 1 deletion __docs__/wonder-blocks-icon/phosphor-icon.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
LabelMedium,
} from "@khanacademy/wonder-blocks-typography";
import {PhosphorIcon} from "@khanacademy/wonder-blocks-icon";
import {tokens} from "@khanacademy/wonder-blocks-theming";
import * as tokens from "@khanacademy/wonder-blocks-tokens";

import ComponentInfo from "../../.storybook/components/component-info";
import packageConfig from "../../packages/wonder-blocks-icon/package.json";
Expand Down
5 changes: 3 additions & 2 deletions __docs__/wonder-blocks-modal/modal-dialog.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {View} from "@khanacademy/wonder-blocks-core";
import {Strut} from "@khanacademy/wonder-blocks-layout";
import Spacing from "@khanacademy/wonder-blocks-spacing";
import {Body, Title} from "@khanacademy/wonder-blocks-typography";
import {ThemeSwitcherContext, tokens} from "@khanacademy/wonder-blocks-theming";
import {ThemeSwitcherContext} from "@khanacademy/wonder-blocks-theming";
import {spacing} from "@khanacademy/wonder-blocks-tokens";

import {
ModalLauncher,
Expand Down Expand Up @@ -279,7 +280,7 @@ export const WithDarkPanel: StoryComponentType = {
/>
<View
style={{
marginTop: tokens.spacing.medium_16,
marginTop: spacing.medium_16,
}}
>
<Title id="modal-title-0">
Expand Down
2 changes: 1 addition & 1 deletion __docs__/wonder-blocks-pill/pill.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {View} from "@khanacademy/wonder-blocks-core";
import Link from "@khanacademy/wonder-blocks-link";
import Pill from "@khanacademy/wonder-blocks-pill";
import {Strut} from "@khanacademy/wonder-blocks-layout";
import {tokens} from "@khanacademy/wonder-blocks-theming";
import * as tokens from "@khanacademy/wonder-blocks-tokens";
import {
Body,
BodySerif,
Expand Down
3 changes: 2 additions & 1 deletion __docs__/wonder-blocks-switch/switch.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import magnifyingGlassIcon from "@phosphor-icons/core/bold/magnifying-glass-bold
import Switch from "@khanacademy/wonder-blocks-switch";
import {PropsFor, View} from "@khanacademy/wonder-blocks-core";
import {PhosphorIcon} from "@khanacademy/wonder-blocks-icon";
import {ThemeSwitcherContext, tokens} from "@khanacademy/wonder-blocks-theming";
import {ThemeSwitcherContext} from "@khanacademy/wonder-blocks-theming";
import * as tokens from "@khanacademy/wonder-blocks-tokens";
import {LabelMedium} from "@khanacademy/wonder-blocks-typography";

import packageConfig from "../../packages/wonder-blocks-switch/package.json";
Expand Down
2 changes: 1 addition & 1 deletion __docs__/wonder-blocks-theming/adding-a-theme.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ component folder (under `themes`).

```ts
// e.g. wonder-blocks-button/src/themes/default.js
import {tokens} from "@khanacademy/wonder-blocks-theming";
import * as tokens from "@khanacademy/wonder-blocks-tokens";

export default {
color: {
Expand Down
3 changes: 2 additions & 1 deletion __docs__/wonder-blocks-theming/merge-theme.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {Meta, Canvas} from "@storybook/blocks";

import Banner from "@khanacademy/wonder-blocks-banner";
import {tokens, mergeTheme} from "@khanacademy/wonder-blocks-theming";
import {mergeTheme} from "@khanacademy/wonder-blocks-theming";
import * as tokens from "@khanacademy/wonder-blocks-tokens";

import {ButtonWithCustomTheme} from "./theme-examples";

Expand Down
2 changes: 1 addition & 1 deletion __docs__/wonder-blocks-theming/theme-examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {View} from "@khanacademy/wonder-blocks-core";
import {
createThemeContext,
mergeTheme,
tokens,
useScopedTheme,
useStyles,
ThemedStylesFn,
Expand All @@ -15,6 +14,7 @@ import {
WithThemeProps,
SupportedThemes,
} from "@khanacademy/wonder-blocks-theming";
import * as tokens from "@khanacademy/wonder-blocks-tokens";

const defaultTheme = {
color: {
Expand Down
5 changes: 3 additions & 2 deletions __docs__/wonder-blocks-theming/use-scoped-theme.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Meta, Canvas} from "@storybook/blocks";

import {tokens, useScopedTheme} from "@khanacademy/wonder-blocks-theming";
import {useScopedTheme} from "@khanacademy/wonder-blocks-theming";
import * as tokens from "@khanacademy/wonder-blocks-tokens";

import {ViewWithTheme} from "./theme-examples";

Expand Down Expand Up @@ -31,9 +32,9 @@ The `useScopedTheme` hook returns a `ScopedTheme` object with the following prop
```tsx
import {
createThemeContext,
tokens,
useScopedTheme,
} from "@khanacademy/wonder-blocks-theming";
import * as tokens from "@khanacademy/wonder-blocks-tokens";

// 👉 1. Define the theme.
const defaultTheme = {
Expand Down
4 changes: 2 additions & 2 deletions __docs__/wonder-blocks-theming/use-styles.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {Meta, Canvas} from "@storybook/blocks";

import {
tokens,
useScopedTheme,
useStyles,
} from "@khanacademy/wonder-blocks-theming";
import * as tokens from "@khanacademy/wonder-blocks-tokens";

import {UseStylesExample} from "./theme-examples";

Expand All @@ -30,8 +30,8 @@ import {
createThemeContext
useScopedTheme,
useStyles,
tokens,
} from "@khanacademy/wonder-blocks-theming";
import * as tokens from "@khanacademy/wonder-blocks-tokens";

// 👉 1. Define the theme.
const defaultTheme = {
Expand Down
6 changes: 4 additions & 2 deletions __docs__/wonder-blocks-theming/with-scoped-theme.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Meta, Canvas} from "@storybook/blocks";

import {tokens, useScopedTheme} from "@khanacademy/wonder-blocks-theming";
import {useScopedTheme} from "@khanacademy/wonder-blocks-theming";
import * as tokens from "@khanacademy/wonder-blocks-tokens";

import {WithScopedThemeExample} from "./theme-examples";

Expand All @@ -26,7 +27,8 @@ function withScopedTheme<T>(

```tsx
import {StyleSheet} from "aphrodite";
import {withScopedTheme, ThemedStylesFn, tokens} from "@khanacademy/wonder-blocks-theming";
import {withScopedTheme, ThemedStylesFn} from "@khanacademy/wonder-blocks-theming";
import * as tokens from "@khanacademy/wonder-blocks-tokens";

// 👉 1. Define the theme.
const defaultTheme = {
Expand Down
26 changes: 26 additions & 0 deletions __docs__/wonder-blocks-tokens/__overview__.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {Meta, Source} from "@storybook/blocks";

import TokenTable from "../../.storybook/components/token-table";

import Banner from "@khanacademy/wonder-blocks-banner";
import {View} from "@khanacademy/wonder-blocks-core";
import * as tokens from "@khanacademy/wonder-blocks-tokens";

<Meta title="Tokens" />

# Wonder Blocks Tokens

Wonder Blocks uses a set of tokens to define the look and feel of our
components. These tokens are defined in the `@khanacademy/wonder-blocks-tokens`
package.

Design tokens are a set of key-value pairs that define the visual and behavioral
design attributes of our components. They are the primitives that define the
building blocks of our design system.

These represent the design decisions at Khan Academy, such as:

- <a href="../?path=/docs/tokens-border--docs">Border</a>
- <a href="../?path=/docs/tokens-color--docs">Color</a>
- <a href="../?path=/docs/tokens-spacing--docs">Spacing</a>
- <a href="../?path=/docs/tokens-typography--docs">Typography</a>
Loading
Loading