Añade componentes básicos traducibles Html/Text

This commit is contained in:
Manuel Cillero 2023-05-30 19:13:13 +02:00
parent 6c76e3519c
commit 1d83bbc80a
20 changed files with 243 additions and 369 deletions

View file

@ -16,6 +16,7 @@ license = "Apache-2.0 OR MIT"
[dependencies]
pagetop = { version = "0.0", path = "../pagetop" }
pagetop-jquery = { version = "0.0", path = "../pagetop-jquery" }
pagetop-minimal = { version = "0.0", path = "../pagetop-minimal" }
static-files = "0.2.3"
[build-dependencies]

View file

@ -2,7 +2,8 @@ use pagetop::prelude::*;
define_handle!(COMPONENT_MEGAMENUITEM);
type Label = OneComponent<L10n>;
type Label = OneComponent<Text>;
type Content = OneComponent<Html>;
#[derive(Default)]
pub enum MegaMenuItemType {
@ -11,7 +12,7 @@ pub enum MegaMenuItemType {
Label(Label),
Link(Label, String),
LinkBlank(Label, String),
Html(Markup),
Html(Content),
Submenu(Label, MegaMenu),
Separator,
}
@ -58,8 +59,8 @@ impl ComponentTrait for MegaMenuItem {
a href=(path) target="_blank" { (label.render(rcx)) }
}
},
MegaMenuItemType::Html(html) => html! {
li class="html" { (*html) }
MegaMenuItemType::Html(content) => html! {
li class="html" { (content.render(rcx)) }
},
MegaMenuItemType::Submenu(label, menu) => html! {
li class="submenu" {
@ -85,35 +86,35 @@ impl ComponentTrait for MegaMenuItem {
}
impl MegaMenuItem {
pub fn label(label: L10n) -> Self {
pub fn label(label: Text) -> Self {
MegaMenuItem {
item_type: MegaMenuItemType::Label(OneComponent::new_with(label)),
..Default::default()
}
}
pub fn link(label: L10n, path: &str) -> Self {
pub fn link(label: Text, path: &str) -> Self {
MegaMenuItem {
item_type: MegaMenuItemType::Link(OneComponent::new_with(label), path.to_owned()),
..Default::default()
}
}
pub fn link_blank(label: L10n, path: &str) -> Self {
pub fn link_blank(label: Text, path: &str) -> Self {
MegaMenuItem {
item_type: MegaMenuItemType::LinkBlank(OneComponent::new_with(label), path.to_owned()),
..Default::default()
}
}
pub fn html(html: Markup) -> Self {
pub fn html(content: Html) -> Self {
MegaMenuItem {
item_type: MegaMenuItemType::Html(html),
item_type: MegaMenuItemType::Html(OneComponent::new_with(content)),
..Default::default()
}
}
pub fn submenu(label: L10n, menu: MegaMenu) -> Self {
pub fn submenu(label: Text, menu: MegaMenu) -> Self {
MegaMenuItem {
item_type: MegaMenuItemType::Submenu(OneComponent::new_with(label), menu),
..Default::default()

View file

@ -14,7 +14,7 @@ impl ModuleTrait for MegaMenu {
}
fn dependencies(&self) -> Vec<ModuleStaticRef> {
vec![&pagetop_jquery::JQuery]
vec![&pagetop_jquery::JQuery, &pagetop_minimal::Minimal]
}
fn configure_service(&self, cfg: &mut server::web::ServiceConfig) {