Skip to content

Commit

Permalink
Refactor label (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
janhohenheim committed Aug 10, 2024
1 parent cfc390d commit 4b96cd7
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions src/theme/widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,21 @@ impl<T: Spawn> Widgets for T {
}

fn label(&mut self, text: impl Into<String>) -> EntityCommands {
let mut entity = self.spawn((
let entity = self.spawn((
Name::new("Label"),
NodeBundle {
style: Style {
width: Px(500.0),
align_items: AlignItems::Center,
TextBundle::from_section(
text,
TextStyle {
font_size: 24.0,
color: LABEL_TEXT,
..default()
},
)
.with_style(Style {
width: Px(500.0),
..default()
},
}),
));
entity.with_children(|children| {
children.spawn((
Name::new("Label Text"),
TextBundle::from_section(
text,
TextStyle {
font_size: 24.0,
color: LABEL_TEXT,
..default()
},
),
));
});
entity
}
}
Expand Down

0 comments on commit 4b96cd7

Please sign in to comment.