From 4b96cd76cc58b5d244c8fe4e476a2d374d928d6d Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Sat, 10 Aug 2024 23:54:22 +0200 Subject: [PATCH] Refactor label (#260) --- src/theme/widgets.rs | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/theme/widgets.rs b/src/theme/widgets.rs index 4e27c88..490277e 100644 --- a/src/theme/widgets.rs +++ b/src/theme/widgets.rs @@ -93,30 +93,21 @@ impl Widgets for T { } fn label(&mut self, text: impl Into) -> 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 } }