@@ -58,33 +58,37 @@ pub enum HeadingLevel {
5858 H3 ,
5959 Subheading ,
6060}
61+
6162/// Does appropriate sizing, weighting and colouring for a given heading level
6263pub fn heading < ' a > (
6364 level : HeadingLevel ,
6465 text : String ,
6566 font : Option < iced:: Font > ,
6667) -> widget:: Text < ' a > {
68+ use HeadingLevel as HL ;
69+
6770 let mut font = font. unwrap_or ( iced:: Font :: DEFAULT ) ;
6871
6972 let font_mult = match level {
70- HeadingLevel :: H1 => 2.0 ,
71- HeadingLevel :: H2 => 1.5 ,
72- HeadingLevel :: H3 => 1.0 ,
73- HeadingLevel :: Subheading => 0.7 ,
73+ HL :: H1 => 2.0 ,
74+ HL :: H2 => 1.5 ,
75+ HL :: H3 => 1.0 ,
76+ HL :: Subheading => 0.7 ,
7477 } ;
7578
7679 font. weight = match level {
77- HeadingLevel :: H1 | HeadingLevel :: H2 => iced:: font:: Weight :: Bold ,
80+ HL :: H1 | HL :: H2 => iced:: font:: Weight :: Bold ,
7881 _ => iced:: font:: Weight :: Normal ,
7982 } ;
8083
8184 widget:: text ( text)
8285 . size ( iced:: Settings :: default ( ) . default_text_size * font_mult)
8386 . style ( move |_theme : & iced:: Theme | {
8487 let c = match level {
85- HeadingLevel :: Subheading => Some ( iced:: color!( 140 , 140 , 150 ) ) ,
88+ HL :: Subheading => Some ( iced:: color!( 140 , 140 , 150 ) ) ,
8689 _ => None ,
8790 } ;
8891 widget:: text:: Style { color : c }
8992 } )
93+ . font ( font)
9094}
0 commit comments