🚧 Simplify basic components

This commit is contained in:
Manuel Cillero 2024-03-08 22:28:31 +01:00
parent c65ac74a6f
commit 496c9d375b
5 changed files with 14 additions and 32 deletions

View file

@ -160,6 +160,12 @@ pub use html::Html;
mod fluent; mod fluent;
pub use fluent::Fluent; pub use fluent::Fluent;
mod error403;
pub use error403::Error403;
mod error404;
pub use error404::Error404;
mod wrapper; mod wrapper;
pub use wrapper::{Wrapper, WrapperType}; pub use wrapper::{Wrapper, WrapperType};
@ -189,12 +195,6 @@ pub use branding::Branding;
mod powered_by; mod powered_by;
pub use powered_by::{PoweredBy, PoweredByLogo}; pub use powered_by::{PoweredBy, PoweredByLogo};
mod error403;
pub use error403::Error403;
mod error404;
pub use error404::Error404;
pub mod menu; pub mod menu;
pub use menu::Menu; pub use menu::Menu;

View file

@ -1,11 +1,11 @@
use crate::core::component::{ComponentTrait, Context}; use crate::prelude::*;
use crate::html::{html, PrepareMarkup};
#[derive(AutoDefault)]
pub struct Error403; pub struct Error403;
impl ComponentTrait for Error403 { impl ComponentTrait for Error403 {
fn new() -> Self { fn new() -> Self {
Error403 Error403::default()
} }
fn prepare_component(&self, _cx: &mut Context) -> PrepareMarkup { fn prepare_component(&self, _cx: &mut Context) -> PrepareMarkup {

View file

@ -1,11 +1,11 @@
use crate::core::component::{ComponentTrait, Context}; use crate::prelude::*;
use crate::html::{html, PrepareMarkup};
#[derive(AutoDefault)]
pub struct Error404; pub struct Error404;
impl ComponentTrait for Error404 { impl ComponentTrait for Error404 {
fn new() -> Self { fn new() -> Self {
Error404 Error404::default()
} }
fn prepare_component(&self, _cx: &mut Context) -> PrepareMarkup { fn prepare_component(&self, _cx: &mut Context) -> PrepareMarkup {

View file

@ -9,7 +9,7 @@ impl ComponentTrait for Fluent {
} }
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup { fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
PrepareMarkup::With(self.l10n().escaped(cx.langid())) PrepareMarkup::With(self.0.escaped(cx.langid()))
} }
} }
@ -18,17 +18,8 @@ impl Fluent {
Fluent(l10n) Fluent(l10n)
} }
// Fluent BUILDER.
#[fn_builder]
pub fn alter_l10n(&mut self, l10n: L10n) -> &mut Self { pub fn alter_l10n(&mut self, l10n: L10n) -> &mut Self {
self.0 = l10n; self.0 = l10n;
self self
} }
// Fluent GETTERS.
pub fn l10n(&self) -> &L10n {
&self.0
}
} }

View file

@ -9,7 +9,7 @@ impl ComponentTrait for Html {
} }
fn prepare_component(&self, _cx: &mut Context) -> PrepareMarkup { fn prepare_component(&self, _cx: &mut Context) -> PrepareMarkup {
PrepareMarkup::With(html! { (self.html()) }) PrepareMarkup::With(html! { (self.0) })
} }
} }
@ -18,17 +18,8 @@ impl Html {
Html(html) Html(html)
} }
// Html BUILDER.
#[fn_builder]
pub fn alter_html(&mut self, html: Markup) -> &mut Self { pub fn alter_html(&mut self, html: Markup) -> &mut Self {
self.0 = html; self.0 = html;
self self
} }
// Html GETTERS.
pub fn html(&self) -> &Markup {
&self.0
}
} }