histoire-dev / histoire-dev/histoire
Can't use CSS var with theme colors
- Dominant language
- TypeScript
- Stars
- 3.6k
- Forks
- 212
- PR merge metrics
- No merged PRs in 30d
Description
Maybe we should be able to add CSS vars support for theming?
example:
```ts
theme: {
colors: {
gray: {
100: "var(--color-background-0)",
200: "hsl(200, 35%, 25%)",
/* ... */
}
}
}
```
For now, we get this:
```
14:23:15 [vite] Internal server error: Cannot read properties of null (reading 'color')
at Context.load (file:///D:/Library/Projects/LunaPark/node_modules/.pnpm/histoire@0.3.0_rwdbogf7wrm2jtre4wogxlia4e/node_modules/histoire/dist/node/vite.js:136:117)
at Object.load (D:\Library\Projects\LunaPark\node_modules\.pnpm\vite@2.9.6_sass@1.51.0\node_modules\vite\dist\node\chunks\dep-3397b401.js:38793:50)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async doTransform (D:\Library\Projects\LunaPark\node_modules\.pnpm\vite@2.9.6_sass@1.51.0\node_modules\vite\dist\node\chunks\dep-3397b401.js:55688:24)
```
Probably linked to the `parseColor` function call.
And the HSL color simply does not work since the frontend still use a rgb function on hsl percentages.
Contributor guide
Research direction
The issue points to the parseColor call in the frontend; start there and reproduce the theme using var(--color-background-0) and an HSL value. Done means CSS variable and HSL theme colors no longer trigger the reported error or an incompatible RGB conversion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, typescript, vite
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100