👽️ Apply latest changes to the API
This commit is contained in:
parent
9c16aa2519
commit
255fb393a9
6 changed files with 53 additions and 18 deletions
|
|
@ -75,13 +75,13 @@ fn hello_world() -> Wrapper {
|
||||||
L10n::t("hello_code", &LOCALES_HOMEDEMO),
|
L10n::t("hello_code", &LOCALES_HOMEDEMO),
|
||||||
)
|
)
|
||||||
.with_target(ButtonTarget::Blank)
|
.with_target(ButtonTarget::Blank)
|
||||||
.with_left_icon(Icon::with("git"))
|
.with_left_icon(Some(Icon::with("git")))
|
||||||
.with_classes(ClassesOp::Add, "code-link")
|
.with_classes(ClassesOp::Add, "code-link")
|
||||||
.with_font_size(FontSize::Medium),
|
.with_font_size(FontSize::Medium),
|
||||||
)
|
)
|
||||||
.add_component(
|
.add_component(
|
||||||
Button::link("#welcome", L10n::t("hello_welcome", &LOCALES_HOMEDEMO))
|
Button::link("#welcome", L10n::t("hello_welcome", &LOCALES_HOMEDEMO))
|
||||||
.with_left_icon(Icon::with("arrow-down-circle-fill"))
|
.with_left_icon(Some(Icon::with("arrow-down-circle-fill")))
|
||||||
.with_classes(ClassesOp::Add, "welcome-link")
|
.with_classes(ClassesOp::Add, "welcome-link")
|
||||||
.with_font_size(FontSize::Medium),
|
.with_font_size(FontSize::Medium),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -34,12 +34,13 @@ impl ComponentTrait for Branding {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
||||||
|
let logo = self.logo().render(cx);
|
||||||
let title = L10n::l("site_home").using(cx.langid());
|
let title = L10n::l("site_home").using(cx.langid());
|
||||||
PrepareMarkup::With(html! {
|
PrepareMarkup::With(html! {
|
||||||
div id=[self.id()] class="pt-branding" {
|
div id=[self.id()] class="pt-branding" {
|
||||||
div class="pt-branding__wrapper" {
|
div class="pt-branding__wrapper" {
|
||||||
div class="pt-branding__logo" {
|
@if !logo.is_empty() {
|
||||||
(self.logo().render(cx))
|
div class="pt-branding__logo" { (logo) }
|
||||||
}
|
}
|
||||||
div class="pt-branding__text" {
|
div class="pt-branding__text" {
|
||||||
div class="pt-branding__name" {
|
div class="pt-branding__name" {
|
||||||
|
|
@ -93,8 +94,8 @@ impl Branding {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_logo(&mut self, logo: Image) -> &mut Self {
|
pub fn alter_logo(&mut self, logo: Option<Image>) -> &mut Self {
|
||||||
self.logo.set(logo);
|
self.logo.alter_value(logo);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,7 +115,7 @@ impl Branding {
|
||||||
&self.slogan
|
&self.slogan
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn logo(&self) -> &ArcTypedComponent<Image> {
|
pub fn logo(&self) -> &OptionComponent<Image> {
|
||||||
&self.logo
|
&self.logo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@ pub struct Button {
|
||||||
font_size : FontSize,
|
font_size : FontSize,
|
||||||
href : OptionString,
|
href : OptionString,
|
||||||
html : OptionTranslated,
|
html : OptionTranslated,
|
||||||
left_icon : ButtonIcon,
|
left_icon : OptionComponent<Icon>,
|
||||||
right_icon : ButtonIcon,
|
right_icon : OptionComponent<Icon>,
|
||||||
target : ButtonTarget,
|
target : ButtonTarget,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,7 +85,7 @@ impl ComponentTrait for Button {
|
||||||
target=[target]
|
target=[target]
|
||||||
{
|
{
|
||||||
(self.left_icon().render(cx))
|
(self.left_icon().render(cx))
|
||||||
" " span { (self.html().escaped(cx.langid()).unwrap_or_default()) } " "
|
" " span { (self.html().escaped(cx.langid())) } " "
|
||||||
(self.right_icon().render(cx))
|
(self.right_icon().render(cx))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -163,14 +163,14 @@ impl Button {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_left_icon(&mut self, icon: Icon) -> &mut Self {
|
pub fn alter_left_icon(&mut self, icon: Option<Icon>) -> &mut Self {
|
||||||
self.left_icon.set(icon);
|
self.left_icon.alter_value(icon);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_right_icon(&mut self, icon: Icon) -> &mut Self {
|
pub fn alter_right_icon(&mut self, icon: Option<Icon>) -> &mut Self {
|
||||||
self.right_icon.set(icon);
|
self.right_icon.alter_value(icon);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -198,11 +198,11 @@ impl Button {
|
||||||
&self.html
|
&self.html
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn left_icon(&self) -> &ButtonIcon {
|
pub fn left_icon(&self) -> &OptionComponent<Icon> {
|
||||||
&self.left_icon
|
&self.left_icon
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn right_icon(&self) -> &ButtonIcon {
|
pub fn right_icon(&self) -> &OptionComponent<Icon> {
|
||||||
&self.right_icon
|
&self.right_icon
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ impl ComponentTrait for Button {
|
||||||
autofocus=[self.autofocus().get()]
|
autofocus=[self.autofocus().get()]
|
||||||
disabled=[self.disabled().get()]
|
disabled=[self.disabled().get()]
|
||||||
{
|
{
|
||||||
(self.value().escaped(cx.langid()).unwrap_or_default())
|
(self.value().escaped(cx.langid()))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ impl ComponentTrait for Heading {
|
||||||
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
||||||
let id = self.id();
|
let id = self.id();
|
||||||
let classes = self.classes().get();
|
let classes = self.classes().get();
|
||||||
let text = self.text().escaped(cx.langid()).unwrap_or_default();
|
let text = self.text().escaped(cx.langid());
|
||||||
PrepareMarkup::With(html! { @match &self.heading_type() {
|
PrepareMarkup::With(html! { @match &self.heading_type() {
|
||||||
HeadingType::H1 => h1 id=[id] class=[classes] { (text) },
|
HeadingType::H1 => h1 id=[id] class=[classes] { (text) },
|
||||||
HeadingType::H2 => h2 id=[id] class=[classes] { (text) },
|
HeadingType::H2 => h2 id=[id] class=[classes] { (text) },
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@ pub struct Item {
|
||||||
renderable : Renderable,
|
renderable : Renderable,
|
||||||
item_type : ItemType,
|
item_type : ItemType,
|
||||||
description: OptionTranslated,
|
description: OptionTranslated,
|
||||||
|
left_icon : OptionComponent<Icon>,
|
||||||
|
right_icon : OptionComponent<Icon>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_handle!(COMPONENT_BASE_MENU_ITEM for Item);
|
impl_handle!(COMPONENT_BASE_MENU_ITEM for Item);
|
||||||
|
|
@ -47,26 +49,36 @@ impl ComponentTrait for Item {
|
||||||
|
|
||||||
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
||||||
let description = self.description.using(cx.langid());
|
let description = self.description.using(cx.langid());
|
||||||
|
|
||||||
|
let left_icon = self.left_icon().render(cx);
|
||||||
|
let right_icon = self.right_icon().render(cx);
|
||||||
|
|
||||||
match self.item_type() {
|
match self.item_type() {
|
||||||
ItemType::Void => PrepareMarkup::None,
|
ItemType::Void => PrepareMarkup::None,
|
||||||
ItemType::Label(label) => PrepareMarkup::With(html! {
|
ItemType::Label(label) => PrepareMarkup::With(html! {
|
||||||
li class="pt-menu__label" {
|
li class="pt-menu__label" {
|
||||||
span title=[description] {
|
span title=[description] {
|
||||||
|
(left_icon)
|
||||||
(label.escaped(cx.langid()))
|
(label.escaped(cx.langid()))
|
||||||
|
(right_icon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
ItemType::Link(label, path) => PrepareMarkup::With(html! {
|
ItemType::Link(label, path) => PrepareMarkup::With(html! {
|
||||||
li class="pt-menu__link" {
|
li class="pt-menu__link" {
|
||||||
a href=(path(cx)) title=[description] {
|
a href=(path(cx)) title=[description] {
|
||||||
|
(left_icon)
|
||||||
(label.escaped(cx.langid()))
|
(label.escaped(cx.langid()))
|
||||||
|
(right_icon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
ItemType::LinkBlank(label, path) => PrepareMarkup::With(html! {
|
ItemType::LinkBlank(label, path) => PrepareMarkup::With(html! {
|
||||||
li class="pt-menu__link" {
|
li class="pt-menu__link" {
|
||||||
a href=(path(cx)) title=[description] target="_blank" {
|
a href=(path(cx)) title=[description] target="_blank" {
|
||||||
|
(left_icon)
|
||||||
(label.escaped(cx.langid()))
|
(label.escaped(cx.langid()))
|
||||||
|
(right_icon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
@ -78,6 +90,7 @@ impl ComponentTrait for Item {
|
||||||
ItemType::Submenu(label, submenu) => PrepareMarkup::With(html! {
|
ItemType::Submenu(label, submenu) => PrepareMarkup::With(html! {
|
||||||
li class="pt-menu__children" {
|
li class="pt-menu__children" {
|
||||||
a href="#" title=[description] {
|
a href="#" title=[description] {
|
||||||
|
(left_icon)
|
||||||
(label.escaped(cx.langid())) i class="pt-menu__icon bi-chevron-down" {}
|
(label.escaped(cx.langid())) i class="pt-menu__icon bi-chevron-down" {}
|
||||||
}
|
}
|
||||||
div class="pt-menu__subs" {
|
div class="pt-menu__subs" {
|
||||||
|
|
@ -88,6 +101,7 @@ impl ComponentTrait for Item {
|
||||||
ItemType::Megamenu(label, megamenu) => PrepareMarkup::With(html! {
|
ItemType::Megamenu(label, megamenu) => PrepareMarkup::With(html! {
|
||||||
li class="pt-menu__children" {
|
li class="pt-menu__children" {
|
||||||
a href="#" title=[description] {
|
a href="#" title=[description] {
|
||||||
|
(left_icon)
|
||||||
(label.escaped(cx.langid())) i class="pt-menu__icon bi-chevron-down" {}
|
(label.escaped(cx.langid())) i class="pt-menu__icon bi-chevron-down" {}
|
||||||
}
|
}
|
||||||
div class="pt-menu__subs pt-menu__mega" {
|
div class="pt-menu__subs pt-menu__mega" {
|
||||||
|
|
@ -162,6 +176,18 @@ impl Item {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[fn_builder]
|
||||||
|
pub fn alter_left_icon(&mut self, icon: Option<Icon>) -> &mut Self {
|
||||||
|
self.left_icon.alter_value(icon);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
#[fn_builder]
|
||||||
|
pub fn alter_right_icon(&mut self, icon: Option<Icon>) -> &mut Self {
|
||||||
|
self.right_icon.alter_value(icon);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
// Item GETTERS.
|
// Item GETTERS.
|
||||||
|
|
||||||
pub fn item_type(&self) -> &ItemType {
|
pub fn item_type(&self) -> &ItemType {
|
||||||
|
|
@ -171,4 +197,12 @@ impl Item {
|
||||||
pub fn description(&self) -> &OptionTranslated {
|
pub fn description(&self) -> &OptionTranslated {
|
||||||
&self.description
|
&self.description
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn left_icon(&self) -> &OptionComponent<Icon> {
|
||||||
|
&self.left_icon
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn right_icon(&self) -> &OptionComponent<Icon> {
|
||||||
|
&self.right_icon
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue