💥 Adjust downcasting component function names
This commit is contained in:
parent
8b4a78f553
commit
ef3592f08a
4 changed files with 12 additions and 12 deletions
|
|
@ -49,7 +49,7 @@ impl ThemeTrait for Bulmix {
|
||||||
) {
|
) {
|
||||||
match component.handle() {
|
match component.handle() {
|
||||||
COMPONENT_ANCHOR => {
|
COMPONENT_ANCHOR => {
|
||||||
let a = component_mut::<Anchor>(component);
|
let a = component_as_mut::<Anchor>(component);
|
||||||
a.alter_classes(
|
a.alter_classes(
|
||||||
ClassesOp::SetDefault,
|
ClassesOp::SetDefault,
|
||||||
match a.anchor_type() {
|
match a.anchor_type() {
|
||||||
|
|
@ -59,7 +59,7 @@ impl ThemeTrait for Bulmix {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
COMPONENT_HEADING => {
|
COMPONENT_HEADING => {
|
||||||
let h = component_mut::<Heading>(component);
|
let h = component_as_mut::<Heading>(component);
|
||||||
h.alter_classes(
|
h.alter_classes(
|
||||||
ClassesOp::SetDefault,
|
ClassesOp::SetDefault,
|
||||||
match h.display() {
|
match h.display() {
|
||||||
|
|
@ -74,7 +74,7 @@ impl ThemeTrait for Bulmix {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
COMPONENT_PARAGRAPH => {
|
COMPONENT_PARAGRAPH => {
|
||||||
let p = component_mut::<Paragraph>(component);
|
let p = component_as_mut::<Paragraph>(component);
|
||||||
p.alter_classes(
|
p.alter_classes(
|
||||||
ClassesOp::SetDefault,
|
ClassesOp::SetDefault,
|
||||||
match p.display() {
|
match p.display() {
|
||||||
|
|
@ -88,7 +88,7 @@ impl ThemeTrait for Bulmix {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
grid::COMPONENT_GRID_COLUMN => {
|
grid::COMPONENT_GRID_COLUMN => {
|
||||||
let col = component_mut::<grid::Column>(component);
|
let col = component_as_mut::<grid::Column>(component);
|
||||||
col.alter_classes(
|
col.alter_classes(
|
||||||
ClassesOp::SetDefault,
|
ClassesOp::SetDefault,
|
||||||
concat_string!(
|
concat_string!(
|
||||||
|
|
@ -114,7 +114,7 @@ impl ThemeTrait for Bulmix {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
grid::COMPONENT_GRID_ROW => {
|
grid::COMPONENT_GRID_ROW => {
|
||||||
let row = component_mut::<grid::Row>(component);
|
let row = component_as_mut::<grid::Row>(component);
|
||||||
row.alter_classes(ClassesOp::SetDefault, "columns");
|
row.alter_classes(ClassesOp::SetDefault, "columns");
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
@ -128,7 +128,7 @@ impl ThemeTrait for Bulmix {
|
||||||
) -> Option<Markup> {
|
) -> Option<Markup> {
|
||||||
match component.handle() {
|
match component.handle() {
|
||||||
COMPONENT_ICON => {
|
COMPONENT_ICON => {
|
||||||
let icon = component_ref::<Icon>(component);
|
let icon = component_as_ref::<Icon>(component);
|
||||||
Some(html! {
|
Some(html! {
|
||||||
span class="icon" {
|
span class="icon" {
|
||||||
i class=[icon.classes().get()] {};
|
i class=[icon.classes().get()] {};
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ pub use context::{Context, ContextOp};
|
||||||
pub type FnContextualPath = fn(cx: &Context) -> &str;
|
pub type FnContextualPath = fn(cx: &Context) -> &str;
|
||||||
|
|
||||||
mod definition;
|
mod definition;
|
||||||
pub use definition::{component_mut, component_ref, ComponentBase, ComponentTrait};
|
pub use definition::{component_as_mut, component_as_ref, ComponentBase, ComponentTrait};
|
||||||
|
|
||||||
mod arc;
|
mod arc;
|
||||||
pub use arc::ComponentArc;
|
pub use arc::ComponentArc;
|
||||||
|
|
|
||||||
|
|
@ -87,10 +87,10 @@ impl<C: ComponentTrait> ComponentBase for C {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn component_ref<C: ComponentTrait>(component: &dyn ComponentTrait) -> &C {
|
pub fn component_as_ref<C: ComponentTrait>(component: &dyn ComponentTrait) -> &C {
|
||||||
component.as_ref_any().downcast_ref::<C>().unwrap()
|
component.as_ref_any().downcast_ref::<C>().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn component_mut<C: ComponentTrait>(component: &mut dyn ComponentTrait) -> &mut C {
|
pub fn component_as_mut<C: ComponentTrait>(component: &mut dyn ComponentTrait) -> &mut C {
|
||||||
component.as_mut_any().downcast_mut::<C>().unwrap()
|
component.as_mut_any().downcast_mut::<C>().unwrap()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ pub trait ThemeTrait: ModuleTrait + Send + Sync {
|
||||||
|
|
||||||
match component.handle() {
|
match component.handle() {
|
||||||
BLOCK_COMPONENT => {
|
BLOCK_COMPONENT => {
|
||||||
let block = component_mut::<Block>(component);
|
let block = component_as_mut::<Block>(component);
|
||||||
block.alter_title("New title");
|
block.alter_title("New title");
|
||||||
},
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
|
|
@ -110,7 +110,7 @@ pub trait ThemeTrait: ModuleTrait + Send + Sync {
|
||||||
|
|
||||||
match component.handle() {
|
match component.handle() {
|
||||||
BLOCK_COMPONENT => {
|
BLOCK_COMPONENT => {
|
||||||
let block = component_mut::<Block>(component);
|
let block = component_as_mut::<Block>(component);
|
||||||
block.alter_title("New title");
|
block.alter_title("New title");
|
||||||
},
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
|
|
@ -131,7 +131,7 @@ pub trait ThemeTrait: ModuleTrait + Send + Sync {
|
||||||
|
|
||||||
match component.handle() {
|
match component.handle() {
|
||||||
BLOCK_COMPONENT => {
|
BLOCK_COMPONENT => {
|
||||||
let block = component_ref::<Block>(component);
|
let block = component_as_ref::<Block>(component);
|
||||||
match block.template() {
|
match block.template() {
|
||||||
"default" => Some(block_default(block)),
|
"default" => Some(block_default(block)),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue