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

feat(tokens): add text color #741

Merged
merged 2 commits into from
May 10, 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
3 changes: 3 additions & 0 deletions packages/tokens/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ export type {
SkinTonePalette,
SkinToneNestedPalettes,
} from './skin-tone';

export { textColor } from './text-color';
export type { TextColorToken, TextColorPalette } from './text-color';
110 changes: 110 additions & 0 deletions packages/tokens/src/text-color.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import type { Meta, StoryObj } from '@storybook/react';
import * as textColor from './text-color';

const meta: Meta = {
title: 'Text color',
};

export default meta;

type Story = StoryObj;

export const Heading: Story = {
render: () => (
<span style={{ color: textColor.heading }}>
Empower learners everywhere
</span>
),
name: 'heading',
};

export const Body: Story = {
render: () => (
<span style={{ color: textColor.body }}>Empower learners everywhere</span>
),
name: 'body',
};

export const Disabled: Story = {
render: () => (
<span style={{ color: textColor.disabled }}>
Empower learners everywhere
</span>
),
name: 'disabled',
};

export const Icon: Story = {
render: () => (
<span style={{ color: textColor.icon }}>Empower learners everywhere</span>
),
name: 'icon',
};

export const SecondaryIcon: Story = {
render: () => (
<span style={{ color: textColor.secondaryIcon }}>
Empower learners everywhere
</span>
),
name: 'secondaryIcon',
};

export const InverseHeading: Story = {
render: () => (
<span style={{ color: textColor.inverseHeading }}>
Empower learners everywhere
</span>
),
name: 'inverseHeading',
};

export const InverseBody: Story = {
render: () => (
<span style={{ color: textColor.inverseBody }}>
Empower learners everywhere
</span>
),
name: 'inverseBody',
};

export const InverseDisabled: Story = {
render: () => (
<span style={{ color: textColor.inverseDisabled }}>
Empower learners everywhere
</span>
),
name: 'inverseDisabled',
};

export const InverseIcon: Story = {
render: () => (
<span style={{ color: textColor.inverseIcon }}>
Empower learners everywhere
</span>
),
name: 'inverseIcon',
};

export const InverseSecondaryIcon: Story = {
render: () => (
<span style={{ color: textColor.inverseSecondaryIcon }}>
Empower learners everywhere
</span>
),
name: 'inverseSecondaryIcon',
};

export const TextColor: Story = {
render: () => (
<div>
{Object.entries(textColor.textColor).map(([name, value]) => (
<div key={name} style={{ marginTop: 8 }}>
<div>{name}</div>
<span style={{ color: value }}>Empower learners everywhere</span>
</div>
))}
</div>
),
name: 'textColor (palette)',
};
37 changes: 37 additions & 0 deletions packages/tokens/src/text-color.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import * as color from './color';
import type { ColorToken } from './color';

/** An alias token for a CSS color property value. */
export type TextColorToken = ColorToken;

export const heading = color.N600 satisfies TextColorToken;
export const body = color.N500 satisfies TextColorToken;
export const subdued = color.N400 satisfies TextColorToken;
export const disabled = color.N100 satisfies TextColorToken;
export const icon = color.N500 satisfies TextColorToken;
export const secondaryIcon = color.N300 satisfies TextColorToken;

export const inverseHeading = color.N0 satisfies TextColorToken;
export const inverseBody = color.N60 satisfies TextColorToken;
export const inverseSubdued = color.N70 satisfies TextColorToken;
export const inverseDisabled = color.N90 satisfies TextColorToken;
export const inverseIcon = color.N60 satisfies TextColorToken;
export const inverseSecondaryIcon = color.N80 satisfies TextColorToken;

/** A palette of text color tokens. */
export type TextColorPalette = Record<string, TextColorToken>;

export const textColor = {
heading,
body,
subdued,
disabled,
icon,
secondaryIcon,
inverseHeading,
inverseBody,
inverseSubdued,
inverseDisabled,
inverseIcon,
inverseSecondaryIcon,
} as const satisfies TextColorPalette;