🍻 Tercera revista a las traducciones por contexto
This commit is contained in:
parent
88d6ce2a72
commit
dd443ca375
21 changed files with 415 additions and 252 deletions
|
|
@ -23,6 +23,7 @@ pub enum AnchorTarget {
|
|||
}
|
||||
|
||||
pub type AnchorIcon = ComponentArc;
|
||||
pub type AnchorHtml = ComponentArc;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(Default)]
|
||||
|
|
@ -33,7 +34,7 @@ pub struct Anchor {
|
|||
classes : Classes,
|
||||
anchor_type: AnchorType,
|
||||
href : AttributeValue,
|
||||
html : HtmlMarkup,
|
||||
html10n : AnchorHtml,
|
||||
left_icon : AnchorIcon,
|
||||
right_icon : AnchorIcon,
|
||||
target : AnchorTarget,
|
||||
|
|
@ -74,7 +75,7 @@ impl ComponentTrait for Anchor {
|
|||
target=[target]
|
||||
{
|
||||
(self.left_icon().render(rcx))
|
||||
(" ") span { (*self.html()) } (" ")
|
||||
(" ") span { (self.html().render(rcx)) } (" ")
|
||||
(self.right_icon().render(rcx))
|
||||
}
|
||||
}
|
||||
|
|
@ -90,15 +91,15 @@ impl ComponentTrait for Anchor {
|
|||
}
|
||||
|
||||
impl Anchor {
|
||||
pub fn link(href: &str, html: Markup) -> Self {
|
||||
Anchor::new().with_href(href).with_html(html)
|
||||
pub fn link(href: &str, html10n: L10n) -> Self {
|
||||
Anchor::new().with_href(href).with_html(html10n)
|
||||
}
|
||||
|
||||
pub fn button(href: &str, html: Markup) -> Self {
|
||||
pub fn button(href: &str, html10n: L10n) -> Self {
|
||||
Anchor::new()
|
||||
.with_type(AnchorType::Button)
|
||||
.with_href(href)
|
||||
.with_html(html)
|
||||
.with_html(html10n)
|
||||
}
|
||||
|
||||
pub fn location(id: &str) -> Self {
|
||||
|
|
@ -151,20 +152,20 @@ impl Anchor {
|
|||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_html(&mut self, html: Markup) -> &mut Self {
|
||||
self.html.markup = html;
|
||||
pub fn alter_html(&mut self, html10n: L10n) -> &mut Self {
|
||||
self.html10n.set(html10n);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_left_icon(&mut self, icon: Icon) -> &mut Self {
|
||||
self.left_icon.replace(icon);
|
||||
self.left_icon.set(icon);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_right_icon(&mut self, icon: Icon) -> &mut Self {
|
||||
self.right_icon.replace(icon);
|
||||
self.right_icon.set(icon);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -198,8 +199,8 @@ impl Anchor {
|
|||
&self.href
|
||||
}
|
||||
|
||||
pub fn html(&self) -> &Markup {
|
||||
&self.html.markup
|
||||
pub fn html(&self) -> &AnchorHtml {
|
||||
&self.html10n
|
||||
}
|
||||
|
||||
pub fn left_icon(&self) -> &AnchorIcon {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ pub enum ButtonType {
|
|||
Reset,
|
||||
}
|
||||
|
||||
pub type ButtonValue = ComponentArc;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(Default)]
|
||||
pub struct Button {
|
||||
|
|
@ -18,7 +20,7 @@ pub struct Button {
|
|||
classes : Classes,
|
||||
button_type: ButtonType,
|
||||
name : AttributeValue,
|
||||
value : AttributeValue,
|
||||
value : ButtonValue,
|
||||
autofocus : AttributeValue,
|
||||
disabled : AttributeValue,
|
||||
template : String,
|
||||
|
|
@ -43,7 +45,7 @@ impl ComponentTrait for Button {
|
|||
(self.renderable.check)(rcx)
|
||||
}
|
||||
|
||||
fn default_render(&self, _: &mut RenderContext) -> Markup {
|
||||
fn default_render(&self, rcx: &mut RenderContext) -> Markup {
|
||||
let button_type = match self.button_type() {
|
||||
ButtonType::Button => "button",
|
||||
ButtonType::Submit => "submit",
|
||||
|
|
@ -56,11 +58,11 @@ impl ComponentTrait for Button {
|
|||
id=[id]
|
||||
class=[self.classes().get()]
|
||||
name=[self.name().get()]
|
||||
value=[self.value().get()]
|
||||
value=(self.value().render(rcx))
|
||||
autofocus=[self.autofocus().get()]
|
||||
disabled=[self.disabled().get()]
|
||||
{
|
||||
@if let Some(value) = self.value().get() { (value) }
|
||||
(self.value().render(rcx))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -75,11 +77,11 @@ impl ComponentTrait for Button {
|
|||
}
|
||||
|
||||
impl Button {
|
||||
pub fn with(value: &str) -> Self {
|
||||
pub fn with(value: L10n) -> Self {
|
||||
Button::new().with_value(value)
|
||||
}
|
||||
|
||||
pub fn submit(value: &str) -> Self {
|
||||
pub fn submit(value: L10n) -> Self {
|
||||
let mut button = Button::new()
|
||||
.with_classes(ClassesOp::Replace("form-button"), "form-submit")
|
||||
.with_value(value);
|
||||
|
|
@ -87,7 +89,7 @@ impl Button {
|
|||
button
|
||||
}
|
||||
|
||||
pub fn reset(value: &str) -> Self {
|
||||
pub fn reset(value: L10n) -> Self {
|
||||
let mut button = Button::new()
|
||||
.with_classes(ClassesOp::Replace("form-button"), "form-reset")
|
||||
.with_value(value);
|
||||
|
|
@ -122,8 +124,8 @@ impl Button {
|
|||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_value(&mut self, value: &str) -> &mut Self {
|
||||
self.value.alter_value(value);
|
||||
pub fn alter_value(&mut self, value: L10n) -> &mut Self {
|
||||
self.value.set(value);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -165,7 +167,7 @@ impl Button {
|
|||
&self.name
|
||||
}
|
||||
|
||||
pub fn value(&self) -> &AttributeValue {
|
||||
pub fn value(&self) -> &ButtonValue {
|
||||
&self.value
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ pub enum InputType {
|
|||
Url,
|
||||
}
|
||||
|
||||
pub type InputLabel = ComponentArc;
|
||||
pub type InputHelpText = ComponentArc;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(Default)]
|
||||
pub struct Input {
|
||||
|
|
@ -22,7 +25,7 @@ pub struct Input {
|
|||
input_type : InputType,
|
||||
name : NameValue,
|
||||
value : AttributeValue,
|
||||
label : AttributeValue,
|
||||
label : InputLabel,
|
||||
size : Option<u16>,
|
||||
minlength : Option<u16>,
|
||||
maxlength : Option<u16>,
|
||||
|
|
@ -32,7 +35,7 @@ pub struct Input {
|
|||
disabled : AttributeValue,
|
||||
readonly : AttributeValue,
|
||||
required : AttributeValue,
|
||||
help_text : AttributeValue,
|
||||
help_text : InputHelpText,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +61,7 @@ impl ComponentTrait for Input {
|
|||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
fn default_render(&self, _: &mut RenderContext) -> Markup {
|
||||
fn default_render(&self, rcx: &mut RenderContext) -> Markup {
|
||||
let type_input = match self.input_type() {
|
||||
InputType::Textfield => "text",
|
||||
InputType::Password => "password",
|
||||
|
|
@ -70,7 +73,7 @@ impl ComponentTrait for Input {
|
|||
let id = self.name().get().map(|name| concat_string!("edit-", name));
|
||||
html! {
|
||||
div class=[self.classes().get()] {
|
||||
@if let Some(label) = self.label().get() {
|
||||
@if let Some(label) = self.label().optional_render(rcx) {
|
||||
label class="form-label" for=[&id] {
|
||||
(label) " "
|
||||
@if self.required().get().is_some() {
|
||||
|
|
@ -95,8 +98,8 @@ impl ComponentTrait for Input {
|
|||
readonly=[self.readonly().get()]
|
||||
required=[self.required().get()]
|
||||
disabled=[self.disabled().get()];
|
||||
@if let Some(help_text) = self.help_text().get() {
|
||||
div class="form-text" { (help_text) }
|
||||
@if let Some(description) = self.help_text().optional_render(rcx) {
|
||||
div class="form-text" { (description) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -203,8 +206,8 @@ impl Input {
|
|||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_label(&mut self, label: &str) -> &mut Self {
|
||||
self.label.alter_value(label);
|
||||
pub fn alter_label(&mut self, label: L10n) -> &mut Self {
|
||||
self.label.set(label);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -278,8 +281,8 @@ impl Input {
|
|||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_help_text(&mut self, help_text: &str) -> &mut Self {
|
||||
self.help_text.alter_value(help_text);
|
||||
pub fn alter_help_text(&mut self, help_text: L10n) -> &mut Self {
|
||||
self.help_text.set(help_text);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -307,7 +310,7 @@ impl Input {
|
|||
&self.value
|
||||
}
|
||||
|
||||
pub fn label(&self) -> &AttributeValue {
|
||||
pub fn label(&self) -> &InputLabel {
|
||||
&self.label
|
||||
}
|
||||
|
||||
|
|
@ -347,7 +350,7 @@ impl Input {
|
|||
&self.required
|
||||
}
|
||||
|
||||
pub fn help_text(&self) -> &AttributeValue {
|
||||
pub fn help_text(&self) -> &InputHelpText {
|
||||
&self.help_text
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ pub enum HeadingDisplay {
|
|||
Subtitle,
|
||||
}
|
||||
|
||||
pub type HeadingText = ComponentArc;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(Default)]
|
||||
pub struct Heading {
|
||||
|
|
@ -33,7 +35,7 @@ pub struct Heading {
|
|||
id : IdentifierValue,
|
||||
classes : Classes,
|
||||
heading_type: HeadingType,
|
||||
html : HtmlMarkup,
|
||||
text : HeadingText,
|
||||
display : HeadingDisplay,
|
||||
template : String,
|
||||
}
|
||||
|
|
@ -55,16 +57,16 @@ impl ComponentTrait for Heading {
|
|||
(self.renderable.check)(rcx)
|
||||
}
|
||||
|
||||
fn default_render(&self, _: &mut RenderContext) -> Markup {
|
||||
fn default_render(&self, rcx: &mut RenderContext) -> Markup {
|
||||
let id = self.id().get();
|
||||
let classes = self.classes().get();
|
||||
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()) },
|
||||
HeadingType::H4 => h4 id=[id] class=[classes] { (*self.html()) },
|
||||
HeadingType::H5 => h5 id=[id] class=[classes] { (*self.html()) },
|
||||
HeadingType::H6 => h6 id=[id] class=[classes] { (*self.html()) },
|
||||
HeadingType::H1 => h1 id=[id] class=[classes] { (self.text().render(rcx)) },
|
||||
HeadingType::H2 => h2 id=[id] class=[classes] { (self.text().render(rcx)) },
|
||||
HeadingType::H3 => h3 id=[id] class=[classes] { (self.text().render(rcx)) },
|
||||
HeadingType::H4 => h4 id=[id] class=[classes] { (self.text().render(rcx)) },
|
||||
HeadingType::H5 => h5 id=[id] class=[classes] { (self.text().render(rcx)) },
|
||||
HeadingType::H6 => h6 id=[id] class=[classes] { (self.text().render(rcx)) },
|
||||
}}
|
||||
}
|
||||
|
||||
|
|
@ -78,40 +80,40 @@ impl ComponentTrait for Heading {
|
|||
}
|
||||
|
||||
impl Heading {
|
||||
pub fn h1(html: Markup) -> Self {
|
||||
pub fn h1(text: L10n) -> Self {
|
||||
Heading::new()
|
||||
.with_heading_type(HeadingType::H1)
|
||||
.with_html(html)
|
||||
.with_text(text)
|
||||
}
|
||||
|
||||
pub fn h2(html: Markup) -> Self {
|
||||
pub fn h2(text: L10n) -> Self {
|
||||
Heading::new()
|
||||
.with_heading_type(HeadingType::H2)
|
||||
.with_html(html)
|
||||
.with_text(text)
|
||||
}
|
||||
|
||||
pub fn h3(html: Markup) -> Self {
|
||||
pub fn h3(text: L10n) -> Self {
|
||||
Heading::new()
|
||||
.with_heading_type(HeadingType::H3)
|
||||
.with_html(html)
|
||||
.with_text(text)
|
||||
}
|
||||
|
||||
pub fn h4(html: Markup) -> Self {
|
||||
pub fn h4(text: L10n) -> Self {
|
||||
Heading::new()
|
||||
.with_heading_type(HeadingType::H4)
|
||||
.with_html(html)
|
||||
.with_text(text)
|
||||
}
|
||||
|
||||
pub fn h5(html: Markup) -> Self {
|
||||
pub fn h5(text: L10n) -> Self {
|
||||
Heading::new()
|
||||
.with_heading_type(HeadingType::H5)
|
||||
.with_html(html)
|
||||
.with_text(text)
|
||||
}
|
||||
|
||||
pub fn h6(html: Markup) -> Self {
|
||||
pub fn h6(text: L10n) -> Self {
|
||||
Heading::new()
|
||||
.with_heading_type(HeadingType::H6)
|
||||
.with_html(html)
|
||||
.with_text(text)
|
||||
}
|
||||
|
||||
// Heading BUILDER.
|
||||
|
|
@ -147,8 +149,8 @@ impl Heading {
|
|||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_html(&mut self, html: Markup) -> &mut Self {
|
||||
self.html.markup = html;
|
||||
pub fn alter_text(&mut self, text: L10n) -> &mut Self {
|
||||
self.text.set(text);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -191,8 +193,8 @@ impl Heading {
|
|||
&self.heading_type
|
||||
}
|
||||
|
||||
pub fn html(&self) -> &Markup {
|
||||
&self.html.markup
|
||||
pub fn text(&self) -> &HeadingText {
|
||||
&self.text
|
||||
}
|
||||
|
||||
pub fn display(&self) -> &HeadingDisplay {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
use crate::component::Html;
|
||||
|
||||
define_handle!(COMPONENT_PARAGRAPH);
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
@ -65,8 +63,8 @@ impl ComponentTrait for Paragraph {
|
|||
}
|
||||
|
||||
impl Paragraph {
|
||||
pub fn with(html: Markup) -> Self {
|
||||
Paragraph::new().with_component(Html::with(html))
|
||||
pub fn with(component: impl ComponentTrait) -> Self {
|
||||
Paragraph::new().with_component(component)
|
||||
}
|
||||
|
||||
// Paragraph BUILDER.
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ impl ModuleTrait for Menu {
|
|||
}
|
||||
|
||||
fn name(&self) -> String {
|
||||
_t("module_name", Locale::From(&LOCALE_MENU))
|
||||
t("module_name", Locale::From(&LOCALE_MENU))
|
||||
}
|
||||
|
||||
fn description(&self) -> Option<String> {
|
||||
Some(_t("module_description", Locale::From(&LOCALE_MENU)))
|
||||
Some(t("module_description", Locale::From(&LOCALE_MENU)))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue