From 4c5ae65eb2de0bd9b96458001bc5e84b91ee2824 Mon Sep 17 00:00:00 2001 From: Peter Krull <31969909+peterkrull@users.noreply.github.com> Date: Mon, 5 Aug 2024 12:22:51 +0200 Subject: [PATCH] improv(toggle): Make handle and border radius concentric --- src/theme/style/iced.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/theme/style/iced.rs b/src/theme/style/iced.rs index 5591a05..6c79823 100644 --- a/src/theme/style/iced.rs +++ b/src/theme/style/iced.rs @@ -823,6 +823,7 @@ impl toggler::StyleSheet for Theme { fn active(&self, _style: &Self::Style, is_active: bool) -> toggler::Appearance { let theme = self.cosmic(); + const HANDLE_MARGIN: f32 = 2.0; toggler::Appearance { background: if is_active { theme.accent.base.into() @@ -833,8 +834,11 @@ impl toggler::StyleSheet for Theme { foreground: theme.palette.neutral_2.into(), foreground_border: None, border_radius: theme.radius_xl().into(), - handle_radius: theme.radius_xl().into(), - handle_margin: 2.0, + handle_radius: theme + .radius_xl() + .map(|x| (x - HANDLE_MARGIN).max(0.0)) + .into(), + handle_margin: HANDLE_MARGIN, } }