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(box): add typography tokens #1087

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 7 additions & 0 deletions .changeset/weak-walls-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@launchpad-ui/tokens': patch
'@launchpad-ui/box': patch
'@launchpad-ui/vars': patch
---

Add typography tokens to vars and box
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"@vanilla-extract/css": "^1.14.0",
"@vanilla-extract/vite-plugin": "^3.9.0",
"@vanilla-extract/vite-plugin": "^3.9.2",
"@vitejs/plugin-react-swc": "^3.5.0",
"@vitest/coverage-v8": "^1.0.0-beta.4",
"@vitest/ui": "^1.0.0-beta.4",
Expand Down
12 changes: 12 additions & 0 deletions packages/box/src/styles/rainbow-sprinkles.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { flatten } from 'flat';
import { defineProperties, createRainbowSprinkles } from 'rainbow-sprinkles';

const { bg, border, fill, shadow, text, gradient, ...global } = vars.color;
const { body, heading, small, label, code, display } = vars;
const typography = {
body,
heading,
small,
label,
code,
display,
};

type FlattenObjectKeys<T extends Record<string, unknown>, Key = keyof T> = Key extends string
? T[Key] extends Record<string, unknown>
Expand All @@ -16,13 +25,15 @@ type BackgroundKeys = FlattenObjectKeys<typeof bg>;
type BorderKeys = FlattenObjectKeys<typeof border>;
type FillKeys = FlattenObjectKeys<typeof fill>;
type TextKeys = FlattenObjectKeys<typeof text>;
type TypographyKeys = FlattenObjectKeys<typeof typography>;

const colors = flatten<typeof global, Record<GlobalKeys, string>>(global);
const gradients = flatten<typeof gradient, Record<GradientKeys, string>>(gradient);
const backgrounds = flatten<typeof bg, Record<BackgroundKeys, string>>(bg);
const borders = flatten<typeof border, Record<BorderKeys, string>>(border);
const fills = flatten<typeof fill, Record<FillKeys, string>>(fill);
const texts = flatten<typeof text, Record<TextKeys, string>>(text);
const typographies = flatten<typeof typography, Record<TypographyKeys, string>>(typography);

const responsiveProperties = defineProperties({
conditions: {
Expand Down Expand Up @@ -53,6 +64,7 @@ const responsiveProperties = defineProperties({
marginBottom: vars.spacing,
borderRadius: vars.border.radius,
borderWidth: vars.border.width,
font: typographies,
fontFamily: vars.font.family,
fontSize: vars.font.size,
fontWeight: vars.font.weight,
Expand Down
2 changes: 1 addition & 1 deletion packages/tokens/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const myStyleDictionary = StyleDictionary.extend({
},
json: {
buildPath: 'dist/',
transforms: ['attribute/cti', 'name/cti/kebab', 'value/path'],
transforms: ['attribute/cti', 'name/cti/kebab', 'font/css', 'value/path'],
files: [
{
format: 'json/nested',
Expand Down
41 changes: 34 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.