Mejora disposición de propiedades de componentes
This commit is contained in:
parent
743e32b0f6
commit
88a59780c3
21 changed files with 554 additions and 453 deletions
|
|
@ -3,34 +3,34 @@ use super::l;
|
|||
|
||||
pub async fn summary() -> app::Result<Markup> {
|
||||
let top_menu = Menu::new()
|
||||
.add(MenuItem::label(l("module_name").as_str()))
|
||||
.add(MenuItem::link("Opción 2", "https://www.google.es"))
|
||||
.add(MenuItem::link_blank("Opción 3", "https://www.google.es"))
|
||||
.add(MenuItem::submenu("Submenú 1", Menu::new()
|
||||
.add(MenuItem::label("Opción 1"))
|
||||
.add(MenuItem::label("Opción 2"))
|
||||
.with_item(MenuItem::label(l("module_name").as_str()))
|
||||
.with_item(MenuItem::link("Opción 2", "https://www.google.es"))
|
||||
.with_item(MenuItem::link_blank("Opción 3", "https://www.google.es"))
|
||||
.with_item(MenuItem::submenu("Submenú 1", Menu::new()
|
||||
.with_item(MenuItem::label("Opción 1"))
|
||||
.with_item(MenuItem::label("Opción 2"))
|
||||
))
|
||||
.add(MenuItem::separator())
|
||||
.add(MenuItem::submenu("Submenú 2", Menu::new()
|
||||
.add(MenuItem::label("Opción 1"))
|
||||
.add(MenuItem::label("Opción 2"))
|
||||
.with_item(MenuItem::separator())
|
||||
.with_item(MenuItem::submenu("Submenú 2", Menu::new()
|
||||
.with_item(MenuItem::label("Opción 1"))
|
||||
.with_item(MenuItem::label("Opción 2"))
|
||||
))
|
||||
.add(MenuItem::label("Opción 4"));
|
||||
.with_item(MenuItem::label("Opción 4"));
|
||||
|
||||
let side_menu = Menu::new()
|
||||
.add(MenuItem::label("Opción 1"))
|
||||
.add(MenuItem::link("Opción 2", "https://www.google.es"))
|
||||
.add(MenuItem::link_blank("Opción 3", "https://www.google.es"))
|
||||
.add(MenuItem::submenu("Submenú 1", Menu::new()
|
||||
.add(MenuItem::label("Opción 1"))
|
||||
.add(MenuItem::label("Opción 2"))
|
||||
.with_item(MenuItem::label("Opción 1"))
|
||||
.with_item(MenuItem::link("Opción 2", "https://www.google.es"))
|
||||
.with_item(MenuItem::link_blank("Opción 3", "https://www.google.es"))
|
||||
.with_item(MenuItem::submenu("Submenú 1", Menu::new()
|
||||
.with_item(MenuItem::label("Opción 1"))
|
||||
.with_item(MenuItem::label("Opción 2"))
|
||||
))
|
||||
.add(MenuItem::separator())
|
||||
.add(MenuItem::submenu("Submenú 2", Menu::new()
|
||||
.add(MenuItem::label("Opción 1"))
|
||||
.add(MenuItem::label("Opción 2"))
|
||||
.with_item(MenuItem::separator())
|
||||
.with_item(MenuItem::submenu("Submenú 2", Menu::new()
|
||||
.with_item(MenuItem::label("Opción 1"))
|
||||
.with_item(MenuItem::label("Opción 2"))
|
||||
))
|
||||
.add(MenuItem::label("Opción 4"));
|
||||
.with_item(MenuItem::label("Opción 4"));
|
||||
|
||||
Page::new()
|
||||
|
||||
|
|
@ -41,11 +41,11 @@ pub async fn summary() -> app::Result<Markup> {
|
|||
.add_to("top-menu", top_menu)
|
||||
|
||||
.add_to("content", grid::Row::new()
|
||||
.add_column(grid::Column::new()
|
||||
.add(side_menu)
|
||||
.with_column(grid::Column::new()
|
||||
.with_component(side_menu)
|
||||
)
|
||||
.add_column(grid::Column::new()
|
||||
.add(Chunck::with(html! {
|
||||
.with_column(grid::Column::new()
|
||||
.with_component(Chunck::with(html! {
|
||||
p { "Columna 2"}
|
||||
}))
|
||||
)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ async fn login() -> app::Result<Markup> {
|
|||
)
|
||||
.add_to("content", Container::new()
|
||||
.with_id("welcome")
|
||||
.add(form_login())
|
||||
.with_component(form_login())
|
||||
)
|
||||
.render()
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ async fn login() -> app::Result<Markup> {
|
|||
fn form_login() -> Form {
|
||||
Form::new()
|
||||
.with_id("user-login")
|
||||
.add(form::Input::textfield()
|
||||
.with_element(form::Input::textfield()
|
||||
.with_name("name")
|
||||
.with_label(l("username").as_str())
|
||||
.with_help_text(t("username_help", &args![
|
||||
|
|
@ -58,10 +58,10 @@ fn form_login() -> Form {
|
|||
]).as_str())
|
||||
.with_autofocus(true)
|
||||
)
|
||||
.add(form::Input::password()
|
||||
.with_element(form::Input::password()
|
||||
.with_name("pass")
|
||||
.with_label(l("password").as_str())
|
||||
.with_help_text(l("password_help").as_str())
|
||||
)
|
||||
.add(form::Button::submit(l("login").as_str()))
|
||||
.with_element(form::Button::submit(l("login").as_str()))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,15 +21,15 @@ pub type AnchorIcon = ComponentsBundle;
|
|||
pub struct Anchor {
|
||||
renderable : fn() -> bool,
|
||||
weight : isize,
|
||||
id : IdentifierValue,
|
||||
classes : Classes,
|
||||
spaces : Spaces,
|
||||
anchor_type: AnchorType,
|
||||
href : AttributeValue,
|
||||
html : Markup,
|
||||
left_icon : AnchorIcon,
|
||||
right_icon : AnchorIcon,
|
||||
target : AnchorTarget,
|
||||
id : IdentifierValue,
|
||||
classes : Classes,
|
||||
spaces : Spaces,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -38,15 +38,15 @@ impl ComponentTrait for Anchor {
|
|||
Anchor {
|
||||
renderable : render_always,
|
||||
weight : 0,
|
||||
id : IdentifierValue::new(),
|
||||
classes : Classes::new(),
|
||||
spaces : Spaces::new(),
|
||||
anchor_type: AnchorType::Link,
|
||||
href : AttributeValue::new(),
|
||||
html : html! {},
|
||||
left_icon : AnchorIcon::new(),
|
||||
right_icon : AnchorIcon::new(),
|
||||
target : AnchorTarget::Default,
|
||||
id : IdentifierValue::new(),
|
||||
classes : Classes::new(),
|
||||
spaces : Spaces::new(),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
}
|
||||
|
|
@ -120,6 +120,21 @@ impl Anchor {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_id(mut self, id: &str) -> Self {
|
||||
self.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_classes(mut self, classes: &str, op: ClassesOp) -> Self {
|
||||
self.alter_classes(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_spaces(mut self, spaces: &[SpaceSet]) -> Self {
|
||||
self.alter_spaces(spaces);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_type(mut self, anchor_type: AnchorType) -> Self {
|
||||
self.alter_type(anchor_type);
|
||||
self
|
||||
|
|
@ -150,21 +165,6 @@ impl Anchor {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_id(mut self, id: &str) -> Self {
|
||||
self.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_classes(mut self, classes: &str, op: ClassesOp) -> Self {
|
||||
self.alter_classes(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_spaces(mut self, spaces: &[SpaceSet]) -> Self {
|
||||
self.alter_spaces(spaces);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn using_template(mut self, template: &str) -> Self {
|
||||
self.alter_template(template);
|
||||
self
|
||||
|
|
@ -182,6 +182,21 @@ impl Anchor {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_id(&mut self, id: &str) -> &mut Self {
|
||||
self.id.with_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_classes(&mut self, classes: &str, op: ClassesOp) -> &mut Self {
|
||||
self.classes.alter(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_spaces(&mut self, spaces: &[SpaceSet]) -> &mut Self {
|
||||
self.spaces.add(spaces);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_type(&mut self, anchor_type: AnchorType) -> &mut Self {
|
||||
self.anchor_type = anchor_type;
|
||||
self.classes.alter(match self.anchor_type {
|
||||
|
|
@ -218,21 +233,6 @@ impl Anchor {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_id(&mut self, id: &str) -> &mut Self {
|
||||
self.id.with_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_classes(&mut self, classes: &str, op: ClassesOp) -> &mut Self {
|
||||
self.classes.alter(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_spaces(&mut self, spaces: &[SpaceSet]) -> &mut Self {
|
||||
self.spaces.add(spaces);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_template(&mut self, template: &str) -> &mut Self {
|
||||
self.template = template.to_owned();
|
||||
self
|
||||
|
|
@ -240,6 +240,18 @@ impl Anchor {
|
|||
|
||||
// Anchor GETTERS.
|
||||
|
||||
pub fn id(&self) -> &IdentifierValue {
|
||||
&self.id
|
||||
}
|
||||
|
||||
pub fn classes(&self) -> &Classes {
|
||||
&self.classes
|
||||
}
|
||||
|
||||
pub fn spaces(&self) -> &Spaces {
|
||||
&self.spaces
|
||||
}
|
||||
|
||||
pub fn anchor_type(&self) -> &AnchorType {
|
||||
&self.anchor_type
|
||||
}
|
||||
|
|
@ -264,18 +276,6 @@ impl Anchor {
|
|||
&self.target
|
||||
}
|
||||
|
||||
pub fn id(&self) -> &IdentifierValue {
|
||||
&self.id
|
||||
}
|
||||
|
||||
pub fn classes(&self) -> &Classes {
|
||||
&self.classes
|
||||
}
|
||||
|
||||
pub fn spaces(&self) -> &Spaces {
|
||||
&self.spaces
|
||||
}
|
||||
|
||||
pub fn template(&self) -> &str {
|
||||
self.template.as_str()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ pub const BLOCK_COMPONENT: &str = "pagetop::component::block";
|
|||
pub struct Block {
|
||||
renderable: fn() -> bool,
|
||||
weight : isize,
|
||||
components: ComponentsBundle,
|
||||
title : AttributeValue,
|
||||
id : IdentifierValue,
|
||||
classes : Classes,
|
||||
title : AttributeValue,
|
||||
components: ComponentsBundle,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -17,10 +17,10 @@ impl ComponentTrait for Block {
|
|||
Block {
|
||||
renderable: render_always,
|
||||
weight : 0,
|
||||
components: ComponentsBundle::new(),
|
||||
title : AttributeValue::new(),
|
||||
id : IdentifierValue::new(),
|
||||
classes : Classes::new_with_default("block"),
|
||||
title : AttributeValue::new(),
|
||||
components: ComponentsBundle::new(),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
}
|
||||
|
|
@ -63,17 +63,6 @@ impl ComponentTrait for Block {
|
|||
|
||||
impl Block {
|
||||
|
||||
// Block CONTAINER.
|
||||
|
||||
pub fn add(mut self, component: impl ComponentTrait) -> Self {
|
||||
self.components.add(component);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn components(&self) -> &ComponentsBundle {
|
||||
&self.components
|
||||
}
|
||||
|
||||
// Block BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
|
|
@ -86,11 +75,6 @@ impl Block {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_title(mut self, title: &str) -> Self {
|
||||
self.alter_title(title);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_id(mut self, id: &str) -> Self {
|
||||
self.alter_id(id);
|
||||
self
|
||||
|
|
@ -101,6 +85,16 @@ impl Block {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_title(mut self, title: &str) -> Self {
|
||||
self.alter_title(title);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_component(mut self, component: impl ComponentTrait) -> Self {
|
||||
self.alter_component(component);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn using_template(mut self, template: &str) -> Self {
|
||||
self.alter_template(template);
|
||||
self
|
||||
|
|
@ -118,11 +112,6 @@ impl Block {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_title(&mut self, title: &str) -> &mut Self {
|
||||
self.title.with_value(title);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_id(&mut self, id: &str) -> &mut Self {
|
||||
self.id.with_value(id);
|
||||
self
|
||||
|
|
@ -133,6 +122,16 @@ impl Block {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_title(&mut self, title: &str) -> &mut Self {
|
||||
self.title.with_value(title);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_component(&mut self, component: impl ComponentTrait) -> &mut Self {
|
||||
self.components.add(component);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_template(&mut self, template: &str) -> &mut Self {
|
||||
self.template = template.to_owned();
|
||||
self
|
||||
|
|
@ -140,10 +139,6 @@ impl Block {
|
|||
|
||||
// Block GETTERS.
|
||||
|
||||
pub fn title(&self) -> &AttributeValue {
|
||||
&self.title
|
||||
}
|
||||
|
||||
pub fn id(&self) -> &IdentifierValue {
|
||||
&self.id
|
||||
}
|
||||
|
|
@ -152,6 +147,14 @@ impl Block {
|
|||
&self.classes
|
||||
}
|
||||
|
||||
pub fn title(&self) -> &AttributeValue {
|
||||
&self.title
|
||||
}
|
||||
|
||||
pub fn components(&self) -> &ComponentsBundle {
|
||||
&self.components
|
||||
}
|
||||
|
||||
pub fn template(&self) -> &str {
|
||||
self.template.as_str()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ pub enum ContainerType { Header, Footer, Main, Section, Wrapper }
|
|||
pub struct Container {
|
||||
renderable : fn() -> bool,
|
||||
weight : isize,
|
||||
components : ComponentsBundle,
|
||||
container : ContainerType,
|
||||
id : IdentifierValue,
|
||||
classes : Classes,
|
||||
inner_classes : Classes,
|
||||
container_type: ContainerType,
|
||||
components : ComponentsBundle,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -20,11 +20,11 @@ impl ComponentTrait for Container {
|
|||
Container {
|
||||
renderable : render_always,
|
||||
weight : 0,
|
||||
components : ComponentsBundle::new(),
|
||||
container : ContainerType::Wrapper,
|
||||
id : IdentifierValue::new(),
|
||||
classes : Classes::new_with_default("container"),
|
||||
inner_classes : Classes::new_with_default("container"),
|
||||
container_type: ContainerType::Wrapper,
|
||||
components : ComponentsBundle::new(),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
}
|
||||
|
|
@ -91,39 +91,28 @@ impl ComponentTrait for Container {
|
|||
impl Container {
|
||||
pub fn header() -> Self {
|
||||
let mut c = Container::new().with_classes("header", ClassesOp::SetDefault);
|
||||
c.container = ContainerType::Header;
|
||||
c.container_type = ContainerType::Header;
|
||||
c
|
||||
}
|
||||
|
||||
pub fn footer() -> Self {
|
||||
let mut c = Container::new().with_classes("footer", ClassesOp::SetDefault);
|
||||
c.container = ContainerType::Footer;
|
||||
c.container_type = ContainerType::Footer;
|
||||
c
|
||||
}
|
||||
|
||||
pub fn main() -> Self {
|
||||
let mut c = Container::new().with_classes("main", ClassesOp::SetDefault);
|
||||
c.container = ContainerType::Main;
|
||||
c.container_type = ContainerType::Main;
|
||||
c
|
||||
}
|
||||
|
||||
pub fn section() -> Self {
|
||||
let mut c = Container::new().with_classes("section", ClassesOp::SetDefault);
|
||||
c.container = ContainerType::Section;
|
||||
c.container_type = ContainerType::Section;
|
||||
c
|
||||
}
|
||||
|
||||
// Container CONTAINER.
|
||||
|
||||
pub fn add(mut self, component: impl ComponentTrait) -> Self {
|
||||
self.components.add(component);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn components(&self) -> &ComponentsBundle {
|
||||
&self.components
|
||||
}
|
||||
|
||||
// Container BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
|
|
@ -151,6 +140,11 @@ impl Container {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_component(mut self, component: impl ComponentTrait) -> Self {
|
||||
self.alter_component(component);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn using_template(mut self, template: &str) -> Self {
|
||||
self.alter_template(template);
|
||||
self
|
||||
|
|
@ -183,6 +177,11 @@ impl Container {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_component(&mut self, component: impl ComponentTrait) -> &mut Self {
|
||||
self.components.add(component);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_template(&mut self, template: &str) -> &mut Self {
|
||||
self.template = template.to_owned();
|
||||
self
|
||||
|
|
@ -190,10 +189,6 @@ impl Container {
|
|||
|
||||
// Container GETTERS.
|
||||
|
||||
pub fn container_type(&self) -> &ContainerType {
|
||||
&self.container
|
||||
}
|
||||
|
||||
pub fn id(&self) -> &IdentifierValue {
|
||||
&self.id
|
||||
}
|
||||
|
|
@ -206,6 +201,14 @@ impl Container {
|
|||
&self.inner_classes
|
||||
}
|
||||
|
||||
pub fn container_type(&self) -> &ContainerType {
|
||||
&self.container_type
|
||||
}
|
||||
|
||||
pub fn components(&self) -> &ComponentsBundle {
|
||||
&self.components
|
||||
}
|
||||
|
||||
pub fn template(&self) -> &str {
|
||||
self.template.as_str()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ pub enum ButtonType {Button, Reset, Submit}
|
|||
pub struct Button {
|
||||
renderable : fn() -> bool,
|
||||
weight : isize,
|
||||
classes : Classes,
|
||||
button_type: ButtonType,
|
||||
name : AttributeValue,
|
||||
value : AttributeValue,
|
||||
autofocus : AttributeValue,
|
||||
disabled : AttributeValue,
|
||||
classes : Classes,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -21,12 +21,12 @@ impl ComponentTrait for Button {
|
|||
Button {
|
||||
renderable : render_always,
|
||||
weight : 0,
|
||||
classes : Classes::new_with_default("btn btn-primary"),
|
||||
button_type: ButtonType::Button,
|
||||
name : AttributeValue::new(),
|
||||
value : AttributeValue::new(),
|
||||
autofocus : AttributeValue::new(),
|
||||
disabled : AttributeValue::new(),
|
||||
classes : Classes::new_with_default("btn btn-primary"),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
.with_classes("form-button", ClassesOp::AddFirst)
|
||||
|
|
@ -114,6 +114,11 @@ impl Button {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_classes(mut self, classes: &str, op: ClassesOp) -> Self {
|
||||
self.alter_classes(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_name(mut self, name: &str) -> Self {
|
||||
self.alter_name(name);
|
||||
self
|
||||
|
|
@ -134,11 +139,6 @@ impl Button {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_classes(mut self, classes: &str, op: ClassesOp) -> Self {
|
||||
self.alter_classes(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn using_template(mut self, template: &str) -> Self {
|
||||
self.alter_template(template);
|
||||
self
|
||||
|
|
@ -156,6 +156,11 @@ impl Button {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_classes(&mut self, classes: &str, op: ClassesOp) -> &mut Self {
|
||||
self.classes.alter(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_name(&mut self, name: &str) -> &mut Self {
|
||||
self.name.with_value(name);
|
||||
self
|
||||
|
|
@ -182,11 +187,6 @@ impl Button {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_classes(&mut self, classes: &str, op: ClassesOp) -> &mut Self {
|
||||
self.classes.alter(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_template(&mut self, template: &str) -> &mut Self {
|
||||
self.template = template.to_owned();
|
||||
self
|
||||
|
|
@ -194,6 +194,10 @@ impl Button {
|
|||
|
||||
// Button GETTERS.
|
||||
|
||||
pub fn classes(&self) -> &Classes {
|
||||
&self.classes
|
||||
}
|
||||
|
||||
pub fn button_type(&self) -> &ButtonType {
|
||||
&self.button_type
|
||||
}
|
||||
|
|
@ -214,10 +218,6 @@ impl Button {
|
|||
&self.disabled
|
||||
}
|
||||
|
||||
pub fn classes(&self) -> &Classes {
|
||||
&self.classes
|
||||
}
|
||||
|
||||
pub fn template(&self) -> &str {
|
||||
self.template.as_str()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ pub const DATE_COMPONENT: &str = "pagetop::component::form::date";
|
|||
pub struct Date {
|
||||
renderable : fn() -> bool,
|
||||
weight : isize,
|
||||
classes : Classes,
|
||||
name : AttributeValue,
|
||||
value : AttributeValue,
|
||||
label : AttributeValue,
|
||||
|
|
@ -15,7 +16,6 @@ pub struct Date {
|
|||
readonly : AttributeValue,
|
||||
required : AttributeValue,
|
||||
help_text : AttributeValue,
|
||||
classes : Classes,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -24,6 +24,7 @@ impl ComponentTrait for Date {
|
|||
Date {
|
||||
renderable : render_always,
|
||||
weight : 0,
|
||||
classes : Classes::new_with_default("form-item"),
|
||||
name : AttributeValue::new(),
|
||||
value : AttributeValue::new(),
|
||||
label : AttributeValue::new(),
|
||||
|
|
@ -34,7 +35,6 @@ impl ComponentTrait for Date {
|
|||
readonly : AttributeValue::new(),
|
||||
required : AttributeValue::new(),
|
||||
help_text : AttributeValue::new(),
|
||||
classes : Classes::new_with_default("form-item"),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
.with_classes("form-type-date", ClassesOp::AddFirst)
|
||||
|
|
@ -114,6 +114,11 @@ impl Date {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_classes(mut self, classes: &str, op: ClassesOp) -> Self {
|
||||
self.alter_classes(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_name(mut self, name: &str) -> Self {
|
||||
self.alter_name(name);
|
||||
self
|
||||
|
|
@ -164,11 +169,6 @@ impl Date {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_classes(mut self, classes: &str, op: ClassesOp) -> Self {
|
||||
self.alter_classes(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn using_template(mut self, template: &str) -> Self {
|
||||
self.alter_template(template);
|
||||
self
|
||||
|
|
@ -186,6 +186,11 @@ impl Date {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_classes(&mut self, classes: &str, op: ClassesOp) -> &mut Self {
|
||||
self.classes.alter(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_name(&mut self, name: &str) -> &mut Self {
|
||||
self.name.with_value(name);
|
||||
self
|
||||
|
|
@ -251,11 +256,6 @@ impl Date {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_classes(&mut self, classes: &str, op: ClassesOp) -> &mut Self {
|
||||
self.classes.alter(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_template(&mut self, template: &str) -> &mut Self {
|
||||
self.template = template.to_owned();
|
||||
self
|
||||
|
|
@ -263,6 +263,10 @@ impl Date {
|
|||
|
||||
// Date GETTERS.
|
||||
|
||||
pub fn classes(&self) -> &Classes {
|
||||
&self.classes
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &AttributeValue {
|
||||
&self.name
|
||||
}
|
||||
|
|
@ -303,10 +307,6 @@ impl Date {
|
|||
&self.help_text
|
||||
}
|
||||
|
||||
pub fn classes(&self) -> &Classes {
|
||||
&self.classes
|
||||
}
|
||||
|
||||
pub fn template(&self) -> &str {
|
||||
self.template.as_str()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ pub enum FormMethod {Get, Post}
|
|||
pub struct Form {
|
||||
renderable: fn() -> bool,
|
||||
weight : isize,
|
||||
elements : ComponentsBundle,
|
||||
id : IdentifierValue,
|
||||
classes : Classes,
|
||||
action : AttributeValue,
|
||||
charset : AttributeValue,
|
||||
method : FormMethod,
|
||||
id : IdentifierValue,
|
||||
classes : Classes,
|
||||
elements : ComponentsBundle,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -21,12 +21,12 @@ impl ComponentTrait for Form {
|
|||
Form {
|
||||
renderable: render_always,
|
||||
weight : 0,
|
||||
elements : ComponentsBundle::new(),
|
||||
id : IdentifierValue::new(),
|
||||
classes : Classes::new_with_default("form"),
|
||||
action : AttributeValue::new(),
|
||||
charset : AttributeValue::new_with_value("UTF-8"),
|
||||
method : FormMethod::Post,
|
||||
id : IdentifierValue::new(),
|
||||
classes : Classes::new_with_default("form"),
|
||||
elements : ComponentsBundle::new(),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
}
|
||||
|
|
@ -72,17 +72,6 @@ impl ComponentTrait for Form {
|
|||
|
||||
impl Form {
|
||||
|
||||
// Form CONTAINER.
|
||||
|
||||
pub fn add(mut self, element: impl ComponentTrait) -> Self {
|
||||
self.elements.add(element);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn elements(&self) -> &ComponentsBundle {
|
||||
&self.elements
|
||||
}
|
||||
|
||||
// Form BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
|
|
@ -95,6 +84,16 @@ impl Form {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_id(mut self, id: &str) -> Self {
|
||||
self.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_classes(mut self, classes: &str, op: ClassesOp) -> Self {
|
||||
self.alter_classes(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_action(mut self, action: &str) -> Self {
|
||||
self.alter_action(action);
|
||||
self
|
||||
|
|
@ -110,13 +109,8 @@ impl Form {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_id(mut self, id: &str) -> Self {
|
||||
self.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_classes(mut self, classes: &str, op: ClassesOp) -> Self {
|
||||
self.alter_classes(classes, op);
|
||||
pub fn with_element(mut self, element: impl ComponentTrait) -> Self {
|
||||
self.alter_element(element);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -137,6 +131,16 @@ impl Form {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_id(&mut self, id: &str) -> &mut Self {
|
||||
self.id.with_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_classes(&mut self, classes: &str, op: ClassesOp) -> &mut Self {
|
||||
self.classes.alter(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_action(&mut self, action: &str) -> &mut Self {
|
||||
self.action.with_value(action);
|
||||
self
|
||||
|
|
@ -152,13 +156,8 @@ impl Form {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_id(&mut self, id: &str) -> &mut Self {
|
||||
self.id.with_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_classes(&mut self, classes: &str, op: ClassesOp) -> &mut Self {
|
||||
self.classes.alter(classes, op);
|
||||
pub fn alter_element(&mut self, element: impl ComponentTrait) -> &mut Self {
|
||||
self.elements.add(element);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -169,6 +168,14 @@ impl Form {
|
|||
|
||||
// Form GETTERS.
|
||||
|
||||
pub fn id(&self) -> &IdentifierValue {
|
||||
&self.id
|
||||
}
|
||||
|
||||
pub fn classes(&self) -> &Classes {
|
||||
&self.classes
|
||||
}
|
||||
|
||||
pub fn action(&self) -> &AttributeValue {
|
||||
&self.action
|
||||
}
|
||||
|
|
@ -181,12 +188,8 @@ impl Form {
|
|||
&self.method
|
||||
}
|
||||
|
||||
pub fn id(&self) -> &IdentifierValue {
|
||||
&self.id
|
||||
}
|
||||
|
||||
pub fn classes(&self) -> &Classes {
|
||||
&self.classes
|
||||
pub fn elements(&self) -> &ComponentsBundle {
|
||||
&self.elements
|
||||
}
|
||||
|
||||
pub fn template(&self) -> &str {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ pub enum InputType {Email, Password, Search, Telephone, Textfield, Url}
|
|||
pub struct Input {
|
||||
renderable : fn() -> bool,
|
||||
weight : isize,
|
||||
classes : Classes,
|
||||
input_type : InputType,
|
||||
name : IdentifierValue,
|
||||
value : AttributeValue,
|
||||
|
|
@ -21,7 +22,6 @@ pub struct Input {
|
|||
readonly : AttributeValue,
|
||||
required : AttributeValue,
|
||||
help_text : AttributeValue,
|
||||
classes : Classes,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -30,6 +30,7 @@ impl ComponentTrait for Input {
|
|||
Input {
|
||||
renderable : render_always,
|
||||
weight : 0,
|
||||
classes : Classes::new_with_default("form-item"),
|
||||
input_type : InputType::Textfield,
|
||||
name : IdentifierValue::new(),
|
||||
value : AttributeValue::new(),
|
||||
|
|
@ -44,7 +45,6 @@ impl ComponentTrait for Input {
|
|||
readonly : AttributeValue::new(),
|
||||
required : AttributeValue::new(),
|
||||
help_text : AttributeValue::new(),
|
||||
classes : Classes::new_with_default("form-item"),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
.with_classes("form-type-textfield", ClassesOp::AddFirst)
|
||||
|
|
@ -173,6 +173,11 @@ impl Input {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_classes(mut self, classes: &str, op: ClassesOp) -> Self {
|
||||
self.alter_classes(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_name(mut self, name: &str) -> Self {
|
||||
self.alter_name(name);
|
||||
self
|
||||
|
|
@ -238,11 +243,6 @@ impl Input {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_classes(mut self, classes: &str, op: ClassesOp) -> Self {
|
||||
self.alter_classes(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn using_template(mut self, template: &str) -> Self {
|
||||
self.alter_template(template);
|
||||
self
|
||||
|
|
@ -260,6 +260,11 @@ impl Input {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_classes(&mut self, classes: &str, op: ClassesOp) -> &mut Self {
|
||||
self.classes.alter(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_name(&mut self, name: &str) -> &mut Self {
|
||||
self.name.with_value(name);
|
||||
self.alter_classes(
|
||||
|
|
@ -344,11 +349,6 @@ impl Input {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_classes(&mut self, classes: &str, op: ClassesOp) -> &mut Self {
|
||||
self.classes.alter(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_template(&mut self, template: &str) -> &mut Self {
|
||||
self.template = template.to_owned();
|
||||
self
|
||||
|
|
@ -356,6 +356,10 @@ impl Input {
|
|||
|
||||
// Input GETTERS.
|
||||
|
||||
pub fn classes(&self) -> &Classes {
|
||||
&self.classes
|
||||
}
|
||||
|
||||
pub fn input_type(&self) -> &InputType {
|
||||
&self.input_type
|
||||
}
|
||||
|
|
@ -412,10 +416,6 @@ impl Input {
|
|||
&self.help_text
|
||||
}
|
||||
|
||||
pub fn classes(&self) -> &Classes {
|
||||
&self.classes
|
||||
}
|
||||
|
||||
pub fn template(&self) -> &str {
|
||||
self.template.as_str()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ pub use row::{
|
|||
};
|
||||
mod column;
|
||||
pub use column::{
|
||||
COLUMN_COMPONENT, Column
|
||||
COLUMN_COMPONENT, Column, ColumnSize
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,12 +2,29 @@ use crate::prelude::*;
|
|||
|
||||
pub const COLUMN_COMPONENT: &str = "pagetop::component::grid::column";
|
||||
|
||||
pub enum ColumnSize {
|
||||
Default,
|
||||
Is1of12,
|
||||
Is2of12,
|
||||
Is3of12,
|
||||
Is4of12,
|
||||
Is5of12,
|
||||
Is6of12,
|
||||
Is7of12,
|
||||
Is8of12,
|
||||
Is9of12,
|
||||
Is10of12,
|
||||
Is11of12,
|
||||
IsFull,
|
||||
}
|
||||
pub struct Column {
|
||||
renderable: fn() -> bool,
|
||||
weight : isize,
|
||||
components: ComponentsBundle,
|
||||
id : IdentifierValue,
|
||||
classes : Classes,
|
||||
spaces : Spaces,
|
||||
size : ColumnSize,
|
||||
components: ComponentsBundle,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -16,9 +33,11 @@ impl ComponentTrait for Column {
|
|||
Column {
|
||||
renderable: render_always,
|
||||
weight : 0,
|
||||
components: ComponentsBundle::new(),
|
||||
id : IdentifierValue::new(),
|
||||
classes : Classes::new_with_default("col-md"),
|
||||
classes : Classes::new(),
|
||||
spaces : Spaces::new(),
|
||||
size : ColumnSize::Default,
|
||||
components: ComponentsBundle::new(),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
}
|
||||
|
|
@ -35,9 +54,27 @@ impl ComponentTrait for Column {
|
|||
self.weight
|
||||
}
|
||||
|
||||
fn before_render(&mut self, _context: &mut InContext) {
|
||||
match self.size() {
|
||||
ColumnSize::Default => self.alter_classes("col-sm", ClassesOp::SetDefault),
|
||||
ColumnSize::Is1of12 => self.alter_classes("col-sm-1", ClassesOp::SetDefault),
|
||||
ColumnSize::Is2of12 => self.alter_classes("col-sm-2", ClassesOp::SetDefault),
|
||||
ColumnSize::Is3of12 => self.alter_classes("col-sm-3", ClassesOp::SetDefault),
|
||||
ColumnSize::Is4of12 => self.alter_classes("col-sm-4", ClassesOp::SetDefault),
|
||||
ColumnSize::Is5of12 => self.alter_classes("col-sm-5", ClassesOp::SetDefault),
|
||||
ColumnSize::Is6of12 => self.alter_classes("col-sm-6", ClassesOp::SetDefault),
|
||||
ColumnSize::Is7of12 => self.alter_classes("col-sm-7", ClassesOp::SetDefault),
|
||||
ColumnSize::Is8of12 => self.alter_classes("col-sm-8", ClassesOp::SetDefault),
|
||||
ColumnSize::Is9of12 => self.alter_classes("col-sm-9", ClassesOp::SetDefault),
|
||||
ColumnSize::Is10of12 => self.alter_classes("col-sm-10", ClassesOp::SetDefault),
|
||||
ColumnSize::Is11of12 => self.alter_classes("col-sm-11", ClassesOp::SetDefault),
|
||||
ColumnSize::IsFull => self.alter_classes("col-sm-12", ClassesOp::SetDefault),
|
||||
};
|
||||
}
|
||||
|
||||
fn default_render(&self, context: &mut InContext) -> Markup {
|
||||
html! {
|
||||
div id=[self.id().get()] class=[self.classes().get()] {
|
||||
div id=[self.id().get()] class=[self.classes().get()] style=[self.spaces().get()] {
|
||||
(self.components().render(context))
|
||||
}
|
||||
}
|
||||
|
|
@ -54,17 +91,6 @@ impl ComponentTrait for Column {
|
|||
|
||||
impl Column {
|
||||
|
||||
// Column CONTAINER.
|
||||
|
||||
pub fn add(mut self, component: impl ComponentTrait) -> Self {
|
||||
self.components.add(component);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn components(&self) -> &ComponentsBundle {
|
||||
&self.components
|
||||
}
|
||||
|
||||
// Column BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
|
|
@ -87,6 +113,21 @@ impl Column {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_spaces(mut self, spaces: &[SpaceSet]) -> Self {
|
||||
self.alter_spaces(spaces);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_size(mut self, size: ColumnSize) -> Self {
|
||||
self.alter_size(size);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_component(mut self, component: impl ComponentTrait) -> Self {
|
||||
self.alter_component(component);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn using_template(mut self, template: &str) -> Self {
|
||||
self.alter_template(template);
|
||||
self
|
||||
|
|
@ -114,6 +155,20 @@ impl Column {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_spaces(&mut self, spaces: &[SpaceSet]) -> &mut Self {
|
||||
self.spaces.add(spaces);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_size(&mut self, size: ColumnSize) -> &mut Self {
|
||||
self.size = size;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_component(&mut self, component: impl ComponentTrait) -> &mut Self {
|
||||
self.components.add(component);
|
||||
self
|
||||
}
|
||||
pub fn alter_template(&mut self, template: &str) -> &mut Self {
|
||||
self.template = template.to_owned();
|
||||
self
|
||||
|
|
@ -129,6 +184,18 @@ impl Column {
|
|||
&self.classes
|
||||
}
|
||||
|
||||
pub fn spaces(&self) -> &Spaces {
|
||||
&self.spaces
|
||||
}
|
||||
|
||||
pub fn size(&self) -> &ColumnSize {
|
||||
&self.size
|
||||
}
|
||||
|
||||
pub fn components(&self) -> &ComponentsBundle {
|
||||
&self.components
|
||||
}
|
||||
|
||||
pub fn template(&self) -> &str {
|
||||
self.template.as_str()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ pub const ROW_COMPONENT: &str = "pagetop::component::grid::row";
|
|||
pub struct Row {
|
||||
renderable: fn() -> bool,
|
||||
weight : isize,
|
||||
columns : ComponentsBundle,
|
||||
id : IdentifierValue,
|
||||
classes : Classes,
|
||||
spaces : Spaces,
|
||||
columns : ComponentsBundle,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -17,10 +17,10 @@ impl ComponentTrait for Row {
|
|||
Row {
|
||||
renderable: render_always,
|
||||
weight : 0,
|
||||
columns : ComponentsBundle::new(),
|
||||
id : IdentifierValue::new(),
|
||||
classes : Classes::new_with_default("row"),
|
||||
spaces : Spaces::new(),
|
||||
columns : ComponentsBundle::new(),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
}
|
||||
|
|
@ -56,17 +56,6 @@ impl ComponentTrait for Row {
|
|||
|
||||
impl Row {
|
||||
|
||||
// Row CONTAINER.
|
||||
|
||||
pub fn add_column(mut self, column: grid::Column) -> Self {
|
||||
self.columns.add(column);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn columns(&self) -> &ComponentsBundle {
|
||||
&self.columns
|
||||
}
|
||||
|
||||
// Row BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
|
|
@ -94,6 +83,11 @@ impl Row {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_column(mut self, column: grid::Column) -> Self {
|
||||
self.alter_column(column);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn using_template(mut self, template: &str) -> Self {
|
||||
self.alter_template(template);
|
||||
self
|
||||
|
|
@ -126,6 +120,11 @@ impl Row {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_column(&mut self, column: grid::Column) -> &mut Self {
|
||||
self.columns.add(column);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_template(&mut self, template: &str) -> &mut Self {
|
||||
self.template = template.to_owned();
|
||||
self
|
||||
|
|
@ -145,6 +144,10 @@ impl Row {
|
|||
&self.spaces
|
||||
}
|
||||
|
||||
pub fn columns(&self) -> &ComponentsBundle {
|
||||
&self.columns
|
||||
}
|
||||
|
||||
pub fn template(&self) -> &str {
|
||||
self.template.as_str()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@ pub enum HeadingDisplay {
|
|||
pub struct Heading {
|
||||
renderable : fn() -> bool,
|
||||
weight : isize,
|
||||
heading : HeadingType,
|
||||
html : Markup,
|
||||
display : HeadingDisplay,
|
||||
id : IdentifierValue,
|
||||
classes : Classes,
|
||||
heading_type: HeadingType,
|
||||
html : Markup,
|
||||
display : HeadingDisplay,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -29,11 +29,11 @@ impl ComponentTrait for Heading {
|
|||
Heading {
|
||||
renderable : render_always,
|
||||
weight : 0,
|
||||
heading : HeadingType::H1,
|
||||
html : html! {},
|
||||
display : HeadingDisplay::Normal,
|
||||
id : IdentifierValue::new(),
|
||||
classes : Classes::new(),
|
||||
heading_type: HeadingType::H1,
|
||||
html : html! {},
|
||||
display : HeadingDisplay::Normal,
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
}
|
||||
|
|
@ -53,7 +53,7 @@ impl ComponentTrait for Heading {
|
|||
fn default_render(&self, _: &mut InContext) -> Markup {
|
||||
let id = self.id().get();
|
||||
let classes = self.classes().get();
|
||||
html! { @match &self.heading() {
|
||||
html! { @match &self.heading_type() {
|
||||
HeadingType::H1 => h1 id=[id] class=[classes] { (*self.html()) },
|
||||
HeadingType::H2 => h2 id=[id] class=[classes] { (*self.html()) },
|
||||
HeadingType::H3 => h3 id=[id] class=[classes] { (*self.html()) },
|
||||
|
|
@ -74,27 +74,27 @@ impl ComponentTrait for Heading {
|
|||
|
||||
impl Heading {
|
||||
pub fn h1(html: Markup) -> Self {
|
||||
Heading::new().with_heading(HeadingType::H1).with_html(html)
|
||||
Heading::new().with_heading_type(HeadingType::H1).with_html(html)
|
||||
}
|
||||
|
||||
pub fn h2(html: Markup) -> Self {
|
||||
Heading::new().with_heading(HeadingType::H2).with_html(html)
|
||||
Heading::new().with_heading_type(HeadingType::H2).with_html(html)
|
||||
}
|
||||
|
||||
pub fn h3(html: Markup) -> Self {
|
||||
Heading::new().with_heading(HeadingType::H3).with_html(html)
|
||||
Heading::new().with_heading_type(HeadingType::H3).with_html(html)
|
||||
}
|
||||
|
||||
pub fn h4(html: Markup) -> Self {
|
||||
Heading::new().with_heading(HeadingType::H4).with_html(html)
|
||||
Heading::new().with_heading_type(HeadingType::H4).with_html(html)
|
||||
}
|
||||
|
||||
pub fn h5(html: Markup) -> Self {
|
||||
Heading::new().with_heading(HeadingType::H5).with_html(html)
|
||||
Heading::new().with_heading_type(HeadingType::H5).with_html(html)
|
||||
}
|
||||
|
||||
pub fn h6(html: Markup) -> Self {
|
||||
Heading::new().with_heading(HeadingType::H6).with_html(html)
|
||||
Heading::new().with_heading_type(HeadingType::H6).with_html(html)
|
||||
}
|
||||
|
||||
// Heading BUILDER.
|
||||
|
|
@ -109,8 +109,18 @@ impl Heading {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_heading(mut self, heading: HeadingType) -> Self {
|
||||
self.alter_heading(heading);
|
||||
pub fn with_id(mut self, id: &str) -> Self {
|
||||
self.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_classes(mut self, classes: &str, op: ClassesOp) -> Self {
|
||||
self.alter_classes(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_heading_type(mut self, heading_type: HeadingType) -> Self {
|
||||
self.alter_heading_type(heading_type);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -124,16 +134,6 @@ impl Heading {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_id(mut self, id: &str) -> Self {
|
||||
self.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_classes(mut self, classes: &str, op: ClassesOp) -> Self {
|
||||
self.alter_classes(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn using_template(mut self, template: &str) -> Self {
|
||||
self.alter_template(template);
|
||||
self
|
||||
|
|
@ -151,8 +151,18 @@ impl Heading {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_heading(&mut self, heading: HeadingType) -> &mut Self {
|
||||
self.heading = heading;
|
||||
pub fn alter_id(&mut self, id: &str) -> &mut Self {
|
||||
self.id.with_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_classes(&mut self, classes: &str, op: ClassesOp) -> &mut Self {
|
||||
self.classes.alter(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_heading_type(&mut self, heading_type: HeadingType) -> &mut Self {
|
||||
self.heading_type = heading_type;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -174,16 +184,6 @@ impl Heading {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_id(&mut self, id: &str) -> &mut Self {
|
||||
self.id.with_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_classes(&mut self, classes: &str, op: ClassesOp) -> &mut Self {
|
||||
self.classes.alter(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_template(&mut self, template: &str) -> &mut Self {
|
||||
self.template = template.to_owned();
|
||||
self
|
||||
|
|
@ -191,8 +191,16 @@ impl Heading {
|
|||
|
||||
// Paragraph GETTERS.
|
||||
|
||||
pub fn heading(&self) -> &HeadingType {
|
||||
&self.heading
|
||||
pub fn id(&self) -> &IdentifierValue {
|
||||
&self.id
|
||||
}
|
||||
|
||||
pub fn classes(&self) -> &Classes {
|
||||
&self.classes
|
||||
}
|
||||
|
||||
pub fn heading_type(&self) -> &HeadingType {
|
||||
&self.heading_type
|
||||
}
|
||||
|
||||
pub fn html(&self) -> &Markup {
|
||||
|
|
@ -203,14 +211,6 @@ impl Heading {
|
|||
&self.display
|
||||
}
|
||||
|
||||
pub fn id(&self) -> &IdentifierValue {
|
||||
&self.id
|
||||
}
|
||||
|
||||
pub fn classes(&self) -> &Classes {
|
||||
&self.classes
|
||||
}
|
||||
|
||||
pub fn template(&self) -> &str {
|
||||
self.template.as_str()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ pub const ICON_COMPONENT: &str = "pagetop::component::icon";
|
|||
pub struct Icon {
|
||||
renderable: fn() -> bool,
|
||||
weight : isize,
|
||||
icon_name : String,
|
||||
classes : Classes,
|
||||
spaces : Spaces,
|
||||
}
|
||||
|
|
@ -14,7 +15,8 @@ impl ComponentTrait for Icon {
|
|||
Icon {
|
||||
renderable: render_always,
|
||||
weight : 0,
|
||||
classes : Classes::new_with_default("bi-question-circle-fill"),
|
||||
icon_name : "question-circle-fill".to_owned(),
|
||||
classes : Classes::new(),
|
||||
spaces : Spaces::new(),
|
||||
}
|
||||
}
|
||||
|
|
@ -31,12 +33,16 @@ impl ComponentTrait for Icon {
|
|||
self.weight
|
||||
}
|
||||
|
||||
fn default_render(&self, context: &mut InContext) -> Markup {
|
||||
fn before_render(&mut self, context: &mut InContext) {
|
||||
context
|
||||
.add_stylesheet(StyleSheet::with_source(
|
||||
"/theme/icons/bootstrap-icons.css?ver=1.8.2"
|
||||
));
|
||||
|
||||
self.alter_classes(concat_string!("bi-", self.icon_name()).as_str(), ClassesOp::SetDefault);
|
||||
}
|
||||
|
||||
fn default_render(&self, _context: &mut InContext) -> Markup {
|
||||
html! { i class=[self.classes().get()] style=[self.spaces().get()] {}; }
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +100,7 @@ impl Icon {
|
|||
}
|
||||
|
||||
pub fn alter_icon_name(&mut self, name: &str) -> &mut Self {
|
||||
self.classes.alter(concat_string!("bi-", name).as_str(), ClassesOp::SetDefault);
|
||||
self.icon_name = name.to_owned();
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -110,6 +116,10 @@ impl Icon {
|
|||
|
||||
// Icon GETTERS.
|
||||
|
||||
pub fn icon_name(&self) -> &str {
|
||||
self.icon_name.as_str()
|
||||
}
|
||||
|
||||
pub fn classes(&self) -> &Classes {
|
||||
&self.classes
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ pub const IMAGE_COMPONENT: &str = "pagetop::component::image";
|
|||
pub struct Image {
|
||||
renderable: fn() -> bool,
|
||||
weight : isize,
|
||||
source : AttributeValue,
|
||||
id : IdentifierValue,
|
||||
classes : Classes,
|
||||
source : AttributeValue,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -16,9 +16,9 @@ impl ComponentTrait for Image {
|
|||
Image {
|
||||
renderable: render_always,
|
||||
weight : 0,
|
||||
source : AttributeValue::new(),
|
||||
id : IdentifierValue::new(),
|
||||
classes : Classes::new_with_default("img-fluid"),
|
||||
source : AttributeValue::new(),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
}
|
||||
|
|
@ -70,11 +70,6 @@ impl Image {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_source(mut self, source: &str) -> Self {
|
||||
self.alter_source(source);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_id(mut self, id: &str) -> Self {
|
||||
self.alter_id(id);
|
||||
self
|
||||
|
|
@ -85,6 +80,11 @@ impl Image {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_source(mut self, source: &str) -> Self {
|
||||
self.alter_source(source);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn using_template(mut self, template: &str) -> Self {
|
||||
self.alter_template(template);
|
||||
self
|
||||
|
|
@ -102,11 +102,6 @@ impl Image {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_source(&mut self, source: &str) -> &mut Self {
|
||||
self.source.with_value(source);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_id(&mut self, id: &str) -> &mut Self {
|
||||
self.id.with_value(id);
|
||||
self
|
||||
|
|
@ -117,6 +112,11 @@ impl Image {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_source(&mut self, source: &str) -> &mut Self {
|
||||
self.source.with_value(source);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_template(&mut self, template: &str) -> &mut Self {
|
||||
self.template = template.to_owned();
|
||||
self
|
||||
|
|
@ -124,10 +124,6 @@ impl Image {
|
|||
|
||||
// Image GETTERS.
|
||||
|
||||
pub fn source(&self) -> &AttributeValue {
|
||||
&self.source
|
||||
}
|
||||
|
||||
pub fn id(&self) -> &IdentifierValue {
|
||||
&self.id
|
||||
}
|
||||
|
|
@ -136,6 +132,10 @@ impl Image {
|
|||
&self.classes
|
||||
}
|
||||
|
||||
pub fn source(&self) -> &AttributeValue {
|
||||
&self.source
|
||||
}
|
||||
|
||||
pub fn template(&self) -> &str {
|
||||
self.template.as_str()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,9 +176,9 @@ impl MenuItem {
|
|||
pub struct Menu {
|
||||
renderable: fn() -> bool,
|
||||
weight : isize,
|
||||
items : ComponentsBundle,
|
||||
id : IdentifierValue,
|
||||
classes : Classes,
|
||||
items : ComponentsBundle,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ impl ComponentTrait for Menu {
|
|||
self.weight
|
||||
}
|
||||
|
||||
fn default_render(&self, context: &mut InContext) -> Markup {
|
||||
fn before_render(&mut self, context: &mut InContext) {
|
||||
context
|
||||
.add_stylesheet(StyleSheet::with_source(
|
||||
"/theme/menu/css/menu.css?ver=1.1.1"
|
||||
|
|
@ -218,7 +218,9 @@ impl ComponentTrait for Menu {
|
|||
"/theme/menu/js/menu.min.js?ver=1.1.1"
|
||||
))
|
||||
.add_jquery();
|
||||
}
|
||||
|
||||
fn default_render(&self, context: &mut InContext) -> Markup {
|
||||
let id = context.required_id::<Menu>(self.id());
|
||||
html! {
|
||||
ul id=(id) class=[self.classes().get()] {
|
||||
|
|
@ -244,17 +246,6 @@ impl ComponentTrait for Menu {
|
|||
|
||||
impl Menu {
|
||||
|
||||
// Menu CONTAINER.
|
||||
|
||||
pub fn add(mut self, item: MenuItem) -> Self {
|
||||
self.items.add(item);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn items(&self) -> &ComponentsBundle {
|
||||
&self.items
|
||||
}
|
||||
|
||||
// Menu BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
|
|
@ -277,6 +268,11 @@ impl Menu {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_item(mut self, item: MenuItem) -> Self {
|
||||
self.alter_item(item);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn using_template(mut self, template: &str) -> Self {
|
||||
self.alter_template(template);
|
||||
self
|
||||
|
|
@ -304,6 +300,11 @@ impl Menu {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_item(&mut self, item: MenuItem) -> &mut Self {
|
||||
self.items.add(item);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_template(&mut self, template: &str) -> &mut Self {
|
||||
self.template = template.to_owned();
|
||||
self
|
||||
|
|
@ -319,6 +320,10 @@ impl Menu {
|
|||
&self.classes
|
||||
}
|
||||
|
||||
pub fn items(&self) -> &ComponentsBundle {
|
||||
&self.items
|
||||
}
|
||||
|
||||
pub fn template(&self) -> &str {
|
||||
self.template.as_str()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ pub enum ParagraphDisplay {
|
|||
pub struct Paragraph {
|
||||
renderable: fn() -> bool,
|
||||
weight : isize,
|
||||
html : Markup,
|
||||
display : ParagraphDisplay,
|
||||
id : IdentifierValue,
|
||||
classes : Classes,
|
||||
html : Markup,
|
||||
display : ParagraphDisplay,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -26,10 +26,10 @@ impl ComponentTrait for Paragraph {
|
|||
Paragraph {
|
||||
renderable: render_always,
|
||||
weight : 0,
|
||||
html : html! {},
|
||||
display : ParagraphDisplay::Normal,
|
||||
id : IdentifierValue::new(),
|
||||
classes : Classes::new(),
|
||||
html : html! {},
|
||||
display : ParagraphDisplay::Normal,
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
}
|
||||
|
|
@ -78,16 +78,6 @@ impl Paragraph {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_html(mut self, html: Markup) -> Self {
|
||||
self.alter_html(html);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_display(mut self, display: ParagraphDisplay) -> Self {
|
||||
self.alter_display(display);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_id(mut self, id: &str) -> Self {
|
||||
self.alter_id(id);
|
||||
self
|
||||
|
|
@ -98,6 +88,16 @@ impl Paragraph {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_html(mut self, html: Markup) -> Self {
|
||||
self.alter_html(html);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_display(mut self, display: ParagraphDisplay) -> Self {
|
||||
self.alter_display(display);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn using_template(mut self, template: &str) -> Self {
|
||||
self.alter_template(template);
|
||||
self
|
||||
|
|
@ -115,6 +115,16 @@ impl Paragraph {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_id(&mut self, id: &str) -> &mut Self {
|
||||
self.id.with_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_classes(&mut self, classes: &str, op: ClassesOp) -> &mut Self {
|
||||
self.classes.alter(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_html(&mut self, html: Markup) -> &mut Self {
|
||||
self.html = html;
|
||||
self
|
||||
|
|
@ -133,16 +143,6 @@ impl Paragraph {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_id(&mut self, id: &str) -> &mut Self {
|
||||
self.id.with_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_classes(&mut self, classes: &str, op: ClassesOp) -> &mut Self {
|
||||
self.classes.alter(classes, op);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_template(&mut self, template: &str) -> &mut Self {
|
||||
self.template = template.to_owned();
|
||||
self
|
||||
|
|
@ -150,14 +150,6 @@ impl Paragraph {
|
|||
|
||||
// Paragraph GETTERS.
|
||||
|
||||
pub fn html(&self) -> &Markup {
|
||||
&self.html
|
||||
}
|
||||
|
||||
pub fn display(&self) -> &ParagraphDisplay {
|
||||
&self.display
|
||||
}
|
||||
|
||||
pub fn id(&self) -> &IdentifierValue {
|
||||
&self.id
|
||||
}
|
||||
|
|
@ -166,6 +158,14 @@ impl Paragraph {
|
|||
&self.classes
|
||||
}
|
||||
|
||||
pub fn html(&self) -> &Markup {
|
||||
&self.html
|
||||
}
|
||||
|
||||
pub fn display(&self) -> &ParagraphDisplay {
|
||||
&self.display
|
||||
}
|
||||
|
||||
pub fn template(&self) -> &str {
|
||||
self.template.as_str()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,76 +37,68 @@ async fn demo() -> app::Result<Markup> {
|
|||
|
||||
fn hello_world() -> Container {
|
||||
Container::header()
|
||||
.add(grid::Row::new()
|
||||
.add_column(grid::Column::new()
|
||||
.add(Heading::h1(html! {
|
||||
.with_component(grid::Row::new()
|
||||
.with_column(grid::Column::new()
|
||||
.with_component(Heading::h1(html! {
|
||||
(l("page_title"))
|
||||
}).with_display(HeadingDisplay::Large))
|
||||
.add(Paragraph::with(html! {
|
||||
(t("welcome_to", &args![
|
||||
"app" => SETTINGS.app.name.as_str()
|
||||
]))
|
||||
}))
|
||||
.add(Paragraph::with(html! {
|
||||
})
|
||||
.with_display(HeadingDisplay::Large)
|
||||
)
|
||||
.with_component(Paragraph::with(html! {
|
||||
(t("welcome_to", &args!["app" => SETTINGS.app.name.as_str()]))
|
||||
})
|
||||
)
|
||||
.with_component(Paragraph::with(html! {
|
||||
(e("welcome_intro", &args![
|
||||
"app" => format!("<strong>{}</strong>", &SETTINGS.app.name)
|
||||
]))
|
||||
}).with_display(ParagraphDisplay::Small))
|
||||
.add(Paragraph::with(html! {
|
||||
})
|
||||
.with_display(ParagraphDisplay::Small)
|
||||
)
|
||||
.with_component(Paragraph::with(html! {
|
||||
(e("welcome_pagetop", &args![
|
||||
"pagetop" => "<a href=\"https://pagetop-rs\">PageTop</a>"
|
||||
]))
|
||||
}))
|
||||
.add(Anchor::button("#",
|
||||
html! {
|
||||
})
|
||||
)
|
||||
.with_component(Anchor::button("#", html! {
|
||||
("Offered services")
|
||||
}).with_left_icon(
|
||||
Icon::with("card-checklist")
|
||||
})
|
||||
.with_left_icon(Icon::with("card-checklist"))
|
||||
)
|
||||
)
|
||||
.add(Anchor::button("#",
|
||||
html! {
|
||||
.with_component(Anchor::button("#", html! {
|
||||
("Get quote")
|
||||
}).with_left_icon(
|
||||
Icon::with("envelope-open-heart-fill")
|
||||
})
|
||||
.with_left_icon(Icon::with("envelope-open-heart-fill"))
|
||||
)
|
||||
)
|
||||
)
|
||||
.add_column(grid::Column::new()
|
||||
.add(Image::image("/theme/images/demo-header.svg"))
|
||||
.with_column(grid::Column::new()
|
||||
.with_component(Image::image("/theme/images/demo-header.svg"))
|
||||
)
|
||||
.with_spaces(&[SpaceSet::PaddingBoth(SpaceValue::RelEm(2.0), SpaceValue::RelPct(5.0))])
|
||||
)
|
||||
}
|
||||
|
||||
fn just_visiting() -> Chunck {
|
||||
Chunck::with(html! {
|
||||
div id="details" class="basic-1" {
|
||||
div class="container" {
|
||||
div class="row" {
|
||||
div class="col-lg-6 col-xl-7" {
|
||||
div class="image-container" {
|
||||
img class="img-fluid" src="/bootsier/images/demo-visiting.svg" alt="alternative" {}
|
||||
}
|
||||
}
|
||||
div class="col-lg-6 col-xl-5" {
|
||||
div class="text-container" {
|
||||
h2 {
|
||||
span {
|
||||
(l("visiting_title"))
|
||||
}
|
||||
br;
|
||||
(l("visiting_subtitle"))
|
||||
}
|
||||
p { (l("visiting_text1")) }
|
||||
p { (l("visiting_text2")) }
|
||||
a class="btn-solid-reg" data-bs-toggle="modal" data-bs-target="#staticBackdrop" { "Modal" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
fn just_visiting() -> Container {
|
||||
Container::new()
|
||||
.with_component(grid::Row::new()
|
||||
.with_column(grid::Column::new()
|
||||
.with_size(grid::ColumnSize::Is5of12)
|
||||
.with_component(Image::image("/theme/images/demo-visiting.svg"))
|
||||
.with_spaces(&[SpaceSet::PaddingAll(SpaceValue::RelPct(2.0))])
|
||||
)
|
||||
.with_column(grid::Column::new()
|
||||
.with_component(Heading::h2(html! { (l("visiting_title")) }))
|
||||
.with_component(Heading::h3(html! { (l("visiting_subtitle")) }))
|
||||
.with_component(Paragraph::with(html! { (l("visiting_text1")) }))
|
||||
.with_component(Paragraph::with(html! { (l("visiting_text2")) }))
|
||||
.with_spaces(&[
|
||||
SpaceSet::PaddingTop(SpaceValue::RelPct(2.5)),
|
||||
SpaceSet::PaddingLeft(SpaceValue::RelPct(5.0)),
|
||||
])
|
||||
)
|
||||
.with_spaces(&[SpaceSet::PaddingBoth(SpaceValue::RelEm(1.0), SpaceValue::RelPct(5.0))])
|
||||
)
|
||||
}
|
||||
|
||||
fn about_pagetop() -> Chunck {
|
||||
|
|
|
|||
|
|
@ -66,7 +66,21 @@ impl ThemeTrait for Bulmix {
|
|||
},
|
||||
grid::COLUMN_COMPONENT => {
|
||||
let col = component_mut::<grid::Column>(component);
|
||||
col.alter_classes("column content", ClassesOp::SetDefault);
|
||||
col.alter_classes(concat_string!("column", match col.size() {
|
||||
grid::ColumnSize::Default => "",
|
||||
grid::ColumnSize::Is1of12 => " is-1",
|
||||
grid::ColumnSize::Is2of12 => " is-2",
|
||||
grid::ColumnSize::Is3of12 => " is-3",
|
||||
grid::ColumnSize::Is4of12 => " is-4",
|
||||
grid::ColumnSize::Is5of12 => " is-5",
|
||||
grid::ColumnSize::Is6of12 => " is-6",
|
||||
grid::ColumnSize::Is7of12 => " is-7",
|
||||
grid::ColumnSize::Is8of12 => " is-8",
|
||||
grid::ColumnSize::Is9of12 => " is-9",
|
||||
grid::ColumnSize::Is10of12 => " is-10",
|
||||
grid::ColumnSize::Is11of12 => " is-11",
|
||||
grid::ColumnSize::IsFull => " is-12",
|
||||
}, " content").as_str(), ClassesOp::SetDefault);
|
||||
},
|
||||
grid::ROW_COMPONENT => {
|
||||
let row = component_mut::<grid::Row>(component);
|
||||
|
|
@ -79,15 +93,11 @@ impl ThemeTrait for Bulmix {
|
|||
fn render_component(
|
||||
&self,
|
||||
component: &dyn ComponentTrait,
|
||||
context: &mut InContext
|
||||
_context: &mut InContext
|
||||
) -> Option<Markup> {
|
||||
match component.handler() {
|
||||
ICON_COMPONENT => {
|
||||
let icon = component_ref::<Icon>(component);
|
||||
context
|
||||
.add_stylesheet(StyleSheet::with_source(
|
||||
"/theme/icons/bootstrap-icons.css?ver=1.8.2"
|
||||
));
|
||||
Some(html! {
|
||||
span class="icon" {
|
||||
i class=[icon.classes().get()] style=[icon.spaces().get()] {};
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ pub trait ComponentTrait: AnyComponent + Send + Sync {
|
|||
0
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn before_render(&mut self, context: &mut InContext) {
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn default_render(&self, context: &mut InContext) -> Markup {
|
||||
html! {}
|
||||
|
|
@ -45,6 +49,9 @@ pub fn component_mut<C: 'static>(component: &mut dyn ComponentTrait) -> &mut C {
|
|||
}
|
||||
|
||||
pub fn render_component(component: &mut dyn ComponentTrait, context: &mut InContext) -> Markup {
|
||||
// Acciones del propio componente antes de renderizarlo.
|
||||
component.before_render(context);
|
||||
|
||||
// Acciones de los módulos antes de renderizar el componente.
|
||||
run_hooks(
|
||||
BEFORE_RENDER_COMPONENT_HOOK,
|
||||
|
|
@ -55,11 +62,9 @@ pub fn render_component(component: &mut dyn ComponentTrait, context: &mut InCont
|
|||
context.theme().before_render_component(component, context);
|
||||
|
||||
match component.is_renderable() {
|
||||
true => {
|
||||
match context.theme().render_component(component, context) {
|
||||
true => match context.theme().render_component(component, context) {
|
||||
Some(html) => html,
|
||||
None => component.default_render(context)
|
||||
}
|
||||
},
|
||||
false => html! {}
|
||||
}
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Loading…
Add table
Add a link
Reference in a new issue