From d69d4cda45f7b166ed7f6295155d2da5fc4688b7 Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Sun, 3 Mar 2024 20:40:14 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor=20code=20with=20l?= =?UTF-8?q?ast=20API=20improvements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/pagetop-bootsier/src/lib.rs | 145 ++++++------------ .../pagetop-bootsier/static/css/styles.css | 4 +- packages/pagetop-bulmix/src/lib.rs | 118 +++++--------- 3 files changed, 85 insertions(+), 182 deletions(-) diff --git a/packages/pagetop-bootsier/src/lib.rs b/packages/pagetop-bootsier/src/lib.rs index 24b01c34..ceb1abd0 100644 --- a/packages/pagetop-bootsier/src/lib.rs +++ b/packages/pagetop-bootsier/src/lib.rs @@ -32,6 +32,14 @@ impl ThemeTrait for Bootsier { ] } + #[rustfmt::skip] + fn builtin_classes(&self, builtin: ThemeBuiltInClasses) -> Option<&str> { + match builtin { + ThemeBuiltInClasses::RegionContainer => Some("container"), + _ => None, + } + } + fn prepare_body(&self, page: &mut Page) -> Markup { match page.template() { "admin" => html! { @@ -79,120 +87,45 @@ impl ThemeTrait for Bootsier { )); } + #[rustfmt::skip] fn before_prepare_component(&self, component: &mut dyn ComponentTrait, _cx: &mut Context) { match component.type_id() { t if t == TypeId::of::() => { if let Some(i) = component_as_mut::(component) { - match i.font_size() { - FontSize::ExtraLarge => { - i.replace_classes(i.font_size().to_string(), "fs-1"); - } - FontSize::XxLarge => { - i.replace_classes(i.font_size().to_string(), "fs-2"); - } - FontSize::XLarge => { - i.replace_classes(i.font_size().to_string(), "fs-3"); - } - FontSize::Large => { - i.replace_classes(i.font_size().to_string(), "fs-4"); - } - FontSize::Medium => { - i.replace_classes(i.font_size().to_string(), "fs-5"); - } - _ => {} - }; + i.replace_classes(i.font_size().to_string(), with_font(i.font_size())); } } t if t == TypeId::of::