Añade identificador en componentes

This commit is contained in:
Manuel Cillero 2023-06-08 00:12:07 +02:00
parent cb04a29388
commit f0e4aea672
18 changed files with 77 additions and 90 deletions

View file

@ -50,6 +50,10 @@ impl ComponentTrait for Anchor {
COMPONENT_ANCHOR
}
fn id(&self) -> Option<String> {
self.id.get()
}
fn weight(&self) -> isize {
self.weight
}
@ -69,7 +73,7 @@ impl ComponentTrait for Anchor {
};
html! {
a
id=[self.id().get()]
id=[self.id()]
class=[self.classes().get()]
href=[self.href().get()]
target=[target]
@ -183,10 +187,6 @@ impl Anchor {
// Anchor GETTERS.
pub fn id(&self) -> &IdentifierValue {
&self.id
}
pub fn classes(&self) -> &Classes {
&self.classes
}

View file

@ -38,6 +38,10 @@ impl ComponentTrait for Container {
COMPONENT_CONTAINER
}
fn id(&self) -> Option<String> {
self.id.get()
}
fn weight(&self) -> isize {
self.weight
}
@ -53,35 +57,35 @@ impl ComponentTrait for Container {
fn default_render(&self, rcx: &mut RenderContext) -> Markup {
match self.container_type() {
ContainerType::Header => html! {
header id=[self.id().get()] class=[self.classes().get()] {
header id=[self.id()] class=[self.classes().get()] {
div class=[self.inner_classes().get()] {
(self.components().render(rcx))
}
}
},
ContainerType::Footer => html! {
footer id=[self.id().get()] class=[self.classes().get()] {
footer id=[self.id()] class=[self.classes().get()] {
div class=[self.inner_classes().get()] {
(self.components().render(rcx))
}
}
},
ContainerType::Main => html! {
main id=[self.id().get()] class=[self.classes().get()] {
main id=[self.id()] class=[self.classes().get()] {
div class=[self.inner_classes().get()] {
(self.components().render(rcx))
}
}
},
ContainerType::Section => html! {
section id=[self.id().get()] class=[self.classes().get()] {
section id=[self.id()] class=[self.classes().get()] {
div class=[self.inner_classes().get()] {
(self.components().render(rcx))
}
}
},
_ => html! {
div id=[self.id().get()] class=[self.classes().get()] {
div id=[self.id()] class=[self.classes().get()] {
(self.components().render(rcx))
}
},
@ -168,10 +172,6 @@ impl Container {
// Container GETTERS.
pub fn id(&self) -> &IdentifierValue {
&self.id
}
pub fn classes(&self) -> &Classes {
&self.classes
}

View file

@ -36,6 +36,10 @@ impl ComponentTrait for Form {
COMPONENT_FORM
}
fn id(&self) -> Option<String> {
self.id.get()
}
fn weight(&self) -> isize {
self.weight
}
@ -55,7 +59,7 @@ impl ComponentTrait for Form {
};
html! {
form
id=[self.id().get()]
id=[self.id()]
class=[self.classes().get()]
action=[self.action().get()]
method=[method]
@ -134,10 +138,6 @@ impl Form {
// Form GETTERS.
pub fn id(&self) -> &IdentifierValue {
&self.id
}
pub fn classes(&self) -> &Classes {
&self.classes
}

View file

@ -57,6 +57,10 @@ impl ComponentTrait for Column {
COMPONENT_COLUMN
}
fn id(&self) -> Option<String> {
self.id.get()
}
fn weight(&self) -> isize {
self.weight
}
@ -71,7 +75,7 @@ impl ComponentTrait for Column {
fn default_render(&self, rcx: &mut RenderContext) -> Markup {
html! {
div id=[self.id().get()] class=[self.classes().get()] {
div id=[self.id()] class=[self.classes().get()] {
(self.components().render(rcx))
}
}
@ -149,10 +153,6 @@ impl Column {
// Column GETTERS.
pub fn id(&self) -> &IdentifierValue {
&self.id
}
pub fn classes(&self) -> &Classes {
&self.classes
}

View file

@ -26,6 +26,10 @@ impl ComponentTrait for Row {
COMPONENT_ROW
}
fn id(&self) -> Option<String> {
self.id.get()
}
fn weight(&self) -> isize {
self.weight
}
@ -40,7 +44,7 @@ impl ComponentTrait for Row {
fn default_render(&self, rcx: &mut RenderContext) -> Markup {
html! {
div id=[self.id().get()] class=[self.classes().get()] {
div id=[self.id()] class=[self.classes().get()] {
(self.columns().render(rcx))
}
}
@ -96,10 +100,6 @@ impl Row {
// Row GETTERS.
pub fn id(&self) -> &IdentifierValue {
&self.id
}
pub fn classes(&self) -> &Classes {
&self.classes
}

View file

@ -49,6 +49,10 @@ impl ComponentTrait for Heading {
COMPONENT_HEADING
}
fn id(&self) -> Option<String> {
self.id.get()
}
fn weight(&self) -> isize {
self.weight
}
@ -58,7 +62,7 @@ impl ComponentTrait for Heading {
}
fn default_render(&self, rcx: &mut RenderContext) -> Markup {
let id = self.id().get();
let id = self.id();
let classes = self.classes().get();
html! { @match &self.heading_type() {
HeadingType::H1 => h1 id=[id] class=[classes] { (self.text().render(rcx)) },
@ -181,10 +185,6 @@ impl Heading {
// Paragraph GETTERS.
pub fn id(&self) -> &IdentifierValue {
&self.id
}
pub fn classes(&self) -> &Classes {
&self.classes
}

View file

@ -22,6 +22,10 @@ impl ComponentTrait for Image {
COMPONENT_IMAGE
}
fn id(&self) -> Option<String> {
self.id.get()
}
fn weight(&self) -> isize {
self.weight
}
@ -34,7 +38,7 @@ impl ComponentTrait for Image {
html! {
img
src=[self.source().get()]
id=[self.id().get()]
id=[self.id()]
class=[self.classes().get()];
}
}
@ -93,10 +97,6 @@ impl Image {
// Image GETTERS.
pub fn id(&self) -> &IdentifierValue {
&self.id
}
pub fn classes(&self) -> &Classes {
&self.classes
}

View file

@ -34,6 +34,10 @@ impl ComponentTrait for Paragraph {
COMPONENT_PARAGRAPH
}
fn id(&self) -> Option<String> {
self.id.get()
}
fn weight(&self) -> isize {
self.weight
}
@ -45,7 +49,7 @@ impl ComponentTrait for Paragraph {
fn default_render(&self, rcx: &mut RenderContext) -> Markup {
html! {
p
id=[self.id().get()]
id=[self.id()]
class=[self.classes().get()]
{
(self.components().render(rcx))
@ -125,10 +129,6 @@ impl Paragraph {
// Paragraph GETTERS.
pub fn id(&self) -> &IdentifierValue {
&self.id
}
pub fn classes(&self) -> &Classes {
&self.classes
}