Skip to content

Commit 72f1804

Browse files
committed
feat: Add design tokens
1 parent 921fdec commit 72f1804

25 files changed

Lines changed: 3233 additions & 517 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
node_modules
22
_site
3+
src/css/tokens.css
4+
src/_data/tokens.js
5+
src/_data/tokens.d.ts

eleventy.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@ import { eleventyImageTransformPlugin } from "@11ty/eleventy-img";
55
import site from "./src/_data/site.js";
66

77
export default async function (eleventyConfig) {
8+
eleventyConfig.addShortcode("getToken", function (tokenId, mode) {
9+
const { resolver } = this.ctx.environments.tokens;
10+
11+
const tokenSet = resolver.apply(mode ? { mode } : {});
12+
const token = tokenSet?.[tokenId];
13+
14+
if (!token) {
15+
console.warn(`Token not found: ${tokenId}`);
16+
return "";
17+
}
18+
19+
if (token.$type === "color") {
20+
return `oklch(${token.$value.components.join(" ")})`;
21+
}
22+
23+
return token.$value;
24+
});
25+
826
eleventyConfig.setFrontMatterParsingOptions({
927
excerpt: true,
1028
excerpt_separator: "---",

package-lock.json

Lines changed: 2744 additions & 425 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"version": "1.0.0",
44
"description": "My personal blog",
55
"scripts": {
6-
"start": "eleventy --serve",
7-
"build": "eleventy",
6+
"start": "tz build --watch & eleventy --serve",
7+
"build": "tz build && eleventy",
88
"new:post": "node scripts/new-post.js"
99
},
1010
"author": "Robert Rhoades",
@@ -13,7 +13,10 @@
1313
"@11ty/eleventy": "^3.1.5",
1414
"@11ty/eleventy-img": "^6.0.4",
1515
"@11ty/eleventy-plugin-rss": "^3.0.0",
16-
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.2"
16+
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.2",
17+
"@terrazzo/cli": "^2.1.0",
18+
"@terrazzo/plugin-css": "^2.1.0",
19+
"@terrazzo/plugin-js": "^2.1.0"
1720
},
1821
"devDependencies": {
1922
"@shopify/prettier-plugin-liquid": "^1.10.2",

src/_includes/meta.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
<meta name="description" content="{{ site.description }}">
77
<meta property="og:description" content="{{ site.description }}">
88
{% endif %}
9-
<meta name="theme-color" content="#359567">
9+
10+
<meta name="theme-color" content="{% getToken 'color.bg.accent' %}">
1011

1112
<meta property="og:site_name" content="{{ site.title }}">
1213
{% if title %}

src/css/index.11ty.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as sass from "sass";
22
import path from "path";
3+
import fs from "node:fs/promises";
34

45
export default class {
56
async data() {
@@ -21,7 +22,13 @@ export default class {
2122

2223
async render({ entryFile }) {
2324
try {
24-
return await this.compileSass(entryFile);
25+
// Read the tokens.css
26+
const tokensPath = path.join(import.meta.dirname, "tokens.css");
27+
const tokensCss = await fs.readFile(tokensPath, "utf-8");
28+
29+
const sassCss = await this.compileSass(entryFile);
30+
31+
return tokensCss + "\n" + sassCss;
2532
} catch (error) {
2633
throw error;
2734
}

src/scss/base.body.scss

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,21 @@ html {
44
}
55

66
body {
7-
background: rgb(248, 246, 241);
8-
// background: $colour-grey;
9-
color: $colour-space-grey;
10-
font-family: $font-family;
7+
background: var(--color-bg-page);
8+
color: var(--color-text-primary);
9+
font-family: var(--font-family);
1110
font-optical-sizing: auto;
1211
font-size: var(--step-0);
13-
line-height: $line-height;
12+
line-height: var(--font-line-height);
1413
font-optical-sizing: auto;
1514
// font-variation-settings: "wdth" 100;
1615
margin: 0 auto;
17-
max-width: $container-width;
16+
max-width: var(--size-container);
1817
text-rendering: optimizeLegibility;
1918
word-wrap: break-word;
2019

2120
&::before {
22-
background: $colour-green;
21+
background: var(--color-bg-accent);
2322
content: "";
2423
height: 12.5rem;
2524
left: 0;
@@ -31,7 +30,7 @@ body {
3130
}
3231

3332
::selection {
34-
background: $colour-grey;
35-
color: $colour-space-grey-dark;
33+
background: var(--color-bg-page);
34+
color: var(--color-text-heading);
3635
text-shadow: none;
3736
}

src/scss/base.heading.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ h4,
55
h5 {
66
text-wrap: balance;
77
line-height: 1.15;
8-
margin-top: 3rem;
9-
margin-bottom: 1rem;
8+
margin-top: var(--spacing-xl);
9+
margin-bottom: var(--spacing-md);
1010
word-break: break-word;
1111
hyphens: auto;
1212
}

src/scss/base.link.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
a {
2-
color: $colour-space-grey-dark;
2+
color: var(--color-text-heading);
33
text-decoration: none;
44

55
&:hover,
66
&:focus {
7-
color: $colour-space-grey-light;
7+
color: var(--color-text-secondary);
88
}
99
}

src/scss/base.quotation.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
blockquote {
2-
border-left: 3px solid $colour-space-grey-light;
3-
padding-left: 1rem;
2+
border-left: 3px solid var(--color-border-subtle);
3+
padding-left: var(--spacing-md);
44

55
cite {
6-
color: $colour-space-grey-light;
6+
color: var(--color-text-secondary);
77
}
88
}

0 commit comments

Comments
 (0)