♻️ (locale): Renombra L10n a Lc
Simplifica el nombre del tipo de localización. Actualiza todas las referencias en el crate principal, extensiones, ejemplos y tests.
This commit is contained in:
parent
3198b74399
commit
be10dd28a1
65 changed files with 612 additions and 621 deletions
|
|
@ -21,13 +21,13 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||||
.with_child(
|
.with_child(
|
||||||
Intro::default()
|
Intro::default()
|
||||||
.with_opening(IntroOpening::Custom)
|
.with_opening(IntroOpening::Custom)
|
||||||
.with_title(L10n::t("title", &LOC))
|
.with_title(Lc::t("title", &LOC))
|
||||||
.with_slogan(L10n::t("slogan", &LOC))
|
.with_slogan(Lc::t("slogan", &LOC))
|
||||||
.with_button(None::<(L10n, Route)>)
|
.with_button(None::<(Lc, Route)>)
|
||||||
// Bloque 1: casillas, interruptores y botones de opción.
|
// Bloque 1: casillas, interruptores y botones de opción.
|
||||||
.with_child(
|
.with_child(
|
||||||
Block::new()
|
Block::new()
|
||||||
.with_title(L10n::t("block_selections", &LOC))
|
.with_title(Lc::t("block_selections", &LOC))
|
||||||
.with_child(
|
.with_child(
|
||||||
Form::new()
|
Form::new()
|
||||||
.with_id("form-selections")
|
.with_id("form-selections")
|
||||||
|
|
@ -36,69 +36,69 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||||
// Casillas e interruptores (form::Checkbox).
|
// Casillas e interruptores (form::Checkbox).
|
||||||
.with_child(
|
.with_child(
|
||||||
form::Fieldset::new()
|
form::Fieldset::new()
|
||||||
.with_legend(L10n::t("fieldset_checkbox", &LOC))
|
.with_legend(Lc::t("fieldset_checkbox", &LOC))
|
||||||
.with_description(L10n::t("desc_checkbox", &LOC))
|
.with_description(Lc::t("desc_checkbox", &LOC))
|
||||||
.with_child(
|
.with_child(
|
||||||
form::Checkbox::new()
|
form::Checkbox::new()
|
||||||
.with_name("accept_terms")
|
.with_name("accept_terms")
|
||||||
.with_label(L10n::t("label_terms", &LOC))
|
.with_label(Lc::t("label_terms", &LOC))
|
||||||
.with_required(true),
|
.with_required(true),
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
form::Checkbox::new()
|
form::Checkbox::new()
|
||||||
.with_name("accept_marketing")
|
.with_name("accept_marketing")
|
||||||
.with_label(L10n::t("label_marketing", &LOC))
|
.with_label(Lc::t("label_marketing", &LOC))
|
||||||
.with_checked(true)
|
.with_checked(true)
|
||||||
.with_inline(true),
|
.with_inline(true),
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
form::Checkbox::new()
|
form::Checkbox::new()
|
||||||
.with_name("newsletter")
|
.with_name("newsletter")
|
||||||
.with_label(L10n::t("label_newsletter", &LOC))
|
.with_label(Lc::t("label_newsletter", &LOC))
|
||||||
.with_inline(true),
|
.with_inline(true),
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
form::Checkbox::switch()
|
form::Checkbox::switch()
|
||||||
.with_name("notifications")
|
.with_name("notifications")
|
||||||
.with_label(L10n::t("label_notifications", &LOC))
|
.with_label(Lc::t("label_notifications", &LOC))
|
||||||
.with_checked(true)
|
.with_checked(true)
|
||||||
.with_reverse(true),
|
.with_reverse(true),
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
form::Checkbox::switch()
|
form::Checkbox::switch()
|
||||||
.with_name("dark_mode")
|
.with_name("dark_mode")
|
||||||
.with_label(L10n::t("label_dark_mode", &LOC))
|
.with_label(Lc::t("label_dark_mode", &LOC))
|
||||||
.with_disabled(true),
|
.with_disabled(true),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
// Grupo de casillas de verificación (form::check::Field).
|
// Grupo de casillas de verificación (form::check::Field).
|
||||||
.with_child(
|
.with_child(
|
||||||
form::Fieldset::new()
|
form::Fieldset::new()
|
||||||
.with_legend(L10n::t("fieldset_checkgroup", &LOC))
|
.with_legend(Lc::t("fieldset_checkgroup", &LOC))
|
||||||
.with_child(
|
.with_child(
|
||||||
form::check::Field::new()
|
form::check::Field::new()
|
||||||
.with_name("interests")
|
.with_name("interests")
|
||||||
.with_label(L10n::t("label_interests", &LOC))
|
.with_label(Lc::t("label_interests", &LOC))
|
||||||
.with_help_text(L10n::t("help_interests", &LOC))
|
.with_help_text(Lc::t("help_interests", &LOC))
|
||||||
.with_item(
|
.with_item(
|
||||||
form::check::Item::new(
|
form::check::Item::new(
|
||||||
"rust",
|
"rust",
|
||||||
L10n::t("check_rust", &LOC),
|
Lc::t("check_rust", &LOC),
|
||||||
)
|
)
|
||||||
.with_checked(true),
|
.with_checked(true),
|
||||||
)
|
)
|
||||||
.with_item(form::check::Item::new(
|
.with_item(form::check::Item::new(
|
||||||
"web",
|
"web",
|
||||||
L10n::t("check_web", &LOC),
|
Lc::t("check_web", &LOC),
|
||||||
))
|
))
|
||||||
.with_item(form::check::Item::new(
|
.with_item(form::check::Item::new(
|
||||||
"ai",
|
"ai",
|
||||||
L10n::t("check_ai", &LOC),
|
Lc::t("check_ai", &LOC),
|
||||||
))
|
))
|
||||||
.with_item(
|
.with_item(
|
||||||
form::check::Item::new(
|
form::check::Item::new(
|
||||||
"games",
|
"games",
|
||||||
L10n::t("check_games", &LOC),
|
Lc::t("check_games", &LOC),
|
||||||
)
|
)
|
||||||
.with_disabled(true),
|
.with_disabled(true),
|
||||||
),
|
),
|
||||||
|
|
@ -107,30 +107,30 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||||
// Botones de opción (form::radio::Field).
|
// Botones de opción (form::radio::Field).
|
||||||
.with_child(
|
.with_child(
|
||||||
form::Fieldset::new()
|
form::Fieldset::new()
|
||||||
.with_legend(L10n::t("fieldset_radio", &LOC))
|
.with_legend(Lc::t("fieldset_radio", &LOC))
|
||||||
.with_child(
|
.with_child(
|
||||||
form::radio::Field::new()
|
form::radio::Field::new()
|
||||||
.with_name("frequency")
|
.with_name("frequency")
|
||||||
.with_label(L10n::t("label_frequency", &LOC))
|
.with_label(Lc::t("label_frequency", &LOC))
|
||||||
.with_item(form::radio::Item::new(
|
.with_item(form::radio::Item::new(
|
||||||
"daily",
|
"daily",
|
||||||
L10n::t("radio_daily", &LOC),
|
Lc::t("radio_daily", &LOC),
|
||||||
))
|
))
|
||||||
.with_item(
|
.with_item(
|
||||||
form::radio::Item::new(
|
form::radio::Item::new(
|
||||||
"weekly",
|
"weekly",
|
||||||
L10n::t("radio_weekly", &LOC),
|
Lc::t("radio_weekly", &LOC),
|
||||||
)
|
)
|
||||||
.with_checked(true),
|
.with_checked(true),
|
||||||
)
|
)
|
||||||
.with_item(form::radio::Item::new(
|
.with_item(form::radio::Item::new(
|
||||||
"monthly",
|
"monthly",
|
||||||
L10n::t("radio_monthly", &LOC),
|
Lc::t("radio_monthly", &LOC),
|
||||||
))
|
))
|
||||||
.with_item(
|
.with_item(
|
||||||
form::radio::Item::new(
|
form::radio::Item::new(
|
||||||
"never",
|
"never",
|
||||||
L10n::t("radio_never", &LOC),
|
Lc::t("radio_never", &LOC),
|
||||||
)
|
)
|
||||||
.with_disabled(true),
|
.with_disabled(true),
|
||||||
),
|
),
|
||||||
|
|
@ -139,18 +139,18 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||||
// Campo oculto (form::Hidden).
|
// Campo oculto (form::Hidden).
|
||||||
.with_child(form::Hidden::field("origin", "form-selections"))
|
.with_child(form::Hidden::field("origin", "form-selections"))
|
||||||
// Botones de acción.
|
// Botones de acción.
|
||||||
.with_child(Button::submit(L10n::t("btn_submit", &LOC)).with_prop(
|
.with_child(Button::submit(Lc::t("btn_submit", &LOC)).with_prop(
|
||||||
PropsOp::add_classes(class::ButtonColor::solid(
|
PropsOp::add_classes(class::ButtonColor::solid(
|
||||||
ThemeColor::Primary,
|
ThemeColor::Primary,
|
||||||
)),
|
)),
|
||||||
))
|
))
|
||||||
.with_child(Button::reset(L10n::t("btn_reset", &LOC)).with_prop(
|
.with_child(Button::reset(Lc::t("btn_reset", &LOC)).with_prop(
|
||||||
PropsOp::add_classes(class::ButtonColor::outline(
|
PropsOp::add_classes(class::ButtonColor::outline(
|
||||||
ThemeColor::Secondary,
|
ThemeColor::Secondary,
|
||||||
)),
|
)),
|
||||||
))
|
))
|
||||||
.with_child(
|
.with_child(
|
||||||
Button::plain(L10n::t("btn_cancel", &LOC)).with_prop(
|
Button::plain(Lc::t("btn_cancel", &LOC)).with_prop(
|
||||||
PropsOp::add_classes(class::ButtonColor::link()),
|
PropsOp::add_classes(class::ButtonColor::link()),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -159,7 +159,7 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||||
// Bloque 2: campos de texto, multilínea y rango.
|
// Bloque 2: campos de texto, multilínea y rango.
|
||||||
.with_child(
|
.with_child(
|
||||||
Block::new()
|
Block::new()
|
||||||
.with_title(L10n::t("block_text", &LOC))
|
.with_title(Lc::t("block_text", &LOC))
|
||||||
.with_child(
|
.with_child(
|
||||||
Form::new()
|
Form::new()
|
||||||
.with_id("form-text")
|
.with_id("form-text")
|
||||||
|
|
@ -168,24 +168,21 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||||
// Campos de texto (form::input::Field).
|
// Campos de texto (form::input::Field).
|
||||||
.with_child(
|
.with_child(
|
||||||
form::Fieldset::new()
|
form::Fieldset::new()
|
||||||
.with_legend(L10n::t("fieldset_text", &LOC))
|
.with_legend(Lc::t("fieldset_text", &LOC))
|
||||||
.with_child(
|
.with_child(
|
||||||
form::input::Field::text()
|
form::input::Field::text()
|
||||||
.with_name("name")
|
.with_name("name")
|
||||||
.with_label(L10n::t("label_name", &LOC))
|
.with_label(Lc::t("label_name", &LOC))
|
||||||
.with_placeholder(L10n::t("placeholder_name", &LOC))
|
.with_placeholder(Lc::t("placeholder_name", &LOC))
|
||||||
.with_help_text(L10n::t("help_name", &LOC))
|
.with_help_text(Lc::t("help_name", &LOC))
|
||||||
.with_required(true),
|
.with_required(true),
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
form::input::Field::email()
|
form::input::Field::email()
|
||||||
.with_name("email")
|
.with_name("email")
|
||||||
.with_label(L10n::t("label_email", &LOC))
|
.with_label(Lc::t("label_email", &LOC))
|
||||||
.with_placeholder(L10n::t(
|
.with_placeholder(Lc::t("placeholder_email", &LOC))
|
||||||
"placeholder_email",
|
.with_help_text(Lc::t("help_email", &LOC))
|
||||||
&LOC,
|
|
||||||
))
|
|
||||||
.with_help_text(L10n::t("help_email", &LOC))
|
|
||||||
.with_autocomplete(
|
.with_autocomplete(
|
||||||
Some(form::Autocomplete::email()),
|
Some(form::Autocomplete::email()),
|
||||||
)
|
)
|
||||||
|
|
@ -194,7 +191,7 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||||
.with_child(
|
.with_child(
|
||||||
form::input::Field::password()
|
form::input::Field::password()
|
||||||
.with_name("password")
|
.with_name("password")
|
||||||
.with_label(L10n::t("label_password", &LOC))
|
.with_label(Lc::t("label_password", &LOC))
|
||||||
.with_autocomplete(Some(
|
.with_autocomplete(Some(
|
||||||
form::Autocomplete::new_password(),
|
form::Autocomplete::new_password(),
|
||||||
))
|
))
|
||||||
|
|
@ -203,23 +200,20 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||||
.with_child(
|
.with_child(
|
||||||
form::input::Field::telephone()
|
form::input::Field::telephone()
|
||||||
.with_name("phone")
|
.with_name("phone")
|
||||||
.with_label(L10n::t("label_phone", &LOC))
|
.with_label(Lc::t("label_phone", &LOC))
|
||||||
.with_placeholder(L10n::t(
|
.with_placeholder(Lc::t("placeholder_phone", &LOC)),
|
||||||
"placeholder_phone",
|
|
||||||
&LOC,
|
|
||||||
)),
|
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
form::input::Field::url()
|
form::input::Field::url()
|
||||||
.with_name("website")
|
.with_name("website")
|
||||||
.with_label(L10n::t("label_url", &LOC))
|
.with_label(Lc::t("label_url", &LOC))
|
||||||
.with_placeholder(L10n::t("placeholder_url", &LOC)),
|
.with_placeholder(Lc::t("placeholder_url", &LOC)),
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
form::input::Field::search()
|
form::input::Field::search()
|
||||||
.with_name("search")
|
.with_name("search")
|
||||||
.with_label(L10n::t("label_search", &LOC))
|
.with_label(Lc::t("label_search", &LOC))
|
||||||
.with_placeholder(L10n::t(
|
.with_placeholder(Lc::t(
|
||||||
"placeholder_search",
|
"placeholder_search",
|
||||||
&LOC,
|
&LOC,
|
||||||
)),
|
)),
|
||||||
|
|
@ -228,49 +222,49 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||||
// Área de texto (form::Textarea).
|
// Área de texto (form::Textarea).
|
||||||
.with_child(
|
.with_child(
|
||||||
form::Fieldset::new()
|
form::Fieldset::new()
|
||||||
.with_legend(L10n::t("fieldset_textarea", &LOC))
|
.with_legend(Lc::t("fieldset_textarea", &LOC))
|
||||||
.with_child(
|
.with_child(
|
||||||
form::Textarea::new()
|
form::Textarea::new()
|
||||||
.with_name("comment")
|
.with_name("comment")
|
||||||
.with_label(L10n::t("label_comment", &LOC))
|
.with_label(Lc::t("label_comment", &LOC))
|
||||||
.with_placeholder(L10n::t(
|
.with_placeholder(Lc::t(
|
||||||
"placeholder_comment",
|
"placeholder_comment",
|
||||||
&LOC,
|
&LOC,
|
||||||
))
|
))
|
||||||
.with_rows(Some(4))
|
.with_rows(Some(4))
|
||||||
.with_help_text(L10n::t("help_comment", &LOC)),
|
.with_help_text(Lc::t("help_comment", &LOC)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
// Control deslizante (form::Range).
|
// Control deslizante (form::Range).
|
||||||
.with_child(
|
.with_child(
|
||||||
form::Fieldset::new()
|
form::Fieldset::new()
|
||||||
.with_legend(L10n::t("fieldset_range", &LOC))
|
.with_legend(Lc::t("fieldset_range", &LOC))
|
||||||
.with_child(
|
.with_child(
|
||||||
form::Range::new()
|
form::Range::new()
|
||||||
.with_name("rating")
|
.with_name("rating")
|
||||||
.with_label(L10n::t("label_rating", &LOC))
|
.with_label(Lc::t("label_rating", &LOC))
|
||||||
.with_min(Some(1.0))
|
.with_min(Some(1.0))
|
||||||
.with_max(Some(10.0))
|
.with_max(Some(10.0))
|
||||||
.with_step(Some(1.0))
|
.with_step(Some(1.0))
|
||||||
.with_value(Some(5.0))
|
.with_value(Some(5.0))
|
||||||
.with_help_text(L10n::t("help_rating", &LOC)),
|
.with_help_text(Lc::t("help_rating", &LOC)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
// Campo oculto (form::Hidden).
|
// Campo oculto (form::Hidden).
|
||||||
.with_child(form::Hidden::field("origin", "form-text"))
|
.with_child(form::Hidden::field("origin", "form-text"))
|
||||||
// Botones de acción.
|
// Botones de acción.
|
||||||
.with_child(Button::submit(L10n::t("btn_submit", &LOC)).with_prop(
|
.with_child(Button::submit(Lc::t("btn_submit", &LOC)).with_prop(
|
||||||
PropsOp::add_classes(class::ButtonColor::solid(
|
PropsOp::add_classes(class::ButtonColor::solid(
|
||||||
ThemeColor::Primary,
|
ThemeColor::Primary,
|
||||||
)),
|
)),
|
||||||
))
|
))
|
||||||
.with_child(Button::reset(L10n::t("btn_reset", &LOC)).with_prop(
|
.with_child(Button::reset(Lc::t("btn_reset", &LOC)).with_prop(
|
||||||
PropsOp::add_classes(class::ButtonColor::outline(
|
PropsOp::add_classes(class::ButtonColor::outline(
|
||||||
ThemeColor::Secondary,
|
ThemeColor::Secondary,
|
||||||
)),
|
)),
|
||||||
))
|
))
|
||||||
.with_child(
|
.with_child(
|
||||||
Button::plain(L10n::t("btn_cancel", &LOC)).with_prop(
|
Button::plain(Lc::t("btn_cancel", &LOC)).with_prop(
|
||||||
PropsOp::add_classes(class::ButtonColor::link()),
|
PropsOp::add_classes(class::ButtonColor::link()),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -281,9 +275,9 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||||
Block::new()
|
Block::new()
|
||||||
.with_title(
|
.with_title(
|
||||||
if global::SETTINGS.app.theme.eq_ignore_ascii_case("bootsier") {
|
if global::SETTINGS.app.theme.eq_ignore_ascii_case("bootsier") {
|
||||||
L10n::t("block_lists_floating", &LOC)
|
Lc::t("block_lists_floating", &LOC)
|
||||||
} else {
|
} else {
|
||||||
L10n::t("block_lists", &LOC)
|
Lc::t("block_lists", &LOC)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.with_child(form_lists()),
|
.with_child(form_lists()),
|
||||||
|
|
@ -301,39 +295,39 @@ fn form_lists() -> Form {
|
||||||
// Listas de selección (form::select::Field).
|
// Listas de selección (form::select::Field).
|
||||||
.with_child(
|
.with_child(
|
||||||
form::Fieldset::new()
|
form::Fieldset::new()
|
||||||
.with_legend(L10n::t("fieldset_select", &LOC))
|
.with_legend(Lc::t("fieldset_select", &LOC))
|
||||||
.with_child(
|
.with_child(
|
||||||
form::select::Field::new()
|
form::select::Field::new()
|
||||||
.with_name("language")
|
.with_name("language")
|
||||||
.with_label(L10n::t("label_language", &LOC))
|
.with_label(Lc::t("label_language", &LOC))
|
||||||
.with_item(
|
.with_item(
|
||||||
form::select::Item::new("", L10n::t("select_choose", &LOC))
|
form::select::Item::new("", Lc::t("select_choose", &LOC))
|
||||||
.with_selected(true),
|
.with_selected(true),
|
||||||
)
|
)
|
||||||
.with_group(
|
.with_group(
|
||||||
form::select::Group::new(L10n::t("select_group_europe", &LOC))
|
form::select::Group::new(Lc::t("select_group_europe", &LOC))
|
||||||
.with_item(form::select::Item::new(
|
.with_item(form::select::Item::new(
|
||||||
"es",
|
"es",
|
||||||
L10n::t("select_spanish", &LOC),
|
Lc::t("select_spanish", &LOC),
|
||||||
))
|
))
|
||||||
.with_item(form::select::Item::new(
|
.with_item(form::select::Item::new(
|
||||||
"fr",
|
"fr",
|
||||||
L10n::t("select_french", &LOC),
|
Lc::t("select_french", &LOC),
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
.with_group(
|
.with_group(
|
||||||
form::select::Group::new(L10n::t("select_group_americas", &LOC))
|
form::select::Group::new(Lc::t("select_group_americas", &LOC))
|
||||||
.with_item(form::select::Item::new(
|
.with_item(form::select::Item::new(
|
||||||
"en",
|
"en",
|
||||||
L10n::t("select_english", &LOC),
|
Lc::t("select_english", &LOC),
|
||||||
))
|
))
|
||||||
.with_item(form::select::Item::new(
|
.with_item(form::select::Item::new(
|
||||||
"pt",
|
"pt",
|
||||||
L10n::t("select_portuguese", &LOC),
|
Lc::t("select_portuguese", &LOC),
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
.with_item(
|
.with_item(
|
||||||
form::select::Item::new("xx", L10n::t("select_disabled", &LOC))
|
form::select::Item::new("xx", Lc::t("select_disabled", &LOC))
|
||||||
.with_disabled(true),
|
.with_disabled(true),
|
||||||
)
|
)
|
||||||
.with_required(true),
|
.with_required(true),
|
||||||
|
|
@ -341,20 +335,19 @@ fn form_lists() -> Form {
|
||||||
.with_child(
|
.with_child(
|
||||||
form::select::Field::new()
|
form::select::Field::new()
|
||||||
.with_name("technologies")
|
.with_name("technologies")
|
||||||
.with_label(L10n::t("label_technologies", &LOC))
|
.with_label(Lc::t("label_technologies", &LOC))
|
||||||
.with_item(
|
.with_item(
|
||||||
form::select::Item::new("rust", L10n::n("Rust")).with_selected(true),
|
form::select::Item::new("rust", Lc::n("Rust")).with_selected(true),
|
||||||
)
|
)
|
||||||
.with_item(
|
.with_item(
|
||||||
form::select::Item::new("python", L10n::n("Python"))
|
form::select::Item::new("python", Lc::n("Python")).with_selected(true),
|
||||||
.with_selected(true),
|
|
||||||
)
|
)
|
||||||
.with_item(form::select::Item::new("javascript", L10n::n("JavaScript")))
|
.with_item(form::select::Item::new("javascript", Lc::n("JavaScript")))
|
||||||
.with_item(form::select::Item::new("go", L10n::n("Go")))
|
.with_item(form::select::Item::new("go", Lc::n("Go")))
|
||||||
.with_item(form::select::Item::new("typescript", L10n::n("TypeScript")))
|
.with_item(form::select::Item::new("typescript", Lc::n("TypeScript")))
|
||||||
.with_multiple(true)
|
.with_multiple(true)
|
||||||
.with_rows(Some(4))
|
.with_rows(Some(4))
|
||||||
.with_help_text(L10n::t("help_technologies", &LOC)),
|
.with_help_text(Lc::t("help_technologies", &LOC)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -362,42 +355,36 @@ fn form_lists() -> Form {
|
||||||
if global::SETTINGS.app.theme.eq_ignore_ascii_case("bootsier") {
|
if global::SETTINGS.app.theme.eq_ignore_ascii_case("bootsier") {
|
||||||
form = form.with_child(
|
form = form.with_child(
|
||||||
form::Fieldset::new()
|
form::Fieldset::new()
|
||||||
.with_legend(L10n::t("fieldset_floating", &LOC))
|
.with_legend(Lc::t("fieldset_floating", &LOC))
|
||||||
.with_child(
|
.with_child(
|
||||||
form::input::Field::text()
|
form::input::Field::text()
|
||||||
.with_name("fl_name")
|
.with_name("fl_name")
|
||||||
.with_label(L10n::t("label_name", &LOC))
|
.with_label(Lc::t("label_name", &LOC))
|
||||||
.with_placeholder(L10n::t("placeholder_name", &LOC))
|
.with_placeholder(Lc::t("placeholder_name", &LOC))
|
||||||
.with_floating_label(true)
|
.with_floating_label(true)
|
||||||
.with_required(true),
|
.with_required(true),
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
form::Textarea::new()
|
form::Textarea::new()
|
||||||
.with_name("fl_comment")
|
.with_name("fl_comment")
|
||||||
.with_label(L10n::t("label_comment", &LOC))
|
.with_label(Lc::t("label_comment", &LOC))
|
||||||
.with_placeholder(L10n::t("placeholder_comment", &LOC))
|
.with_placeholder(Lc::t("placeholder_comment", &LOC))
|
||||||
.with_floating_label(true),
|
.with_floating_label(true),
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
form::select::Field::new()
|
form::select::Field::new()
|
||||||
.with_name("fl_country")
|
.with_name("fl_country")
|
||||||
.with_label(L10n::t("label_country", &LOC))
|
.with_label(Lc::t("label_country", &LOC))
|
||||||
.with_item(
|
.with_item(
|
||||||
form::select::Item::new("", L10n::t("select_choose", &LOC))
|
form::select::Item::new("", Lc::t("select_choose", &LOC))
|
||||||
.with_selected(true),
|
.with_selected(true),
|
||||||
)
|
)
|
||||||
.with_item(form::select::Item::new(
|
.with_item(form::select::Item::new("de", Lc::t("select_germany", &LOC)))
|
||||||
"de",
|
.with_item(form::select::Item::new("es", Lc::t("select_spain", &LOC)))
|
||||||
L10n::t("select_germany", &LOC),
|
.with_item(form::select::Item::new("fr", Lc::t("select_france", &LOC)))
|
||||||
))
|
|
||||||
.with_item(form::select::Item::new("es", L10n::t("select_spain", &LOC)))
|
|
||||||
.with_item(form::select::Item::new(
|
|
||||||
"fr",
|
|
||||||
L10n::t("select_france", &LOC),
|
|
||||||
))
|
|
||||||
.with_item(form::select::Item::new(
|
.with_item(form::select::Item::new(
|
||||||
"pt",
|
"pt",
|
||||||
L10n::t("select_portugal", &LOC),
|
Lc::t("select_portugal", &LOC),
|
||||||
))
|
))
|
||||||
.with_floating_label(true)
|
.with_floating_label(true)
|
||||||
.with_required(true),
|
.with_required(true),
|
||||||
|
|
@ -410,17 +397,17 @@ fn form_lists() -> Form {
|
||||||
.with_child(form::Hidden::field("origin", "form-lists"))
|
.with_child(form::Hidden::field("origin", "form-lists"))
|
||||||
// Botones de acción.
|
// Botones de acción.
|
||||||
.with_child(
|
.with_child(
|
||||||
Button::submit(L10n::t("btn_submit", &LOC)).with_prop(PropsOp::add_classes(
|
Button::submit(Lc::t("btn_submit", &LOC)).with_prop(PropsOp::add_classes(
|
||||||
class::ButtonColor::solid(ThemeColor::Primary),
|
class::ButtonColor::solid(ThemeColor::Primary),
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
Button::reset(L10n::t("btn_reset", &LOC)).with_prop(PropsOp::add_classes(
|
Button::reset(Lc::t("btn_reset", &LOC)).with_prop(PropsOp::add_classes(
|
||||||
class::ButtonColor::outline(ThemeColor::Secondary),
|
class::ButtonColor::outline(ThemeColor::Secondary),
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
Button::plain(L10n::t("btn_cancel", &LOC))
|
Button::plain(Lc::t("btn_cancel", &LOC))
|
||||||
.with_prop(PropsOp::add_classes(class::ButtonColor::link())),
|
.with_prop(PropsOp::add_classes(class::ButtonColor::link())),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,60 +16,60 @@ async fn intro_colors(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||||
.with_child(
|
.with_child(
|
||||||
Intro::default()
|
Intro::default()
|
||||||
.with_opening(IntroOpening::Custom)
|
.with_opening(IntroOpening::Custom)
|
||||||
.with_title(L10n::n("PageTop"))
|
.with_title(Lc::n("PageTop"))
|
||||||
.with_slogan(L10n::t("colors_slogan", &LOC))
|
.with_slogan(Lc::t("colors_slogan", &LOC))
|
||||||
.with_button(None::<(L10n, Route)>)
|
.with_button(None::<(Lc, Route)>)
|
||||||
.with_child(
|
.with_child(
|
||||||
Block::new()
|
Block::new()
|
||||||
.with_title(L10n::t("colors_block", &LOC).with_arg("n", "1"))
|
.with_title(Lc::t("colors_block", &LOC).with_arg("n", "1"))
|
||||||
.with_child(Html::with(|cx| {
|
.with_child(Html::with(|cx| {
|
||||||
html! {
|
html! {
|
||||||
p { (L10n::t("colors_val_1", &LOC).using(cx)) }
|
p { (Lc::t("colors_val_1", &LOC).using(cx)) }
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
Block::new()
|
Block::new()
|
||||||
.with_title(L10n::t("colors_block", &LOC).with_arg("n", "2"))
|
.with_title(Lc::t("colors_block", &LOC).with_arg("n", "2"))
|
||||||
.with_child(Html::with(|cx| {
|
.with_child(Html::with(|cx| {
|
||||||
html! {
|
html! {
|
||||||
p { (L10n::t("colors_val_2", &LOC).using(cx)) }
|
p { (Lc::t("colors_val_2", &LOC).using(cx)) }
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
Block::new()
|
Block::new()
|
||||||
.with_title(L10n::t("colors_block", &LOC).with_arg("n", "3"))
|
.with_title(Lc::t("colors_block", &LOC).with_arg("n", "3"))
|
||||||
.with_child(Html::with(|cx| {
|
.with_child(Html::with(|cx| {
|
||||||
html! {
|
html! {
|
||||||
p { (L10n::t("colors_val_3", &LOC).using(cx)) }
|
p { (Lc::t("colors_val_3", &LOC).using(cx)) }
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
Block::new()
|
Block::new()
|
||||||
.with_title(L10n::t("colors_block", &LOC).with_arg("n", "4"))
|
.with_title(Lc::t("colors_block", &LOC).with_arg("n", "4"))
|
||||||
.with_child(Html::with(|cx| {
|
.with_child(Html::with(|cx| {
|
||||||
html! {
|
html! {
|
||||||
p { (L10n::t("colors_val_4", &LOC).using(cx)) }
|
p { (Lc::t("colors_val_4", &LOC).using(cx)) }
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
Block::new()
|
Block::new()
|
||||||
.with_title(L10n::t("colors_block", &LOC).with_arg("n", "5"))
|
.with_title(Lc::t("colors_block", &LOC).with_arg("n", "5"))
|
||||||
.with_child(Html::with(|cx| {
|
.with_child(Html::with(|cx| {
|
||||||
html! {
|
html! {
|
||||||
p { (L10n::t("colors_val_5", &LOC).using(cx)) }
|
p { (Lc::t("colors_val_5", &LOC).using(cx)) }
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
Block::new()
|
Block::new()
|
||||||
.with_title(L10n::t("colors_block", &LOC).with_arg("n", "6"))
|
.with_title(Lc::t("colors_block", &LOC).with_arg("n", "6"))
|
||||||
.with_child(Html::with(|cx| {
|
.with_child(Html::with(|cx| {
|
||||||
html! {
|
html! {
|
||||||
p { (L10n::t("colors_val_6", &LOC).using(cx)) }
|
p { (Lc::t("colors_val_6", &LOC).using(cx)) }
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -20,69 +20,63 @@ impl Extension for SuperMenu {
|
||||||
.with_expand(BreakPoint::LG)
|
.with_expand(BreakPoint::LG)
|
||||||
.with_item(bs::navbar::Item::nav(
|
.with_item(bs::navbar::Item::nav(
|
||||||
bs::Nav::new()
|
bs::Nav::new()
|
||||||
.with_item(bs::nav::Item::link(L10n::t("menus_item_link", &LOC), "/"))
|
.with_item(bs::nav::Item::link(Lc::t("menus_item_link", &LOC), "/"))
|
||||||
.with_item(bs::nav::Item::link_blank(
|
.with_item(bs::nav::Item::link_blank(
|
||||||
L10n::t("menus_item_blank", &LOC),
|
Lc::t("menus_item_blank", &LOC),
|
||||||
"https://docs.rs/pagetop",
|
"https://docs.rs/pagetop",
|
||||||
))
|
))
|
||||||
.with_item(bs::nav::Item::dropdown(
|
.with_item(bs::nav::Item::dropdown(
|
||||||
bs::Dropdown::new()
|
bs::Dropdown::new()
|
||||||
.with_title(L10n::t("menus_test_title", &LOC))
|
.with_title(Lc::t("menus_test_title", &LOC))
|
||||||
.with_item(bs::dropdown::Item::header(L10n::t(
|
.with_item(bs::dropdown::Item::header(Lc::t("menus_dev_header", &LOC)))
|
||||||
"menus_dev_header",
|
|
||||||
&LOC,
|
|
||||||
)))
|
|
||||||
.with_item(bs::dropdown::Item::link(
|
.with_item(bs::dropdown::Item::link(
|
||||||
L10n::t("menus_dev_getting_started", &LOC),
|
Lc::t("menus_dev_getting_started", &LOC),
|
||||||
"/dev/getting-started",
|
"/dev/getting-started",
|
||||||
))
|
))
|
||||||
.with_item(bs::dropdown::Item::link(
|
.with_item(bs::dropdown::Item::link(
|
||||||
L10n::t("menus_dev_guides", &LOC),
|
Lc::t("menus_dev_guides", &LOC),
|
||||||
"/dev/guides",
|
"/dev/guides",
|
||||||
))
|
))
|
||||||
.with_item(bs::dropdown::Item::link_blank(
|
.with_item(bs::dropdown::Item::link_blank(
|
||||||
L10n::t("menus_dev_forum", &LOC),
|
Lc::t("menus_dev_forum", &LOC),
|
||||||
"https://forum.example.dev",
|
"https://forum.example.dev",
|
||||||
))
|
))
|
||||||
.with_item(bs::dropdown::Item::divider())
|
.with_item(bs::dropdown::Item::divider())
|
||||||
.with_item(bs::dropdown::Item::header(L10n::t(
|
.with_item(bs::dropdown::Item::header(Lc::t("menus_sdk_header", &LOC)))
|
||||||
"menus_sdk_header",
|
|
||||||
&LOC,
|
|
||||||
)))
|
|
||||||
.with_item(bs::dropdown::Item::link(
|
.with_item(bs::dropdown::Item::link(
|
||||||
L10n::t("menus_sdk_rust", &LOC),
|
Lc::t("menus_sdk_rust", &LOC),
|
||||||
"/dev/sdks/rust",
|
"/dev/sdks/rust",
|
||||||
))
|
))
|
||||||
.with_item(bs::dropdown::Item::link(
|
.with_item(bs::dropdown::Item::link(
|
||||||
L10n::t("menus_sdk_js", &LOC),
|
Lc::t("menus_sdk_js", &LOC),
|
||||||
"/dev/sdks/js",
|
"/dev/sdks/js",
|
||||||
))
|
))
|
||||||
.with_item(bs::dropdown::Item::link(
|
.with_item(bs::dropdown::Item::link(
|
||||||
L10n::t("menus_sdk_python", &LOC),
|
Lc::t("menus_sdk_python", &LOC),
|
||||||
"/dev/sdks/python",
|
"/dev/sdks/python",
|
||||||
))
|
))
|
||||||
.with_item(bs::dropdown::Item::divider())
|
.with_item(bs::dropdown::Item::divider())
|
||||||
.with_item(bs::dropdown::Item::header(L10n::t(
|
.with_item(bs::dropdown::Item::header(Lc::t(
|
||||||
"menus_plugin_header",
|
"menus_plugin_header",
|
||||||
&LOC,
|
&LOC,
|
||||||
)))
|
)))
|
||||||
.with_item(bs::dropdown::Item::link(
|
.with_item(bs::dropdown::Item::link(
|
||||||
L10n::t("menus_plugin_auth", &LOC),
|
Lc::t("menus_plugin_auth", &LOC),
|
||||||
"/dev/sdks/rust/plugins/auth",
|
"/dev/sdks/rust/plugins/auth",
|
||||||
))
|
))
|
||||||
.with_item(bs::dropdown::Item::link(
|
.with_item(bs::dropdown::Item::link(
|
||||||
L10n::t("menus_plugin_cache", &LOC),
|
Lc::t("menus_plugin_cache", &LOC),
|
||||||
"/dev/sdks/rust/plugins/cache",
|
"/dev/sdks/rust/plugins/cache",
|
||||||
))
|
))
|
||||||
.with_item(bs::dropdown::Item::divider())
|
.with_item(bs::dropdown::Item::divider())
|
||||||
.with_item(bs::dropdown::Item::label(L10n::t("menus_item_label", &LOC)))
|
.with_item(bs::dropdown::Item::label(Lc::t("menus_item_label", &LOC)))
|
||||||
.with_item(bs::dropdown::Item::link_disabled(
|
.with_item(bs::dropdown::Item::link_disabled(
|
||||||
L10n::t("menus_item_disabled", &LOC),
|
Lc::t("menus_item_disabled", &LOC),
|
||||||
"#",
|
"#",
|
||||||
)),
|
)),
|
||||||
))
|
))
|
||||||
.with_item(bs::nav::Item::link_disabled(
|
.with_item(bs::nav::Item::link_disabled(
|
||||||
L10n::t("menus_item_disabled", &LOC),
|
Lc::t("menus_item_disabled", &LOC),
|
||||||
"#",
|
"#",
|
||||||
)),
|
)),
|
||||||
))
|
))
|
||||||
|
|
@ -93,11 +87,11 @@ impl Extension for SuperMenu {
|
||||||
ScaleSize::Auto,
|
ScaleSize::Auto,
|
||||||
)))
|
)))
|
||||||
.with_item(bs::nav::Item::link(
|
.with_item(bs::nav::Item::link(
|
||||||
L10n::t("menus_item_sign_up", &LOC),
|
Lc::t("menus_item_sign_up", &LOC),
|
||||||
"/auth/sign-up",
|
"/auth/sign-up",
|
||||||
))
|
))
|
||||||
.with_item(bs::nav::Item::link(
|
.with_item(bs::nav::Item::link(
|
||||||
L10n::t("menus_item_login", &LOC),
|
Lc::t("menus_item_login", &LOC),
|
||||||
"/auth/login",
|
"/auth/login",
|
||||||
)),
|
)),
|
||||||
));
|
));
|
||||||
|
|
|
||||||
|
|
@ -64,9 +64,9 @@ async fn homepage(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||||
.with_theme(&Aliner)
|
.with_theme(&Aliner)
|
||||||
.with_child(
|
.with_child(
|
||||||
Block::new()
|
Block::new()
|
||||||
.with_title(L10n::l("sample_title"))
|
.with_title(Lc::l("sample_title"))
|
||||||
.with_child(Html::with(|cx| html! {
|
.with_child(Html::with(|cx| html! {
|
||||||
p { (L10n::l("sample_content").using(cx)) }
|
p { (Lc::l("sample_content").using(cx)) }
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.render().await
|
.render().await
|
||||||
|
|
|
||||||
|
|
@ -65,9 +65,9 @@ async fn homepage(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||||
.with_theme(&Aliner)
|
.with_theme(&Aliner)
|
||||||
.with_child(
|
.with_child(
|
||||||
Block::new()
|
Block::new()
|
||||||
.with_title(L10n::l("sample_title"))
|
.with_title(Lc::l("sample_title"))
|
||||||
.with_child(Html::with(|cx| html! {
|
.with_child(Html::with(|cx| html! {
|
||||||
p { (L10n::l("sample_content").using(cx)) }
|
p { (Lc::l("sample_content").using(cx)) }
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.render().await
|
.render().await
|
||||||
|
|
@ -92,12 +92,12 @@ pub struct Aliner;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Extension for Aliner {
|
impl Extension for Aliner {
|
||||||
fn name(&self) -> L10n {
|
fn name(&self) -> Lc {
|
||||||
L10n::t("extension_name", &LOCALES_ALINER)
|
Lc::t("extension_name", &LOCALES_ALINER)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn description(&self) -> L10n {
|
fn description(&self) -> Lc {
|
||||||
L10n::t("extension_description", &LOCALES_ALINER)
|
Lc::t("extension_description", &LOCALES_ALINER)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn theme(&self) -> Option<ThemeRef> {
|
fn theme(&self) -> Option<ThemeRef> {
|
||||||
|
|
@ -129,7 +129,7 @@ impl Theme for Aliner {
|
||||||
.with_weight(-99),
|
.with_weight(-99),
|
||||||
))
|
))
|
||||||
.alter_child_in(
|
.alter_child_in(
|
||||||
&DefaultRegions::Footer,
|
&CoreRegions::Footer,
|
||||||
ChildOp::AddIfEmpty(PoweredBy::new().into()),
|
ChildOp::AddIfEmpty(PoweredBy::new().into()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,9 +65,9 @@ async fn homepage(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||||
.with_theme(&Bootsier)
|
.with_theme(&Bootsier)
|
||||||
.with_child(
|
.with_child(
|
||||||
Block::new()
|
Block::new()
|
||||||
.with_title(L10n::l("sample_title"))
|
.with_title(Lc::l("sample_title"))
|
||||||
.with_child(Html::with(|cx| html! {
|
.with_child(Html::with(|cx| html! {
|
||||||
p { (L10n::l("sample_content").using(cx)) }
|
p { (Lc::l("sample_content").using(cx)) }
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.render().await
|
.render().await
|
||||||
|
|
@ -102,12 +102,12 @@ pub struct Bootsier;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Extension for Bootsier {
|
impl Extension for Bootsier {
|
||||||
fn name(&self) -> L10n {
|
fn name(&self) -> Lc {
|
||||||
L10n::t("extension_name", &LOCALES_BOOTSIER)
|
Lc::t("extension_name", &LOCALES_BOOTSIER)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn description(&self) -> L10n {
|
fn description(&self) -> Lc {
|
||||||
L10n::t("extension_description", &LOCALES_BOOTSIER)
|
Lc::t("extension_description", &LOCALES_BOOTSIER)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn theme(&self) -> Option<ThemeRef> {
|
fn theme(&self) -> Option<ThemeRef> {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ const EXTRA_TEXT_BG: &str = "bootsier.badge.text_bg";
|
||||||
/// use pagetop::prelude::*;
|
/// use pagetop::prelude::*;
|
||||||
/// use pagetop_bootsier::theme::*;
|
/// use pagetop_bootsier::theme::*;
|
||||||
///
|
///
|
||||||
/// let admin = bs::Badge::labeled(L10n::n("Admin")).with_text_bg(ThemeColor::Danger);
|
/// let admin = bs::Badge::labeled(Lc::n("Admin")).with_text_bg(ThemeColor::Danger);
|
||||||
/// ```
|
/// ```
|
||||||
pub trait BadgeBootsier {
|
pub trait BadgeBootsier {
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
//! navegación, botones de acción, encabezados o divisores visuales.
|
//! navegación, botones de acción, encabezados o divisores visuales.
|
||||||
//!
|
//!
|
||||||
//! Los ítems pueden estar activos, deshabilitados o abrirse en nueva ventana según su contexto y
|
//! Los ítems pueden estar activos, deshabilitados o abrirse en nueva ventana según su contexto y
|
||||||
//! configuración, y permiten incluir etiquetas localizables usando [`L10n`](pagetop::locale::L10n).
|
//! configuración, y permiten incluir etiquetas localizables usando [`Lc`](pagetop::locale::Lc).
|
||||||
|
|
||||||
mod props;
|
mod props;
|
||||||
pub use props::{AutoClose, Direction, MenuAlign, MenuPosition};
|
pub use props::{AutoClose, Direction, MenuAlign, MenuPosition};
|
||||||
|
|
|
||||||
|
|
@ -27,22 +27,22 @@ use crate::theme::*;
|
||||||
/// use pagetop_bootsier::theme::*;
|
/// use pagetop_bootsier::theme::*;
|
||||||
///
|
///
|
||||||
/// let dd = bs::Dropdown::new()
|
/// let dd = bs::Dropdown::new()
|
||||||
/// .with_title(L10n::n("Menu"))
|
/// .with_title(Lc::n("Menu"))
|
||||||
/// .with_button_color(class::ButtonColor::solid(token::Color::Secondary))
|
/// .with_button_color(class::ButtonColor::solid(token::Color::Secondary))
|
||||||
/// .with_auto_close(bs::dropdown::AutoClose::ClickableInside)
|
/// .with_auto_close(bs::dropdown::AutoClose::ClickableInside)
|
||||||
/// .with_direction(bs::dropdown::Direction::Dropend)
|
/// .with_direction(bs::dropdown::Direction::Dropend)
|
||||||
/// .with_item(bs::dropdown::Item::link(L10n::n("Home"), |_| "/".into()))
|
/// .with_item(bs::dropdown::Item::link(Lc::n("Home"), "/"))
|
||||||
/// .with_item(bs::dropdown::Item::link_blank(L10n::n("Doc"), |_| "https://docs.rs".into()))
|
/// .with_item(bs::dropdown::Item::link_blank(Lc::n("Doc"), "https://docs.rs"))
|
||||||
/// .with_item(bs::dropdown::Item::divider())
|
/// .with_item(bs::dropdown::Item::divider())
|
||||||
/// .with_item(bs::dropdown::Item::header(L10n::n("User session")))
|
/// .with_item(bs::dropdown::Item::header(Lc::n("User session")))
|
||||||
/// .with_item(bs::dropdown::Item::button(L10n::n("Sign out")));
|
/// .with_item(bs::dropdown::Item::button(Lc::n("Sign out")));
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(AutoDefault, Clone, Debug, Getters)]
|
#[derive(AutoDefault, Clone, Debug, Getters)]
|
||||||
pub struct Dropdown {
|
pub struct Dropdown {
|
||||||
/// Devuelve identificador, clases CSS, atributos HTML y valores extra del componente.
|
/// Devuelve identificador, clases CSS, atributos HTML y valores extra del componente.
|
||||||
props: Props,
|
props: Props,
|
||||||
/// Devuelve el título del menú desplegable.
|
/// Devuelve el título del menú desplegable.
|
||||||
title: L10n,
|
title: Lc,
|
||||||
/// Devuelve el tamaño configurado del botón.
|
/// Devuelve el tamaño configurado del botón.
|
||||||
button_size: class::ButtonSize,
|
button_size: class::ButtonSize,
|
||||||
/// Devuelve el color/estilo configurado del botón.
|
/// Devuelve el color/estilo configurado del botón.
|
||||||
|
|
@ -133,7 +133,7 @@ impl Component for Dropdown {
|
||||||
aria-expanded="false"
|
aria-expanded="false"
|
||||||
{
|
{
|
||||||
span class="visually-hidden" {
|
span class="visually-hidden" {
|
||||||
(L10n::t("dropdown_toggle", &LOCALES_BOOTSIER).using(cx))
|
(Lc::t("dropdown_toggle", &LOCALES_BOOTSIER).using(cx))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -194,7 +194,7 @@ impl Dropdown {
|
||||||
|
|
||||||
/// Establece el título del menú desplegable.
|
/// Establece el título del menú desplegable.
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_title(mut self, title: L10n) -> Self {
|
pub fn with_title(mut self, title: Lc) -> Self {
|
||||||
self.title = title;
|
self.title = title;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,21 +13,20 @@ pub enum ItemKind {
|
||||||
#[default]
|
#[default]
|
||||||
Void,
|
Void,
|
||||||
/// Etiqueta sin comportamiento interactivo.
|
/// Etiqueta sin comportamiento interactivo.
|
||||||
Label(L10n),
|
Label(Lc),
|
||||||
/// Elemento de navegación basado en una [`RoutePath`] dinámica devuelta por
|
/// Elemento de navegación basado en una [`RoutePath`] dinámica resuelta por una [`Route`].
|
||||||
/// [`FnPathByContext`]. Opcionalmente, puede abrirse en una nueva ventana y estar inicialmente
|
/// Opcionalmente, puede abrirse en una nueva ventana y estar inicialmente deshabilitado.
|
||||||
/// deshabilitado.
|
|
||||||
Link {
|
Link {
|
||||||
label: L10n,
|
label: Lc,
|
||||||
route: FnPathByContext,
|
route: Route,
|
||||||
blank: bool,
|
blank: bool,
|
||||||
disabled: bool,
|
disabled: bool,
|
||||||
},
|
},
|
||||||
/// Acción ejecutable en la propia página, sin navegación asociada. Inicialmente puede estar
|
/// Acción ejecutable en la propia página, sin navegación asociada. Inicialmente puede estar
|
||||||
/// deshabilitado.
|
/// deshabilitado.
|
||||||
Button { label: L10n, disabled: bool },
|
Button { label: Lc, disabled: bool },
|
||||||
/// Título o encabezado que separa grupos de opciones.
|
/// Título o encabezado que separa grupos de opciones.
|
||||||
Header(L10n),
|
Header(Lc),
|
||||||
/// Separador visual entre bloques de elementos.
|
/// Separador visual entre bloques de elementos.
|
||||||
Divider,
|
Divider,
|
||||||
}
|
}
|
||||||
|
|
@ -79,7 +78,7 @@ impl Component for Item {
|
||||||
blank,
|
blank,
|
||||||
disabled,
|
disabled,
|
||||||
} => {
|
} => {
|
||||||
let route_link = route(cx);
|
let route_link = route.resolve(cx);
|
||||||
let current_path = cx.request().map(|request| request.path());
|
let current_path = cx.request().map(|request| request.path());
|
||||||
let is_current = !*disabled && (current_path == Some(route_link.path()));
|
let is_current = !*disabled && (current_path == Some(route_link.path()));
|
||||||
|
|
||||||
|
|
@ -156,7 +155,7 @@ impl Component for Item {
|
||||||
|
|
||||||
impl Item {
|
impl Item {
|
||||||
/// Crea un elemento de tipo texto, mostrado sin interacción.
|
/// Crea un elemento de tipo texto, mostrado sin interacción.
|
||||||
pub fn label(label: L10n) -> Self {
|
pub fn label(label: Lc) -> Self {
|
||||||
Self {
|
Self {
|
||||||
item_kind: ItemKind::Label(label),
|
item_kind: ItemKind::Label(label),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
@ -165,14 +164,14 @@ impl Item {
|
||||||
|
|
||||||
/// Crea un enlace para la navegación.
|
/// Crea un enlace para la navegación.
|
||||||
///
|
///
|
||||||
/// La ruta se obtiene invocando [`FnPathByContext`], que devuelve dinámicamente una
|
/// La ruta se obtiene invocando [`Route::resolve()`], que devuelve dinámicamente una
|
||||||
/// [`RoutePath`] en función del [`Context`]. El enlace se marca como `active` si la ruta actual
|
/// [`RoutePath`] en función del [`Context`]. El enlace se marca como `active` si la ruta actual
|
||||||
/// del *request* coincide con la ruta de destino (devuelta por `RoutePath::path`).
|
/// del *request* coincide con la ruta de destino (devuelta por `RoutePath::path`).
|
||||||
pub fn link(label: L10n, route: FnPathByContext) -> Self {
|
pub fn link(label: Lc, route: impl Into<Route>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
item_kind: ItemKind::Link {
|
item_kind: ItemKind::Link {
|
||||||
label,
|
label,
|
||||||
route,
|
route: route.into(),
|
||||||
blank: false,
|
blank: false,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
},
|
},
|
||||||
|
|
@ -181,11 +180,11 @@ impl Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Crea un enlace deshabilitado que no permite la interacción.
|
/// Crea un enlace deshabilitado que no permite la interacción.
|
||||||
pub fn link_disabled(label: L10n, route: FnPathByContext) -> Self {
|
pub fn link_disabled(label: Lc, route: impl Into<Route>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
item_kind: ItemKind::Link {
|
item_kind: ItemKind::Link {
|
||||||
label,
|
label,
|
||||||
route,
|
route: route.into(),
|
||||||
blank: false,
|
blank: false,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
},
|
},
|
||||||
|
|
@ -194,11 +193,11 @@ impl Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Crea un enlace que se abre en una nueva ventana o pestaña.
|
/// Crea un enlace que se abre en una nueva ventana o pestaña.
|
||||||
pub fn link_blank(label: L10n, route: FnPathByContext) -> Self {
|
pub fn link_blank(label: Lc, route: impl Into<Route>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
item_kind: ItemKind::Link {
|
item_kind: ItemKind::Link {
|
||||||
label,
|
label,
|
||||||
route,
|
route: route.into(),
|
||||||
blank: true,
|
blank: true,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
},
|
},
|
||||||
|
|
@ -207,11 +206,11 @@ impl Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Crea un enlace inicialmente deshabilitado que se abriría en una nueva ventana.
|
/// Crea un enlace inicialmente deshabilitado que se abriría en una nueva ventana.
|
||||||
pub fn link_blank_disabled(label: L10n, route: FnPathByContext) -> Self {
|
pub fn link_blank_disabled(label: Lc, route: impl Into<Route>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
item_kind: ItemKind::Link {
|
item_kind: ItemKind::Link {
|
||||||
label,
|
label,
|
||||||
route,
|
route: route.into(),
|
||||||
blank: true,
|
blank: true,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
},
|
},
|
||||||
|
|
@ -220,7 +219,7 @@ impl Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Crea un botón de acción local, sin navegación asociada.
|
/// Crea un botón de acción local, sin navegación asociada.
|
||||||
pub fn button(label: L10n) -> Self {
|
pub fn button(label: Lc) -> Self {
|
||||||
Self {
|
Self {
|
||||||
item_kind: ItemKind::Button {
|
item_kind: ItemKind::Button {
|
||||||
label,
|
label,
|
||||||
|
|
@ -231,7 +230,7 @@ impl Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Crea un botón deshabilitado.
|
/// Crea un botón deshabilitado.
|
||||||
pub fn button_disabled(label: L10n) -> Self {
|
pub fn button_disabled(label: Lc) -> Self {
|
||||||
Self {
|
Self {
|
||||||
item_kind: ItemKind::Button {
|
item_kind: ItemKind::Button {
|
||||||
label,
|
label,
|
||||||
|
|
@ -242,7 +241,7 @@ impl Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Crea un encabezado para un grupo de elementos dentro del menú.
|
/// Crea un encabezado para un grupo de elementos dentro del menú.
|
||||||
pub fn header(label: L10n) -> Self {
|
pub fn header(label: Lc) -> Self {
|
||||||
Self {
|
Self {
|
||||||
item_kind: ItemKind::Header(label),
|
item_kind: ItemKind::Header(label),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ const EXTRA_FLOATING_LABEL: &str = "bootsier.form.input.floating_label";
|
||||||
///
|
///
|
||||||
/// let nombre = bs::form::input::Field::text()
|
/// let nombre = bs::form::input::Field::text()
|
||||||
/// .with_name("name")
|
/// .with_name("name")
|
||||||
/// .with_label(L10n::n("Name"))
|
/// .with_label(Lc::n("Name"))
|
||||||
/// .with_placeholder(L10n::n("Enter your name"))
|
/// .with_placeholder(Lc::n("Enter your name"))
|
||||||
/// .with_floating_label(true);
|
/// .with_floating_label(true);
|
||||||
/// ```
|
/// ```
|
||||||
pub trait InputBootsier {
|
pub trait InputBootsier {
|
||||||
|
|
@ -83,7 +83,7 @@ pub(crate) fn render(field: &Field, cx: &mut Context) -> Result<Markup, Componen
|
||||||
@if *field.required() {
|
@if *field.required() {
|
||||||
span
|
span
|
||||||
class="form-required"
|
class="form-required"
|
||||||
title=[L10n::l("field_required").lookup(cx)]
|
title=[Lc::l("field_required").lookup(cx)]
|
||||||
{
|
{
|
||||||
"*"
|
"*"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,11 @@ const EXTRA_FLOATING_LABEL: &str = "bootsier.form.select.floating_label";
|
||||||
///
|
///
|
||||||
/// let language = bs::form::select::Field::new()
|
/// let language = bs::form::select::Field::new()
|
||||||
/// .with_name("language")
|
/// .with_name("language")
|
||||||
/// .with_label(L10n::n("Language"))
|
/// .with_label(Lc::n("Language"))
|
||||||
/// .with_floating_label(true)
|
/// .with_floating_label(true)
|
||||||
/// .with_item(bs::form::select::Item::new("", L10n::n("— Choose —")).with_selected(true))
|
/// .with_item(bs::form::select::Item::new("", Lc::n("— Choose —")).with_selected(true))
|
||||||
/// .with_item(bs::form::select::Item::new("es", L10n::n("Spanish")))
|
/// .with_item(bs::form::select::Item::new("es", Lc::n("Spanish")))
|
||||||
/// .with_item(bs::form::select::Item::new("en", L10n::n("English")));
|
/// .with_item(bs::form::select::Item::new("en", Lc::n("English")));
|
||||||
/// ```
|
/// ```
|
||||||
pub trait SelectBootsier {
|
pub trait SelectBootsier {
|
||||||
/// Establece si la etiqueta se muestra flotante sobre el campo.
|
/// Establece si la etiqueta se muestra flotante sobre el campo.
|
||||||
|
|
@ -70,7 +70,7 @@ pub(crate) fn render(field: &Field, cx: &mut Context) -> Result<Markup, Componen
|
||||||
@if *field.required() {
|
@if *field.required() {
|
||||||
span
|
span
|
||||||
class="form-required"
|
class="form-required"
|
||||||
title=[L10n::l("field_required").lookup(cx)]
|
title=[Lc::l("field_required").lookup(cx)]
|
||||||
{
|
{
|
||||||
"*"
|
"*"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ const EXTRA_FLOATING_LABEL: &str = "bootsier.form.textarea.floating_label";
|
||||||
///
|
///
|
||||||
/// let comentario = bs::form::Textarea::new()
|
/// let comentario = bs::form::Textarea::new()
|
||||||
/// .with_name("comment")
|
/// .with_name("comment")
|
||||||
/// .with_label(L10n::n("Comment"))
|
/// .with_label(Lc::n("Comment"))
|
||||||
/// .with_placeholder(L10n::n("Write here..."))
|
/// .with_placeholder(Lc::n("Write here..."))
|
||||||
/// .with_floating_label(true);
|
/// .with_floating_label(true);
|
||||||
/// ```
|
/// ```
|
||||||
pub trait TextareaBootsier {
|
pub trait TextareaBootsier {
|
||||||
|
|
@ -76,7 +76,7 @@ pub(crate) fn render(field: &Textarea, cx: &mut Context) -> Result<Markup, Compo
|
||||||
@if *field.required() {
|
@if *field.required() {
|
||||||
span
|
span
|
||||||
class="form-required"
|
class="form-required"
|
||||||
title=[L10n::l("field_required").lookup(cx)]
|
title=[Lc::l("field_required").lookup(cx)]
|
||||||
{
|
{
|
||||||
"*"
|
"*"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use crate::theme::*;
|
||||||
/// - Configurar sus **dimensiones** ([`with_size()`](Self::with_size)), **borde**
|
/// - Configurar sus **dimensiones** ([`with_size()`](Self::with_size)), **borde**
|
||||||
/// ([`Border`](crate::theme::class::Border)) y **redondeo de esquinas**
|
/// ([`Border`](crate::theme::class::Border)) y **redondeo de esquinas**
|
||||||
/// ([`Rounded`](crate::theme::class::Rounded)).
|
/// ([`Rounded`](crate::theme::class::Rounded)).
|
||||||
/// - Aplicar el texto alternativo `alt` con **localización** mediante [`L10n`].
|
/// - Aplicar el texto alternativo `alt` con **localización** mediante [`Lc`].
|
||||||
#[derive(AutoDefault, Clone, Debug, Getters)]
|
#[derive(AutoDefault, Clone, Debug, Getters)]
|
||||||
pub struct Image {
|
pub struct Image {
|
||||||
/// Devuelve identificador, clases CSS, atributos HTML y valores extra del componente.
|
/// Devuelve identificador, clases CSS, atributos HTML y valores extra del componente.
|
||||||
|
|
@ -21,7 +21,7 @@ pub struct Image {
|
||||||
/// Devuelve el origen de la imagen.
|
/// Devuelve el origen de la imagen.
|
||||||
source: bs::image::Source,
|
source: bs::image::Source,
|
||||||
/// Devuelve el texto alternativo localizado.
|
/// Devuelve el texto alternativo localizado.
|
||||||
alternative: Attr<L10n>,
|
alternative: Attr<Lc>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|
@ -112,12 +112,12 @@ impl Image {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Define un *texto localizado* ([`L10n`]) alternativo para la imagen.
|
/// Define un *texto localizado* ([`Lc`]) alternativo para la imagen.
|
||||||
///
|
///
|
||||||
/// Se recomienda siempre aportar un texto alternativo salvo que la imagen sea puramente
|
/// Se recomienda siempre aportar un texto alternativo salvo que la imagen sea puramente
|
||||||
/// decorativa.
|
/// decorativa.
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_alternative(mut self, alt: L10n) -> Self {
|
pub fn with_alternative(mut self, alt: Lc) -> Self {
|
||||||
self.alternative.alter_value(alt);
|
self.alternative.alter_value(alt);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
//! desplegables [`Dropdown`](crate::theme::bs::Dropdown).
|
//! desplegables [`Dropdown`](crate::theme::bs::Dropdown).
|
||||||
//!
|
//!
|
||||||
//! Los ítems pueden estar activos, deshabilitados o abrirse en nueva ventana según su contexto y
|
//! Los ítems pueden estar activos, deshabilitados o abrirse en nueva ventana según su contexto y
|
||||||
//! configuración, y permiten incluir etiquetas localizables usando [`L10n`](pagetop::locale::L10n).
|
//! configuración, y permiten incluir etiquetas localizables usando [`Lc`](pagetop::locale::Lc).
|
||||||
|
|
||||||
mod props;
|
mod props;
|
||||||
pub use props::{Kind, Layout};
|
pub use props::{Kind, Layout};
|
||||||
|
|
|
||||||
|
|
@ -20,17 +20,17 @@ use crate::theme::*;
|
||||||
///
|
///
|
||||||
/// let nav = bs::Nav::tabs()
|
/// let nav = bs::Nav::tabs()
|
||||||
/// .with_layout(bs::nav::Layout::End)
|
/// .with_layout(bs::nav::Layout::End)
|
||||||
/// .with_item(bs::nav::Item::link(L10n::n("Home"), |_| "/".into()))
|
/// .with_item(bs::nav::Item::link(Lc::n("Home"), "/"))
|
||||||
/// .with_item(bs::nav::Item::link_blank(L10n::n("External"), |_| "https://docs.rs".into()))
|
/// .with_item(bs::nav::Item::link_blank(Lc::n("External"), "https://docs.rs"))
|
||||||
/// .with_item(bs::nav::Item::dropdown(
|
/// .with_item(bs::nav::Item::dropdown(
|
||||||
/// bs::Dropdown::new()
|
/// bs::Dropdown::new()
|
||||||
/// .with_title(L10n::n("Options"))
|
/// .with_title(Lc::n("Options"))
|
||||||
/// .with_item(ChildOp::AddMany(vec![
|
/// .with_item(ChildOp::AddMany(vec![
|
||||||
/// bs::dropdown::Item::link(L10n::n("Action"), |_| "/action".into()).into(),
|
/// bs::dropdown::Item::link(Lc::n("Action"), "/action").into(),
|
||||||
/// bs::dropdown::Item::link(L10n::n("Another"), |_| "/another".into()).into(),
|
/// bs::dropdown::Item::link(Lc::n("Another"), "/another").into(),
|
||||||
/// ])),
|
/// ])),
|
||||||
/// ))
|
/// ))
|
||||||
/// .with_item(bs::nav::Item::link_disabled(L10n::n("Disabled"), |_| "#".into()));
|
/// .with_item(bs::nav::Item::link_disabled(Lc::n("Disabled"), "#"));
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(AutoDefault, Clone, Debug, Getters)]
|
#[derive(AutoDefault, Clone, Debug, Getters)]
|
||||||
pub struct Nav {
|
pub struct Nav {
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,12 @@ pub enum ItemKind {
|
||||||
#[default]
|
#[default]
|
||||||
Void,
|
Void,
|
||||||
/// Etiqueta sin comportamiento interactivo.
|
/// Etiqueta sin comportamiento interactivo.
|
||||||
Label(L10n),
|
Label(Lc),
|
||||||
/// Elemento de navegación basado en una [`RoutePath`] dinámica devuelta por
|
/// Elemento de navegación basado en una [`RoutePath`] dinámica resuelta por una [`Route`].
|
||||||
/// [`FnPathByContext`]. Opcionalmente, puede abrirse en una nueva ventana y estar inicialmente
|
/// Opcionalmente, puede abrirse en una nueva ventana y estar inicialmente deshabilitado.
|
||||||
/// deshabilitado.
|
|
||||||
Link {
|
Link {
|
||||||
label: L10n,
|
label: Lc,
|
||||||
route: FnPathByContext,
|
route: Route,
|
||||||
blank: bool,
|
blank: bool,
|
||||||
disabled: bool,
|
disabled: bool,
|
||||||
},
|
},
|
||||||
|
|
@ -97,7 +96,7 @@ impl Component for Item {
|
||||||
blank,
|
blank,
|
||||||
disabled,
|
disabled,
|
||||||
} => {
|
} => {
|
||||||
let route_link = route(cx);
|
let route_link = route.resolve(cx);
|
||||||
let current_path = cx.request().map(|request| request.path());
|
let current_path = cx.request().map(|request| request.path());
|
||||||
let is_current = !*disabled && (current_path == Some(route_link.path()));
|
let is_current = !*disabled && (current_path == Some(route_link.path()));
|
||||||
|
|
||||||
|
|
@ -145,7 +144,7 @@ impl Component for Item {
|
||||||
return Ok(html! {});
|
return Ok(html! {});
|
||||||
}
|
}
|
||||||
let title = dd.title().lookup(cx).unwrap_or_else(|| {
|
let title = dd.title().lookup(cx).unwrap_or_else(|| {
|
||||||
L10n::t("dropdown", &LOCALES_BOOTSIER)
|
Lc::t("dropdown", &LOCALES_BOOTSIER)
|
||||||
.lookup(cx)
|
.lookup(cx)
|
||||||
.unwrap_or_else(|| "Dropdown".to_string())
|
.unwrap_or_else(|| "Dropdown".to_string())
|
||||||
});
|
});
|
||||||
|
|
@ -175,7 +174,7 @@ impl Component for Item {
|
||||||
|
|
||||||
impl Item {
|
impl Item {
|
||||||
/// Crea un elemento de tipo texto, mostrado sin interacción.
|
/// Crea un elemento de tipo texto, mostrado sin interacción.
|
||||||
pub fn label(label: L10n) -> Self {
|
pub fn label(label: Lc) -> Self {
|
||||||
Self {
|
Self {
|
||||||
item_kind: ItemKind::Label(label),
|
item_kind: ItemKind::Label(label),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
@ -184,14 +183,14 @@ impl Item {
|
||||||
|
|
||||||
/// Crea un enlace para la navegación.
|
/// Crea un enlace para la navegación.
|
||||||
///
|
///
|
||||||
/// La ruta se obtiene invocando [`FnPathByContext`], que devuelve dinámicamente una
|
/// La ruta se obtiene invocando [`Route::resolve()`], que devuelve dinámicamente una
|
||||||
/// [`RoutePath`] en función del [`Context`]. El enlace se marca como `active` si la ruta actual
|
/// [`RoutePath`] en función del [`Context`]. El enlace se marca como `active` si la ruta actual
|
||||||
/// del *request* coincide con la ruta de destino (devuelta por `RoutePath::path`).
|
/// del *request* coincide con la ruta de destino (devuelta por `RoutePath::path`).
|
||||||
pub fn link(label: L10n, route: FnPathByContext) -> Self {
|
pub fn link(label: Lc, route: impl Into<Route>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
item_kind: ItemKind::Link {
|
item_kind: ItemKind::Link {
|
||||||
label,
|
label,
|
||||||
route,
|
route: route.into(),
|
||||||
blank: false,
|
blank: false,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
},
|
},
|
||||||
|
|
@ -200,11 +199,11 @@ impl Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Crea un enlace deshabilitado que no permite la interacción.
|
/// Crea un enlace deshabilitado que no permite la interacción.
|
||||||
pub fn link_disabled(label: L10n, route: FnPathByContext) -> Self {
|
pub fn link_disabled(label: Lc, route: impl Into<Route>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
item_kind: ItemKind::Link {
|
item_kind: ItemKind::Link {
|
||||||
label,
|
label,
|
||||||
route,
|
route: route.into(),
|
||||||
blank: false,
|
blank: false,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
},
|
},
|
||||||
|
|
@ -213,11 +212,11 @@ impl Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Crea un enlace que se abre en una nueva ventana o pestaña.
|
/// Crea un enlace que se abre en una nueva ventana o pestaña.
|
||||||
pub fn link_blank(label: L10n, route: FnPathByContext) -> Self {
|
pub fn link_blank(label: Lc, route: impl Into<Route>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
item_kind: ItemKind::Link {
|
item_kind: ItemKind::Link {
|
||||||
label,
|
label,
|
||||||
route,
|
route: route.into(),
|
||||||
blank: true,
|
blank: true,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
},
|
},
|
||||||
|
|
@ -226,11 +225,11 @@ impl Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Crea un enlace inicialmente deshabilitado que se abriría en una nueva ventana.
|
/// Crea un enlace inicialmente deshabilitado que se abriría en una nueva ventana.
|
||||||
pub fn link_blank_disabled(label: L10n, route: FnPathByContext) -> Self {
|
pub fn link_blank_disabled(label: Lc, route: impl Into<Route>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
item_kind: ItemKind::Link {
|
item_kind: ItemKind::Link {
|
||||||
label,
|
label,
|
||||||
route,
|
route: route.into(),
|
||||||
blank: true,
|
blank: true,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! Cada [`navbar::Item`](crate::theme::bs::navbar::Item) representa un elemento individual de la
|
//! Cada [`navbar::Item`](crate::theme::bs::navbar::Item) representa un elemento individual de la
|
||||||
//! barra de navegación [`Navbar`], con distintos comportamientos según su finalidad, como menús
|
//! barra de navegación [`Navbar`], con distintos comportamientos según su finalidad, como menús
|
||||||
//! [`Nav`](crate::theme::bs::Nav) o *textos localizados* usando [`L10n`](pagetop::locale::L10n).
|
//! [`Nav`](crate::theme::bs::Nav) o *textos localizados* usando [`Lc`](pagetop::locale::Lc).
|
||||||
//!
|
//!
|
||||||
//! También puede añadir una marca de identidad ([`navbar::Brand`](crate::theme::bs::navbar::Brand))
|
//! También puede añadir una marca de identidad ([`navbar::Brand`](crate::theme::bs::navbar::Brand))
|
||||||
//! que identifique la compañía, producto o nombre del proyecto asociado a la solución web.
|
//! que identifique la compañía, producto o nombre del proyecto asociado a la solución web.
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,13 @@ pub struct Brand {
|
||||||
/// Devuelve la imagen de marca (si la hay).
|
/// Devuelve la imagen de marca (si la hay).
|
||||||
image: Embed<bs::Image>,
|
image: Embed<bs::Image>,
|
||||||
/// Devuelve el título de la identidad de marca.
|
/// Devuelve el título de la identidad de marca.
|
||||||
#[default(_code = "L10n::n(&global::SETTINGS.app.name)")]
|
#[default(_code = "Lc::n(&global::SETTINGS.app.name)")]
|
||||||
title: L10n,
|
title: Lc,
|
||||||
/// Devuelve el eslogan de la marca.
|
/// Devuelve el eslogan de la marca.
|
||||||
slogan: L10n,
|
slogan: Lc,
|
||||||
/// Devuelve la función que resuelve la URL asociada a la marca (si existe).
|
/// Devuelve la ruta asociada a la marca (si existe).
|
||||||
#[default(_code = "Some(|cx| cx.route(\"/\"))")]
|
#[default(_code = "Some(\"/\".into())")]
|
||||||
route: Option<FnPathByContext>,
|
route: Option<Route>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|
@ -40,7 +40,7 @@ impl Component for Brand {
|
||||||
let slogan = self.slogan().using(cx);
|
let slogan = self.slogan().using(cx);
|
||||||
Ok(html! {
|
Ok(html! {
|
||||||
@if let Some(route) = self.route() {
|
@if let Some(route) = self.route() {
|
||||||
a class="navbar-brand" href=(route(cx)) { (image) (title) (slogan) }
|
a class="navbar-brand" href=(route.resolve(cx)) { (image) (title) (slogan) }
|
||||||
} @else {
|
} @else {
|
||||||
span class="navbar-brand" { (image) (title) (slogan) }
|
span class="navbar-brand" { (image) (title) (slogan) }
|
||||||
}
|
}
|
||||||
|
|
@ -60,21 +60,21 @@ impl Brand {
|
||||||
|
|
||||||
/// Establece el título de la identidad de marca.
|
/// Establece el título de la identidad de marca.
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_title(mut self, title: L10n) -> Self {
|
pub fn with_title(mut self, title: Lc) -> Self {
|
||||||
self.title = title;
|
self.title = title;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Define el eslogan de la marca.
|
/// Define el eslogan de la marca.
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_slogan(mut self, slogan: L10n) -> Self {
|
pub fn with_slogan(mut self, slogan: Lc) -> Self {
|
||||||
self.slogan = slogan;
|
self.slogan = slogan;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Define la URL de destino. Si es `None`, la marca no será un enlace.
|
/// Define la ruta de destino. Si es `None`, la marca no será un enlace.
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_route(mut self, route: Option<FnPathByContext>) -> Self {
|
pub fn with_route(mut self, route: Option<Route>) -> Self {
|
||||||
self.route = route;
|
self.route = route;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,9 @@ const TOGGLE_OFFCANVAS: &str = "offcanvas";
|
||||||
/// let navbar = bs::Navbar::simple()
|
/// let navbar = bs::Navbar::simple()
|
||||||
/// .with_item(bs::navbar::Item::nav(
|
/// .with_item(bs::navbar::Item::nav(
|
||||||
/// bs::Nav::new()
|
/// bs::Nav::new()
|
||||||
/// .with_item(bs::nav::Item::link(L10n::n("Home"), |_| "/".into()))
|
/// .with_item(bs::nav::Item::link(Lc::n("Home"), "/"))
|
||||||
/// .with_item(bs::nav::Item::link(L10n::n("About"), |_| "/about".into()))
|
/// .with_item(bs::nav::Item::link(Lc::n("About"), "/about"))
|
||||||
/// .with_item(bs::nav::Item::link(L10n::n("Contact"), |_| "/contact".into()))
|
/// .with_item(bs::nav::Item::link(Lc::n("Contact"), "/contact"))
|
||||||
/// ));
|
/// ));
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
|
@ -38,12 +38,12 @@ const TOGGLE_OFFCANVAS: &str = "offcanvas";
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// # use pagetop_bootsier::theme::*;
|
/// # use pagetop_bootsier::theme::*;
|
||||||
/// let navbar = bs::Navbar::simple_toggle()
|
/// let navbar = bs::Navbar::simple_toggle()
|
||||||
/// .with_expand(token::BreakPoint::MD)
|
/// .with_expand(BreakPoint::MD)
|
||||||
/// .with_item(bs::navbar::Item::nav(
|
/// .with_item(bs::navbar::Item::nav(
|
||||||
/// bs::Nav::new()
|
/// bs::Nav::new()
|
||||||
/// .with_item(bs::nav::Item::link(L10n::n("Home"), |_| "/".into()))
|
/// .with_item(bs::nav::Item::link(Lc::n("Home"), "/"))
|
||||||
/// .with_item(bs::nav::Item::link_blank(L10n::n("Doc"), |_| "https://docs.rs".into()))
|
/// .with_item(bs::nav::Item::link_blank(Lc::n("Doc"), "https://docs.rs"))
|
||||||
/// .with_item(bs::nav::Item::link(L10n::n("Support"), |_| "/support".into()))
|
/// .with_item(bs::nav::Item::link(Lc::n("Support"), "/support"))
|
||||||
/// ));
|
/// ));
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
|
@ -53,24 +53,24 @@ const TOGGLE_OFFCANVAS: &str = "offcanvas";
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// # use pagetop_bootsier::theme::*;
|
/// # use pagetop_bootsier::theme::*;
|
||||||
/// let brand = bs::navbar::Brand::new()
|
/// let brand = bs::navbar::Brand::new()
|
||||||
/// .with_title(L10n::n("PageTop"))
|
/// .with_title(Lc::n("PageTop"))
|
||||||
/// .with_route(Some(|cx| cx.route("/")));
|
/// .with_route(Some("/".into()));
|
||||||
///
|
///
|
||||||
/// let navbar = bs::Navbar::brand_left(brand)
|
/// let navbar = bs::Navbar::brand_left(brand)
|
||||||
/// .with_item(bs::navbar::Item::nav(
|
/// .with_item(bs::navbar::Item::nav(
|
||||||
/// bs::Nav::new()
|
/// bs::Nav::new()
|
||||||
/// .with_item(bs::nav::Item::link(L10n::n("Home"), |_| "/".into()))
|
/// .with_item(bs::nav::Item::link(Lc::n("Home"), "/"))
|
||||||
/// .with_item(bs::nav::Item::dropdown(
|
/// .with_item(bs::nav::Item::dropdown(
|
||||||
/// bs::Dropdown::new()
|
/// bs::Dropdown::new()
|
||||||
/// .with_title(L10n::n("Tools"))
|
/// .with_title(Lc::n("Tools"))
|
||||||
/// .with_item(bs::dropdown::Item::link(
|
/// .with_item(bs::dropdown::Item::link(
|
||||||
/// L10n::n("Generator"), |_| "/tools/gen".into())
|
/// Lc::n("Generator"), "/tools/gen")
|
||||||
/// )
|
/// )
|
||||||
/// .with_item(bs::dropdown::Item::link(
|
/// .with_item(bs::dropdown::Item::link(
|
||||||
/// L10n::n("Reports"), |_| "/tools/reports".into())
|
/// Lc::n("Reports"), "/tools/reports")
|
||||||
/// )
|
/// )
|
||||||
/// ))
|
/// ))
|
||||||
/// .with_item(bs::nav::Item::link_disabled(L10n::n("Disabled"), |_| "#".into()))
|
/// .with_item(bs::nav::Item::link_disabled(Lc::n("Disabled"), "#"))
|
||||||
/// ));
|
/// ));
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
|
@ -80,15 +80,15 @@ const TOGGLE_OFFCANVAS: &str = "offcanvas";
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// # use pagetop_bootsier::theme::*;
|
/// # use pagetop_bootsier::theme::*;
|
||||||
/// let brand = bs::navbar::Brand::new()
|
/// let brand = bs::navbar::Brand::new()
|
||||||
/// .with_title(L10n::n("Intranet"))
|
/// .with_title(Lc::n("Intranet"))
|
||||||
/// .with_route(Some(|cx| cx.route("/")));
|
/// .with_route(Some("/".into()));
|
||||||
///
|
///
|
||||||
/// let navbar = bs::Navbar::brand_right(brand)
|
/// let navbar = bs::Navbar::brand_right(brand)
|
||||||
/// .with_expand(token::BreakPoint::LG)
|
/// .with_expand(BreakPoint::LG)
|
||||||
/// .with_item(bs::navbar::Item::nav(
|
/// .with_item(bs::navbar::Item::nav(
|
||||||
/// bs::Nav::pills()
|
/// bs::Nav::pills()
|
||||||
/// .with_item(bs::nav::Item::link(L10n::n("Dashboard"), |_| "/dashboard".into()))
|
/// .with_item(bs::nav::Item::link(Lc::n("Dashboard"), "/dashboard"))
|
||||||
/// .with_item(bs::nav::Item::link(L10n::n("Users"), |_| "/users".into()))
|
/// .with_item(bs::nav::Item::link(Lc::n("Users"), "/users"))
|
||||||
/// ));
|
/// ));
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
|
@ -99,20 +99,20 @@ const TOGGLE_OFFCANVAS: &str = "offcanvas";
|
||||||
/// # use pagetop_bootsier::theme::*;
|
/// # use pagetop_bootsier::theme::*;
|
||||||
/// let oc = bs::Offcanvas::new()
|
/// let oc = bs::Offcanvas::new()
|
||||||
/// .with_id("main_offcanvas")
|
/// .with_id("main_offcanvas")
|
||||||
/// .with_title(L10n::n("Main menu"))
|
/// .with_title(Lc::n("Main menu"))
|
||||||
/// .with_placement(bs::offcanvas::Placement::Start)
|
/// .with_placement(bs::offcanvas::Placement::Start)
|
||||||
/// .with_backdrop(bs::offcanvas::Backdrop::Enabled);
|
/// .with_backdrop(bs::offcanvas::Backdrop::Enabled);
|
||||||
///
|
///
|
||||||
/// let navbar = bs::Navbar::offcanvas(oc)
|
/// let navbar = bs::Navbar::offcanvas(oc)
|
||||||
/// .with_item(bs::navbar::Item::nav(
|
/// .with_item(bs::navbar::Item::nav(
|
||||||
/// bs::Nav::new()
|
/// bs::Nav::new()
|
||||||
/// .with_item(bs::nav::Item::link(L10n::n("Home"), |_| "/".into()))
|
/// .with_item(bs::nav::Item::link(Lc::n("Home"), "/"))
|
||||||
/// .with_item(bs::nav::Item::link(L10n::n("Profile"), |_| "/profile".into()))
|
/// .with_item(bs::nav::Item::link(Lc::n("Profile"), "/profile"))
|
||||||
/// .with_item(bs::nav::Item::dropdown(
|
/// .with_item(bs::nav::Item::dropdown(
|
||||||
/// bs::Dropdown::new()
|
/// bs::Dropdown::new()
|
||||||
/// .with_title(L10n::n("More"))
|
/// .with_title(Lc::n("More"))
|
||||||
/// .with_item(bs::dropdown::Item::link(L10n::n("Settings"), |_| "/settings".into()))
|
/// .with_item(bs::dropdown::Item::link(Lc::n("Settings"), "/settings"))
|
||||||
/// .with_item(bs::dropdown::Item::link(L10n::n("Help"), |_| "/help".into()))
|
/// .with_item(bs::dropdown::Item::link(Lc::n("Help"), "/help"))
|
||||||
/// ))
|
/// ))
|
||||||
/// ));
|
/// ));
|
||||||
/// ```
|
/// ```
|
||||||
|
|
@ -123,16 +123,16 @@ const TOGGLE_OFFCANVAS: &str = "offcanvas";
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// # use pagetop_bootsier::theme::*;
|
/// # use pagetop_bootsier::theme::*;
|
||||||
/// let brand = bs::navbar::Brand::new()
|
/// let brand = bs::navbar::Brand::new()
|
||||||
/// .with_title(L10n::n("Main App"))
|
/// .with_title(Lc::n("Main App"))
|
||||||
/// .with_route(Some(|cx| cx.route("/")));
|
/// .with_route(Some("/".into()));
|
||||||
///
|
///
|
||||||
/// let navbar = bs::Navbar::brand_left(brand)
|
/// let navbar = bs::Navbar::brand_left(brand)
|
||||||
/// .with_position(bs::navbar::Position::FixedTop)
|
/// .with_position(bs::navbar::Position::FixedTop)
|
||||||
/// .with_item(bs::navbar::Item::nav(
|
/// .with_item(bs::navbar::Item::nav(
|
||||||
/// bs::Nav::new()
|
/// bs::Nav::new()
|
||||||
/// .with_item(bs::nav::Item::link(L10n::n("Dashboard"), |_| "/".into()))
|
/// .with_item(bs::nav::Item::link(Lc::n("Dashboard"), "/"))
|
||||||
/// .with_item(bs::nav::Item::link(L10n::n("Donors"), |_| "/donors".into()))
|
/// .with_item(bs::nav::Item::link(Lc::n("Donors"), "/donors"))
|
||||||
/// .with_item(bs::nav::Item::link(L10n::n("Stock"), |_| "/stock".into()))
|
/// .with_item(bs::nav::Item::link(Lc::n("Stock"), "/stock"))
|
||||||
/// ));
|
/// ));
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(AutoDefault, Clone, Debug, Getters)]
|
#[derive(AutoDefault, Clone, Debug, Getters)]
|
||||||
|
|
@ -140,7 +140,7 @@ pub struct Navbar {
|
||||||
/// Devuelve identificador, clases CSS, atributos HTML y valores extra del componente.
|
/// Devuelve identificador, clases CSS, atributos HTML y valores extra del componente.
|
||||||
props: Props,
|
props: Props,
|
||||||
/// Devuelve el punto de ruptura configurado.
|
/// Devuelve el punto de ruptura configurado.
|
||||||
expand: token::BreakPoint,
|
expand: BreakPoint,
|
||||||
/// Devuelve la disposición configurada para la barra de navegación.
|
/// Devuelve la disposición configurada para la barra de navegación.
|
||||||
layout: bs::navbar::Layout,
|
layout: bs::navbar::Layout,
|
||||||
/// Devuelve la posición configurada para la barra de navegación.
|
/// Devuelve la posición configurada para la barra de navegación.
|
||||||
|
|
@ -189,7 +189,7 @@ impl Component for Navbar {
|
||||||
data-bs-target=(id_content_target)
|
data-bs-target=(id_content_target)
|
||||||
aria-controls=(id_content)
|
aria-controls=(id_content)
|
||||||
aria-expanded=[aria_expanded]
|
aria-expanded=[aria_expanded]
|
||||||
aria-label=[L10n::t("toggle", &LOCALES_BOOTSIER).lookup(cx)]
|
aria-label=[Lc::t("toggle", &LOCALES_BOOTSIER).lookup(cx)]
|
||||||
{
|
{
|
||||||
span class="navbar-toggler-icon" {}
|
span class="navbar-toggler-icon" {}
|
||||||
}
|
}
|
||||||
|
|
@ -350,7 +350,7 @@ impl Navbar {
|
||||||
///
|
///
|
||||||
/// También acepta clases predefinidas para:
|
/// También acepta clases predefinidas para:
|
||||||
///
|
///
|
||||||
/// - Modificar el color de fondo ([`Background`]).
|
/// - Modificar el color de fondo ([`Bg`]).
|
||||||
/// - Definir la apariencia del texto ([`Text`]).
|
/// - Definir la apariencia del texto ([`Text`]).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||||
|
|
@ -360,7 +360,7 @@ impl Navbar {
|
||||||
|
|
||||||
/// Define a partir de qué punto de ruptura la barra de navegación deja de colapsar.
|
/// Define a partir de qué punto de ruptura la barra de navegación deja de colapsar.
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_expand(mut self, bp: token::BreakPoint) -> Self {
|
pub fn with_expand(mut self, bp: BreakPoint) -> Self {
|
||||||
self.expand = bp;
|
self.expand = bp;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ pub enum Item {
|
||||||
/// Representa un menú de navegación [`Nav`](crate::theme::bs::Nav).
|
/// Representa un menú de navegación [`Nav`](crate::theme::bs::Nav).
|
||||||
Nav(Embed<bs::Nav>),
|
Nav(Embed<bs::Nav>),
|
||||||
/// Representa un *texto localizado* libre.
|
/// Representa un *texto localizado* libre.
|
||||||
Text(L10n),
|
Text(Lc),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|
@ -92,7 +92,7 @@ impl Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Crea un elemento con un *texto localizado*, mostrado sin interacción.
|
/// Crea un elemento con un *texto localizado*, mostrado sin interacción.
|
||||||
pub fn text(item: L10n) -> Self {
|
pub fn text(item: Lc) -> Self {
|
||||||
Self::Text(item)
|
Self::Text(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,16 +29,16 @@ use crate::theme::*;
|
||||||
///
|
///
|
||||||
/// let panel = bs::Offcanvas::new()
|
/// let panel = bs::Offcanvas::new()
|
||||||
/// .with_id("offcanvas_example")
|
/// .with_id("offcanvas_example")
|
||||||
/// .with_title(L10n::n("Offcanvas title"))
|
/// .with_title(Lc::n("Offcanvas title"))
|
||||||
/// .with_placement(bs::offcanvas::Placement::End)
|
/// .with_placement(bs::offcanvas::Placement::End)
|
||||||
/// .with_backdrop(bs::offcanvas::Backdrop::Enabled)
|
/// .with_backdrop(bs::offcanvas::Backdrop::Enabled)
|
||||||
/// .with_body_scroll(bs::offcanvas::BodyScroll::Enabled)
|
/// .with_body_scroll(bs::offcanvas::BodyScroll::Enabled)
|
||||||
/// .with_visibility(bs::offcanvas::Visibility::Default)
|
/// .with_visibility(bs::offcanvas::Visibility::Default)
|
||||||
/// .with_child(bs::Dropdown::new()
|
/// .with_child(bs::Dropdown::new()
|
||||||
/// .with_title(L10n::n("Menu"))
|
/// .with_title(Lc::n("Menu"))
|
||||||
/// .with_item(bs::dropdown::Item::label(L10n::n("Label")))
|
/// .with_item(bs::dropdown::Item::label(Lc::n("Label")))
|
||||||
/// .with_item(bs::dropdown::Item::link_blank(L10n::n("Doc"), |_| "https://docs.rs".into()))
|
/// .with_item(bs::dropdown::Item::link_blank(Lc::n("Doc"), "https://docs.rs"))
|
||||||
/// .with_item(bs::dropdown::Item::link(L10n::n("Sign out"), |_| "/signout".into()))
|
/// .with_item(bs::dropdown::Item::link(Lc::n("Sign out"), "/signout"))
|
||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(AutoDefault, Clone, Debug, Getters)]
|
#[derive(AutoDefault, Clone, Debug, Getters)]
|
||||||
|
|
@ -46,9 +46,9 @@ pub struct Offcanvas {
|
||||||
/// Devuelve identificador, clases CSS, atributos HTML y valores extra del componente.
|
/// Devuelve identificador, clases CSS, atributos HTML y valores extra del componente.
|
||||||
props: Props,
|
props: Props,
|
||||||
/// Devuelve el título del panel.
|
/// Devuelve el título del panel.
|
||||||
title: L10n,
|
title: Lc,
|
||||||
/// Devuelve el punto de ruptura configurado para cambiar el comportamiento del panel.
|
/// Devuelve el punto de ruptura configurado para cambiar el comportamiento del panel.
|
||||||
breakpoint: token::BreakPoint,
|
breakpoint: BreakPoint,
|
||||||
/// Devuelve el comportamiento configurado para la capa de fondo.
|
/// Devuelve el comportamiento configurado para la capa de fondo.
|
||||||
backdrop: bs::offcanvas::Backdrop,
|
backdrop: bs::offcanvas::Backdrop,
|
||||||
/// Indica si la página principal puede desplazarse mientras el panel está abierto.
|
/// Indica si la página principal puede desplazarse mientras el panel está abierto.
|
||||||
|
|
@ -109,7 +109,7 @@ impl Offcanvas {
|
||||||
|
|
||||||
/// Establece el título del encabezado.
|
/// Establece el título del encabezado.
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_title(mut self, title: L10n) -> Self {
|
pub fn with_title(mut self, title: Lc) -> Self {
|
||||||
self.title = title;
|
self.title = title;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +124,7 @@ impl Offcanvas {
|
||||||
/// directamente en pantallas grandes. Por defecto usa `BreakPoint::None` para que sea
|
/// directamente en pantallas grandes. Por defecto usa `BreakPoint::None` para que sea
|
||||||
/// *offcanvas* siempre.
|
/// *offcanvas* siempre.
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_breakpoint(mut self, bp: token::BreakPoint) -> Self {
|
pub fn with_breakpoint(mut self, bp: BreakPoint) -> Self {
|
||||||
self.breakpoint = bp;
|
self.breakpoint = bp;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -210,7 +210,7 @@ impl Offcanvas {
|
||||||
class="btn-close"
|
class="btn-close"
|
||||||
data-bs-dismiss="offcanvas"
|
data-bs-dismiss="offcanvas"
|
||||||
data-bs-target=(id_target)
|
data-bs-target=(id_target)
|
||||||
aria-label=[L10n::t("offcanvas_close", &LOCALES_BOOTSIER).lookup(cx)]
|
aria-label=[Lc::t("offcanvas_close", &LOCALES_BOOTSIER).lookup(cx)]
|
||||||
{}
|
{}
|
||||||
}
|
}
|
||||||
div class="offcanvas-body" {
|
div class="offcanvas-body" {
|
||||||
|
|
|
||||||
|
|
@ -27,15 +27,15 @@ pub enum ButtonColorStyle {
|
||||||
/// use pagetop_bootsier::theme::*;
|
/// use pagetop_bootsier::theme::*;
|
||||||
///
|
///
|
||||||
/// // Botón sólido.
|
/// // Botón sólido.
|
||||||
/// let save = bs::Button::submit(L10n::n("Save"))
|
/// let save = bs::Button::submit(Lc::n("Save"))
|
||||||
/// .with_prop(PropsOp::add_classes(class::ButtonColor::solid(ThemeColor::Primary)));
|
/// .with_prop(PropsOp::add_classes(class::ButtonColor::solid(ThemeColor::Primary)));
|
||||||
///
|
///
|
||||||
/// // Botón con contorno.
|
/// // Botón con contorno.
|
||||||
/// let cancel = bs::Button::plain(L10n::n("Cancel"))
|
/// let cancel = bs::Button::plain(Lc::n("Cancel"))
|
||||||
/// .with_prop(PropsOp::add_classes(class::ButtonColor::outline(ThemeColor::Secondary)));
|
/// .with_prop(PropsOp::add_classes(class::ButtonColor::outline(ThemeColor::Secondary)));
|
||||||
///
|
///
|
||||||
/// // Botón tipo enlace.
|
/// // Botón tipo enlace.
|
||||||
/// let back = bs::Button::plain(L10n::n("Back"))
|
/// let back = bs::Button::plain(Lc::n("Back"))
|
||||||
/// .with_prop(PropsOp::add_classes(class::ButtonColor::link()));
|
/// .with_prop(PropsOp::add_classes(class::ButtonColor::link()));
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(AutoDefault, Clone, Copy, Debug, PartialEq)]
|
#[derive(AutoDefault, Clone, Copy, Debug, PartialEq)]
|
||||||
|
|
@ -148,10 +148,10 @@ pub enum ButtonSizeKind {
|
||||||
/// use pagetop::prelude::*;
|
/// use pagetop::prelude::*;
|
||||||
/// use pagetop_bootsier::theme::*;
|
/// use pagetop_bootsier::theme::*;
|
||||||
///
|
///
|
||||||
/// let small = bs::Button::submit(L10n::n("Save"))
|
/// let small = bs::Button::submit(Lc::n("Save"))
|
||||||
/// .with_prop(PropsOp::add_classes(class::ButtonSize::small()));
|
/// .with_prop(PropsOp::add_classes(class::ButtonSize::small()));
|
||||||
///
|
///
|
||||||
/// let large = bs::Button::submit(L10n::n("Save"))
|
/// let large = bs::Button::submit(Lc::n("Save"))
|
||||||
/// .with_prop(PropsOp::add_classes(class::ButtonSize::large()));
|
/// .with_prop(PropsOp::add_classes(class::ButtonSize::large()));
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(AutoDefault, Clone, Copy, Debug, PartialEq)]
|
#[derive(AutoDefault, Clone, Copy, Debug, PartialEq)]
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ use crate::hx;
|
||||||
/// .with_param("sort", field)
|
/// .with_param("sort", field)
|
||||||
/// .with_param("dir", next_dir);
|
/// .with_param("dir", next_dir);
|
||||||
///
|
///
|
||||||
/// table::Column::new(L10n::n("User"))
|
/// table::Column::new(Lc::n("User"))
|
||||||
/// .with_sort(hx_table::sort_link(href, "#user-table-wrapper", active))
|
/// .with_sort(hx_table::sort_link(href, "#user-table-wrapper", active))
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
|
||||||
|
|
@ -135,12 +135,12 @@ pub struct Htmx;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Extension for Htmx {
|
impl Extension for Htmx {
|
||||||
fn name(&self) -> L10n {
|
fn name(&self) -> Lc {
|
||||||
L10n::t("extension_name", &LOCALES_HTMX)
|
Lc::t("extension_name", &LOCALES_HTMX)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn description(&self) -> L10n {
|
fn description(&self) -> Lc {
|
||||||
L10n::t("extension_description", &LOCALES_HTMX)
|
Lc::t("extension_description", &LOCALES_HTMX)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn actions(&self) -> Vec<ActionBox> {
|
fn actions(&self) -> Vec<ActionBox> {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ async fn render_column(column: table::Column) -> String {
|
||||||
|
|
||||||
#[pagetop::test]
|
#[pagetop::test]
|
||||||
async fn sort_link_sets_the_four_fixed_htmx_attributes() {
|
async fn sort_link_sets_the_four_fixed_htmx_attributes() {
|
||||||
let column = table::Column::new(L10n::n("User")).with_sort(hx_table::sort_link(
|
let column = table::Column::new(Lc::n("User")).with_sort(hx_table::sort_link(
|
||||||
"/admin/users",
|
"/admin/users",
|
||||||
"#user-table",
|
"#user-table",
|
||||||
None,
|
None,
|
||||||
|
|
@ -34,7 +34,7 @@ async fn sort_link_sets_the_four_fixed_htmx_attributes() {
|
||||||
async fn sort_link_href_matches_the_hx_get_value() {
|
async fn sort_link_href_matches_the_hx_get_value() {
|
||||||
// The link must work with or without HTMX: `href` is the real destination, and `hx-get` must
|
// The link must work with or without HTMX: `href` is the real destination, and `hx-get` must
|
||||||
// request that very same URL so both navigation paths land on the same state.
|
// request that very same URL so both navigation paths land on the same state.
|
||||||
let column = table::Column::new(L10n::n("User")).with_sort(hx_table::sort_link(
|
let column = table::Column::new(Lc::n("User")).with_sort(hx_table::sort_link(
|
||||||
"/admin/users?sort=username",
|
"/admin/users?sort=username",
|
||||||
"#user-table",
|
"#user-table",
|
||||||
None,
|
None,
|
||||||
|
|
@ -48,7 +48,7 @@ async fn sort_link_href_matches_the_hx_get_value() {
|
||||||
|
|
||||||
#[pagetop::test]
|
#[pagetop::test]
|
||||||
async fn sort_link_target_is_configurable_per_table() {
|
async fn sort_link_target_is_configurable_per_table() {
|
||||||
let column = table::Column::new(L10n::n("Email")).with_sort(hx_table::sort_link(
|
let column = table::Column::new(Lc::n("Email")).with_sort(hx_table::sort_link(
|
||||||
"/admin/users",
|
"/admin/users",
|
||||||
"#other-wrapper",
|
"#other-wrapper",
|
||||||
None,
|
None,
|
||||||
|
|
@ -63,7 +63,7 @@ async fn sort_link_target_is_configurable_per_table() {
|
||||||
|
|
||||||
#[pagetop::test]
|
#[pagetop::test]
|
||||||
async fn sort_link_without_active_direction_marks_aria_sort_none() {
|
async fn sort_link_without_active_direction_marks_aria_sort_none() {
|
||||||
let column = table::Column::new(L10n::n("User")).with_sort(hx_table::sort_link(
|
let column = table::Column::new(Lc::n("User")).with_sort(hx_table::sort_link(
|
||||||
"/admin/users",
|
"/admin/users",
|
||||||
"#user-table",
|
"#user-table",
|
||||||
None,
|
None,
|
||||||
|
|
@ -76,7 +76,7 @@ async fn sort_link_without_active_direction_marks_aria_sort_none() {
|
||||||
|
|
||||||
#[pagetop::test]
|
#[pagetop::test]
|
||||||
async fn sort_link_with_active_direction_marks_aria_sort_and_css_class() {
|
async fn sort_link_with_active_direction_marks_aria_sort_and_css_class() {
|
||||||
let column = table::Column::new(L10n::n("User")).with_sort(hx_table::sort_link(
|
let column = table::Column::new(Lc::n("User")).with_sort(hx_table::sort_link(
|
||||||
"/admin/users",
|
"/admin/users",
|
||||||
"#user-table",
|
"#user-table",
|
||||||
SortDir::Desc,
|
SortDir::Desc,
|
||||||
|
|
@ -94,7 +94,7 @@ async fn sort_link_with_active_direction_marks_aria_sort_and_css_class() {
|
||||||
async fn sort_link_with_a_bare_literal_href_never_adds_lang() {
|
async fn sort_link_with_a_bare_literal_href_never_adds_lang() {
|
||||||
// `sort_link()` does not receive `cx`, so it cannot add `lang` on its own: passing a raw
|
// `sort_link()` does not receive `cx`, so it cannot add `lang` on its own: passing a raw
|
||||||
// literal must leave both `href` and `hx-get` exactly as given.
|
// literal must leave both `href` and `hx-get` exactly as given.
|
||||||
let column = table::Column::new(L10n::n("User")).with_sort(hx_table::sort_link(
|
let column = table::Column::new(Lc::n("User")).with_sort(hx_table::sort_link(
|
||||||
"/admin/users",
|
"/admin/users",
|
||||||
"#user-table",
|
"#user-table",
|
||||||
None,
|
None,
|
||||||
|
|
@ -113,11 +113,8 @@ async fn sort_link_carries_through_a_lang_aware_href_unchanged() {
|
||||||
let cx = cx_with_lang("es-ES");
|
let cx = cx_with_lang("es-ES");
|
||||||
let href = cx.route("/admin/users");
|
let href = cx.route("/admin/users");
|
||||||
|
|
||||||
let column = table::Column::new(L10n::n("User")).with_sort(hx_table::sort_link(
|
let column =
|
||||||
href,
|
table::Column::new(Lc::n("User")).with_sort(hx_table::sort_link(href, "#user-table", None));
|
||||||
"#user-table",
|
|
||||||
None,
|
|
||||||
));
|
|
||||||
|
|
||||||
let html = render_column(column).await;
|
let html = render_column(column).await;
|
||||||
|
|
||||||
|
|
@ -133,7 +130,7 @@ async fn sort_link_carries_through_extra_query_params_in_order() {
|
||||||
.with_param("sort", "username")
|
.with_param("sort", "username")
|
||||||
.with_param("dir", "desc");
|
.with_param("dir", "desc");
|
||||||
|
|
||||||
let column = table::Column::new(L10n::n("User")).with_sort(hx_table::sort_link(
|
let column = table::Column::new(Lc::n("User")).with_sort(hx_table::sort_link(
|
||||||
href,
|
href,
|
||||||
"#user-table",
|
"#user-table",
|
||||||
SortDir::Desc,
|
SortDir::Desc,
|
||||||
|
|
@ -153,7 +150,7 @@ async fn sort_link_with_an_external_href_is_left_untouched() {
|
||||||
let href = cx.route("https://example.com/export");
|
let href = cx.route("https://example.com/export");
|
||||||
|
|
||||||
let column =
|
let column =
|
||||||
table::Column::new(L10n::n("Export")).with_sort(hx_table::sort_link(href, "#table", None));
|
table::Column::new(Lc::n("Export")).with_sort(hx_table::sort_link(href, "#table", None));
|
||||||
|
|
||||||
let html = render_column(column).await;
|
let html = render_column(column).await;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -194,12 +194,12 @@ pub struct SeaORM;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Extension for SeaORM {
|
impl Extension for SeaORM {
|
||||||
fn name(&self) -> L10n {
|
fn name(&self) -> Lc {
|
||||||
L10n::t("extension_name", &LOCALES_SEAORM)
|
Lc::t("extension_name", &LOCALES_SEAORM)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn description(&self) -> L10n {
|
fn description(&self) -> Lc {
|
||||||
L10n::t("extension_description", &LOCALES_SEAORM)
|
Lc::t("extension_description", &LOCALES_SEAORM)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn initialize(&self) {
|
async fn initialize(&self) {
|
||||||
|
|
|
||||||
10
src/auth.rs
10
src/auth.rs
|
|
@ -17,7 +17,7 @@
|
||||||
//! [`Context`]: crate::core::component::Context
|
//! [`Context`]: crate::core::component::Context
|
||||||
|
|
||||||
use crate::core::action::{ActionDispatcher, ActionKey, try_dispatch_actions};
|
use crate::core::action::{ActionDispatcher, ActionKey, try_dispatch_actions};
|
||||||
use crate::locale::L10n;
|
use crate::locale::Lc;
|
||||||
use crate::response::ErrorPage;
|
use crate::response::ErrorPage;
|
||||||
use crate::web::HttpRequest;
|
use crate::web::HttpRequest;
|
||||||
use crate::{CowStr, UniqueId, Weight};
|
use crate::{CowStr, UniqueId, Weight};
|
||||||
|
|
@ -116,8 +116,8 @@ pub trait Permission: Send + Sync {
|
||||||
///
|
///
|
||||||
/// Por defecto devuelve la propia clave; una extensión que registre sus permisos en un catálogo
|
/// Por defecto devuelve la propia clave; una extensión que registre sus permisos en un catálogo
|
||||||
/// visible debería sobrescribirlo con un texto traducible.
|
/// visible debería sobrescribirlo con un texto traducible.
|
||||||
fn label(&self) -> L10n {
|
fn label(&self) -> Lc {
|
||||||
L10n::n(self.key())
|
Lc::n(self.key())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Identificador estable de la categoría del permiso, usado para agrupar en un catálogo (p.
|
/// Identificador estable de la categoría del permiso, usado para agrupar en un catálogo (p.
|
||||||
|
|
@ -129,8 +129,8 @@ pub trait Permission: Send + Sync {
|
||||||
/// Título traducible de [`group()`](Self::group), mostrado en la UI de administración.
|
/// Título traducible de [`group()`](Self::group), mostrado en la UI de administración.
|
||||||
///
|
///
|
||||||
/// Por defecto reutiliza el propio identificador del grupo como texto fijo.
|
/// Por defecto reutiliza el propio identificador del grupo como texto fijo.
|
||||||
fn group_label(&self) -> L10n {
|
fn group_label(&self) -> Lc {
|
||||||
L10n::n(self.group())
|
Lc::n(self.group())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@ use crate::prelude::*;
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// let badge = Badge::labeled(L10n::n("Admin"));
|
/// let badge = Badge::labeled(Lc::n("Admin"));
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(AutoDefault, Clone, Debug, Getters)]
|
#[derive(AutoDefault, Clone, Debug, Getters)]
|
||||||
pub struct Badge {
|
pub struct Badge {
|
||||||
/// Devuelve identificador, clases CSS, atributos HTML y valores extra del componente.
|
/// Devuelve identificador, clases CSS, atributos HTML y valores extra del componente.
|
||||||
props: Props,
|
props: Props,
|
||||||
/// Devuelve la etiqueta del badge.
|
/// Devuelve la etiqueta del badge.
|
||||||
label: L10n,
|
label: Lc,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|
@ -41,7 +41,7 @@ impl Component for Badge {
|
||||||
|
|
||||||
impl Badge {
|
impl Badge {
|
||||||
/// Crea un badge a partir de la etiqueta indicada.
|
/// Crea un badge a partir de la etiqueta indicada.
|
||||||
pub fn labeled(label: L10n) -> Self {
|
pub fn labeled(label: Lc) -> Self {
|
||||||
Self {
|
Self {
|
||||||
label,
|
label,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
@ -66,7 +66,7 @@ impl Badge {
|
||||||
|
|
||||||
/// Establece la etiqueta del badge.
|
/// Establece la etiqueta del badge.
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_label(mut self, label: L10n) -> Self {
|
pub fn with_label(mut self, label: Lc) -> Self {
|
||||||
self.label = label;
|
self.label = label;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ pub struct Block {
|
||||||
/// Devuelve identificador, clases CSS, atributos HTML y valores extra del componente.
|
/// Devuelve identificador, clases CSS, atributos HTML y valores extra del componente.
|
||||||
props: Props,
|
props: Props,
|
||||||
/// Devuelve el título del bloque.
|
/// Devuelve el título del bloque.
|
||||||
title: L10n,
|
title: Lc,
|
||||||
/// Devuelve la lista de componentes hijo del bloque.
|
/// Devuelve la lista de componentes hijo del bloque.
|
||||||
children: Children,
|
children: Children,
|
||||||
}
|
}
|
||||||
|
|
@ -69,7 +69,7 @@ impl Block {
|
||||||
|
|
||||||
/// Establece el título del bloque.
|
/// Establece el título del bloque.
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_title(mut self, title: L10n) -> Self {
|
pub fn with_title(mut self, title: Lc) -> Self {
|
||||||
self.title = title;
|
self.title = title;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ use crate::prelude::*;
|
||||||
/// use pagetop::prelude::*;
|
/// use pagetop::prelude::*;
|
||||||
///
|
///
|
||||||
/// let bc = Breadcrumb::new()
|
/// let bc = Breadcrumb::new()
|
||||||
/// .with_crumb(breadcrumb::Crumb::new(L10n::n("Home"), "/"))
|
/// .with_crumb(breadcrumb::Crumb::new(Lc::n("Home"), "/"))
|
||||||
/// .with_crumb(breadcrumb::Crumb::new(L10n::n("Users"), "/admin/users"))
|
/// .with_crumb(breadcrumb::Crumb::new(Lc::n("Users"), "/admin/users"))
|
||||||
/// .with_crumb(breadcrumb::Crumb::current(L10n::n("Julia")));
|
/// .with_crumb(breadcrumb::Crumb::current(Lc::n("Julia")));
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(AutoDefault, Clone, Debug, Getters)]
|
#[derive(AutoDefault, Clone, Debug, Getters)]
|
||||||
pub struct Breadcrumb {
|
pub struct Breadcrumb {
|
||||||
|
|
@ -56,7 +56,7 @@ impl Component for Breadcrumb {
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(html! {
|
Ok(html! {
|
||||||
nav (self.props()) aria-label=[L10n::l("breadcrumb_label").lookup(cx)] {
|
nav (self.props()) aria-label=[Lc::l("breadcrumb_label").lookup(cx)] {
|
||||||
ol.breadcrumb {
|
ol.breadcrumb {
|
||||||
@for crumb in self.crumbs() {
|
@for crumb in self.crumbs() {
|
||||||
(crumb.render_crumb(cx))
|
(crumb.render_crumb(cx))
|
||||||
|
|
|
||||||
|
|
@ -15,16 +15,16 @@ use crate::prelude::*;
|
||||||
/// use pagetop::prelude::*;
|
/// use pagetop::prelude::*;
|
||||||
///
|
///
|
||||||
/// let bc = Breadcrumb::new()
|
/// let bc = Breadcrumb::new()
|
||||||
/// .with_crumb(breadcrumb::Crumb::new(L10n::n("Home"), "/"))
|
/// .with_crumb(breadcrumb::Crumb::new(Lc::n("Home"), "/"))
|
||||||
/// .with_crumb(breadcrumb::Crumb::text(L10n::n("Users")))
|
/// .with_crumb(breadcrumb::Crumb::text(Lc::n("Users")))
|
||||||
/// .with_crumb(breadcrumb::Crumb::current(L10n::n("Julia")));
|
/// .with_crumb(breadcrumb::Crumb::current(Lc::n("Julia")));
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(AutoDefault, Clone, Debug, Getters)]
|
#[derive(AutoDefault, Clone, Debug, Getters)]
|
||||||
pub struct Crumb {
|
pub struct Crumb {
|
||||||
/// Devuelve identificador, clases CSS y atributos HTML del elemento.
|
/// Devuelve identificador, clases CSS y atributos HTML del elemento.
|
||||||
props: Props,
|
props: Props,
|
||||||
/// Devuelve la etiqueta del elemento.
|
/// Devuelve la etiqueta del elemento.
|
||||||
label: L10n,
|
label: Lc,
|
||||||
/// Devuelve la ruta de destino del elemento, si es un enlace.
|
/// Devuelve la ruta de destino del elemento, si es un enlace.
|
||||||
route: Option<Route>,
|
route: Option<Route>,
|
||||||
/// Devuelve si el elemento representa la página actual.
|
/// Devuelve si el elemento representa la página actual.
|
||||||
|
|
@ -33,7 +33,7 @@ pub struct Crumb {
|
||||||
|
|
||||||
impl Crumb {
|
impl Crumb {
|
||||||
/// Crea un elemento enlazado a la ruta indicada.
|
/// Crea un elemento enlazado a la ruta indicada.
|
||||||
pub fn new(label: L10n, route: impl Into<Route>) -> Self {
|
pub fn new(label: Lc, route: impl Into<Route>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
label,
|
label,
|
||||||
route: Some(route.into()),
|
route: Some(route.into()),
|
||||||
|
|
@ -46,7 +46,7 @@ impl Crumb {
|
||||||
///
|
///
|
||||||
/// Al renderizarse dentro de un `Breadcrumb`, el elemento lleva `aria-current="page"` y la
|
/// Al renderizarse dentro de un `Breadcrumb`, el elemento lleva `aria-current="page"` y la
|
||||||
/// clase `.active`.
|
/// clase `.active`.
|
||||||
pub fn current(label: L10n) -> Self {
|
pub fn current(label: Lc) -> Self {
|
||||||
Self {
|
Self {
|
||||||
label,
|
label,
|
||||||
is_current: true,
|
is_current: true,
|
||||||
|
|
@ -56,7 +56,7 @@ impl Crumb {
|
||||||
|
|
||||||
/// Crea un elemento de sólo texto, sin enlace ni marca de página actual (por ejemplo, un nivel
|
/// Crea un elemento de sólo texto, sin enlace ni marca de página actual (por ejemplo, un nivel
|
||||||
/// intermedio sin URL propia).
|
/// intermedio sin URL propia).
|
||||||
pub fn text(label: L10n) -> Self {
|
pub fn text(label: Lc) -> Self {
|
||||||
Self {
|
Self {
|
||||||
label,
|
label,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,9 @@ impl fmt::Display for ButtonAction {
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// use pagetop::prelude::*;
|
/// use pagetop::prelude::*;
|
||||||
///
|
///
|
||||||
/// let save = Button::submit(L10n::n("Save"));
|
/// let save = Button::submit(Lc::n("Save"));
|
||||||
/// let cancel = Button::plain(L10n::n("Cancel"));
|
/// let cancel = Button::plain(Lc::n("Cancel"));
|
||||||
/// let clear = Button::reset(L10n::n("Clear"));
|
/// let clear = Button::reset(Lc::n("Clear"));
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Cuando el botón activa el envío, el navegador incluye el par `name=value` en los datos del
|
/// Cuando el botón activa el envío, el navegador incluye el par `name=value` en los datos del
|
||||||
|
|
@ -74,9 +74,9 @@ pub struct Button {
|
||||||
/// Devuelve el valor del botón.
|
/// Devuelve el valor del botón.
|
||||||
value: AttrValue,
|
value: AttrValue,
|
||||||
/// Devuelve la etiqueta del botón.
|
/// Devuelve la etiqueta del botón.
|
||||||
label: Attr<L10n>,
|
label: Attr<Lc>,
|
||||||
/// Devuelve el texto emergente del botón (atributo `title`).
|
/// Devuelve el texto emergente del botón (atributo `title`).
|
||||||
title: Attr<L10n>,
|
title: Attr<Lc>,
|
||||||
/// Devuelve si el botón recibe el foco automáticamente al cargar la página.
|
/// Devuelve si el botón recibe el foco automáticamente al cargar la página.
|
||||||
autofocus: bool,
|
autofocus: bool,
|
||||||
/// Devuelve si el botón está deshabilitado.
|
/// Devuelve si el botón está deshabilitado.
|
||||||
|
|
@ -121,7 +121,7 @@ impl Button {
|
||||||
///
|
///
|
||||||
/// Es la acción predeterminada al pulsar un botón en la mayoría de los formularios: envía los
|
/// Es la acción predeterminada al pulsar un botón en la mayoría de los formularios: envía los
|
||||||
/// datos al servidor.
|
/// datos al servidor.
|
||||||
pub fn submit(label: L10n) -> Self {
|
pub fn submit(label: Lc) -> Self {
|
||||||
Self {
|
Self {
|
||||||
kind: ButtonAction::Submit,
|
kind: ButtonAction::Submit,
|
||||||
label: Attr::some(label),
|
label: Attr::some(label),
|
||||||
|
|
@ -132,7 +132,7 @@ impl Button {
|
||||||
/// Crea un botón de **restablecimiento** (`type="reset"`).
|
/// Crea un botón de **restablecimiento** (`type="reset"`).
|
||||||
///
|
///
|
||||||
/// Al pulsarlo, devuelve todos los campos del formulario a sus valores iniciales.
|
/// Al pulsarlo, devuelve todos los campos del formulario a sus valores iniciales.
|
||||||
pub fn reset(label: L10n) -> Self {
|
pub fn reset(label: Lc) -> Self {
|
||||||
Self {
|
Self {
|
||||||
kind: ButtonAction::Reset,
|
kind: ButtonAction::Reset,
|
||||||
label: Attr::some(label),
|
label: Attr::some(label),
|
||||||
|
|
@ -144,7 +144,7 @@ impl Button {
|
||||||
///
|
///
|
||||||
/// No tiene un comportamiento predeterminado sobre el formulario. Su comportamiento puede
|
/// No tiene un comportamiento predeterminado sobre el formulario. Su comportamiento puede
|
||||||
/// definirse mediante JavaScript.
|
/// definirse mediante JavaScript.
|
||||||
pub fn plain(label: L10n) -> Self {
|
pub fn plain(label: Lc) -> Self {
|
||||||
Self {
|
Self {
|
||||||
kind: ButtonAction::Plain,
|
kind: ButtonAction::Plain,
|
||||||
label: Attr::some(label),
|
label: Attr::some(label),
|
||||||
|
|
@ -190,14 +190,14 @@ impl Button {
|
||||||
|
|
||||||
/// Establece o elimina la etiqueta visible del botón (basta pasar `None` para quitarla).
|
/// Establece o elimina la etiqueta visible del botón (basta pasar `None` para quitarla).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_label(mut self, label: impl Into<Option<L10n>>) -> Self {
|
pub fn with_label(mut self, label: impl Into<Option<Lc>>) -> Self {
|
||||||
self.label.alter_opt(label.into());
|
self.label.alter_opt(label.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Establece o elimina el texto emergente del botón (basta pasar `None` para quitarlo).
|
/// Establece o elimina el texto emergente del botón (basta pasar `None` para quitarlo).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_title(mut self, title: impl Into<Option<L10n>>) -> Self {
|
pub fn with_title(mut self, title: impl Into<Option<Lc>>) -> Self {
|
||||||
self.title.alter_opt(title.into());
|
self.title.alter_opt(title.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,14 @@ use crate::prelude::*;
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// use pagetop::prelude::*;
|
/// use pagetop::prelude::*;
|
||||||
///
|
///
|
||||||
/// let item = form::check::Item::new("apple", L10n::n("Apple")).with_checked(true);
|
/// let item = form::check::Item::new("apple", Lc::n("Apple")).with_checked(true);
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(AutoDefault, Clone, Debug, Getters)]
|
#[derive(AutoDefault, Clone, Debug, Getters)]
|
||||||
pub struct Item {
|
pub struct Item {
|
||||||
/// Devuelve el valor enviado al servidor cuando la casilla está marcada.
|
/// Devuelve el valor enviado al servidor cuando la casilla está marcada.
|
||||||
value: AttrValue,
|
value: AttrValue,
|
||||||
/// Devuelve la etiqueta de la casilla.
|
/// Devuelve la etiqueta de la casilla.
|
||||||
label: L10n,
|
label: Lc,
|
||||||
/// Devuelve si la casilla debe aparecer marcada por defecto.
|
/// Devuelve si la casilla debe aparecer marcada por defecto.
|
||||||
checked: bool,
|
checked: bool,
|
||||||
/// Devuelve si la casilla está deshabilitada.
|
/// Devuelve si la casilla está deshabilitada.
|
||||||
|
|
@ -30,7 +30,7 @@ pub struct Item {
|
||||||
|
|
||||||
impl Item {
|
impl Item {
|
||||||
/// Crea una nueva casilla con el valor y la etiqueta indicados.
|
/// Crea una nueva casilla con el valor y la etiqueta indicados.
|
||||||
pub fn new(value: impl AsRef<str>, label: L10n) -> Self {
|
pub fn new(value: impl AsRef<str>, label: Lc) -> Self {
|
||||||
Self {
|
Self {
|
||||||
value: AttrValue::new(value),
|
value: AttrValue::new(value),
|
||||||
label,
|
label,
|
||||||
|
|
@ -70,10 +70,10 @@ impl Item {
|
||||||
///
|
///
|
||||||
/// let interests = form::check::Field::new()
|
/// let interests = form::check::Field::new()
|
||||||
/// .with_name("interests")
|
/// .with_name("interests")
|
||||||
/// .with_label(L10n::n("Areas of interest"))
|
/// .with_label(Lc::n("Areas of interest"))
|
||||||
/// .with_item(form::check::Item::new("art", L10n::n("Art")))
|
/// .with_item(form::check::Item::new("art", Lc::n("Art")))
|
||||||
/// .with_item(form::check::Item::new("tech", L10n::n("Technology")))
|
/// .with_item(form::check::Item::new("tech", Lc::n("Technology")))
|
||||||
/// .with_item(form::check::Item::new("science", L10n::n("Science")).with_checked(true));
|
/// .with_item(form::check::Item::new("science", Lc::n("Science")).with_checked(true));
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// El navegador envía una entrada por cada casilla marcada, todas bajo la misma clave (por ejemplo,
|
/// El navegador envía una entrada por cada casilla marcada, todas bajo la misma clave (por ejemplo,
|
||||||
|
|
@ -101,9 +101,9 @@ pub struct Field {
|
||||||
/// Devuelve el nombre compartido por todas las casillas del grupo.
|
/// Devuelve el nombre compartido por todas las casillas del grupo.
|
||||||
name: AttrName,
|
name: AttrName,
|
||||||
/// Devuelve la etiqueta del grupo.
|
/// Devuelve la etiqueta del grupo.
|
||||||
label: Attr<L10n>,
|
label: Attr<Lc>,
|
||||||
/// Devuelve el texto de ayuda del grupo.
|
/// Devuelve el texto de ayuda del grupo.
|
||||||
help_text: Attr<L10n>,
|
help_text: Attr<Lc>,
|
||||||
/// Devuelve las casillas del grupo.
|
/// Devuelve las casillas del grupo.
|
||||||
items: Vec<Item>,
|
items: Vec<Item>,
|
||||||
/// Devuelve si todo el grupo está deshabilitado.
|
/// Devuelve si todo el grupo está deshabilitado.
|
||||||
|
|
@ -207,14 +207,14 @@ impl Field {
|
||||||
|
|
||||||
/// Establece o elimina la etiqueta visible del grupo (basta pasar `None` para quitarla).
|
/// Establece o elimina la etiqueta visible del grupo (basta pasar `None` para quitarla).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_label(mut self, label: impl Into<Option<L10n>>) -> Self {
|
pub fn with_label(mut self, label: impl Into<Option<Lc>>) -> Self {
|
||||||
self.label.alter_opt(label.into());
|
self.label.alter_opt(label.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Establece o elimina el texto de ayuda del grupo (basta pasar `None` para quitarlo).
|
/// Establece o elimina el texto de ayuda del grupo (basta pasar `None` para quitarlo).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_help_text(mut self, help_text: impl Into<Option<L10n>>) -> Self {
|
pub fn with_help_text(mut self, help_text: impl Into<Option<Lc>>) -> Self {
|
||||||
self.help_text.alter_opt(help_text.into());
|
self.help_text.alter_opt(help_text.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,12 @@ use crate::prelude::*;
|
||||||
///
|
///
|
||||||
/// let accept_terms = form::Checkbox::new()
|
/// let accept_terms = form::Checkbox::new()
|
||||||
/// .with_name("terms_accepted")
|
/// .with_name("terms_accepted")
|
||||||
/// .with_label(L10n::n("I accept the terms and conditions"))
|
/// .with_label(Lc::n("I accept the terms and conditions"))
|
||||||
/// .with_required(true);
|
/// .with_required(true);
|
||||||
///
|
///
|
||||||
/// let notifications = form::Checkbox::switch()
|
/// let notifications = form::Checkbox::switch()
|
||||||
/// .with_name("notifications_enabled")
|
/// .with_name("notifications_enabled")
|
||||||
/// .with_label(L10n::n("Receive email notifications"))
|
/// .with_label(Lc::n("Receive email notifications"))
|
||||||
/// .with_checked(true);
|
/// .with_checked(true);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
|
@ -46,7 +46,7 @@ pub struct Checkbox {
|
||||||
/// Devuelve el nombre del campo.
|
/// Devuelve el nombre del campo.
|
||||||
name: AttrName,
|
name: AttrName,
|
||||||
/// Devuelve la etiqueta del control.
|
/// Devuelve la etiqueta del control.
|
||||||
label: Attr<L10n>,
|
label: Attr<Lc>,
|
||||||
/// Devuelve si el control debe estar marcado/activo por defecto.
|
/// Devuelve si el control debe estar marcado/activo por defecto.
|
||||||
checked: bool,
|
checked: bool,
|
||||||
/// Devuelve si el control recibe el foco automáticamente al cargar la página.
|
/// Devuelve si el control recibe el foco automáticamente al cargar la página.
|
||||||
|
|
@ -123,7 +123,7 @@ impl Component for Checkbox {
|
||||||
@if *self.required() {
|
@if *self.required() {
|
||||||
span
|
span
|
||||||
class="form-required"
|
class="form-required"
|
||||||
title=[L10n::l("field_required").lookup(cx)]
|
title=[Lc::l("field_required").lookup(cx)]
|
||||||
{
|
{
|
||||||
"*"
|
"*"
|
||||||
}
|
}
|
||||||
|
|
@ -184,7 +184,7 @@ impl Checkbox {
|
||||||
|
|
||||||
/// Establece o elimina la etiqueta visible del control (basta pasar `None` para quitarla).
|
/// Establece o elimina la etiqueta visible del control (basta pasar `None` para quitarla).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_label(mut self, label: impl Into<Option<L10n>>) -> Self {
|
pub fn with_label(mut self, label: impl Into<Option<Lc>>) -> Self {
|
||||||
self.label.alter_opt(label.into());
|
self.label.alter_opt(label.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,22 +24,22 @@ use crate::base::component::form;
|
||||||
/// .with_child(
|
/// .with_child(
|
||||||
/// form::input::Field::email()
|
/// form::input::Field::email()
|
||||||
/// .with_name("email")
|
/// .with_name("email")
|
||||||
/// .with_label(L10n::n("Email"))
|
/// .with_label(Lc::n("Email"))
|
||||||
/// .with_required(true),
|
/// .with_required(true),
|
||||||
/// )
|
/// )
|
||||||
/// .with_child(
|
/// .with_child(
|
||||||
/// form::input::Field::password()
|
/// form::input::Field::password()
|
||||||
/// .with_name("password")
|
/// .with_name("password")
|
||||||
/// .with_label(L10n::n("Password"))
|
/// .with_label(Lc::n("Password"))
|
||||||
/// .with_required(true),
|
/// .with_required(true),
|
||||||
/// )
|
/// )
|
||||||
/// .with_child(
|
/// .with_child(
|
||||||
/// form::Checkbox::check()
|
/// form::Checkbox::check()
|
||||||
/// .with_name("remember")
|
/// .with_name("remember")
|
||||||
/// .with_label(L10n::n("Remember me")),
|
/// .with_label(Lc::n("Remember me")),
|
||||||
/// )
|
/// )
|
||||||
/// .with_child(
|
/// .with_child(
|
||||||
/// Button::submit(L10n::n("Sign in"))
|
/// Button::submit(Lc::n("Sign in"))
|
||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(AutoDefault, Clone, Debug, Getters)]
|
#[derive(AutoDefault, Clone, Debug, Getters)]
|
||||||
|
|
|
||||||
|
|
@ -17,19 +17,19 @@ use crate::prelude::*;
|
||||||
/// use pagetop::prelude::*;
|
/// use pagetop::prelude::*;
|
||||||
///
|
///
|
||||||
/// let personal_data = form::Fieldset::new()
|
/// let personal_data = form::Fieldset::new()
|
||||||
/// .with_legend(L10n::n("Personal data"))
|
/// .with_legend(Lc::n("Personal data"))
|
||||||
/// .with_description(L10n::n("Enter your full name and contact email."))
|
/// .with_description(Lc::n("Enter your full name and contact email."))
|
||||||
/// .with_child(form::input::Field::text().with_name("name").with_label(L10n::n("Full name")))
|
/// .with_child(form::input::Field::text().with_name("name").with_label(Lc::n("Full name")))
|
||||||
/// .with_child(form::input::Field::email().with_name("email").with_label(L10n::n("Email")));
|
/// .with_child(form::input::Field::email().with_name("email").with_label(Lc::n("Email")));
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(AutoDefault, Clone, Debug, Getters)]
|
#[derive(AutoDefault, Clone, Debug, Getters)]
|
||||||
pub struct Fieldset {
|
pub struct Fieldset {
|
||||||
/// Devuelve identificador, clases CSS, atributos HTML y valores extra del componente.
|
/// Devuelve identificador, clases CSS, atributos HTML y valores extra del componente.
|
||||||
props: Props,
|
props: Props,
|
||||||
/// Devuelve la leyenda del `fieldset`.
|
/// Devuelve la leyenda del `fieldset`.
|
||||||
legend: Attr<L10n>,
|
legend: Attr<Lc>,
|
||||||
/// Devuelve la descripción del `fieldset`.
|
/// Devuelve la descripción del `fieldset`.
|
||||||
description: Attr<L10n>,
|
description: Attr<Lc>,
|
||||||
/// Devuelve si el `fieldset` está deshabilitado.
|
/// Devuelve si el `fieldset` está deshabilitado.
|
||||||
disabled: bool,
|
disabled: bool,
|
||||||
/// Devuelve la lista de componentes del `fieldset`.
|
/// Devuelve la lista de componentes del `fieldset`.
|
||||||
|
|
@ -86,14 +86,14 @@ impl Fieldset {
|
||||||
|
|
||||||
/// Establece o elimina la leyenda del `fieldset` (basta pasar `None` para quitarla).
|
/// Establece o elimina la leyenda del `fieldset` (basta pasar `None` para quitarla).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_legend(mut self, legend: impl Into<Option<L10n>>) -> Self {
|
pub fn with_legend(mut self, legend: impl Into<Option<Lc>>) -> Self {
|
||||||
self.legend.alter_opt(legend.into());
|
self.legend.alter_opt(legend.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Establece o elimina la descripción del `fieldset` (basta pasar `None` para quitarla).
|
/// Establece o elimina la descripción del `fieldset` (basta pasar `None` para quitarla).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_description(mut self, description: impl Into<Option<L10n>>) -> Self {
|
pub fn with_description(mut self, description: impl Into<Option<Lc>>) -> Self {
|
||||||
self.description.alter_opt(description.into());
|
self.description.alter_opt(description.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -135,8 +135,8 @@ impl fmt::Display for Mode {
|
||||||
///
|
///
|
||||||
/// let email = form::input::Field::email()
|
/// let email = form::input::Field::email()
|
||||||
/// .with_name("email")
|
/// .with_name("email")
|
||||||
/// .with_label(L10n::n("Email address"))
|
/// .with_label(Lc::n("Email address"))
|
||||||
/// .with_placeholder(L10n::n("user@example.com"))
|
/// .with_placeholder(Lc::n("user@example.com"))
|
||||||
/// .with_autocomplete(Some(form::Autocomplete::email()))
|
/// .with_autocomplete(Some(form::Autocomplete::email()))
|
||||||
/// .with_required(true);
|
/// .with_required(true);
|
||||||
/// ```
|
/// ```
|
||||||
|
|
@ -161,15 +161,15 @@ pub struct Field {
|
||||||
/// Devuelve el valor inicial del campo.
|
/// Devuelve el valor inicial del campo.
|
||||||
value: AttrValue,
|
value: AttrValue,
|
||||||
/// Devuelve la etiqueta del campo.
|
/// Devuelve la etiqueta del campo.
|
||||||
label: Attr<L10n>,
|
label: Attr<Lc>,
|
||||||
/// Devuelve el texto de ayuda del campo.
|
/// Devuelve el texto de ayuda del campo.
|
||||||
help_text: Attr<L10n>,
|
help_text: Attr<Lc>,
|
||||||
/// Devuelve la longitud mínima permitida en caracteres.
|
/// Devuelve la longitud mínima permitida en caracteres.
|
||||||
minlength: Attr<u16>,
|
minlength: Attr<u16>,
|
||||||
/// Devuelve la longitud máxima permitida en caracteres.
|
/// Devuelve la longitud máxima permitida en caracteres.
|
||||||
maxlength: Attr<u16>,
|
maxlength: Attr<u16>,
|
||||||
/// Devuelve el texto indicativo del campo.
|
/// Devuelve el texto indicativo del campo.
|
||||||
placeholder: Attr<L10n>,
|
placeholder: Attr<Lc>,
|
||||||
/// Devuelve la configuración de autocompletado del campo.
|
/// Devuelve la configuración de autocompletado del campo.
|
||||||
autocomplete: Attr<form::Autocomplete>,
|
autocomplete: Attr<form::Autocomplete>,
|
||||||
/// Devuelve si el campo recibe el foco automáticamente al cargar la página.
|
/// Devuelve si el campo recibe el foco automáticamente al cargar la página.
|
||||||
|
|
@ -238,7 +238,7 @@ impl Component for Field {
|
||||||
@if *self.required() {
|
@if *self.required() {
|
||||||
span
|
span
|
||||||
class="form-required"
|
class="form-required"
|
||||||
title=[L10n::l("field_required").lookup(cx)]
|
title=[Lc::l("field_required").lookup(cx)]
|
||||||
{
|
{
|
||||||
"*"
|
"*"
|
||||||
}
|
}
|
||||||
|
|
@ -420,14 +420,14 @@ impl Field {
|
||||||
|
|
||||||
/// Establece o elimina la etiqueta visible del campo (basta pasar `None` para quitarla).
|
/// Establece o elimina la etiqueta visible del campo (basta pasar `None` para quitarla).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_label(mut self, label: impl Into<Option<L10n>>) -> Self {
|
pub fn with_label(mut self, label: impl Into<Option<Lc>>) -> Self {
|
||||||
self.label.alter_opt(label.into());
|
self.label.alter_opt(label.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Establece o elimina el texto de ayuda del campo (basta pasar `None` para quitarlo).
|
/// Establece o elimina el texto de ayuda del campo (basta pasar `None` para quitarlo).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_help_text(mut self, help_text: impl Into<Option<L10n>>) -> Self {
|
pub fn with_help_text(mut self, help_text: impl Into<Option<Lc>>) -> Self {
|
||||||
self.help_text.alter_opt(help_text.into());
|
self.help_text.alter_opt(help_text.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -449,9 +449,9 @@ impl Field {
|
||||||
/// Establece o elimina el texto indicativo del campo (`None` para quitarlo).
|
/// Establece o elimina el texto indicativo del campo (`None` para quitarlo).
|
||||||
///
|
///
|
||||||
/// Este texto aparece en el mismo campo y desaparece en cuanto el usuario empieza a escribir.
|
/// Este texto aparece en el mismo campo y desaparece en cuanto el usuario empieza a escribir.
|
||||||
/// Al ser texto visible para el usuario se acepta [`L10n`] para poder localizarlo.
|
/// Al ser texto visible para el usuario se acepta [`Lc`] para poder localizarlo.
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_placeholder(mut self, placeholder: impl Into<Option<L10n>>) -> Self {
|
pub fn with_placeholder(mut self, placeholder: impl Into<Option<Lc>>) -> Self {
|
||||||
self.placeholder.alter_opt(placeholder.into());
|
self.placeholder.alter_opt(placeholder.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ use crate::prelude::*;
|
||||||
///
|
///
|
||||||
/// let quantity = form::Number::new()
|
/// let quantity = form::Number::new()
|
||||||
/// .with_name("quantity")
|
/// .with_name("quantity")
|
||||||
/// .with_label(L10n::n("Quantity"))
|
/// .with_label(Lc::n("Quantity"))
|
||||||
/// .with_min(Some(1))
|
/// .with_min(Some(1))
|
||||||
/// .with_max(Some(100))
|
/// .with_max(Some(100))
|
||||||
/// .with_value(Some(1));
|
/// .with_value(Some(1));
|
||||||
|
|
@ -37,9 +37,9 @@ pub struct Number {
|
||||||
/// Devuelve el valor inicial del campo.
|
/// Devuelve el valor inicial del campo.
|
||||||
value: Attr<u64>,
|
value: Attr<u64>,
|
||||||
/// Devuelve la etiqueta del campo.
|
/// Devuelve la etiqueta del campo.
|
||||||
label: Attr<L10n>,
|
label: Attr<Lc>,
|
||||||
/// Devuelve el texto de ayuda del campo.
|
/// Devuelve el texto de ayuda del campo.
|
||||||
help_text: Attr<L10n>,
|
help_text: Attr<Lc>,
|
||||||
/// Devuelve el valor mínimo permitido.
|
/// Devuelve el valor mínimo permitido.
|
||||||
min: Attr<u64>,
|
min: Attr<u64>,
|
||||||
/// Devuelve el valor máximo permitido.
|
/// Devuelve el valor máximo permitido.
|
||||||
|
|
@ -89,7 +89,7 @@ impl Component for Number {
|
||||||
@if *self.required() {
|
@if *self.required() {
|
||||||
span
|
span
|
||||||
class="form-required"
|
class="form-required"
|
||||||
title=[L10n::l("field_required").lookup(cx)]
|
title=[Lc::l("field_required").lookup(cx)]
|
||||||
{
|
{
|
||||||
"*"
|
"*"
|
||||||
}
|
}
|
||||||
|
|
@ -153,14 +153,14 @@ impl Number {
|
||||||
|
|
||||||
/// Establece o elimina la etiqueta visible del campo (basta pasar `None` para quitarla).
|
/// Establece o elimina la etiqueta visible del campo (basta pasar `None` para quitarla).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_label(mut self, label: impl Into<Option<L10n>>) -> Self {
|
pub fn with_label(mut self, label: impl Into<Option<Lc>>) -> Self {
|
||||||
self.label.alter_opt(label.into());
|
self.label.alter_opt(label.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Establece o elimina el texto de ayuda del campo (basta pasar `None` para quitarlo).
|
/// Establece o elimina el texto de ayuda del campo (basta pasar `None` para quitarlo).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_help_text(mut self, help_text: impl Into<Option<L10n>>) -> Self {
|
pub fn with_help_text(mut self, help_text: impl Into<Option<Lc>>) -> Self {
|
||||||
self.help_text.alter_opt(help_text.into());
|
self.help_text.alter_opt(help_text.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,14 @@ use crate::prelude::*;
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// use pagetop::prelude::*;
|
/// use pagetop::prelude::*;
|
||||||
///
|
///
|
||||||
/// let item = form::radio::Item::new("monthly", L10n::n("Monthly")).with_checked(true);
|
/// let item = form::radio::Item::new("monthly", Lc::n("Monthly")).with_checked(true);
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(AutoDefault, Clone, Debug, Getters)]
|
#[derive(AutoDefault, Clone, Debug, Getters)]
|
||||||
pub struct Item {
|
pub struct Item {
|
||||||
/// Devuelve el valor enviado al servidor cuando la opción está seleccionada.
|
/// Devuelve el valor enviado al servidor cuando la opción está seleccionada.
|
||||||
value: AttrValue,
|
value: AttrValue,
|
||||||
/// Devuelve la etiqueta de la opción.
|
/// Devuelve la etiqueta de la opción.
|
||||||
label: L10n,
|
label: Lc,
|
||||||
/// Devuelve si la opción debe aparecer seleccionada por defecto.
|
/// Devuelve si la opción debe aparecer seleccionada por defecto.
|
||||||
checked: bool,
|
checked: bool,
|
||||||
/// Devuelve si la opción está deshabilitada.
|
/// Devuelve si la opción está deshabilitada.
|
||||||
|
|
@ -31,7 +31,7 @@ pub struct Item {
|
||||||
|
|
||||||
impl Item {
|
impl Item {
|
||||||
/// Crea una nueva opción con el valor y la etiqueta indicados.
|
/// Crea una nueva opción con el valor y la etiqueta indicados.
|
||||||
pub fn new(value: impl AsRef<str>, label: L10n) -> Self {
|
pub fn new(value: impl AsRef<str>, label: Lc) -> Self {
|
||||||
Self {
|
Self {
|
||||||
value: AttrValue::new(value),
|
value: AttrValue::new(value),
|
||||||
label,
|
label,
|
||||||
|
|
@ -77,9 +77,9 @@ impl Item {
|
||||||
///
|
///
|
||||||
/// let plan = form::radio::Field::new()
|
/// let plan = form::radio::Field::new()
|
||||||
/// .with_name("plan")
|
/// .with_name("plan")
|
||||||
/// .with_label(L10n::n("Subscription plan"))
|
/// .with_label(Lc::n("Subscription plan"))
|
||||||
/// .with_item(form::radio::Item::new("monthly", L10n::n("Monthly")))
|
/// .with_item(form::radio::Item::new("monthly", Lc::n("Monthly")))
|
||||||
/// .with_item(form::radio::Item::new("annual", L10n::n("Annual")).with_checked(true))
|
/// .with_item(form::radio::Item::new("annual", Lc::n("Annual")).with_checked(true))
|
||||||
/// .with_required(true);
|
/// .with_required(true);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
|
@ -99,9 +99,9 @@ pub struct Field {
|
||||||
/// Devuelve el nombre compartido por todos los botones de opción del grupo.
|
/// Devuelve el nombre compartido por todos los botones de opción del grupo.
|
||||||
name: AttrName,
|
name: AttrName,
|
||||||
/// Devuelve la etiqueta del grupo.
|
/// Devuelve la etiqueta del grupo.
|
||||||
label: Attr<L10n>,
|
label: Attr<Lc>,
|
||||||
/// Devuelve el texto de ayuda del grupo.
|
/// Devuelve el texto de ayuda del grupo.
|
||||||
help_text: Attr<L10n>,
|
help_text: Attr<Lc>,
|
||||||
/// Devuelve las opciones del grupo.
|
/// Devuelve las opciones del grupo.
|
||||||
items: Vec<Item>,
|
items: Vec<Item>,
|
||||||
/// Devuelve si la selección de alguna opción del grupo es obligatoria.
|
/// Devuelve si la selección de alguna opción del grupo es obligatoria.
|
||||||
|
|
@ -150,7 +150,7 @@ impl Component for Field {
|
||||||
@if *self.required() {
|
@if *self.required() {
|
||||||
span
|
span
|
||||||
class="form-required"
|
class="form-required"
|
||||||
title=[L10n::l("field_required").lookup(cx)]
|
title=[Lc::l("field_required").lookup(cx)]
|
||||||
{
|
{
|
||||||
"*"
|
"*"
|
||||||
}
|
}
|
||||||
|
|
@ -227,14 +227,14 @@ impl Field {
|
||||||
|
|
||||||
/// Establece o elimina la etiqueta visible del grupo (basta pasar `None` para quitarla).
|
/// Establece o elimina la etiqueta visible del grupo (basta pasar `None` para quitarla).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_label(mut self, label: impl Into<Option<L10n>>) -> Self {
|
pub fn with_label(mut self, label: impl Into<Option<Lc>>) -> Self {
|
||||||
self.label.alter_opt(label.into());
|
self.label.alter_opt(label.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Establece o elimina el texto de ayuda del grupo (basta pasar `None` para quitarlo).
|
/// Establece o elimina el texto de ayuda del grupo (basta pasar `None` para quitarlo).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_help_text(mut self, help_text: impl Into<Option<L10n>>) -> Self {
|
pub fn with_help_text(mut self, help_text: impl Into<Option<Lc>>) -> Self {
|
||||||
self.help_text.alter_opt(help_text.into());
|
self.help_text.alter_opt(help_text.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ use crate::prelude::*;
|
||||||
///
|
///
|
||||||
/// let volume = form::Range::new()
|
/// let volume = form::Range::new()
|
||||||
/// .with_name("volume")
|
/// .with_name("volume")
|
||||||
/// .with_label(L10n::n("Volume"))
|
/// .with_label(Lc::n("Volume"))
|
||||||
/// .with_min(Some(0.0))
|
/// .with_min(Some(0.0))
|
||||||
/// .with_max(Some(100.0))
|
/// .with_max(Some(100.0))
|
||||||
/// .with_step(Some(5.0))
|
/// .with_step(Some(5.0))
|
||||||
|
|
@ -38,9 +38,9 @@ pub struct Range {
|
||||||
/// Devuelve el valor inicial del campo.
|
/// Devuelve el valor inicial del campo.
|
||||||
value: Attr<f64>,
|
value: Attr<f64>,
|
||||||
/// Devuelve la etiqueta del campo.
|
/// Devuelve la etiqueta del campo.
|
||||||
label: Attr<L10n>,
|
label: Attr<Lc>,
|
||||||
/// Devuelve el texto de ayuda del campo.
|
/// Devuelve el texto de ayuda del campo.
|
||||||
help_text: Attr<L10n>,
|
help_text: Attr<Lc>,
|
||||||
/// Devuelve el valor mínimo permitido.
|
/// Devuelve el valor mínimo permitido.
|
||||||
min: Attr<f64>,
|
min: Attr<f64>,
|
||||||
/// Devuelve el valor máximo permitido.
|
/// Devuelve el valor máximo permitido.
|
||||||
|
|
@ -141,14 +141,14 @@ impl Range {
|
||||||
|
|
||||||
/// Establece o elimina la etiqueta visible del campo (basta pasar `None` para quitarla).
|
/// Establece o elimina la etiqueta visible del campo (basta pasar `None` para quitarla).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_label(mut self, label: impl Into<Option<L10n>>) -> Self {
|
pub fn with_label(mut self, label: impl Into<Option<Lc>>) -> Self {
|
||||||
self.label.alter_opt(label.into());
|
self.label.alter_opt(label.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Establece o elimina el texto de ayuda del campo (basta pasar `None` para quitarlo).
|
/// Establece o elimina el texto de ayuda del campo (basta pasar `None` para quitarlo).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_help_text(mut self, help_text: impl Into<Option<L10n>>) -> Self {
|
pub fn with_help_text(mut self, help_text: impl Into<Option<Lc>>) -> Self {
|
||||||
self.help_text.alter_opt(help_text.into());
|
self.help_text.alter_opt(help_text.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,14 @@ use crate::prelude::*;
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// use pagetop::prelude::*;
|
/// use pagetop::prelude::*;
|
||||||
///
|
///
|
||||||
/// let item = form::select::Item::new("es", L10n::n("Spanish")).with_selected(true);
|
/// let item = form::select::Item::new("es", Lc::n("Spanish")).with_selected(true);
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(AutoDefault, Clone, Debug, Getters)]
|
#[derive(AutoDefault, Clone, Debug, Getters)]
|
||||||
pub struct Item {
|
pub struct Item {
|
||||||
/// Devuelve el valor enviado al servidor cuando se selecciona el elemento.
|
/// Devuelve el valor enviado al servidor cuando se selecciona el elemento.
|
||||||
value: AttrValue,
|
value: AttrValue,
|
||||||
/// Devuelve la etiqueta visible del elemento.
|
/// Devuelve la etiqueta visible del elemento.
|
||||||
label: L10n,
|
label: Lc,
|
||||||
/// Devuelve si el elemento debe aparecer seleccionado por defecto.
|
/// Devuelve si el elemento debe aparecer seleccionado por defecto.
|
||||||
selected: bool,
|
selected: bool,
|
||||||
/// Devuelve si el elemento está deshabilitado.
|
/// Devuelve si el elemento está deshabilitado.
|
||||||
|
|
@ -34,7 +34,7 @@ pub struct Item {
|
||||||
|
|
||||||
impl Item {
|
impl Item {
|
||||||
/// Crea un nuevo elemento con el valor y la etiqueta indicados.
|
/// Crea un nuevo elemento con el valor y la etiqueta indicados.
|
||||||
pub fn new(value: impl AsRef<str>, label: L10n) -> Self {
|
pub fn new(value: impl AsRef<str>, label: Lc) -> Self {
|
||||||
Self {
|
Self {
|
||||||
value: AttrValue::new(value),
|
value: AttrValue::new(value),
|
||||||
label,
|
label,
|
||||||
|
|
@ -74,14 +74,14 @@ impl Item {
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// use pagetop::prelude::*;
|
/// use pagetop::prelude::*;
|
||||||
///
|
///
|
||||||
/// let group = form::select::Group::new(L10n::n("Europe"))
|
/// let group = form::select::Group::new(Lc::n("Europe"))
|
||||||
/// .with_item(form::select::Item::new("es", L10n::n("Spanish")))
|
/// .with_item(form::select::Item::new("es", Lc::n("Spanish")))
|
||||||
/// .with_item(form::select::Item::new("fr", L10n::n("French")));
|
/// .with_item(form::select::Item::new("fr", Lc::n("French")));
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(AutoDefault, Clone, Debug, Getters)]
|
#[derive(AutoDefault, Clone, Debug, Getters)]
|
||||||
pub struct Group {
|
pub struct Group {
|
||||||
/// Devuelve la etiqueta visible del grupo de elementos.
|
/// Devuelve la etiqueta visible del grupo de elementos.
|
||||||
label: L10n,
|
label: Lc,
|
||||||
/// Devuelve los elementos del grupo.
|
/// Devuelve los elementos del grupo.
|
||||||
items: Vec<Item>,
|
items: Vec<Item>,
|
||||||
/// Devuelve si el grupo de elementos está deshabilitado.
|
/// Devuelve si el grupo de elementos está deshabilitado.
|
||||||
|
|
@ -90,7 +90,7 @@ pub struct Group {
|
||||||
|
|
||||||
impl Group {
|
impl Group {
|
||||||
/// Crea un nuevo grupo con la etiqueta indicada.
|
/// Crea un nuevo grupo con la etiqueta indicada.
|
||||||
pub fn new(label: L10n) -> Self {
|
pub fn new(label: Lc) -> Self {
|
||||||
Self {
|
Self {
|
||||||
label,
|
label,
|
||||||
..Self::default()
|
..Self::default()
|
||||||
|
|
@ -149,17 +149,17 @@ pub enum Entry {
|
||||||
///
|
///
|
||||||
/// let idioma = form::select::Field::new()
|
/// let idioma = form::select::Field::new()
|
||||||
/// .with_name("language")
|
/// .with_name("language")
|
||||||
/// .with_label(L10n::n("Language"))
|
/// .with_label(Lc::n("Language"))
|
||||||
/// .with_item(form::select::Item::new("", L10n::n("— Choose —")).with_selected(true))
|
/// .with_item(form::select::Item::new("", Lc::n("— Choose —")).with_selected(true))
|
||||||
/// .with_group(
|
/// .with_group(
|
||||||
/// form::select::Group::new(L10n::n("Europe"))
|
/// form::select::Group::new(Lc::n("Europe"))
|
||||||
/// .with_item(form::select::Item::new("es", L10n::n("Spanish")))
|
/// .with_item(form::select::Item::new("es", Lc::n("Spanish")))
|
||||||
/// .with_item(form::select::Item::new("fr", L10n::n("French"))),
|
/// .with_item(form::select::Item::new("fr", Lc::n("French"))),
|
||||||
/// )
|
/// )
|
||||||
/// .with_group(
|
/// .with_group(
|
||||||
/// form::select::Group::new(L10n::n("Americas"))
|
/// form::select::Group::new(Lc::n("Americas"))
|
||||||
/// .with_item(form::select::Item::new("en", L10n::n("English")))
|
/// .with_item(form::select::Item::new("en", Lc::n("English")))
|
||||||
/// .with_item(form::select::Item::new("pt", L10n::n("Portuguese"))),
|
/// .with_item(form::select::Item::new("pt", Lc::n("Portuguese"))),
|
||||||
/// )
|
/// )
|
||||||
/// .with_required(true);
|
/// .with_required(true);
|
||||||
/// ```
|
/// ```
|
||||||
|
|
@ -193,9 +193,9 @@ pub struct Field {
|
||||||
/// Devuelve el nombre del campo.
|
/// Devuelve el nombre del campo.
|
||||||
name: AttrName,
|
name: AttrName,
|
||||||
/// Devuelve la etiqueta del campo.
|
/// Devuelve la etiqueta del campo.
|
||||||
label: Attr<L10n>,
|
label: Attr<Lc>,
|
||||||
/// Devuelve el texto de ayuda del campo.
|
/// Devuelve el texto de ayuda del campo.
|
||||||
help_text: Attr<L10n>,
|
help_text: Attr<Lc>,
|
||||||
/// Devuelve las entradas de la lista (elementos individuales y grupos de elementos).
|
/// Devuelve las entradas de la lista (elementos individuales y grupos de elementos).
|
||||||
entries: Vec<Entry>,
|
entries: Vec<Entry>,
|
||||||
/// Devuelve si la lista permite selección múltiple.
|
/// Devuelve si la lista permite selección múltiple.
|
||||||
|
|
@ -246,7 +246,7 @@ impl Component for Field {
|
||||||
@if *self.required() {
|
@if *self.required() {
|
||||||
span
|
span
|
||||||
class="form-required"
|
class="form-required"
|
||||||
title=[L10n::l("field_required").lookup(cx)]
|
title=[Lc::l("field_required").lookup(cx)]
|
||||||
{
|
{
|
||||||
"*"
|
"*"
|
||||||
}
|
}
|
||||||
|
|
@ -331,14 +331,14 @@ impl Field {
|
||||||
|
|
||||||
/// Establece o elimina la etiqueta visible del campo (basta pasar `None` para quitarla).
|
/// Establece o elimina la etiqueta visible del campo (basta pasar `None` para quitarla).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_label(mut self, label: impl Into<Option<L10n>>) -> Self {
|
pub fn with_label(mut self, label: impl Into<Option<Lc>>) -> Self {
|
||||||
self.label.alter_opt(label.into());
|
self.label.alter_opt(label.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Establece o elimina el texto de ayuda del campo (basta pasar `None` para quitarlo).
|
/// Establece o elimina el texto de ayuda del campo (basta pasar `None` para quitarlo).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_help_text(mut self, help_text: impl Into<Option<L10n>>) -> Self {
|
pub fn with_help_text(mut self, help_text: impl Into<Option<Lc>>) -> Self {
|
||||||
self.help_text.alter_opt(help_text.into());
|
self.help_text.alter_opt(help_text.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@ use crate::prelude::*;
|
||||||
///
|
///
|
||||||
/// let descripcion = form::Textarea::new()
|
/// let descripcion = form::Textarea::new()
|
||||||
/// .with_name("description")
|
/// .with_name("description")
|
||||||
/// .with_label(L10n::n("Description"))
|
/// .with_label(Lc::n("Description"))
|
||||||
/// .with_rows(Some(8))
|
/// .with_rows(Some(8))
|
||||||
/// .with_maxlength(Some(500))
|
/// .with_maxlength(Some(500))
|
||||||
/// .with_placeholder(L10n::n("Write here..."))
|
/// .with_placeholder(Lc::n("Write here..."))
|
||||||
/// .with_required(true);
|
/// .with_required(true);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
|
@ -40,9 +40,9 @@ pub struct Textarea {
|
||||||
/// Devuelve el valor inicial del área de texto.
|
/// Devuelve el valor inicial del área de texto.
|
||||||
value: AttrValue,
|
value: AttrValue,
|
||||||
/// Devuelve la etiqueta del campo.
|
/// Devuelve la etiqueta del campo.
|
||||||
label: Attr<L10n>,
|
label: Attr<Lc>,
|
||||||
/// Devuelve el texto de ayuda del campo.
|
/// Devuelve el texto de ayuda del campo.
|
||||||
help_text: Attr<L10n>,
|
help_text: Attr<Lc>,
|
||||||
/// Devuelve el número de filas visibles del área de texto.
|
/// Devuelve el número de filas visibles del área de texto.
|
||||||
rows: Attr<u16>,
|
rows: Attr<u16>,
|
||||||
/// Devuelve la longitud mínima permitida en caracteres.
|
/// Devuelve la longitud mínima permitida en caracteres.
|
||||||
|
|
@ -50,7 +50,7 @@ pub struct Textarea {
|
||||||
/// Devuelve la longitud máxima permitida en caracteres.
|
/// Devuelve la longitud máxima permitida en caracteres.
|
||||||
maxlength: Attr<u16>,
|
maxlength: Attr<u16>,
|
||||||
/// Devuelve el texto indicativo del área de texto.
|
/// Devuelve el texto indicativo del área de texto.
|
||||||
placeholder: Attr<L10n>,
|
placeholder: Attr<Lc>,
|
||||||
/// Devuelve la configuración de autocompletado del campo.
|
/// Devuelve la configuración de autocompletado del campo.
|
||||||
autocomplete: Attr<form::Autocomplete>,
|
autocomplete: Attr<form::Autocomplete>,
|
||||||
/// Devuelve si el campo recibe el foco automáticamente al cargar la página.
|
/// Devuelve si el campo recibe el foco automáticamente al cargar la página.
|
||||||
|
|
@ -99,7 +99,7 @@ impl Component for Textarea {
|
||||||
@if *self.required() {
|
@if *self.required() {
|
||||||
span
|
span
|
||||||
class="form-required"
|
class="form-required"
|
||||||
title=[L10n::l("field_required").lookup(cx)]
|
title=[Lc::l("field_required").lookup(cx)]
|
||||||
{
|
{
|
||||||
"*"
|
"*"
|
||||||
}
|
}
|
||||||
|
|
@ -168,14 +168,14 @@ impl Textarea {
|
||||||
|
|
||||||
/// Establece o elimina la etiqueta visible del campo (basta pasar `None` para quitarla).
|
/// Establece o elimina la etiqueta visible del campo (basta pasar `None` para quitarla).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_label(mut self, label: impl Into<Option<L10n>>) -> Self {
|
pub fn with_label(mut self, label: impl Into<Option<Lc>>) -> Self {
|
||||||
self.label.alter_opt(label.into());
|
self.label.alter_opt(label.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Establece o elimina el texto de ayuda del campo (basta pasar `None` para quitarlo).
|
/// Establece o elimina el texto de ayuda del campo (basta pasar `None` para quitarlo).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_help_text(mut self, help_text: impl Into<Option<L10n>>) -> Self {
|
pub fn with_help_text(mut self, help_text: impl Into<Option<Lc>>) -> Self {
|
||||||
self.help_text.alter_opt(help_text.into());
|
self.help_text.alter_opt(help_text.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -207,9 +207,9 @@ impl Textarea {
|
||||||
/// Establece o elimina el texto indicativo del área de texto (`None` para quitarlo).
|
/// Establece o elimina el texto indicativo del área de texto (`None` para quitarlo).
|
||||||
///
|
///
|
||||||
/// Este texto aparece en el área de texto y desaparece en cuanto el usuario empieza a escribir.
|
/// Este texto aparece en el área de texto y desaparece en cuanto el usuario empieza a escribir.
|
||||||
/// Al ser texto visible para el usuario se acepta [`L10n`] para poder localizarlo.
|
/// Al ser texto visible para el usuario se acepta [`Lc`] para poder localizarlo.
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_placeholder(mut self, placeholder: impl Into<Option<L10n>>) -> Self {
|
pub fn with_placeholder(mut self, placeholder: impl Into<Option<Lc>>) -> Self {
|
||||||
self.placeholder.alter_opt(placeholder.into());
|
self.placeholder.alter_opt(placeholder.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,10 @@ pub enum IntroOpening {
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// let intro = Intro::default()
|
/// let intro = Intro::default()
|
||||||
/// .with_title(L10n::l("intro_custom_title"))
|
/// .with_title(Lc::l("intro_custom_title"))
|
||||||
/// .with_slogan(L10n::l("intro_custom_slogan"))
|
/// .with_slogan(Lc::l("intro_custom_slogan"))
|
||||||
/// .with_button(Some((
|
/// .with_button(Some((
|
||||||
/// L10n::l("intro_learn_more"),
|
/// Lc::l("intro_learn_more"),
|
||||||
/// "/learn-more".into()
|
/// "/learn-more".into()
|
||||||
/// )));
|
/// )));
|
||||||
/// ```
|
/// ```
|
||||||
|
|
@ -57,7 +57,7 @@ pub enum IntroOpening {
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// let intro = Intro::default()
|
/// let intro = Intro::default()
|
||||||
/// .with_button(None::<(L10n, Route)>)
|
/// .with_button(None::<(Lc, Route)>)
|
||||||
/// .with_opening(IntroOpening::Custom);
|
/// .with_opening(IntroOpening::Custom);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
|
@ -68,13 +68,13 @@ pub enum IntroOpening {
|
||||||
/// let intro = Intro::default()
|
/// let intro = Intro::default()
|
||||||
/// .with_child(
|
/// .with_child(
|
||||||
/// Block::new()
|
/// Block::new()
|
||||||
/// .with_title(L10n::l("intro_custom_block_title"))
|
/// .with_title(Lc::l("intro_custom_block_title"))
|
||||||
/// .with_child(Html::with(move |cx| {
|
/// .with_child(Html::with(move |cx| {
|
||||||
/// html! {
|
/// html! {
|
||||||
/// p class="intro-text-lead" {
|
/// p class="intro-text-lead" {
|
||||||
/// (L10n::l("intro_custom_paragraph_1").using(cx))
|
/// (Lc::l("intro_custom_paragraph_1").using(cx))
|
||||||
/// }
|
/// }
|
||||||
/// p { (L10n::l("intro_custom_paragraph_2").using(cx)) }
|
/// p { (Lc::l("intro_custom_paragraph_2").using(cx)) }
|
||||||
/// }
|
/// }
|
||||||
/// })),
|
/// })),
|
||||||
/// );
|
/// );
|
||||||
|
|
@ -82,11 +82,11 @@ pub enum IntroOpening {
|
||||||
#[derive(Clone, Debug, Getters)]
|
#[derive(Clone, Debug, Getters)]
|
||||||
pub struct Intro {
|
pub struct Intro {
|
||||||
/// Devuelve el título de entrada.
|
/// Devuelve el título de entrada.
|
||||||
title: L10n,
|
title: Lc,
|
||||||
/// Devuelve el eslogan de la entrada.
|
/// Devuelve el eslogan de la entrada.
|
||||||
slogan: L10n,
|
slogan: Lc,
|
||||||
/// Devuelve el botón de llamada a la acción, si existe.
|
/// Devuelve el botón de llamada a la acción, si existe.
|
||||||
button: Option<(L10n, Route)>,
|
button: Option<(Lc, Route)>,
|
||||||
/// Devuelve el modo de apertura configurado.
|
/// Devuelve el modo de apertura configurado.
|
||||||
opening: IntroOpening,
|
opening: IntroOpening,
|
||||||
/// Devuelve la lista de componentes hijo de la intro.
|
/// Devuelve la lista de componentes hijo de la intro.
|
||||||
|
|
@ -98,9 +98,9 @@ impl Default for Intro {
|
||||||
const BUTTON_LINK: &str = "https://pagetop.cillero.es";
|
const BUTTON_LINK: &str = "https://pagetop.cillero.es";
|
||||||
|
|
||||||
Intro {
|
Intro {
|
||||||
title: L10n::l("intro_default_title"),
|
title: Lc::l("intro_default_title"),
|
||||||
slogan: L10n::l("intro_default_slogan").with_arg("app", &global::SETTINGS.app.name),
|
slogan: Lc::l("intro_default_slogan").with_arg("app", &global::SETTINGS.app.name),
|
||||||
button: Some((L10n::l("intro_default_button"), BUTTON_LINK.into())),
|
button: Some((Lc::l("intro_default_button"), BUTTON_LINK.into())),
|
||||||
opening: IntroOpening::default(),
|
opening: IntroOpening::default(),
|
||||||
children: Children::default(),
|
children: Children::default(),
|
||||||
}
|
}
|
||||||
|
|
@ -133,7 +133,7 @@ impl Component for Intro {
|
||||||
}
|
}
|
||||||
"#)
|
"#)
|
||||||
.replace("LANGID", cx.langid().to_string().as_str())
|
.replace("LANGID", cx.langid().to_string().as_str())
|
||||||
.replace("LABEL", L10n::l("intro_release_label").using(cx).as_str())
|
.replace("LABEL", Lc::l("intro_release_label").using(cx).as_str())
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -173,24 +173,24 @@ impl Component for Intro {
|
||||||
div class="intro-text-body" {
|
div class="intro-text-body" {
|
||||||
@if *self.opening() == IntroOpening::PageTop {
|
@if *self.opening() == IntroOpening::PageTop {
|
||||||
p class="intro-text-lead" {
|
p class="intro-text-lead" {
|
||||||
(L10n::l("intro_text1").using(cx))
|
(Lc::l("intro_text1").using(cx))
|
||||||
}
|
}
|
||||||
div id="intro-badges" {
|
div id="intro-badges" {
|
||||||
img
|
img
|
||||||
src="https://img.shields.io/crates/v/pagetop.svg?label=PageTop&style=for-the-badge"
|
src="https://img.shields.io/crates/v/pagetop.svg?label=PageTop&style=for-the-badge"
|
||||||
alt=[L10n::l("intro_pagetop_label").lookup(cx)] {} (" ")
|
alt=[Lc::l("intro_pagetop_label").lookup(cx)] {} (" ")
|
||||||
img
|
img
|
||||||
id="intro-release"
|
id="intro-release"
|
||||||
alt=[L10n::l("intro_release_label").lookup(cx)] {} (" ")
|
alt=[Lc::l("intro_release_label").lookup(cx)] {} (" ")
|
||||||
img
|
img
|
||||||
src=(format!(
|
src=(format!(
|
||||||
"https://img.shields.io/badge/license-MIT%2FApache-blue.svg?label={}&style=for-the-badge",
|
"https://img.shields.io/badge/license-MIT%2FApache-blue.svg?label={}&style=for-the-badge",
|
||||||
L10n::l("intro_license_label").lookup(cx).unwrap_or_default()
|
Lc::l("intro_license_label").lookup(cx).unwrap_or_default()
|
||||||
))
|
))
|
||||||
alt=[L10n::l("intro_license_label").lookup(cx)] {}
|
alt=[Lc::l("intro_license_label").lookup(cx)] {}
|
||||||
}
|
}
|
||||||
p class="intro-text-lead" {
|
p class="intro-text-lead" {
|
||||||
(L10n::l("intro_text2").using(cx))
|
(Lc::l("intro_text2").using(cx))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(self.children().render(cx).await)
|
(self.children().render(cx).await)
|
||||||
|
|
@ -206,8 +206,8 @@ impl Component for Intro {
|
||||||
div class="intro-footer-links" {
|
div class="intro-footer-links" {
|
||||||
a href="https://crates.io/crates/pagetop" target="_blank" rel="noopener noreferrer" { ("Crates.io") }
|
a href="https://crates.io/crates/pagetop" target="_blank" rel="noopener noreferrer" { ("Crates.io") }
|
||||||
a href="https://docs.rs/pagetop" target="_blank" rel="noopener noreferrer" { ("Docs.rs") }
|
a href="https://docs.rs/pagetop" target="_blank" rel="noopener noreferrer" { ("Docs.rs") }
|
||||||
a href="https://git.cillero.es/manuelcillero/pagetop" target="_blank" rel="noopener noreferrer" { (L10n::l("intro_code").using(cx)) }
|
a href="https://git.cillero.es/manuelcillero/pagetop" target="_blank" rel="noopener noreferrer" { (Lc::l("intro_code").using(cx)) }
|
||||||
em { (L10n::l("intro_have_fun").using(cx)) }
|
em { (Lc::l("intro_have_fun").using(cx)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -225,10 +225,10 @@ impl Intro {
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// let intro = Intro::default().with_title(L10n::n("Intro title"));
|
/// let intro = Intro::default().with_title(Lc::n("Intro title"));
|
||||||
/// ```
|
/// ```
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_title(mut self, title: L10n) -> Self {
|
pub fn with_title(mut self, title: Lc) -> Self {
|
||||||
self.title = title;
|
self.title = title;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -239,10 +239,10 @@ impl Intro {
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// let intro = Intro::default().with_slogan(L10n::n("A short slogan"));
|
/// let intro = Intro::default().with_slogan(Lc::n("A short slogan"));
|
||||||
/// ```
|
/// ```
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_slogan(mut self, slogan: L10n) -> Self {
|
pub fn with_slogan(mut self, slogan: Lc) -> Self {
|
||||||
self.slogan = slogan;
|
self.slogan = slogan;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -258,12 +258,12 @@ impl Intro {
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// // Define un botón con texto y una ruta interna (preserva `lang` si corresponde).
|
/// // Define un botón con texto y una ruta interna (preserva `lang` si corresponde).
|
||||||
/// let intro = Intro::default().with_button(Some((L10n::n("Start"), "/start".into())));
|
/// let intro = Intro::default().with_button(Some((Lc::n("Start"), "/start".into())));
|
||||||
/// // Descarta el botón de la intro.
|
/// // Descarta el botón de la intro.
|
||||||
/// let intro_no_button = Intro::default().with_button(None);
|
/// let intro_no_button = Intro::default().with_button(None);
|
||||||
/// ```
|
/// ```
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_button(mut self, button: Option<(L10n, Route)>) -> Self {
|
pub fn with_button(mut self, button: Option<(Lc, Route)>) -> Self {
|
||||||
self.button = button;
|
self.button = button;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ use std::fmt;
|
||||||
/// "sidebar"
|
/// "sidebar"
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// fn label(&self) -> L10n {
|
/// fn label(&self) -> Lc {
|
||||||
/// L10n::n("Sidebar")
|
/// Lc::n("Sidebar")
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -163,8 +163,8 @@ pub struct Pager {
|
||||||
/// Devuelve la visibilidad del formulario para saltar directamente a una página.
|
/// Devuelve la visibilidad del formulario para saltar directamente a una página.
|
||||||
jump: PagerVisibility,
|
jump: PagerVisibility,
|
||||||
/// Devuelve la etiqueta de accesibilidad (`aria-label`) del elemento `<nav>`.
|
/// Devuelve la etiqueta de accesibilidad (`aria-label`) del elemento `<nav>`.
|
||||||
#[default(L10n::l("pager_aria_label"))]
|
#[default(Lc::l("pager_aria_label"))]
|
||||||
aria_label: L10n,
|
aria_label: Lc,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Elemento visible del listado de páginas: un número de página o una elipsis que resume un tramo
|
// Elemento visible del listado de páginas: un número de página o una elipsis que resume un tramo
|
||||||
|
|
@ -241,7 +241,7 @@ impl Component for Pager {
|
||||||
@let first = (page - 1) * items_per_page + 1;
|
@let first = (page - 1) * items_per_page + 1;
|
||||||
@let last = (page * items_per_page).min(self.total_items());
|
@let last = (page * items_per_page).min(self.total_items());
|
||||||
span.pager-summary {
|
span.pager-summary {
|
||||||
(L10n::l("pager_summary")
|
(Lc::l("pager_summary")
|
||||||
.with_arg("first", first.to_string())
|
.with_arg("first", first.to_string())
|
||||||
.with_arg("last", last.to_string())
|
.with_arg("last", last.to_string())
|
||||||
.with_arg("total", self.total_items().to_string())
|
.with_arg("total", self.total_items().to_string())
|
||||||
|
|
@ -254,8 +254,8 @@ impl Component for Pager {
|
||||||
a.page-link
|
a.page-link
|
||||||
href=[(!first_disabled).then(|| Self::page_route(&route, page - 1))]
|
href=[(!first_disabled).then(|| Self::page_route(&route, page - 1))]
|
||||||
aria-disabled=[first_disabled.then_some("true")]
|
aria-disabled=[first_disabled.then_some("true")]
|
||||||
aria-label=[L10n::l("pager_previous_aria_label").lookup(cx)] {
|
aria-label=[Lc::l("pager_previous_aria_label").lookup(cx)] {
|
||||||
span.page-link-icon { (L10n::l("pager_previous_label").using(cx)) }
|
span.page-link-icon { (Lc::l("pager_previous_label").using(cx)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -283,8 +283,8 @@ impl Component for Pager {
|
||||||
a.page-link
|
a.page-link
|
||||||
href=[(!last_disabled).then(|| Self::page_route(&route, page + 1))]
|
href=[(!last_disabled).then(|| Self::page_route(&route, page + 1))]
|
||||||
aria-disabled=[last_disabled.then_some("true")]
|
aria-disabled=[last_disabled.then_some("true")]
|
||||||
aria-label=[L10n::l("pager_next_aria_label").lookup(cx)] {
|
aria-label=[Lc::l("pager_next_aria_label").lookup(cx)] {
|
||||||
span.page-link-icon { (L10n::l("pager_next_label").using(cx)) }
|
span.page-link-icon { (Lc::l("pager_next_label").using(cx)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -324,9 +324,9 @@ impl Component for Pager {
|
||||||
.with_value(Some(page)),
|
.with_value(Some(page)),
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
Button::submit(L10n::l("pager_goto_button"))
|
Button::submit(Lc::l("pager_goto_button"))
|
||||||
.with_prop(PropsOp::add_classes("pager-jump-button"))
|
.with_prop(PropsOp::add_classes("pager-jump-button"))
|
||||||
.with_title(L10n::l("pager_goto_label")),
|
.with_title(Lc::l("pager_goto_label")),
|
||||||
)
|
)
|
||||||
.render(cx).await
|
.render(cx).await
|
||||||
}) }
|
}) }
|
||||||
|
|
@ -443,7 +443,7 @@ impl Pager {
|
||||||
/// Establece la etiqueta de accesibilidad (`aria-label`) del elemento `<nav>`. Por defecto es
|
/// Establece la etiqueta de accesibilidad (`aria-label`) del elemento `<nav>`. Por defecto es
|
||||||
/// "Page navigation" (clave `pager_aria_label`), igual que hace el paginador de Bootstrap.
|
/// "Page navigation" (clave `pager_aria_label`), igual que hace el paginador de Bootstrap.
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_aria_label(mut self, aria_label: L10n) -> Self {
|
pub fn with_aria_label(mut self, aria_label: Lc) -> Self {
|
||||||
self.aria_label = aria_label;
|
self.aria_label = aria_label;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,14 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
// Enlace a la página oficial de PageTop.
|
// Enlace a la página oficial de PageTop.
|
||||||
const LINK: &str = "<a href=\"https://pagetop.cillero.es\" rel=\"noopener noreferrer\">PageTop</a>";
|
const PAGETOP_LINK: &str = concat!(
|
||||||
|
"<a ",
|
||||||
|
"href=\"https://pagetop.cillero.es\" ",
|
||||||
|
"target=\"_blank\" ",
|
||||||
|
"rel=\"noopener noreferrer\">",
|
||||||
|
"PageTop",
|
||||||
|
"</a>",
|
||||||
|
);
|
||||||
|
|
||||||
/// Componente que muestra el típico mensaje *Powered by* (*Funciona con*) en el pie de página.
|
/// Componente que muestra el típico mensaje *Powered by* (*Funciona con*) en el pie de página.
|
||||||
///
|
///
|
||||||
|
|
@ -33,7 +40,7 @@ impl Component for PoweredBy {
|
||||||
span class="poweredby__copyright" { (c) "." } " "
|
span class="poweredby__copyright" { (c) "." } " "
|
||||||
}
|
}
|
||||||
span class="poweredby__pagetop" {
|
span class="poweredby__pagetop" {
|
||||||
(L10n::l("poweredby_pagetop").with_arg("pagetop_link", LINK).using(cx))
|
(Lc::l("poweredby_pagetop").with_arg("pagetop_link", PAGETOP_LINK).using(cx))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,12 @@ pub struct Welcome;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Extension for Welcome {
|
impl Extension for Welcome {
|
||||||
fn name(&self) -> L10n {
|
fn name(&self) -> Lc {
|
||||||
L10n::l("welcome_extension_name")
|
Lc::l("welcome_extension_name")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn description(&self) -> L10n {
|
fn description(&self) -> Lc {
|
||||||
L10n::l("welcome_extension_description")
|
Lc::l("welcome_extension_description")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn configure_router(&self, router: Router) -> Router {
|
fn configure_router(&self, router: Router) -> Router {
|
||||||
|
|
@ -30,33 +30,33 @@ async fn home(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||||
let app = &global::SETTINGS.app.name;
|
let app = &global::SETTINGS.app.name;
|
||||||
|
|
||||||
Page::new(request)
|
Page::new(request)
|
||||||
.with_title(L10n::l("welcome_title"))
|
.with_title(Lc::l("welcome_title"))
|
||||||
.with_child(
|
.with_child(
|
||||||
Intro::new()
|
Intro::new()
|
||||||
.with_child(
|
.with_child(
|
||||||
Block::new()
|
Block::new()
|
||||||
.with_title(L10n::l("welcome_status_title"))
|
.with_title(Lc::l("welcome_status_title"))
|
||||||
.with_child(Html::with(move |cx| {
|
.with_child(Html::with(move |cx| {
|
||||||
html! {
|
html! {
|
||||||
p class="intro-text-lead" {
|
p class="intro-text-lead" {
|
||||||
(L10n::l("welcome_status_1").using(cx))
|
(Lc::l("welcome_status_1").using(cx))
|
||||||
}
|
}
|
||||||
p class="intro-text-lead" {
|
p class="intro-text-lead" {
|
||||||
(L10n::l("welcome_status_2").using(cx))
|
(Lc::l("welcome_status_2").using(cx))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
Block::new()
|
Block::new()
|
||||||
.with_title(L10n::l("welcome_support_title"))
|
.with_title(Lc::l("welcome_support_title"))
|
||||||
.with_child(Html::with(move |cx| {
|
.with_child(Html::with(move |cx| {
|
||||||
html! {
|
html! {
|
||||||
p class="intro-text-lead" {
|
p class="intro-text-lead" {
|
||||||
(L10n::l("welcome_support_1").using(cx))
|
(Lc::l("welcome_support_1").using(cx))
|
||||||
}
|
}
|
||||||
p class="intro-text-lead" {
|
p class="intro-text-lead" {
|
||||||
(L10n::l("welcome_support_2").with_arg("app", app).using(cx))
|
(Lc::l("welcome_support_2").with_arg("app", app).using(cx))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
|
|
|
||||||
|
|
@ -206,9 +206,9 @@ impl<C: Component> Embed<C> {
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// let mut embed = Embed::with(Block::new().with_title(L10n::n("Title")));
|
/// let mut embed = Embed::with(Block::new().with_title(Lc::n("Title")));
|
||||||
/// if let Some(component) = embed.get_mut() {
|
/// if let Some(component) = embed.get_mut() {
|
||||||
/// component.alter_title(L10n::n("New Title"));
|
/// component.alter_title(Lc::n("New Title"));
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn get_mut(&mut self) -> Option<&mut C>
|
pub fn get_mut(&mut self) -> Option<&mut C>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use crate::core::theme::{ChildrenInRegions, CoreRegions, CoreTemplates};
|
||||||
use crate::core::theme::{RegionRef, TemplateRef, ThemeRef};
|
use crate::core::theme::{RegionRef, TemplateRef, ThemeRef};
|
||||||
use crate::html::{Assets, Favicon, JavaScript, Preload, StyleSheet};
|
use crate::html::{Assets, Favicon, JavaScript, Preload, StyleSheet};
|
||||||
use crate::html::{Markup, Props, PropsOp, RoutePath, html};
|
use crate::html::{Markup, Props, PropsOp, RoutePath, html};
|
||||||
use crate::locale::L10n;
|
use crate::locale::Lc;
|
||||||
use crate::locale::{LangId, LanguageIdentifier, RequestLocale};
|
use crate::locale::{LangId, LanguageIdentifier, RequestLocale};
|
||||||
use crate::web::HttpRequest;
|
use crate::web::HttpRequest;
|
||||||
use crate::{builder_fn, util};
|
use crate::{builder_fn, util};
|
||||||
|
|
@ -509,9 +509,9 @@ impl Context {
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// # let mut cx = Context::default();
|
/// # let mut cx = Context::default();
|
||||||
/// cx.push_message(MessageLevel::Warning, L10n::n("Session is not valid"));
|
/// cx.push_message(MessageLevel::Warning, Lc::n("Session is not valid"));
|
||||||
/// ```
|
/// ```
|
||||||
pub fn push_message(&mut self, level: MessageLevel, text: L10n) {
|
pub fn push_message(&mut self, level: MessageLevel, text: Lc) {
|
||||||
self.messages.push(StatusMessage::new(level, text));
|
self.messages.push(StatusMessage::new(level, text));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -532,13 +532,13 @@ impl Context {
|
||||||
/// global de idioma de la aplicación, la cabecera `Accept-Language` y/o el idioma de respaldo.
|
/// global de idioma de la aplicación, la cabecera `Accept-Language` y/o el idioma de respaldo.
|
||||||
///
|
///
|
||||||
/// Todo ello según la negociación indicada en [`global::SETTINGS.app.lang_negotiation`]. Esto
|
/// Todo ello según la negociación indicada en [`global::SETTINGS.app.lang_negotiation`]. Esto
|
||||||
/// permite que el [`Context`] se use como fuente de idioma coherente en [`L10n::lookup()`] o
|
/// permite que el [`Context`] se use como fuente de idioma coherente en [`Lc::lookup()`] o
|
||||||
/// [`L10n::using()`].
|
/// [`Lc::using()`].
|
||||||
///
|
///
|
||||||
/// [`Context`]: crate::core::component::Context
|
/// [`Context`]: crate::core::component::Context
|
||||||
/// [`global::SETTINGS.app.lang_negotiation`]: crate::global::App::lang_negotiation
|
/// [`global::SETTINGS.app.lang_negotiation`]: crate::global::App::lang_negotiation
|
||||||
/// [`L10n::lookup()`]: crate::locale::L10n::lookup
|
/// [`Lc::lookup()`]: crate::locale::Lc::lookup
|
||||||
/// [`L10n::using()`]: crate::locale::L10n::using
|
/// [`Lc::using()`]: crate::locale::Lc::using
|
||||||
impl LangId for Context {
|
impl LangId for Context {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn langid(&self) -> &'static LanguageIdentifier {
|
fn langid(&self) -> &'static LanguageIdentifier {
|
||||||
|
|
|
||||||
|
|
@ -111,28 +111,33 @@ pub trait Component: AnyInfo + ComponentClone + ComponentRender + Send + Sync {
|
||||||
/// Genera el marcado HTML del componente cuando ningún tema lo sobrescribe.
|
/// Genera el marcado HTML del componente cuando ningún tema lo sobrescribe.
|
||||||
///
|
///
|
||||||
/// Este es el cuarto paso del [ciclo de renderizado](ComponentRender) tras llamar al
|
/// Este es el cuarto paso del [ciclo de renderizado](ComponentRender) tras llamar al
|
||||||
/// [`setup()`](Self::setup) del componente y despachar la acción
|
/// [`setup()`] del componente y despachar la acción [`BeforeRender`] que atiende los cambios de
|
||||||
/// [`BeforeRender`](crate::base::action::component::BeforeRender) que atiende los cambios de
|
|
||||||
/// otras extensiones antes de renderizar. Se invoca sólo si ningún tema en la cadena devuelve
|
/// otras extensiones antes de renderizar. Se invoca sólo si ningún tema en la cadena devuelve
|
||||||
/// `Some` en [`Theme::handle_component()`](crate::core::theme::Theme::handle_component) para
|
/// `Some` en [`Theme::handle_component()`] para este componente.
|
||||||
/// este componente.
|
|
||||||
///
|
///
|
||||||
/// Es `async`, a diferencia de [`setup()`](Self::setup), para permitir a los componentes
|
/// Es `async`, a diferencia de [`setup()`], para permitir a los componentes realizar aquí sus
|
||||||
/// realizar aquí sus llamadas asíncronas, como consultas a base de datos, peticiones a
|
/// llamadas asíncronas, como consultas a base de datos, peticiones a servicios externos, o
|
||||||
/// servicios externos, o cualquier operación de E/S, que necesiten para preparar su contenido.
|
/// cualquier operación de E/S, que necesiten para preparar su contenido.
|
||||||
///
|
///
|
||||||
/// Se recomienda obtener los datos del componente a través de sus propios métodos para que los
|
/// Se recomienda obtener los datos del componente a través de sus propios métodos para que los
|
||||||
/// temas puedan implementar `handle_component()` sin depender de los detalles internos.
|
/// temas puedan implementar `handle_component()` sin depender de los detalles internos.
|
||||||
///
|
///
|
||||||
/// Los campos que representen contenido no deben almacenar [`Markup`] ya generado, sino que
|
/// Los campos que representen contenido no deben almacenar [`Markup`] ya generado, sino que
|
||||||
/// guardarán el dato en bruto, por ejemplo [`L10n`](crate::locale::L10n) para textos
|
/// guardarán el dato en bruto, por ejemplo [`Lc`] para textos traducibles, o un componente
|
||||||
/// traducibles, o un componente anidado como [`Html`](crate::base::component::Html), o
|
/// anidado como [`Html`], o cualquier otro `Component`, normalmente a través de [`Embed`] o
|
||||||
/// cualquier otro `Component`, normalmente a través de [`Embed`](crate::core::component::Embed)
|
/// [`Child`]; y será este método quien lo convierta en HTML en el momento del renderizado, no
|
||||||
/// o [`Child`](crate::core::component::Child); y será este método quien lo convierta en HTML en
|
/// quien construye la instancia.
|
||||||
/// el momento del renderizado, no quien construye la instancia.
|
|
||||||
///
|
///
|
||||||
/// Por defecto, devuelve un [`Markup`] vacío (`Ok(html! {})`). En caso de error, devuelve un
|
/// Por defecto, devuelve un [`Markup`] vacío (`Ok(html! {})`). En caso de error, devuelve un
|
||||||
/// [`ComponentError`] que puede incluir un marcado alternativo (*fallback*).
|
/// [`ComponentError`] que puede incluir un marcado alternativo (*fallback*).
|
||||||
|
///
|
||||||
|
/// [`setup()`]: Self::setup
|
||||||
|
/// [`BeforeRender`]: crate::base::action::component::BeforeRender
|
||||||
|
/// [`Theme::handle_component()`]: crate::core::theme::Theme::handle_component
|
||||||
|
/// [`Lc`]: crate::locale::Lc
|
||||||
|
/// [`Html`]: crate::base::component::Html
|
||||||
|
/// [`Embed`]: crate::core::component::Embed
|
||||||
|
/// [`Child`]: crate::core::component::Child
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
async fn prepare(&self, cx: &mut Context) -> Result<Markup, ComponentError> {
|
async fn prepare(&self, cx: &mut Context) -> Result<Markup, ComponentError> {
|
||||||
Ok(html! {})
|
Ok(html! {})
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::locale::L10n;
|
use crate::locale::Lc;
|
||||||
use crate::{AutoDefault, Getters};
|
use crate::{AutoDefault, Getters};
|
||||||
|
|
||||||
/// Nivel de severidad de un [`StatusMessage`].
|
/// Nivel de severidad de un [`StatusMessage`].
|
||||||
|
|
@ -20,30 +20,30 @@ pub enum MessageLevel {
|
||||||
/// puede generarse en cualquier punto del procesamiento de una petición web (handlers, renderizado,
|
/// puede generarse en cualquier punto del procesamiento de una petición web (handlers, renderizado,
|
||||||
/// lógica de negocio, etc.).
|
/// lógica de negocio, etc.).
|
||||||
///
|
///
|
||||||
/// El texto se almacena como [`L10n`] para resolverse con el idioma del contexto en el momento de
|
/// El texto se almacena como [`Lc`] para resolverse con el idioma del contexto en el momento de la
|
||||||
/// la visualización.
|
/// visualización.
|
||||||
///
|
///
|
||||||
/// # Ejemplo
|
/// # Ejemplo
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// // Mensaje informativo con clave traducible.
|
/// // Mensaje informativo con clave traducible.
|
||||||
/// let info = StatusMessage::new(MessageLevel::Info, L10n::l("saved-successfully"));
|
/// let info = StatusMessage::new(MessageLevel::Info, Lc::l("saved-successfully"));
|
||||||
///
|
///
|
||||||
/// // Aviso con texto literal sin traducción.
|
/// // Aviso con texto literal sin traducción.
|
||||||
/// let warn = StatusMessage::new(MessageLevel::Warning, L10n::n("Incomplete form."));
|
/// let warn = StatusMessage::new(MessageLevel::Warning, Lc::n("Incomplete form."));
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Debug, Getters)]
|
#[derive(Debug, Getters)]
|
||||||
pub struct StatusMessage {
|
pub struct StatusMessage {
|
||||||
/// Nivel de severidad del mensaje.
|
/// Nivel de severidad del mensaje.
|
||||||
level: MessageLevel,
|
level: MessageLevel,
|
||||||
/// Texto del mensaje.
|
/// Texto del mensaje.
|
||||||
text: L10n,
|
text: Lc,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StatusMessage {
|
impl StatusMessage {
|
||||||
/// Crea un nuevo mensaje de usuario con el nivel y texto indicados.
|
/// Crea un nuevo mensaje de usuario con el nivel y texto indicados.
|
||||||
pub fn new(level: MessageLevel, text: L10n) -> Self {
|
pub fn new(level: MessageLevel, text: Lc) -> Self {
|
||||||
StatusMessage { level, text }
|
StatusMessage { level, text }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use crate::async_trait;
|
||||||
use crate::core::AnyInfo;
|
use crate::core::AnyInfo;
|
||||||
use crate::core::action::ActionBox;
|
use crate::core::action::ActionBox;
|
||||||
use crate::core::theme::ThemeRef;
|
use crate::core::theme::ThemeRef;
|
||||||
use crate::locale::L10n;
|
use crate::locale::Lc;
|
||||||
use crate::web::Router;
|
use crate::web::Router;
|
||||||
|
|
||||||
/// Interfaz común que debe implementar cualquier extensión de PageTop.
|
/// Interfaz común que debe implementar cualquier extensión de PageTop.
|
||||||
|
|
@ -17,12 +17,12 @@ use crate::web::Router;
|
||||||
///
|
///
|
||||||
/// #[async_trait]
|
/// #[async_trait]
|
||||||
/// impl Extension for MyExtension {
|
/// impl Extension for MyExtension {
|
||||||
/// fn name(&self) -> L10n {
|
/// fn name(&self) -> Lc {
|
||||||
/// L10n::n("My Extension")
|
/// Lc::n("My Extension")
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// fn description(&self) -> L10n {
|
/// fn description(&self) -> Lc {
|
||||||
/// L10n::n("Does something useful")
|
/// Lc::n("Does something useful")
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
@ -32,15 +32,15 @@ pub trait Extension: AnyInfo + Send + Sync {
|
||||||
///
|
///
|
||||||
/// Predeterminado por el [`short_name()`](AnyInfo::short_name) del tipo asociado a la
|
/// Predeterminado por el [`short_name()`](AnyInfo::short_name) del tipo asociado a la
|
||||||
/// extensión.
|
/// extensión.
|
||||||
fn name(&self) -> L10n {
|
fn name(&self) -> Lc {
|
||||||
L10n::n(self.short_name())
|
Lc::n(self.short_name())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Descripción corta de la extensión como *texto localizado* para paneles, listados, etc.
|
/// Descripción corta de la extensión como *texto localizado* para paneles, listados, etc.
|
||||||
///
|
///
|
||||||
/// Por defecto devuelve un valor vacío (`L10n::default()`).
|
/// Por defecto devuelve un valor vacío (`Lc::default()`).
|
||||||
fn description(&self) -> L10n {
|
fn description(&self) -> Lc {
|
||||||
L10n::default()
|
Lc::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Devuelve una referencia a esta misma extensión cuando actúa como un tema.
|
/// Devuelve una referencia a esta misma extensión cuando actúa como un tema.
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@
|
||||||
|
|
||||||
use crate::AutoDefault;
|
use crate::AutoDefault;
|
||||||
use crate::core::AnyInfo;
|
use crate::core::AnyInfo;
|
||||||
use crate::locale::L10n;
|
use crate::locale::Lc;
|
||||||
|
|
||||||
// **< RegionName >*********************************************************************************
|
// **< RegionName >*********************************************************************************
|
||||||
|
|
||||||
|
|
@ -162,7 +162,7 @@ pub trait RegionName: Send + Sync + AnyInfo {
|
||||||
///
|
///
|
||||||
/// En la implementación predeterminada de [`Region`](crate::base::component::layout::Region),
|
/// En la implementación predeterminada de [`Region`](crate::base::component::layout::Region),
|
||||||
/// este valor se usa como `aria-label` del contenedor de la región.
|
/// este valor se usa como `aria-label` del contenedor de la región.
|
||||||
fn label(&self) -> L10n;
|
fn label(&self) -> Lc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Referencia estática a una región.
|
/// Referencia estática a una región.
|
||||||
|
|
@ -221,12 +221,12 @@ impl RegionName for CoreRegions {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn label(&self) -> L10n {
|
fn label(&self) -> Lc {
|
||||||
match self {
|
match self {
|
||||||
Self::Header => L10n::l("region_header"),
|
Self::Header => Lc::l("region_header"),
|
||||||
Self::Aside => L10n::l("region_aside"),
|
Self::Aside => Lc::l("region_aside"),
|
||||||
Self::Content => L10n::l("region_content"),
|
Self::Content => Lc::l("region_content"),
|
||||||
Self::Footer => L10n::l("region_footer"),
|
Self::Footer => Lc::l("region_footer"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -249,7 +249,7 @@ pub trait TemplateName: Send + Sync + AnyInfo {
|
||||||
fn name(&self) -> &'static str;
|
fn name(&self) -> &'static str;
|
||||||
|
|
||||||
/// Devuelve un *texto localizado* como etiqueta descriptiva de la plantilla.
|
/// Devuelve un *texto localizado* como etiqueta descriptiva de la plantilla.
|
||||||
fn label(&self) -> L10n;
|
fn label(&self) -> Lc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Referencia estática a una plantilla.
|
/// Referencia estática a una plantilla.
|
||||||
|
|
@ -282,10 +282,10 @@ impl TemplateName for CoreTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn label(&self) -> L10n {
|
fn label(&self) -> Lc {
|
||||||
match self {
|
match self {
|
||||||
Self::Standard => L10n::l("template-standard"),
|
Self::Standard => Lc::l("template-standard"),
|
||||||
Self::Admin => L10n::l("template-admin"),
|
Self::Admin => Lc::l("template-admin"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use crate::core::extension::Extension;
|
||||||
use crate::core::theme::CoreRegions;
|
use crate::core::theme::CoreRegions;
|
||||||
use crate::global;
|
use crate::global;
|
||||||
use crate::html::{Markup, html};
|
use crate::html::{Markup, html};
|
||||||
use crate::locale::L10n;
|
use crate::locale::Lc;
|
||||||
use crate::response::Page;
|
use crate::response::Page;
|
||||||
use crate::web::http::StatusCode;
|
use crate::web::http::StatusCode;
|
||||||
|
|
||||||
|
|
@ -32,12 +32,12 @@ use crate::web::http::StatusCode;
|
||||||
///
|
///
|
||||||
/// #[async_trait]
|
/// #[async_trait]
|
||||||
/// impl Extension for MyTheme {
|
/// impl Extension for MyTheme {
|
||||||
/// fn name(&self) -> L10n {
|
/// fn name(&self) -> Lc {
|
||||||
/// L10n::n("My theme")
|
/// Lc::n("My theme")
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// fn description(&self) -> L10n {
|
/// fn description(&self) -> Lc {
|
||||||
/// L10n::n("A personal theme")
|
/// Lc::n("A personal theme")
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// fn theme(&self) -> Option<ThemeRef> {
|
/// fn theme(&self) -> Option<ThemeRef> {
|
||||||
|
|
@ -234,14 +234,14 @@ pub trait Theme: Extension + Send + Sync {
|
||||||
if let Some(parent) = self.parent() {
|
if let Some(parent) = self.parent() {
|
||||||
return parent.error_403(page);
|
return parent.error_403(page);
|
||||||
}
|
}
|
||||||
page.alter_title(L10n::l("error403_title")).alter_child_in(
|
page.alter_title(Lc::l("error403_title")).alter_child_in(
|
||||||
&CoreRegions::Content,
|
&CoreRegions::Content,
|
||||||
ChildOp::Prepend(
|
ChildOp::Prepend(
|
||||||
Html::with(move |cx| {
|
Html::with(move |cx| {
|
||||||
html! {
|
html! {
|
||||||
div {
|
div {
|
||||||
h1 { (L10n::l("error403_alert").using(cx)) }
|
h1 { (Lc::l("error403_alert").using(cx)) }
|
||||||
p { (L10n::l("error403_help").using(cx)) }
|
p { (Lc::l("error403_help").using(cx)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -260,14 +260,14 @@ pub trait Theme: Extension + Send + Sync {
|
||||||
if let Some(parent) = self.parent() {
|
if let Some(parent) = self.parent() {
|
||||||
return parent.error_404(page);
|
return parent.error_404(page);
|
||||||
}
|
}
|
||||||
page.alter_title(L10n::l("error404_title")).alter_child_in(
|
page.alter_title(Lc::l("error404_title")).alter_child_in(
|
||||||
&CoreRegions::Content,
|
&CoreRegions::Content,
|
||||||
ChildOp::Prepend(
|
ChildOp::Prepend(
|
||||||
Html::with(move |cx| {
|
Html::with(move |cx| {
|
||||||
html! {
|
html! {
|
||||||
div {
|
div {
|
||||||
h1 { (L10n::l("error404_alert").using(cx)) }
|
h1 { (Lc::l("error404_alert").using(cx)) }
|
||||||
p { (L10n::l("error404_help").using(cx)) }
|
p { (Lc::l("error404_help").using(cx)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -304,7 +304,7 @@ pub trait Theme: Extension + Send + Sync {
|
||||||
/// [`ErrorPage::ServiceUnavailable`]: crate::response::ErrorPage::ServiceUnavailable
|
/// [`ErrorPage::ServiceUnavailable`]: crate::response::ErrorPage::ServiceUnavailable
|
||||||
/// [`ErrorPage::GatewayTimeout`]: crate::response::ErrorPage::GatewayTimeout
|
/// [`ErrorPage::GatewayTimeout`]: crate::response::ErrorPage::GatewayTimeout
|
||||||
/// [`CoreTemplates::Standard`]: crate::core::theme::CoreTemplates::Standard
|
/// [`CoreTemplates::Standard`]: crate::core::theme::CoreTemplates::Standard
|
||||||
fn error_fatal(&self, page: &mut Page, code: StatusCode, title: L10n, alert: L10n, help: L10n) {
|
fn error_fatal(&self, page: &mut Page, code: StatusCode, title: Lc, alert: Lc, help: Lc) {
|
||||||
if let Some(parent) = self.parent() {
|
if let Some(parent) = self.parent() {
|
||||||
return parent.error_fatal(page, code, title, alert, help);
|
return parent.error_fatal(page, code, title, alert, help);
|
||||||
}
|
}
|
||||||
|
|
@ -312,8 +312,8 @@ pub trait Theme: Extension + Send + Sync {
|
||||||
&CoreRegions::Content,
|
&CoreRegions::Content,
|
||||||
ChildOp::Prepend(
|
ChildOp::Prepend(
|
||||||
Intro::new()
|
Intro::new()
|
||||||
.with_title(L10n::l("error_code").with_arg("code", code.to_string()))
|
.with_title(Lc::l("error_code").with_arg("code", code.to_string()))
|
||||||
.with_slogan(L10n::n(code.to_string()))
|
.with_slogan(Lc::n(code.to_string()))
|
||||||
.with_button(None)
|
.with_button(None)
|
||||||
.with_opening(IntroOpening::Custom)
|
.with_opening(IntroOpening::Custom)
|
||||||
.with_child(Html::with(move |cx| {
|
.with_child(Html::with(move |cx| {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::locale::{L10n, LangId};
|
use crate::locale::{LangId, Lc};
|
||||||
use crate::{AutoDefault, builder_fn, util};
|
use crate::{AutoDefault, builder_fn, util};
|
||||||
|
|
||||||
/// Valor opcional para atributos HTML.
|
/// Valor opcional para atributos HTML.
|
||||||
|
|
@ -7,7 +7,7 @@ use crate::{AutoDefault, builder_fn, util};
|
||||||
/// opcionales, uniformes y tipados.
|
/// opcionales, uniformes y tipados.
|
||||||
///
|
///
|
||||||
/// Este tipo **no impone ninguna normalización ni semántica concreta**; dichas reglas se definen en
|
/// Este tipo **no impone ninguna normalización ni semántica concreta**; dichas reglas se definen en
|
||||||
/// implementaciones concretas como `Attr<L10n>` y `Attr<String>`, o en tipos específicos como
|
/// implementaciones concretas como `Attr<Lc>` y `Attr<String>`, o en tipos específicos como
|
||||||
/// [`AttrName`].
|
/// [`AttrName`].
|
||||||
#[derive(AutoDefault, Clone, Debug)]
|
#[derive(AutoDefault, Clone, Debug)]
|
||||||
pub struct Attr<T>(Option<T>);
|
pub struct Attr<T>(Option<T>);
|
||||||
|
|
@ -72,18 +72,18 @@ impl<T> Attr<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// **< Attr<L10n> >*********************************************************************************
|
// **< Attr<Lc> >***********************************************************************************
|
||||||
|
|
||||||
/// Extiende [`Attr`] para [texto localizado](crate::locale) en atributos HTML.
|
/// Extiende [`Attr`] para [texto localizado](crate::locale) en atributos HTML.
|
||||||
///
|
///
|
||||||
/// Encapsula un [`L10n`] para manejar traducciones de forma segura en atributos.
|
/// Encapsula un [`Lc`] para manejar traducciones de forma segura en atributos.
|
||||||
///
|
///
|
||||||
/// # Ejemplo
|
/// # Ejemplo
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// // Traducción por clave en las locales por defecto de PageTop.
|
/// // Traducción por clave en las locales por defecto de PageTop.
|
||||||
/// let hello = Attr::<L10n>::new(L10n::l("test_hello_world"));
|
/// let hello = Attr::<Lc>::new(Lc::l("test_hello_world"));
|
||||||
///
|
///
|
||||||
/// // Español disponible.
|
/// // Español disponible.
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
|
|
@ -101,9 +101,9 @@ impl<T> Attr<T> {
|
||||||
/// let title = hello.value(&Locale::resolve("es-ES"));
|
/// let title = hello.value(&Locale::resolve("es-ES"));
|
||||||
/// // Ejemplo: html! { a title=(title) { "Link" } }
|
/// // Ejemplo: html! { a title=(title) { "Link" } }
|
||||||
/// ```
|
/// ```
|
||||||
impl Attr<L10n> {
|
impl Attr<Lc> {
|
||||||
/// Crea una nueva instancia `Attr<L10n>`.
|
/// Crea una nueva instancia `Attr<Lc>`.
|
||||||
pub fn new(value: L10n) -> Self {
|
pub fn new(value: Lc) -> Self {
|
||||||
Self::some(value)
|
Self::some(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::AutoDefault;
|
use crate::AutoDefault;
|
||||||
use crate::core::component::Context;
|
use crate::core::component::Context;
|
||||||
use crate::html::{Markup, html};
|
use crate::html::{Markup, html};
|
||||||
use crate::locale::L10n;
|
use crate::locale::Lc;
|
||||||
|
|
||||||
/// Representación SVG del **logotipo de PageTop** para incrustar en HTML.
|
/// Representación SVG del **logotipo de PageTop** para incrustar en HTML.
|
||||||
///
|
///
|
||||||
|
|
@ -54,7 +54,7 @@ impl PageTopSvg {
|
||||||
viewBox="0 0 1614 1614"
|
viewBox="0 0 1614 1614"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
role="img"
|
role="img"
|
||||||
aria-label=[L10n::l("pagetop_logo").lookup(cx)]
|
aria-label=[Lc::l("pagetop_logo").lookup(cx)]
|
||||||
preserveAspectRatio="xMidYMid slice"
|
preserveAspectRatio="xMidYMid slice"
|
||||||
focusable="false"
|
focusable="false"
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -354,7 +354,7 @@ impl PropsOp {
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// #[derive(AutoDefault, Clone, Getters)]
|
/// #[derive(AutoDefault, Clone, Getters)]
|
||||||
/// pub struct MyButton {
|
/// pub struct MyButton {
|
||||||
/// label: L10n,
|
/// label: Lc,
|
||||||
/// props: Props,
|
/// props: Props,
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! Y *voilà*, sólo queda operar con los idiomas soportados por PageTop usando [`Locale`] y traducir
|
//! Y *voilà*, sólo queda operar con los idiomas soportados por PageTop usando [`Locale`] y traducir
|
||||||
//! textos con [`L10n`].
|
//! textos con [`Lc`].
|
||||||
|
|
||||||
pub use fluent_templates;
|
pub use fluent_templates;
|
||||||
pub use unic_langid::{CharacterDirection, LanguageIdentifier};
|
pub use unic_langid::{CharacterDirection, LanguageIdentifier};
|
||||||
|
|
@ -102,8 +102,8 @@ pub use definition::{LangId, Locale};
|
||||||
mod request;
|
mod request;
|
||||||
pub use request::RequestLocale;
|
pub use request::RequestLocale;
|
||||||
|
|
||||||
mod l10n;
|
mod lc;
|
||||||
pub use l10n::L10n;
|
pub use lc::Lc;
|
||||||
|
|
||||||
// **< include_locales! >***************************************************************************
|
// **< include_locales! >***************************************************************************
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -199,8 +199,11 @@ impl Locale {
|
||||||
/// devuelve el idioma por defecto de la aplicación y, si tampoco está disponible, el idioma de
|
/// devuelve el idioma por defecto de la aplicación y, si tampoco está disponible, el idioma de
|
||||||
/// respaldo (`"en-US"`).
|
/// respaldo (`"en-US"`).
|
||||||
///
|
///
|
||||||
/// Resulta útil para usar un valor de [`Locale`] como fuente de traducción en
|
/// Resulta útil para usar un valor de [`Locale`] como fuente de traducción en [`Lc::lookup()`] o
|
||||||
/// [`L10n::lookup()`](crate::locale::L10n::lookup) o [`L10n::using()`](crate::locale::L10n::using).
|
/// [`Lc::using()`].
|
||||||
|
///
|
||||||
|
/// [`Lc::lookup()`]: crate::locale::Lc::lookup
|
||||||
|
/// [`Lc::using()`]: crate::locale::Lc::using
|
||||||
impl LangId for Locale {
|
impl LangId for Locale {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn langid(&self) -> &'static LanguageIdentifier {
|
fn langid(&self) -> &'static LanguageIdentifier {
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,13 @@ use std::collections::HashMap;
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
/// Operación de localización a realizar.
|
// Tipo de localización a aplicar.
|
||||||
///
|
//
|
||||||
/// * `None` - No se aplica ninguna localización.
|
// * `None` - No se aplica ninguna localización.
|
||||||
/// * `Text` - Con una cadena literal que se devolverá tal cual.
|
// * `Text` - Con una cadena literal que se devolverá tal cual.
|
||||||
/// * `Translate` - Con la clave a resolver en el `Locales` indicado.
|
// * `Translate` - Con la clave a resolver en el `Locales` indicado.
|
||||||
#[derive(AutoDefault, Clone, Debug)]
|
#[derive(AutoDefault, Clone, Debug)]
|
||||||
enum L10nOp {
|
enum LcKind {
|
||||||
#[default]
|
#[default]
|
||||||
None,
|
None,
|
||||||
Text(CowStr),
|
Text(CowStr),
|
||||||
|
|
@ -61,10 +61,10 @@ enum L10nOp {
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// // Texto literal sin traducción.
|
/// // Texto literal sin traducción.
|
||||||
/// let raw = L10n::n("© 2025 PageTop").get();
|
/// let raw = Lc::n("© 2025 PageTop").get();
|
||||||
///
|
///
|
||||||
/// // Traducción simple con clave y argumentos.
|
/// // Traducción simple con clave y argumentos.
|
||||||
/// let hello = L10n::l("greeting")
|
/// let hello = Lc::l("greeting")
|
||||||
/// .with_arg("name", "Manuel")
|
/// .with_arg("name", "Manuel")
|
||||||
/// .get();
|
/// .get();
|
||||||
/// ```
|
/// ```
|
||||||
|
|
@ -73,19 +73,19 @@ enum L10nOp {
|
||||||
///
|
///
|
||||||
/// ```rust,ignore
|
/// ```rust,ignore
|
||||||
/// // Traducción con clave, conjunto de traducciones y fuente de idioma.
|
/// // Traducción con clave, conjunto de traducciones y fuente de idioma.
|
||||||
/// let bye = L10n::t("goodbye", &LOCALES_CUSTOM).lookup(&Locale::resolve("it"));
|
/// let bye = Lc::t("goodbye", &LOCALES_CUSTOM).lookup(&Locale::resolve("it"));
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(AutoDefault, Clone)]
|
#[derive(AutoDefault, Clone)]
|
||||||
pub struct L10n {
|
pub struct Lc {
|
||||||
op: L10nOp,
|
op: LcKind,
|
||||||
#[default(&LOCALES_PAGETOP)]
|
#[default(&LOCALES_PAGETOP)]
|
||||||
locales: &'static Locales,
|
locales: &'static Locales,
|
||||||
args: Vec<(CowStr, CowStr)>,
|
args: Vec<(CowStr, CowStr)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for L10n {
|
impl fmt::Debug for Lc {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("L10n")
|
f.debug_struct("Lc")
|
||||||
.field("op", &self.op)
|
.field("op", &self.op)
|
||||||
.field("args", &self.args)
|
.field("args", &self.args)
|
||||||
// No se puede mostrar `locales`; se representa con un texto fijo.
|
// No se puede mostrar `locales`; se representa con un texto fijo.
|
||||||
|
|
@ -94,11 +94,11 @@ impl fmt::Debug for L10n {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl L10n {
|
impl Lc {
|
||||||
/// **n** = *“native”*. Crea una instancia con una cadena literal sin traducción.
|
/// **n** = *“native”*. Crea una instancia con una cadena literal sin traducción.
|
||||||
pub fn n(text: impl Into<CowStr>) -> Self {
|
pub fn n(text: impl Into<CowStr>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
op: L10nOp::Text(text.into()),
|
op: LcKind::Text(text.into()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -107,7 +107,7 @@ impl L10n {
|
||||||
/// predefinidas propias de PageTop.
|
/// predefinidas propias de PageTop.
|
||||||
pub fn l(key: impl Into<CowStr>) -> Self {
|
pub fn l(key: impl Into<CowStr>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
op: L10nOp::Translate(key.into()),
|
op: LcKind::Translate(key.into()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -116,7 +116,7 @@ impl L10n {
|
||||||
/// específico.
|
/// específico.
|
||||||
pub fn t(key: impl Into<CowStr>, locales: &'static Locales) -> Self {
|
pub fn t(key: impl Into<CowStr>, locales: &'static Locales) -> Self {
|
||||||
Self {
|
Self {
|
||||||
op: L10nOp::Translate(key.into()),
|
op: LcKind::Translate(key.into()),
|
||||||
locales,
|
locales,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
|
|
@ -151,7 +151,7 @@ impl L10n {
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// let text = L10n::l("greeting").with_arg("name", "Manuel").get();
|
/// let text = Lc::l("greeting").with_arg("name", "Manuel").get();
|
||||||
/// ```
|
/// ```
|
||||||
pub fn get(&self) -> Option<String> {
|
pub fn get(&self) -> Option<String> {
|
||||||
self.lookup(&Locale::default())
|
self.lookup(&Locale::default())
|
||||||
|
|
@ -179,13 +179,13 @@ impl L10n {
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// let r = ResourceLang;
|
/// let r = ResourceLang;
|
||||||
/// let text = L10n::l("greeting").with_arg("name", "Usuario").lookup(&r);
|
/// let text = Lc::l("greeting").with_arg("name", "Usuario").lookup(&r);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn lookup(&self, language: &impl LangId) -> Option<String> {
|
pub fn lookup(&self, language: &impl LangId) -> Option<String> {
|
||||||
match &self.op {
|
match &self.op {
|
||||||
L10nOp::None => None,
|
LcKind::None => None,
|
||||||
L10nOp::Text(text) => Some(text.clone().into_owned()),
|
LcKind::Text(text) => Some(text.clone().into_owned()),
|
||||||
L10nOp::Translate(key) => {
|
LcKind::Translate(key) => {
|
||||||
if self.args.is_empty() {
|
if self.args.is_empty() {
|
||||||
self.locales.try_lookup(language.langid(), key.as_ref())
|
self.locales.try_lookup(language.langid(), key.as_ref())
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -219,11 +219,11 @@ impl L10n {
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// let html = L10n::l("welcome.message").using(&Locale::resolve("es"));
|
/// let html = Lc::l("welcome.message").using(&Locale::resolve("es"));
|
||||||
/// ```
|
/// ```
|
||||||
pub fn using(&self, language: &impl LangId) -> Markup {
|
pub fn using(&self, language: &impl LangId) -> Markup {
|
||||||
match &self.op {
|
match &self.op {
|
||||||
L10nOp::Text(text) => text.render(),
|
LcKind::Text(text) => text.render(),
|
||||||
_ => PreEscaped(self.lookup(language).unwrap_or_default()),
|
_ => PreEscaped(self.lookup(language).unwrap_or_default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -27,7 +27,7 @@ use crate::core::theme::{CoreRegions, RegionName, RegionRef, TemplateRef, ThemeR
|
||||||
use crate::html::{Assets, Favicon, JavaScript, StyleSheet};
|
use crate::html::{Assets, Favicon, JavaScript, StyleSheet};
|
||||||
use crate::html::{Attr, Props, PropsOp};
|
use crate::html::{Attr, Props, PropsOp};
|
||||||
use crate::html::{DOCTYPE, Markup, html};
|
use crate::html::{DOCTYPE, Markup, html};
|
||||||
use crate::locale::{CharacterDirection, L10n, LangId, LanguageIdentifier};
|
use crate::locale::{CharacterDirection, LangId, LanguageIdentifier, Lc};
|
||||||
use crate::web::HttpRequest;
|
use crate::web::HttpRequest;
|
||||||
use crate::{AutoDefault, builder_fn};
|
use crate::{AutoDefault, builder_fn};
|
||||||
|
|
||||||
|
|
@ -73,8 +73,8 @@ impl RegionName for ReservedRegions {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn label(&self) -> L10n {
|
fn label(&self) -> Lc {
|
||||||
L10n::default()
|
Lc::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,8 +88,8 @@ impl RegionName for ReservedRegions {
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[derive(AutoDefault)]
|
#[derive(AutoDefault)]
|
||||||
pub struct Page {
|
pub struct Page {
|
||||||
title : Attr<L10n>,
|
title : Attr<Lc>,
|
||||||
description : Attr<L10n>,
|
description : Attr<Lc>,
|
||||||
metadata : Vec<(&'static str, &'static str)>,
|
metadata : Vec<(&'static str, &'static str)>,
|
||||||
properties : Vec<(&'static str, &'static str)>,
|
properties : Vec<(&'static str, &'static str)>,
|
||||||
context : Context,
|
context : Context,
|
||||||
|
|
@ -127,14 +127,14 @@ impl Page {
|
||||||
|
|
||||||
/// Establece el título de la página como un valor traducible.
|
/// Establece el título de la página como un valor traducible.
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_title(mut self, title: L10n) -> Self {
|
pub fn with_title(mut self, title: Lc) -> Self {
|
||||||
self.title.alter_value(title);
|
self.title.alter_value(title);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Establece la descripción de la página como un valor traducible.
|
/// Establece la descripción de la página como un valor traducible.
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_description(mut self, description: L10n) -> Self {
|
pub fn with_description(mut self, description: Lc) -> Self {
|
||||||
self.description.alter_value(description);
|
self.description.alter_value(description);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -258,8 +258,8 @@ impl Page {
|
||||||
|
|
||||||
/// Permite a [`Page`] actuar como proveedor de idioma usando el [`Context`] de la página.
|
/// Permite a [`Page`] actuar como proveedor de idioma usando el [`Context`] de la página.
|
||||||
///
|
///
|
||||||
/// Resulta útil para usar [`Page`] directamente como fuente de traducción en [`L10n::lookup()`] o
|
/// Resulta útil para usar [`Page`] directamente como fuente de traducción en [`Lc::lookup()`] o
|
||||||
/// [`L10n::using()`].
|
/// [`Lc::using()`].
|
||||||
impl LangId for Page {
|
impl LangId for Page {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn langid(&self) -> &'static LanguageIdentifier {
|
fn langid(&self) -> &'static LanguageIdentifier {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use axum::middleware::Next;
|
||||||
|
|
||||||
use crate::core::component::Contextual;
|
use crate::core::component::Contextual;
|
||||||
use crate::html::Markup;
|
use crate::html::Markup;
|
||||||
use crate::locale::L10n;
|
use crate::locale::Lc;
|
||||||
use crate::web::{HttpRequest, IntoResponse, Response, http};
|
use crate::web::{HttpRequest, IntoResponse, Response, http};
|
||||||
use crate::{trace, util};
|
use crate::{trace, util};
|
||||||
|
|
||||||
|
|
@ -89,9 +89,9 @@ impl ErrorPage {
|
||||||
page.theme().error_fatal(
|
page.theme().error_fatal(
|
||||||
&mut page,
|
&mut page,
|
||||||
status,
|
status,
|
||||||
L10n::l(util::join!("error", status.as_str(), "_title")),
|
Lc::l(util::join!("error", status.as_str(), "_title")),
|
||||||
L10n::l(util::join!("error", status.as_str(), "_alert")),
|
Lc::l(util::join!("error", status.as_str(), "_alert")),
|
||||||
L10n::l(util::join!("error", status.as_str(), "_help")),
|
Lc::l(util::join!("error", status.as_str(), "_help")),
|
||||||
);
|
);
|
||||||
page
|
page
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ async fn with_aria_label_overrides_the_default() {
|
||||||
.with_current_page(1)
|
.with_current_page(1)
|
||||||
.with_items_per_page(10)
|
.with_items_per_page(10)
|
||||||
.with_total_items(50)
|
.with_total_items(50)
|
||||||
.with_aria_label(L10n::n("Users pagination"));
|
.with_aria_label(Lc::n("Users pagination"));
|
||||||
|
|
||||||
let html = pager.render(&mut Context::default()).await.into_string();
|
let html = pager.render(&mut Context::default()).await.into_string();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,16 +8,16 @@ async fn setup() {
|
||||||
async fn literal_text() {
|
async fn literal_text() {
|
||||||
setup().await;
|
setup().await;
|
||||||
|
|
||||||
let l10n = L10n::n("© 2025 PageTop");
|
let lc = Lc::n("© 2025 PageTop");
|
||||||
assert_eq!(l10n.get(), Some("© 2025 PageTop".to_string()));
|
assert_eq!(lc.get(), Some("© 2025 PageTop".to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pagetop::test]
|
#[pagetop::test]
|
||||||
async fn translation_without_args() {
|
async fn translation_without_args() {
|
||||||
setup().await;
|
setup().await;
|
||||||
|
|
||||||
let l10n = L10n::l("test_hello_world");
|
let lc = Lc::l("test_hello_world");
|
||||||
let translation = l10n.lookup(&Locale::resolve("es-ES"));
|
let translation = lc.lookup(&Locale::resolve("es-ES"));
|
||||||
assert_eq!(translation, Some("¡Hola mundo!".to_string()));
|
assert_eq!(translation, Some("¡Hola mundo!".to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -25,8 +25,8 @@ async fn translation_without_args() {
|
||||||
async fn translation_with_args() {
|
async fn translation_with_args() {
|
||||||
setup().await;
|
setup().await;
|
||||||
|
|
||||||
let l10n = L10n::l("test_hello_user").with_arg("userName", "Manuel");
|
let lc = Lc::l("test_hello_user").with_arg("userName", "Manuel");
|
||||||
let translation = l10n.lookup(&Locale::resolve("es-ES"));
|
let translation = lc.lookup(&Locale::resolve("es-ES"));
|
||||||
assert_eq!(translation, Some("¡Hola, Manuel!".to_string()));
|
assert_eq!(translation, Some("¡Hola, Manuel!".to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -34,12 +34,12 @@ async fn translation_with_args() {
|
||||||
async fn translation_with_plural_and_select() {
|
async fn translation_with_plural_and_select() {
|
||||||
setup().await;
|
setup().await;
|
||||||
|
|
||||||
let l10n = L10n::l("test_shared_photos").with_args(vec![
|
let lc = Lc::l("test_shared_photos").with_args(vec![
|
||||||
("userName", "Roberto"),
|
("userName", "Roberto"),
|
||||||
("photoCount", "3"),
|
("photoCount", "3"),
|
||||||
("userGender", "male"),
|
("userGender", "male"),
|
||||||
]);
|
]);
|
||||||
let translation = l10n.lookup(&Locale::resolve("es-ES")).unwrap();
|
let translation = lc.lookup(&Locale::resolve("es-ES")).unwrap();
|
||||||
assert!(translation.contains("añadido 3 nuevas fotos de él"));
|
assert!(translation.contains("añadido 3 nuevas fotos de él"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,8 +47,8 @@ async fn translation_with_plural_and_select() {
|
||||||
async fn check_fallback_language() {
|
async fn check_fallback_language() {
|
||||||
setup().await;
|
setup().await;
|
||||||
|
|
||||||
let l10n = L10n::l("test_hello_world");
|
let lc = Lc::l("test_hello_world");
|
||||||
let translation = l10n.lookup(&Locale::resolve("xx-YY")); // Retrocede a "en-US".
|
let translation = lc.lookup(&Locale::resolve("xx-YY")); // Retrocede a "en-US".
|
||||||
assert_eq!(translation, Some("Hello world!".to_string()));
|
assert_eq!(translation, Some("Hello world!".to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,32 +56,32 @@ async fn check_fallback_language() {
|
||||||
async fn check_unknown_key() {
|
async fn check_unknown_key() {
|
||||||
setup().await;
|
setup().await;
|
||||||
|
|
||||||
let l10n = L10n::l("non-existent-key");
|
let lc = Lc::l("non-existent-key");
|
||||||
let translation = l10n.lookup(&Locale::resolve("en-US"));
|
let translation = lc.lookup(&Locale::resolve("en-US"));
|
||||||
assert_eq!(translation, None);
|
assert_eq!(translation, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
// `using()` renders literal text (`L10n::n()`) as HTML-escaped `Markup`, because it may come from
|
// `using()` renders literal text (`Lc::n()`) as HTML-escaped `Markup`, because it may come from
|
||||||
// runtime data (e.g. a menu title or a role label) rather than developer-authored content.
|
// runtime data (e.g. a menu title or a role label) rather than developer-authored content.
|
||||||
#[pagetop::test]
|
#[pagetop::test]
|
||||||
async fn literal_text_is_escaped_when_rendered_as_markup() {
|
async fn literal_text_is_escaped_when_rendered_as_markup() {
|
||||||
setup().await;
|
setup().await;
|
||||||
|
|
||||||
let l10n = L10n::n("<script>alert(1)</script>");
|
let lc = Lc::n("<script>alert(1)</script>");
|
||||||
let markup = l10n.using(&Locale::default());
|
let markup = lc.using(&Locale::default());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
markup.into_string(),
|
markup.into_string(),
|
||||||
"<script>alert(1)</script>"
|
"<script>alert(1)</script>"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translation keys (`L10n::l()`/`L10n::t()`) are developer-authored `.ftl` content that may embed
|
// Translation keys (`Lc::l()`/`Lc::t()`) are developer-authored `.ftl` content that may embed
|
||||||
// HTML on purpose (e.g. `<strong>`), so `using()` must keep rendering them unescaped.
|
// HTML on purpose (e.g. `<strong>`), so `using()` must keep rendering them unescaped.
|
||||||
#[pagetop::test]
|
#[pagetop::test]
|
||||||
async fn translated_text_is_not_escaped_when_rendered_as_markup() {
|
async fn translated_text_is_not_escaped_when_rendered_as_markup() {
|
||||||
setup().await;
|
setup().await;
|
||||||
|
|
||||||
let l10n = L10n::l("test_hello_world");
|
let lc = Lc::l("test_hello_world");
|
||||||
let markup = l10n.using(&Locale::resolve("en-US"));
|
let markup = lc.using(&Locale::resolve("en-US"));
|
||||||
assert_eq!(markup.into_string(), "Hello world!");
|
assert_eq!(markup.into_string(), "Hello world!");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue