@@ -3,8 +3,23 @@ import { themeColors } from "@/colors/getPreconfigColors";
33import { uiColorFormat } from "@/types" ;
44import type { Theme } from "@unocss/preset-uno" ;
55
6- export const getUiTheme = ( colorMode : uiColorFormat , colorPrefix ?: string ) => {
7- const colors = themeColors ( colorMode , colorPrefix ) ;
6+ const getWhite = ( format : uiColorFormat ) : string => {
7+ const formats = {
8+ rgb : 'rgb(255,255,255, <alpha-value>)' ,
9+ hex : '' ,
10+ oklch : 'oklch(1 0 0)' ,
11+ hsl : 'hsl(0 0% 100%)'
12+ } ;
13+ return formats [ format as keyof typeof formats ] ?? '#ffffff' ;
14+ } ;
15+
16+ export const getUiTheme = ( colorMode : uiColorFormat , colorPrefix ?: string , defineColor ?: boolean ) => {
17+ const colors = defineColor ?
18+ {
19+ dark : getBrice ( colorMode , "gray-950" , colorPrefix ) ,
20+ white : getWhite ( colorMode ) ,
21+ ...themeColors ( colorMode , colorPrefix )
22+ } : { } ;
823 const theme : Theme = {
924 colors : {
1025 bg : {
@@ -13,15 +28,15 @@ export const getUiTheme = (colorMode: uiColorFormat, colorPrefix?: string) => {
1328 subtle : getBrice ( colorMode , "bg-subtle" , "none" ) ,
1429 muted : getBrice ( colorMode , "bg-muted" , "none" ) ,
1530 'surface-elevated' : getBrice ( colorMode , "bg-surface-elevated" , "none" ) ,
16- input :getBrice ( colorMode , "bg-input" , "none" ) ,
17- 'input-gray' :getBrice ( colorMode , "bg-input-gray" , "none" ) ,
31+ input : getBrice ( colorMode , "bg-input" , "none" ) ,
32+ 'input-gray' : getBrice ( colorMode , "bg-input-gray" , "none" ) ,
1833 } ,
1934 fg : {
2035 DEFAULT : getBrice ( colorMode , "fg" , "none" ) ,
2136 title : getBrice ( colorMode , "fg-title" , "none" ) ,
2237 subtitle : getBrice ( colorMode , "fg-subtitle" , "none" ) ,
2338 muted : getBrice ( colorMode , "fg-muted" , "none" ) ,
24- input :getBrice ( colorMode , "fg-input" , "none" ) ,
39+ input : getBrice ( colorMode , "fg-input" , "none" ) ,
2540 } ,
2641 border : {
2742 DEFAULT : getBrice ( colorMode , "border" , "none" ) ,
@@ -31,21 +46,18 @@ export const getUiTheme = (colorMode: uiColorFormat, colorPrefix?: string) => {
3146 emphasis : getBrice ( colorMode , "border-emphasis" , "none" ) ,
3247 input : getBrice ( colorMode , "border-input" , "none" ) ,
3348 } ,
34- card :{
49+ card : {
3550 DEFAULT : getBrice ( colorMode , "card" , "none" ) ,
3651 elevated : getBrice ( colorMode , "card-elevated" , "none" ) ,
3752 surface : getBrice ( colorMode , "card-surface" , "none" ) ,
3853 gray : getBrice ( colorMode , "card-gray" , "none" ) ,
3954 } ,
40- popover :{
55+ popover : {
4156 DEFAULT : getBrice ( colorMode , "popover" , "none" ) ,
4257 surface : getBrice ( colorMode , "popover-surface" , "none" ) ,
4358 elevated : getBrice ( colorMode , "popover-elevated" , "none" ) ,
4459 gray : getBrice ( colorMode , "popover-gray" , "none" ) ,
4560 } ,
46-
47- dark : getBrice ( colorMode , "gray-950" , colorPrefix ) ,
48- white : getBrice ( colorMode , "white" , colorPrefix ) ,
4961 ...colors
5062 }
5163 } ;
0 commit comments