🔥 Refactor TypeId/Any use, drop own Handle

This commit is contained in:
Manuel Cillero 2024-02-16 17:00:34 +01:00
parent 8402b7946e
commit 169e562488
59 changed files with 137 additions and 289 deletions

View file

@ -4,7 +4,6 @@ static_locales!(LOCALES_ADMIN);
mod summary;
#[derive(AssignHandle)]
pub struct Admin;
impl PackageTrait for Admin {

View file

@ -4,7 +4,6 @@ static_locales!(LOCALES_BOOTSIER);
static_files!(bootsier);
#[derive(AssignHandle)]
pub struct Bootsier;
impl PackageTrait for Bootsier {
@ -81,8 +80,8 @@ impl ThemeTrait for Bootsier {
}
fn before_prepare_component(&self, component: &mut dyn ComponentTrait, _cx: &mut Context) {
match component.handle() {
h if Icon::matches_handle(h) => {
match component.type_id() {
t if t == TypeId::of::<Icon>() => {
if let Some(i) = component_as_mut::<Icon>(component) {
match i.font_size() {
FontSize::ExtraLarge => {
@ -104,7 +103,7 @@ impl ThemeTrait for Bootsier {
};
}
}
h if Button::matches_handle(h) => {
t if t == TypeId::of::<Button>() => {
if let Some(b) = component_as_mut::<Button>(component) {
match b.style() {
ButtonStyle::Default => {
@ -152,7 +151,7 @@ impl ThemeTrait for Bootsier {
};
}
}
h if Heading::matches_handle(h) => {
t if t == TypeId::of::<Heading>() => {
if let Some(h) = component_as_mut::<Heading>(component) {
match h.size() {
HeadingSize::ExtraLarge => {
@ -174,7 +173,7 @@ impl ThemeTrait for Bootsier {
};
}
}
h if Paragraph::matches_handle(h) => {
t if t == TypeId::of::<Paragraph>() => {
if let Some(p) = component_as_mut::<Paragraph>(component) {
match p.font_size() {
FontSize::ExtraLarge => {
@ -201,8 +200,8 @@ impl ThemeTrait for Bootsier {
}
fn render_component(&self, component: &dyn ComponentTrait, cx: &mut Context) -> Option<Markup> {
match component.handle() {
h if Error404::matches_handle(h) => Some(html! {
match component.type_id() {
t if t == TypeId::of::<Error404>() => Some(html! {
div class="jumbotron" {
div class="media" {
img

View file

@ -2,7 +2,6 @@ use pagetop::prelude::*;
static_files!(bulmix);
#[derive(AssignHandle)]
pub struct Bulmix;
impl PackageTrait for Bulmix {
@ -30,8 +29,8 @@ impl ThemeTrait for Bulmix {
}
fn before_prepare_component(&self, component: &mut dyn ComponentTrait, _cx: &mut Context) {
match component.handle() {
h if Icon::matches_handle(h) => {
match component.type_id() {
t if t == TypeId::of::<Icon>() => {
if let Some(i) = component_as_mut::<Icon>(component) {
match i.font_size() {
FontSize::ExtraLarge => {
@ -53,7 +52,7 @@ impl ThemeTrait for Bulmix {
};
}
}
h if Button::matches_handle(h) => {
t if t == TypeId::of::<Button>() => {
if let Some(b) = component_as_mut::<Button>(component) {
match b.style() {
ButtonStyle::Default => {
@ -101,7 +100,7 @@ impl ThemeTrait for Bulmix {
};
}
}
h if Heading::matches_handle(h) => {
t if t == TypeId::of::<Heading>() => {
if let Some(h) = component_as_mut::<Heading>(component) {
match h.size() {
HeadingSize::Subtitle => {
@ -111,7 +110,7 @@ impl ThemeTrait for Bulmix {
};
}
}
h if Paragraph::matches_handle(h) => {
t if t == TypeId::of::<Paragraph>() => {
if let Some(p) = component_as_mut::<Paragraph>(component) {
p.add_classes("block");
match p.font_size() {
@ -143,8 +142,8 @@ impl ThemeTrait for Bulmix {
component: &dyn ComponentTrait,
_cx: &mut Context,
) -> Option<Markup> {
match component.handle() {
h if Icon::matches_handle(h) => {
match component.type_id() {
t if t == TypeId::of::<Icon>() => {
if let Some(i) = component_as_ref::<Icon>(component) {
return match i.icon_name().get() {
None => None,

View file

@ -4,7 +4,6 @@ static_locales!(LOCALES_HOMEDEMO);
static_files!(homedemo);
#[derive(AssignHandle)]
pub struct HomeDemo;
impl PackageTrait for HomeDemo {

View file

@ -5,7 +5,6 @@ static_locales!(LOCALES_NODE);
//mod entity;
mod migration;
#[derive(AssignHandle)]
pub struct Node;
impl PackageTrait for Node {

View file

@ -4,7 +4,6 @@ static_locales!(LOCALES_USER);
mod migration;
#[derive(AssignHandle)]
pub struct User;
impl PackageTrait for User {