1+ use std:: fmt:: { Debug , Formatter } ;
2+
13use css:: {
24 optimize_multi_css_value:: { check_multi_css_optimize, optimize_mutli_css_value} ,
35 optimize_value:: optimize_value,
@@ -12,7 +14,14 @@ use crate::{
1214 utils:: { convert_value, gcd} ,
1315} ;
1416
15- #[ derive( Debug , PartialEq , Clone , Eq , Hash , Ord , PartialOrd ) ]
17+ #[ derive( Debug , PartialEq , Clone , Copy , Eq , Hash , Ord , PartialOrd , Default ) ]
18+ pub enum ThemeTokenResolution {
19+ #[ default]
20+ CssVariable ,
21+ FirstValue ,
22+ }
23+
24+ #[ derive( PartialEq , Clone , Eq , Hash , Ord , PartialOrd ) ]
1625pub struct ExtractStaticStyle {
1726 /// property
1827 pub property : String ,
@@ -26,6 +35,21 @@ pub struct ExtractStaticStyle {
2635 pub style_order : Option < u8 > ,
2736 /// CSS layer name (from vanilla-extract layer())
2837 pub layer : Option < String > ,
38+ /// How theme tokens should be resolved when converting to CSS.
39+ pub theme_token_resolution : ThemeTokenResolution ,
40+ }
41+
42+ impl Debug for ExtractStaticStyle {
43+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
44+ f. debug_struct ( "ExtractStaticStyle" )
45+ . field ( "property" , & self . property )
46+ . field ( "value" , & self . value )
47+ . field ( "level" , & self . level )
48+ . field ( "selector" , & self . selector )
49+ . field ( "style_order" , & self . style_order )
50+ . field ( "layer" , & self . layer )
51+ . finish ( )
52+ }
2953}
3054
3155impl ExtractStaticStyle {
@@ -55,6 +79,7 @@ impl ExtractStaticStyle {
5579 selector : selector. map ( optimize_selector) ,
5680 style_order : None ,
5781 layer : None ,
82+ theme_token_resolution : ThemeTokenResolution :: CssVariable ,
5883 }
5984 }
6085
@@ -88,9 +113,15 @@ impl ExtractStaticStyle {
88113 selector,
89114 style_order : Some ( 0 ) ,
90115 layer : None ,
116+ theme_token_resolution : ThemeTokenResolution :: CssVariable ,
91117 }
92118 }
93119
120+ pub fn with_theme_token_resolution ( mut self , resolution : ThemeTokenResolution ) -> Self {
121+ self . theme_token_resolution = resolution;
122+ self
123+ }
124+
94125 /// Get the layer name
95126 pub fn layer ( & self ) -> Option < & str > {
96127 self . layer . as_deref ( )
@@ -115,6 +146,10 @@ impl ExtractStaticStyle {
115146 pub fn style_order ( & self ) -> Option < u8 > {
116147 self . style_order
117148 }
149+
150+ pub fn theme_token_resolution ( & self ) -> ThemeTokenResolution {
151+ self . theme_token_resolution
152+ }
118153}
119154
120155impl ExtractStyleProperty for ExtractStaticStyle {
0 commit comments