From 885bd2aeb0f27ff25e3f28d0ce0fd5bee61f60ec Mon Sep 17 00:00:00 2001 From: demenik Date: Fri, 28 Nov 2025 13:04:56 +0100 Subject: [PATCH] fix: Center UI button content --- src/features/savegame/ui/load.rs | 4 ---- src/features/start_screen/mod.rs | 6 ------ src/features/ui/ui/button.rs | 10 ++++++++-- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/features/savegame/ui/load.rs b/src/features/savegame/ui/load.rs index 651ebe1..4478064 100644 --- a/src/features/savegame/ui/load.rs +++ b/src/features/savegame/ui/load.rs @@ -51,8 +51,6 @@ pub fn spawn_load_popup(commands: &mut Commands) { Node { width: px(40), height: px(40), - justify_content: JustifyContent::Center, - align_items: AlignItems::Center, ..default() }, "X", @@ -127,8 +125,6 @@ pub fn spawn_load_popup(commands: &mut Commands) { Node { width: px(40), height: px(40), - justify_content: JustifyContent::Center, - align_items: AlignItems::Center, ..default() }, "X", diff --git a/src/features/start_screen/mod.rs b/src/features/start_screen/mod.rs index 1ccbb20..4ad0a06 100644 --- a/src/features/start_screen/mod.rs +++ b/src/features/start_screen/mod.rs @@ -37,8 +37,6 @@ fn setup(mut commands: Commands) { ButtonVariant::Primary, Node { width: px(280), - justify_content: JustifyContent::Center, - align_items: AlignItems::Center, padding: UiRect::all(px(10)), ..default() }, @@ -50,8 +48,6 @@ fn setup(mut commands: Commands) { ButtonVariant::Primary, Node { width: px(280), - justify_content: JustifyContent::Center, - align_items: AlignItems::Center, padding: UiRect::all(px(10)), ..default() }, @@ -63,8 +59,6 @@ fn setup(mut commands: Commands) { ButtonVariant::Secondary, Node { width: px(280), - justify_content: JustifyContent::Center, - align_items: AlignItems::Center, padding: UiRect::all(px(10)), ..default() }, diff --git a/src/features/ui/ui/button.rs b/src/features/ui/ui/button.rs index 40655a4..b4cb220 100644 --- a/src/features/ui/ui/button.rs +++ b/src/features/ui/ui/button.rs @@ -3,10 +3,13 @@ use crate::prelude::*; pub fn button( button_type: impl Component, variant: ButtonVariant, - node: Node, + mut node: Node, title: impl Into, font_size: f32, ) -> impl Bundle { + node.justify_content = JustifyContent::Center; + node.align_items = AlignItems::Center; + ( Button, button_type, @@ -25,10 +28,13 @@ pub fn button( pub fn pill_button( button_type: impl Component, variant: ButtonVariant, - node: Node, + mut node: Node, title: impl Into, font_size: f32, ) -> impl Bundle { + node.justify_content = JustifyContent::Center; + node.align_items = AlignItems::Center; + ( Button, button_type,