🔧(demo) update demo app to ts config file, customize one token

Showcase a situation where we want to customize a component's design token.
This commit is contained in:
Nathan Vasse
2023-01-04 15:53:36 +01:00
committed by NathanVss
parent be1c9d000b
commit f48dac79c0
10 changed files with 31 additions and 19 deletions

View File

@@ -1,2 +1,3 @@
node_modules node_modules
dist dist
src/cunningham-tokens.ts

View File

@@ -4,9 +4,6 @@
"custom" "custom"
], ],
"parserOptions": { "parserOptions": {
"project": [ "project": "./tsconfig.eslint.json"
"./tsconfig.json",
"./tsconfig.node.json"
]
} }
} }

View File

@@ -1,7 +0,0 @@
module.exports = {
theme: {
colors: {
primary: 'purple'
},
},
};

12
apps/demo/cunningham.ts Normal file
View File

@@ -0,0 +1,12 @@
export default {
theme: {
colors: {
primary: "purple",
},
},
components: {
button: {
"border-radius": "30px",
},
},
};

View File

@@ -5,7 +5,7 @@
"type": "module", "type": "module",
"scripts": { "scripts": {
"lint": "eslint . 'src/**/*.{ts,tsx}'", "lint": "eslint . 'src/**/*.{ts,tsx}'",
"dev": "vite", "dev": "vite & nodemon --watch cunningham.ts --exec yarn build-theme",
"build-theme": "cunningham -o src -g css,ts", "build-theme": "cunningham -o src -g css,ts",
"build": "tsc && vite build", "build": "tsc && vite build",
"preview": "vite preview" "preview": "vite preview"

View File

@@ -1,4 +1,6 @@
:root { :root {
--c--colors--primary: purple; --c--theme--colors--primary: purple;
--c--colors--secondary: #DA0000; --c--theme--colors--primary-gradient: linear-gradient(90deg,#002d7f,#0069b3);
--c--theme--colors--secondary: #DA0000;
--c--components--button--border-radius: 30px;
} }

View File

@@ -1 +1 @@
export const tokens = {"colors":{"primary":"purple","secondary":"#DA0000"}}; export const tokens = {"theme":{"colors":{"primary":"purple","primary-gradient":"linear-gradient(90deg,#002d7f,#0069b3)","secondary":"#DA0000"}},"components":{"button":{"border-radius":"30px"}}};

View File

@@ -6,7 +6,6 @@
font-size: 16px; font-size: 16px;
line-height: 24px; line-height: 24px;
font-weight: 400; font-weight: 400;
color: var(--c--colors--primary);
background-color: #242424; background-color: #242424;
height: 100vh; height: 100vh;
display: flex; display: flex;

View File

@@ -8,8 +8,8 @@ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode> <React.StrictMode>
<div className="center"> <div className="center">
<h1 className="test">Cunningham Demo.</h1> <h1 className="test">Cunningham Demo.</h1>
<Button /> <Button>World best button.</Button>
<h3>Primary color is {tokens.colors.primary}</h3> <h3>Primary color is {tokens.theme.colors.primary}</h3>
</div> </div>
</React.StrictMode> </React.StrictMode>
); );

View File

@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"exclude": [],
"include": [
"**/*.ts",
"**/*.tsx"
]
}