Skip to content

Commit

Permalink
refactor: replace TextFont struct initialization with from_font_size … (
Browse files Browse the repository at this point in the history
#323)

…method

- Use TextFont::from_font_size method to create TextFont instances in
Widgets implementation
- This change improves code readability for font size initialization
  • Loading branch information
ShenMian authored Jan 13, 2025
1 parent b97adac commit 28ce32e
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/theme/widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ impl<T: Spawn> Widgets for T {
(
Name::new("Button Text"),
Text(text.into()),
TextFont {
font_size: 40.0,
..default()
},
TextFont::from_font_size(40.0),
TextColor(BUTTON_TEXT),
),
);
Expand All @@ -71,10 +68,7 @@ impl<T: Spawn> Widgets for T {
(
Name::new("Header Text"),
Text(text.into()),
TextFont {
font_size: 40.0,
..default()
},
TextFont::from_font_size(40.0),
TextColor(HEADER_TEXT),
),
);
Expand All @@ -86,10 +80,7 @@ impl<T: Spawn> Widgets for T {
let entity = self.spawn((
Name::new("Label"),
Text(text.into()),
TextFont {
font_size: 24.0,
..default()
},
TextFont::from_font_size(24.0),
TextColor(LABEL_TEXT),
Node {
width: Px(500.0),
Expand Down

0 comments on commit 28ce32e

Please sign in to comment.