🎨 Refina algunos constructores de componentes
This commit is contained in:
parent
0b4d2b413d
commit
a687c646f2
4 changed files with 20 additions and 32 deletions
|
|
@ -75,7 +75,7 @@ impl ComponentTrait for Button {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Button {
|
impl Button {
|
||||||
pub fn new_with_value(value: &str) -> Self {
|
pub fn with(value: &str) -> Self {
|
||||||
Button::new().with_value(value)
|
Button::new().with_value(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ impl ComponentTrait for Image {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Image {
|
impl Image {
|
||||||
pub fn new_with_source(source: &str) -> Self {
|
pub fn with(source: &str) -> Self {
|
||||||
Image::new().with_source(source)
|
Image::new().with_source(source)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,57 +83,45 @@ impl ComponentTrait for MenuItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MenuItem {
|
impl MenuItem {
|
||||||
#[rustfmt::skip]
|
|
||||||
pub fn label(label: &str) -> Self {
|
pub fn label(label: &str) -> Self {
|
||||||
MenuItem {
|
MenuItem {
|
||||||
weight : 0,
|
item_type: MenuItemType::Label(label.to_owned()),
|
||||||
renderable: Renderable::default(),
|
..Default::default()
|
||||||
item_type : MenuItemType::Label(label.to_owned()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustfmt::skip]
|
|
||||||
pub fn link(label: &str, path: &str) -> Self {
|
pub fn link(label: &str, path: &str) -> Self {
|
||||||
MenuItem {
|
MenuItem {
|
||||||
weight : 0,
|
item_type: MenuItemType::Link(label.to_owned(), path.to_owned()),
|
||||||
renderable: Renderable::default(),
|
..Default::default()
|
||||||
item_type : MenuItemType::Link(label.to_owned(), path.to_owned()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustfmt::skip]
|
|
||||||
pub fn link_blank(label: &str, path: &str) -> Self {
|
pub fn link_blank(label: &str, path: &str) -> Self {
|
||||||
MenuItem {
|
MenuItem {
|
||||||
weight : 0,
|
item_type: MenuItemType::LinkBlank(label.to_owned(), path.to_owned()),
|
||||||
renderable: Renderable::default(),
|
..Default::default()
|
||||||
item_type : MenuItemType::LinkBlank(label.to_owned(), path.to_owned()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustfmt::skip]
|
|
||||||
pub fn html(html: Markup) -> Self {
|
pub fn html(html: Markup) -> Self {
|
||||||
MenuItem {
|
MenuItem {
|
||||||
weight : 0,
|
item_type: MenuItemType::Html(html),
|
||||||
renderable: Renderable::default(),
|
..Default::default()
|
||||||
item_type : MenuItemType::Html(html),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustfmt::skip]
|
|
||||||
pub fn submenu(label: &str, menu: Menu) -> Self {
|
pub fn submenu(label: &str, menu: Menu) -> Self {
|
||||||
MenuItem {
|
MenuItem {
|
||||||
weight : 0,
|
item_type: MenuItemType::Submenu(label.to_owned(), menu),
|
||||||
renderable: Renderable::default(),
|
..Default::default()
|
||||||
item_type : MenuItemType::Submenu(label.to_owned(), menu),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustfmt::skip]
|
|
||||||
pub fn separator() -> Self {
|
pub fn separator() -> Self {
|
||||||
MenuItem {
|
MenuItem {
|
||||||
weight : 0,
|
item_type: MenuItemType::Separator,
|
||||||
renderable: Renderable::default(),
|
..Default::default()
|
||||||
item_type : MenuItemType::Separator,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ async fn demo() -> ResultPage<Markup, FatalError> {
|
||||||
.add_to("region-content", welcome())
|
.add_to("region-content", welcome())
|
||||||
.add_to("region-content", about_pagetop())
|
.add_to("region-content", about_pagetop())
|
||||||
.add_to("region-content", promo_pagetop())
|
.add_to("region-content", promo_pagetop())
|
||||||
.add_to("region-content", reporting_problems())
|
.add_to("region-content", reporting_issues())
|
||||||
.render()
|
.render()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,7 +90,7 @@ fn hello_world() -> Container {
|
||||||
.with_column(
|
.with_column(
|
||||||
grid::Column::new()
|
grid::Column::new()
|
||||||
.with_classes(ClassesOp::Add, "hello-col-image")
|
.with_classes(ClassesOp::Add, "hello-col-image")
|
||||||
.with_component(Image::new_with_source("/theme/images/homepage-header.svg")),
|
.with_component(Image::with("/theme/images/homepage-header.svg")),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -129,7 +129,7 @@ fn about_pagetop() -> Container {
|
||||||
grid::Column::new()
|
grid::Column::new()
|
||||||
.with_classes(ClassesOp::Add, "pagetop-col-image")
|
.with_classes(ClassesOp::Add, "pagetop-col-image")
|
||||||
.with_size(grid::ColumnSize::Is5of12)
|
.with_size(grid::ColumnSize::Is5of12)
|
||||||
.with_component(Image::new_with_source("/theme/images/homepage-about.svg")),
|
.with_component(Image::with("/theme/images/homepage-about.svg")),
|
||||||
)
|
)
|
||||||
.with_column(
|
.with_column(
|
||||||
grid::Column::new()
|
grid::Column::new()
|
||||||
|
|
@ -185,18 +185,18 @@ fn promo_pagetop() -> Container {
|
||||||
grid::Column::new()
|
grid::Column::new()
|
||||||
.with_classes(ClassesOp::Add, "promo-col-image")
|
.with_classes(ClassesOp::Add, "promo-col-image")
|
||||||
.with_size(grid::ColumnSize::Is6of12)
|
.with_size(grid::ColumnSize::Is6of12)
|
||||||
.with_component(Image::new_with_source("/theme/images/homepage-pagetop.png")),
|
.with_component(Image::with("/theme/images/homepage-pagetop.png")),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reporting_problems() -> Container {
|
fn reporting_issues() -> Container {
|
||||||
Container::new().with_id("reporting").with_component(
|
Container::new().with_id("reporting").with_component(
|
||||||
grid::Row::new()
|
grid::Row::new()
|
||||||
.with_column(
|
.with_column(
|
||||||
grid::Column::new()
|
grid::Column::new()
|
||||||
.with_classes(ClassesOp::Add, "reporting-col-image")
|
.with_classes(ClassesOp::Add, "reporting-col-image")
|
||||||
.with_component(Image::new_with_source("/theme/images/homepage-support.jpg")),
|
.with_component(Image::with("/theme/images/homepage-support.jpg")),
|
||||||
)
|
)
|
||||||
.with_column(
|
.with_column(
|
||||||
grid::Column::new()
|
grid::Column::new()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue