1- use crate :: StyleSelector :: { Dual , Postfix , Prefix } ;
1+ use crate :: StyleSelector :: { Dual , Media , Postfix , Prefix } ;
22use once_cell:: sync:: Lazy ;
33use regex:: Regex ;
44use serde:: { Deserialize , Serialize } ;
@@ -22,6 +22,7 @@ static SELECTOR_ORDER_MAP: Lazy<HashMap<String, u8>> = Lazy::new(|| {
2222pub enum StyleSelector {
2323 Postfix ( String ) ,
2424 Prefix ( String ) ,
25+ Media ( String ) ,
2526 Dual ( String , String ) ,
2627}
2728
@@ -34,6 +35,9 @@ impl PartialOrd for StyleSelector {
3435impl Ord for StyleSelector {
3536 fn cmp ( & self , other : & Self ) -> Ordering {
3637 match ( self , other) {
38+ ( Media ( a) , Media ( b) ) => a. cmp ( b) ,
39+ ( Media ( _) , _) => Ordering :: Less ,
40+ ( _, Media ( _) ) => Ordering :: Greater ,
3741 ( Postfix ( a) , Postfix ( b) ) => SELECTOR_ORDER_MAP
3842 . get ( a)
3943 . unwrap_or ( & 0 )
@@ -56,6 +60,8 @@ impl Ord for StyleSelector {
5660
5761impl From < & str > for StyleSelector {
5862 fn from ( value : & str ) -> Self {
63+ println ! ( "value: {}" , value) ;
64+ println ! ( "value: {}" , value == "print" ) ;
5965 if let Some ( s) = value. strip_prefix ( "group" ) {
6066 Dual ( "*[role=group]" . to_string ( ) , to_kebab_case ( s) )
6167 } else if let Some ( s) = value. strip_prefix ( "theme" ) {
@@ -65,6 +71,8 @@ impl From<&str> for StyleSelector {
6571 s. chars( ) . next( ) . unwrap( ) . to_ascii_lowercase( ) ,
6672 & s[ 1 ..]
6773 ) )
74+ } else if value == "print" {
75+ Media ( "print" . to_string ( ) )
6876 } else {
6977 Postfix ( to_kebab_case ( value) )
7078 }
@@ -80,6 +88,7 @@ impl Display for StyleSelector {
8088 Postfix ( value) => format!( "-{}" , value) ,
8189 Prefix ( value) => format!( "-{}-" , value) ,
8290 Dual ( prefix, postfix) => format!( "-{}-{}" , prefix, postfix) ,
91+ Media ( value) => format!( "@{}" , value) ,
8392 }
8493 )
8594 }
@@ -97,6 +106,7 @@ pub fn merge_selector(class_name: &str, selector: Option<&StyleSelector>) -> Str
97106 SelectorSeparator :: Single => format ! ( "{}:{} .{}" , prefix, postfix, class_name) ,
98107 SelectorSeparator :: Double => format ! ( "{}::{} .{}" , prefix, postfix, class_name) ,
99108 } ,
109+ Media ( _) => format ! ( ".{}" , class_name) ,
100110 }
101111 } else {
102112 format ! ( ".{}" , class_name)
@@ -203,6 +213,22 @@ static GLOBAL_STYLE_PROPERTY: Lazy<HashMap<&str, PropertyType>> = Lazy::new(|| {
203213 ( "px" , [ "padding-left" , "padding-right" ] ) ,
204214 ( "py" , [ "padding-top" , "padding-bottom" ] ) ,
205215 ( "boxSize" , [ "width" , "height" ] ) ,
216+ (
217+ "borderBottomRadius" ,
218+ [ "border-bottom-left-radius" , "border-bottom-right-radius" ] ,
219+ ) ,
220+ (
221+ "borderTopRadius" ,
222+ [ "border-top-left-radius" , "border-top-right-radius" ] ,
223+ ) ,
224+ (
225+ "borderLeftRadius" ,
226+ [ "border-top-left-radius" , "border-bottom-left-radius" ] ,
227+ ) ,
228+ (
229+ "borderRightRadius" ,
230+ [ "border-top-right-radius" , "border-bottom-right-radius" ] ,
231+ ) ,
206232 ] {
207233 map. insert ( key, value. into ( ) ) ;
208234 }
@@ -266,7 +292,7 @@ pub fn convert_property(property: &str) -> PropertyType {
266292 . unwrap_or_else ( || to_kebab_case ( property) . into ( ) )
267293}
268294
269- pub fn sort_to_long ( property : & str ) -> String {
295+ pub fn short_to_long ( property : & str ) -> String {
270296 GLOBAL_STYLE_PROPERTY
271297 . get ( property)
272298 . map ( |v| match v {
0 commit comments