💥 New names for optional attributes
This commit is contained in:
parent
7a5c86ac9a
commit
33dff8f085
18 changed files with 167 additions and 143 deletions
|
|
@ -28,10 +28,10 @@ type AnchorHtml = TypedComponent<L10n>;
|
||||||
pub struct Anchor {
|
pub struct Anchor {
|
||||||
weight : Weight,
|
weight : Weight,
|
||||||
renderable : Renderable,
|
renderable : Renderable,
|
||||||
id : IdentifierValue,
|
id : OptionId,
|
||||||
classes : Classes,
|
classes : OptionClasses,
|
||||||
anchor_type: AnchorType,
|
anchor_type: AnchorType,
|
||||||
href : AttributeValue,
|
href : OptionString,
|
||||||
html : AnchorHtml,
|
html : AnchorHtml,
|
||||||
left_icon : AnchorIcon,
|
left_icon : AnchorIcon,
|
||||||
right_icon : AnchorIcon,
|
right_icon : AnchorIcon,
|
||||||
|
|
@ -85,18 +85,18 @@ impl ComponentTrait for Anchor {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Anchor {
|
impl Anchor {
|
||||||
pub fn link(href: &str, html: L10n) -> Self {
|
pub fn link(href: impl Into<String>, html: L10n) -> Self {
|
||||||
Anchor::new().with_href(href).with_html(html)
|
Anchor::new().with_href(href).with_html(html)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn button(href: &str, html: L10n) -> Self {
|
pub fn button(href: impl Into<String>, html: L10n) -> Self {
|
||||||
Anchor::new()
|
Anchor::new()
|
||||||
.with_type(AnchorType::Button)
|
.with_type(AnchorType::Button)
|
||||||
.with_href(href)
|
.with_href(href)
|
||||||
.with_html(html)
|
.with_html(html)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn location(id: &str) -> Self {
|
pub fn location(id: impl Into<String>) -> Self {
|
||||||
Anchor::new().with_type(AnchorType::Location).with_id(id)
|
Anchor::new().with_type(AnchorType::Location).with_id(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -115,7 +115,7 @@ impl Anchor {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_id(&mut self, id: &str) -> &mut Self {
|
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||||
self.id.alter_value(id);
|
self.id.alter_value(id);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -140,7 +140,7 @@ impl Anchor {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_href(&mut self, href: &str) -> &mut Self {
|
pub fn alter_href(&mut self, href: impl Into<String>) -> &mut Self {
|
||||||
self.href.alter_value(href);
|
self.href.alter_value(href);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -177,7 +177,7 @@ impl Anchor {
|
||||||
|
|
||||||
// Anchor GETTERS.
|
// Anchor GETTERS.
|
||||||
|
|
||||||
pub fn classes(&self) -> &Classes {
|
pub fn classes(&self) -> &OptionClasses {
|
||||||
&self.classes
|
&self.classes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -185,7 +185,7 @@ impl Anchor {
|
||||||
&self.anchor_type
|
&self.anchor_type
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn href(&self) -> &AttributeValue {
|
pub fn href(&self) -> &OptionString {
|
||||||
&self.href
|
&self.href
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,16 @@ new_handle!(COMPONENT_BLOCK);
|
||||||
|
|
||||||
actions_for_component!(Block);
|
actions_for_component!(Block);
|
||||||
|
|
||||||
|
type BlockTitle = TypedComponent<L10n>;
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Block {
|
pub struct Block {
|
||||||
weight : Weight,
|
weight : Weight,
|
||||||
renderable: Renderable,
|
renderable: Renderable,
|
||||||
id : IdentifierValue,
|
id : OptionId,
|
||||||
classes : Classes,
|
classes : OptionClasses,
|
||||||
title : AttributeValue,
|
title : BlockTitle,
|
||||||
stuff : ArcComponents,
|
stuff : ArcComponents,
|
||||||
template : String,
|
template : String,
|
||||||
}
|
}
|
||||||
|
|
@ -45,7 +47,7 @@ impl ComponentTrait for Block {
|
||||||
let id = cx.required_id::<Block>(self.id());
|
let id = cx.required_id::<Block>(self.id());
|
||||||
PrepareMarkup::With(html! {
|
PrepareMarkup::With(html! {
|
||||||
div id=(id) class=[self.classes().get()] {
|
div id=(id) class=[self.classes().get()] {
|
||||||
@if let Some(title) = self.title().get() {
|
@if let Some(title) = self.title().get().into_string(cx) {
|
||||||
h2 class="block-title" { (title) }
|
h2 class="block-title" { (title) }
|
||||||
}
|
}
|
||||||
div class="block-body" {
|
div class="block-body" {
|
||||||
|
|
@ -64,7 +66,7 @@ impl Block {
|
||||||
// Block BUILDER.
|
// Block BUILDER.
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_id(&mut self, id: &str) -> &mut Self {
|
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||||
self.id.alter_value(id);
|
self.id.alter_value(id);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -88,8 +90,8 @@ impl Block {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_title(&mut self, title: &str) -> &mut Self {
|
pub fn alter_title(&mut self, title: L10n) -> &mut Self {
|
||||||
self.title.alter_value(title);
|
self.title.set(title);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,11 +114,11 @@ impl Block {
|
||||||
|
|
||||||
// Block GETTERS.
|
// Block GETTERS.
|
||||||
|
|
||||||
pub fn classes(&self) -> &Classes {
|
pub fn classes(&self) -> &OptionClasses {
|
||||||
&self.classes
|
&self.classes
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn title(&self) -> &AttributeValue {
|
pub fn title(&self) -> &BlockTitle {
|
||||||
&self.title
|
&self.title
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,12 @@ type ButtonValue = TypedComponent<L10n>;
|
||||||
pub struct Button {
|
pub struct Button {
|
||||||
weight : Weight,
|
weight : Weight,
|
||||||
renderable : Renderable,
|
renderable : Renderable,
|
||||||
classes : Classes,
|
classes : OptionClasses,
|
||||||
button_type: ButtonType,
|
button_type: ButtonType,
|
||||||
name : AttributeValue,
|
name : OptionString,
|
||||||
value : ButtonValue,
|
value : ButtonValue,
|
||||||
autofocus : AttributeValue,
|
autofocus : OptionString,
|
||||||
disabled : AttributeValue,
|
disabled : OptionString,
|
||||||
template : String,
|
template : String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -146,7 +146,7 @@ impl Button {
|
||||||
|
|
||||||
// Button GETTERS.
|
// Button GETTERS.
|
||||||
|
|
||||||
pub fn classes(&self) -> &Classes {
|
pub fn classes(&self) -> &OptionClasses {
|
||||||
&self.classes
|
&self.classes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -154,7 +154,7 @@ impl Button {
|
||||||
&self.button_type
|
&self.button_type
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn name(&self) -> &AttributeValue {
|
pub fn name(&self) -> &OptionString {
|
||||||
&self.name
|
&self.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,11 +162,11 @@ impl Button {
|
||||||
&self.value
|
&self.value
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn autofocus(&self) -> &AttributeValue {
|
pub fn autofocus(&self) -> &OptionString {
|
||||||
&self.autofocus
|
&self.autofocus
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn disabled(&self) -> &AttributeValue {
|
pub fn disabled(&self) -> &OptionString {
|
||||||
&self.disabled
|
&self.disabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,17 +7,17 @@ new_handle!(COMPONENT_DATE);
|
||||||
pub struct Date {
|
pub struct Date {
|
||||||
weight : Weight,
|
weight : Weight,
|
||||||
renderable : Renderable,
|
renderable : Renderable,
|
||||||
classes : Classes,
|
classes : OptionClasses,
|
||||||
name : AttributeValue,
|
name : OptionString,
|
||||||
value : AttributeValue,
|
value : OptionString,
|
||||||
label : AttributeValue,
|
label : OptionString,
|
||||||
placeholder : AttributeValue,
|
placeholder : OptionString,
|
||||||
autofocus : AttributeValue,
|
autofocus : OptionString,
|
||||||
autocomplete: AttributeValue,
|
autocomplete: OptionString,
|
||||||
disabled : AttributeValue,
|
disabled : OptionString,
|
||||||
readonly : AttributeValue,
|
readonly : OptionString,
|
||||||
required : AttributeValue,
|
required : OptionString,
|
||||||
help_text : AttributeValue,
|
help_text : OptionString,
|
||||||
template : String,
|
template : String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,47 +176,47 @@ impl Date {
|
||||||
|
|
||||||
// Date GETTERS.
|
// Date GETTERS.
|
||||||
|
|
||||||
pub fn classes(&self) -> &Classes {
|
pub fn classes(&self) -> &OptionClasses {
|
||||||
&self.classes
|
&self.classes
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn name(&self) -> &AttributeValue {
|
pub fn name(&self) -> &OptionString {
|
||||||
&self.name
|
&self.name
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn value(&self) -> &AttributeValue {
|
pub fn value(&self) -> &OptionString {
|
||||||
&self.value
|
&self.value
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn label(&self) -> &AttributeValue {
|
pub fn label(&self) -> &OptionString {
|
||||||
&self.label
|
&self.label
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn placeholder(&self) -> &AttributeValue {
|
pub fn placeholder(&self) -> &OptionString {
|
||||||
&self.placeholder
|
&self.placeholder
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn autofocus(&self) -> &AttributeValue {
|
pub fn autofocus(&self) -> &OptionString {
|
||||||
&self.autofocus
|
&self.autofocus
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn autocomplete(&self) -> &AttributeValue {
|
pub fn autocomplete(&self) -> &OptionString {
|
||||||
&self.autocomplete
|
&self.autocomplete
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn disabled(&self) -> &AttributeValue {
|
pub fn disabled(&self) -> &OptionString {
|
||||||
&self.disabled
|
&self.disabled
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn readonly(&self) -> &AttributeValue {
|
pub fn readonly(&self) -> &OptionString {
|
||||||
&self.readonly
|
&self.readonly
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn required(&self) -> &AttributeValue {
|
pub fn required(&self) -> &OptionString {
|
||||||
&self.required
|
&self.required
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn help_text(&self) -> &AttributeValue {
|
pub fn help_text(&self) -> &OptionString {
|
||||||
&self.help_text
|
&self.help_text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@ pub enum FormMethod {
|
||||||
pub struct Form {
|
pub struct Form {
|
||||||
weight : Weight,
|
weight : Weight,
|
||||||
renderable: Renderable,
|
renderable: Renderable,
|
||||||
id : IdentifierValue,
|
id : OptionId,
|
||||||
classes : Classes,
|
classes : OptionClasses,
|
||||||
action : AttributeValue,
|
action : OptionString,
|
||||||
charset : AttributeValue,
|
charset : OptionString,
|
||||||
method : FormMethod,
|
method : FormMethod,
|
||||||
stuff : ArcComponents,
|
stuff : ArcComponents,
|
||||||
template : String,
|
template : String,
|
||||||
|
|
@ -91,7 +91,7 @@ impl Form {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_id(&mut self, id: &str) -> &mut Self {
|
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||||
self.id.alter_value(id);
|
self.id.alter_value(id);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -139,15 +139,15 @@ impl Form {
|
||||||
|
|
||||||
// Form GETTERS.
|
// Form GETTERS.
|
||||||
|
|
||||||
pub fn classes(&self) -> &Classes {
|
pub fn classes(&self) -> &OptionClasses {
|
||||||
&self.classes
|
&self.classes
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn action(&self) -> &AttributeValue {
|
pub fn action(&self) -> &OptionString {
|
||||||
&self.action
|
&self.action
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn charset(&self) -> &AttributeValue {
|
pub fn charset(&self) -> &OptionString {
|
||||||
&self.charset
|
&self.charset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ new_handle!(COMPONENT_HIDDEN);
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Hidden {
|
pub struct Hidden {
|
||||||
weight: Weight,
|
weight: Weight,
|
||||||
name : NameValue,
|
name : OptionName,
|
||||||
value : AttributeValue,
|
value : OptionString,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ComponentTrait for Hidden {
|
impl ComponentTrait for Hidden {
|
||||||
|
|
@ -58,11 +58,11 @@ impl Hidden {
|
||||||
|
|
||||||
// Hidden GETTERS.
|
// Hidden GETTERS.
|
||||||
|
|
||||||
pub fn name(&self) -> &NameValue {
|
pub fn name(&self) -> &OptionName {
|
||||||
&self.name
|
&self.name
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn value(&self) -> &AttributeValue {
|
pub fn value(&self) -> &OptionString {
|
||||||
&self.value
|
&self.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,20 +21,20 @@ type InputHelpText = TypedComponent<L10n>;
|
||||||
pub struct Input {
|
pub struct Input {
|
||||||
weight : Weight,
|
weight : Weight,
|
||||||
renderable : Renderable,
|
renderable : Renderable,
|
||||||
classes : Classes,
|
classes : OptionClasses,
|
||||||
input_type : InputType,
|
input_type : InputType,
|
||||||
name : NameValue,
|
name : OptionName,
|
||||||
value : AttributeValue,
|
value : OptionString,
|
||||||
label : InputLabel,
|
label : InputLabel,
|
||||||
size : Option<u16>,
|
size : Option<u16>,
|
||||||
minlength : Option<u16>,
|
minlength : Option<u16>,
|
||||||
maxlength : Option<u16>,
|
maxlength : Option<u16>,
|
||||||
placeholder : AttributeValue,
|
placeholder : OptionString,
|
||||||
autofocus : AttributeValue,
|
autofocus : OptionString,
|
||||||
autocomplete: AttributeValue,
|
autocomplete: OptionString,
|
||||||
disabled : AttributeValue,
|
disabled : OptionString,
|
||||||
readonly : AttributeValue,
|
readonly : OptionString,
|
||||||
required : AttributeValue,
|
required : OptionString,
|
||||||
help_text : InputHelpText,
|
help_text : InputHelpText,
|
||||||
template : String,
|
template : String,
|
||||||
}
|
}
|
||||||
|
|
@ -282,7 +282,7 @@ impl Input {
|
||||||
|
|
||||||
// Input GETTERS.
|
// Input GETTERS.
|
||||||
|
|
||||||
pub fn classes(&self) -> &Classes {
|
pub fn classes(&self) -> &OptionClasses {
|
||||||
&self.classes
|
&self.classes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -290,11 +290,11 @@ impl Input {
|
||||||
&self.input_type
|
&self.input_type
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn name(&self) -> &NameValue {
|
pub fn name(&self) -> &OptionName {
|
||||||
&self.name
|
&self.name
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn value(&self) -> &AttributeValue {
|
pub fn value(&self) -> &OptionString {
|
||||||
&self.value
|
&self.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -314,27 +314,27 @@ impl Input {
|
||||||
self.maxlength
|
self.maxlength
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn placeholder(&self) -> &AttributeValue {
|
pub fn placeholder(&self) -> &OptionString {
|
||||||
&self.placeholder
|
&self.placeholder
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn autofocus(&self) -> &AttributeValue {
|
pub fn autofocus(&self) -> &OptionString {
|
||||||
&self.autofocus
|
&self.autofocus
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn autocomplete(&self) -> &AttributeValue {
|
pub fn autocomplete(&self) -> &OptionString {
|
||||||
&self.autocomplete
|
&self.autocomplete
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn disabled(&self) -> &AttributeValue {
|
pub fn disabled(&self) -> &OptionString {
|
||||||
&self.disabled
|
&self.disabled
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn readonly(&self) -> &AttributeValue {
|
pub fn readonly(&self) -> &OptionString {
|
||||||
&self.readonly
|
&self.readonly
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn required(&self) -> &AttributeValue {
|
pub fn required(&self) -> &OptionString {
|
||||||
&self.required
|
&self.required
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ type HeadingText = TypedComponent<L10n>;
|
||||||
pub struct Heading {
|
pub struct Heading {
|
||||||
weight : Weight,
|
weight : Weight,
|
||||||
renderable : Renderable,
|
renderable : Renderable,
|
||||||
id : IdentifierValue,
|
id : OptionId,
|
||||||
classes : Classes,
|
classes : OptionClasses,
|
||||||
heading_type: HeadingType,
|
heading_type: HeadingType,
|
||||||
text : HeadingText,
|
text : HeadingText,
|
||||||
display : HeadingDisplay,
|
display : HeadingDisplay,
|
||||||
|
|
@ -127,7 +127,7 @@ impl Heading {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_id(&mut self, id: &str) -> &mut Self {
|
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||||
self.id.alter_value(id);
|
self.id.alter_value(id);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -177,7 +177,7 @@ impl Heading {
|
||||||
|
|
||||||
// Paragraph GETTERS.
|
// Paragraph GETTERS.
|
||||||
|
|
||||||
pub fn classes(&self) -> &Classes {
|
pub fn classes(&self) -> &OptionClasses {
|
||||||
&self.classes
|
&self.classes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ pub struct Icon {
|
||||||
weight : Weight,
|
weight : Weight,
|
||||||
renderable: Renderable,
|
renderable: Renderable,
|
||||||
icon_name : String,
|
icon_name : String,
|
||||||
classes : Classes,
|
classes : OptionClasses,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ComponentTrait for Icon {
|
impl ComponentTrait for Icon {
|
||||||
|
|
@ -73,7 +73,7 @@ impl Icon {
|
||||||
self.icon_name.as_str()
|
self.icon_name.as_str()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn classes(&self) -> &Classes {
|
pub fn classes(&self) -> &OptionClasses {
|
||||||
&self.classes
|
&self.classes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ pub enum ImageSize {
|
||||||
pub struct Image {
|
pub struct Image {
|
||||||
weight : Weight,
|
weight : Weight,
|
||||||
renderable: Renderable,
|
renderable: Renderable,
|
||||||
id : IdentifierValue,
|
id : OptionId,
|
||||||
classes : Classes,
|
classes : OptionClasses,
|
||||||
source : AttributeValue,
|
source : OptionString,
|
||||||
size : ImageSize,
|
size : ImageSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,7 +101,7 @@ impl Image {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_id(&mut self, id: &str) -> &mut Self {
|
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||||
self.id.alter_value(id);
|
self.id.alter_value(id);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -126,11 +126,11 @@ impl Image {
|
||||||
|
|
||||||
// Image GETTERS.
|
// Image GETTERS.
|
||||||
|
|
||||||
pub fn classes(&self) -> &Classes {
|
pub fn classes(&self) -> &OptionClasses {
|
||||||
&self.classes
|
&self.classes
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn source(&self) -> &AttributeValue {
|
pub fn source(&self) -> &OptionString {
|
||||||
&self.source
|
&self.source
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ pub enum ParagraphDisplay {
|
||||||
pub struct Paragraph {
|
pub struct Paragraph {
|
||||||
weight : Weight,
|
weight : Weight,
|
||||||
renderable: Renderable,
|
renderable: Renderable,
|
||||||
id : IdentifierValue,
|
id : OptionId,
|
||||||
classes : Classes,
|
classes : OptionClasses,
|
||||||
stuff : ArcComponents,
|
stuff : ArcComponents,
|
||||||
display : ParagraphDisplay,
|
display : ParagraphDisplay,
|
||||||
template : String,
|
template : String,
|
||||||
|
|
@ -78,7 +78,7 @@ impl Paragraph {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_id(&mut self, id: &str) -> &mut Self {
|
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||||
self.id.alter_value(id);
|
self.id.alter_value(id);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -126,7 +126,7 @@ impl Paragraph {
|
||||||
|
|
||||||
// Paragraph GETTERS.
|
// Paragraph GETTERS.
|
||||||
|
|
||||||
pub fn classes(&self) -> &Classes {
|
pub fn classes(&self) -> &OptionClasses {
|
||||||
&self.classes
|
&self.classes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ pub enum WrapperType {
|
||||||
pub struct Wrapper {
|
pub struct Wrapper {
|
||||||
weight : Weight,
|
weight : Weight,
|
||||||
renderable : Renderable,
|
renderable : Renderable,
|
||||||
id : IdentifierValue,
|
id : OptionId,
|
||||||
classes : Classes,
|
classes : OptionClasses,
|
||||||
inner_classes: Classes,
|
inner_classes: OptionClasses,
|
||||||
wrapper_type : WrapperType,
|
wrapper_type : WrapperType,
|
||||||
stuff : ArcComponents,
|
stuff : ArcComponents,
|
||||||
template : String,
|
template : String,
|
||||||
|
|
@ -137,7 +137,7 @@ impl Wrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_id(&mut self, id: &str) -> &mut Self {
|
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||||
self.id.alter_value(id);
|
self.id.alter_value(id);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -173,11 +173,11 @@ impl Wrapper {
|
||||||
|
|
||||||
// Wrapper GETTERS.
|
// Wrapper GETTERS.
|
||||||
|
|
||||||
pub fn classes(&self) -> &Classes {
|
pub fn classes(&self) -> &OptionClasses {
|
||||||
&self.classes
|
&self.classes
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inner_classes(&self) -> &Classes {
|
pub fn inner_classes(&self) -> &OptionClasses {
|
||||||
&self.inner_classes
|
&self.inner_classes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,17 +13,17 @@ pub use assets::Assets;
|
||||||
mod favicon;
|
mod favicon;
|
||||||
pub use favicon::Favicon;
|
pub use favicon::Favicon;
|
||||||
|
|
||||||
mod identifier;
|
mod opt_id;
|
||||||
pub use identifier::IdentifierValue;
|
pub use opt_id::OptionId;
|
||||||
|
|
||||||
mod name;
|
mod opt_name;
|
||||||
pub use name::NameValue;
|
pub use opt_name::OptionName;
|
||||||
|
|
||||||
mod attribute;
|
mod opt_string;
|
||||||
pub use attribute::AttributeValue;
|
pub use opt_string::OptionString;
|
||||||
|
|
||||||
mod classes;
|
mod opt_classes;
|
||||||
pub use classes::{Classes, ClassesOp};
|
pub use opt_classes::{ClassesOp, OptionClasses};
|
||||||
|
|
||||||
pub mod unit;
|
pub mod unit;
|
||||||
|
|
||||||
|
|
@ -45,7 +45,13 @@ impl PrepareMarkup {
|
||||||
pub fn into_string(self) -> Option<String> {
|
pub fn into_string(self) -> Option<String> {
|
||||||
match self {
|
match self {
|
||||||
PrepareMarkup::None => None,
|
PrepareMarkup::None => None,
|
||||||
PrepareMarkup::Text(text) => Some(text.to_string()),
|
PrepareMarkup::Text(text) => {
|
||||||
|
if text.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(text.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
PrepareMarkup::With(markup) => Some(markup.into_string()),
|
PrepareMarkup::With(markup) => Some(markup.into_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
//! **Classes** implements a *helper* for dynamically adding class names to components.
|
//! **OptionClasses** implements a *helper* for dynamically adding class names to components.
|
||||||
//!
|
//!
|
||||||
//! This *helper* differentiates between default classes (generally associated with styles provided
|
//! This *helper* differentiates between default classes (generally associated with styles provided
|
||||||
//! by the theme) and user classes (for customizing components based on application styles).
|
//! by the theme) and user classes (for customizing components based on application styles).
|
||||||
|
|
@ -18,7 +18,9 @@ pub enum ClassesOp {
|
||||||
Add,
|
Add,
|
||||||
Remove,
|
Remove,
|
||||||
Replace(String),
|
Replace(String),
|
||||||
|
Toggle,
|
||||||
Reset,
|
Reset,
|
||||||
|
Clear,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq)]
|
||||||
|
|
@ -28,14 +30,14 @@ enum ClassType {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Classes(Vec<(String, ClassType)>);
|
pub struct OptionClasses(Vec<(String, ClassType)>);
|
||||||
|
|
||||||
impl Classes {
|
impl OptionClasses {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Classes::default()
|
OptionClasses::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Classes BUILDER.
|
// OptionClasses BUILDER.
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_value(&mut self, op: ClassesOp, classes: impl Into<String>) -> &mut Self {
|
pub fn alter_value(&mut self, op: ClassesOp, classes: impl Into<String>) -> &mut Self {
|
||||||
|
|
@ -58,8 +60,8 @@ impl Classes {
|
||||||
self.add(&classes, self.0.len(), ClassType::User);
|
self.add(&classes, self.0.len(), ClassType::User);
|
||||||
}
|
}
|
||||||
ClassesOp::Remove => {
|
ClassesOp::Remove => {
|
||||||
for name in classes {
|
for class in classes {
|
||||||
self.0.retain(|(c, _)| c.ne(&name.to_string()));
|
self.0.retain(|(c, _)| c.ne(&class.to_string()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClassesOp::Replace(classes_to_replace) => {
|
ClassesOp::Replace(classes_to_replace) => {
|
||||||
|
|
@ -79,9 +81,23 @@ impl Classes {
|
||||||
}
|
}
|
||||||
self.add(&classes, pos, class_type);
|
self.add(&classes, pos, class_type);
|
||||||
}
|
}
|
||||||
|
ClassesOp::Toggle => {
|
||||||
|
for class in classes {
|
||||||
|
if !class.is_empty() {
|
||||||
|
if let Some(pos) = self.0.iter().position(|(c, _)| c.eq(class)) {
|
||||||
|
self.0.remove(pos);
|
||||||
|
} else {
|
||||||
|
self.0.push((class.to_string(), ClassType::User));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
ClassesOp::Reset => {
|
ClassesOp::Reset => {
|
||||||
self.0.retain(|(_, t)| t.ne(&ClassType::User));
|
self.0.retain(|(_, t)| t.ne(&ClassType::User));
|
||||||
}
|
}
|
||||||
|
ClassesOp::Clear => {
|
||||||
|
self.0.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -96,7 +112,7 @@ impl Classes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Classes GETTERS.
|
// OptionClasses GETTERS.
|
||||||
|
|
||||||
pub fn exists(&self, class: impl Into<String>) -> bool {
|
pub fn exists(&self, class: impl Into<String>) -> bool {
|
||||||
let class: String = class.into();
|
let class: String = class.into();
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
use crate::fn_builder;
|
use crate::fn_builder;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct NameValue(String);
|
pub struct OptionId(String);
|
||||||
|
|
||||||
impl NameValue {
|
impl OptionId {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
NameValue::default()
|
OptionId::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
// NameValue BUILDER.
|
// OptionId BUILDER.
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_value(&mut self, value: &str) -> &mut Self {
|
pub fn alter_value(&mut self, value: impl Into<String>) -> &mut Self {
|
||||||
self.0 = value.trim().replace(' ', "_");
|
self.0 = value.into().trim().replace(' ', "_");
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
// NameValue GETTERS.
|
// OptionId GETTERS.
|
||||||
|
|
||||||
pub fn get(&self) -> Option<String> {
|
pub fn get(&self) -> Option<String> {
|
||||||
if self.0.is_empty() {
|
if self.0.is_empty() {
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
use crate::fn_builder;
|
use crate::fn_builder;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct AttributeValue(String);
|
pub struct OptionName(String);
|
||||||
|
|
||||||
impl AttributeValue {
|
impl OptionName {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
AttributeValue::default()
|
OptionName::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
// AttributeValue BUILDER.
|
// OptionName BUILDER.
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_value(&mut self, value: &str) -> &mut Self {
|
pub fn alter_value(&mut self, value: impl Into<String>) -> &mut Self {
|
||||||
self.0 = value.trim().to_owned();
|
self.0 = value.into().trim().replace(' ', "_");
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
// AttributeValue GETTERS.
|
// OptionName GETTERS.
|
||||||
|
|
||||||
pub fn get(&self) -> Option<String> {
|
pub fn get(&self) -> Option<String> {
|
||||||
if self.0.is_empty() {
|
if self.0.is_empty() {
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
use crate::fn_builder;
|
use crate::fn_builder;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct IdentifierValue(String);
|
pub struct OptionString(String);
|
||||||
|
|
||||||
impl IdentifierValue {
|
impl OptionString {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
IdentifierValue::default()
|
OptionString::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
// IdentifierValue BUILDER.
|
// OptionString BUILDER.
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_value(&mut self, value: &str) -> &mut Self {
|
pub fn alter_value(&mut self, value: impl Into<String>) -> &mut Self {
|
||||||
self.0 = value.trim().replace(' ', "_");
|
self.0 = value.into().trim().to_owned();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
// IdentifierValue GETTERS.
|
// OptionString GETTERS.
|
||||||
|
|
||||||
pub fn get(&self) -> Option<String> {
|
pub fn get(&self) -> Option<String> {
|
||||||
if self.0.is_empty() {
|
if self.0.is_empty() {
|
||||||
|
|
@ -3,7 +3,7 @@ use crate::base::component::L10n;
|
||||||
use crate::core::component::{ArcComponent, ComponentTrait, TypedComponent};
|
use crate::core::component::{ArcComponent, ComponentTrait, TypedComponent};
|
||||||
use crate::core::component::{Context, ContextOp};
|
use crate::core::component::{Context, ContextOp};
|
||||||
use crate::core::theme::ComponentsRegions;
|
use crate::core::theme::ComponentsRegions;
|
||||||
use crate::html::{html, Classes, ClassesOp, Favicon, Markup, DOCTYPE};
|
use crate::html::{html, ClassesOp, Favicon, Markup, OptionClasses, DOCTYPE};
|
||||||
use crate::response::fatal_error::FatalError;
|
use crate::response::fatal_error::FatalError;
|
||||||
use crate::{fn_builder, service};
|
use crate::{fn_builder, service};
|
||||||
|
|
||||||
|
|
@ -22,7 +22,7 @@ pub struct Page {
|
||||||
properties : Vec<(&'static str, &'static str)>,
|
properties : Vec<(&'static str, &'static str)>,
|
||||||
favicon : Option<Favicon>,
|
favicon : Option<Favicon>,
|
||||||
context : Context,
|
context : Context,
|
||||||
body_classes: Classes,
|
body_classes: OptionClasses,
|
||||||
regions : ComponentsRegions,
|
regions : ComponentsRegions,
|
||||||
template : String,
|
template : String,
|
||||||
}
|
}
|
||||||
|
|
@ -37,7 +37,7 @@ impl Page {
|
||||||
properties : Vec::new(),
|
properties : Vec::new(),
|
||||||
favicon : None,
|
favicon : None,
|
||||||
context : Context::new(request),
|
context : Context::new(request),
|
||||||
body_classes: Classes::new().with_value(ClassesOp::SetDefault, "body"),
|
body_classes: OptionClasses::new().with_value(ClassesOp::SetDefault, "body"),
|
||||||
regions : ComponentsRegions::new(),
|
regions : ComponentsRegions::new(),
|
||||||
template : "default".to_owned(),
|
template : "default".to_owned(),
|
||||||
}
|
}
|
||||||
|
|
@ -125,7 +125,7 @@ impl Page {
|
||||||
&mut self.context
|
&mut self.context
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn body_classes(&self) -> &Classes {
|
pub fn body_classes(&self) -> &OptionClasses {
|
||||||
&self.body_classes
|
&self.body_classes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue