@@ -18,14 +18,18 @@ import LCARSMarkdown from './components/LCARSMarkdown.vue'
1818import type { ConfigItem } from './ConfigItem'
1919import { ref } from 'vue'
2020import LCARSSample from './components/LCARSSample.vue'
21+ import LCARSThemeSample from './components/LCARSThemeSample.vue'
2122import StateValueTable from './components/StateValueTable.vue'
23+ import themeConfig from '@/assets/themes/themes.yaml?raw'
24+ import YAML from 'yaml'
2225
2326export interface HAConfig {
2427 type : string
2528 vars : Record < string , string >
2629 // eslint-disable-next-line @typescript-eslint/no-explicit-any
2730 mixins : Record < string , any >
2831 children : ConfigItem [ ]
32+ theme ?: string
2933}
3034
3135// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -46,6 +50,7 @@ registerComponent('panel-all', PanelAll)
4650registerComponent ( 'table' , LCARSTable )
4751registerComponent ( 'md' , LCARSMarkdown )
4852registerComponent ( 'sample' , LCARSSample )
53+ registerComponent ( 'theme-sample' , LCARSThemeSample )
4954registerComponent ( 'state-color' , StateColor )
5055registerComponent ( 'state-value' , StateValue )
5156registerComponent ( 'state-value-table' , StateValueTable )
@@ -72,6 +77,15 @@ export function loadVariables(haConfig: HAConfig) {
7277 }
7378}
7479
80+ export function loadTheme ( theme : string ) {
81+ const themes = YAML . parse ( themeConfig )
82+ const colors = themes [ theme ]
83+ for ( let i = 0 ; i < 10 ; i ++ ) {
84+ const index = i % colors . length
85+ setVariable ( `lcars-color-${ i + 1 } ` , `var(--lcars-color-${ colors [ index ] as string } )` )
86+ }
87+ }
88+
7589export function loadMixins ( haConfig : HAConfig ) {
7690 if ( haConfig ?. mixins ) {
7791 mixins . value = haConfig . mixins
0 commit comments