Actualiza código y revisa constantes
This commit is contained in:
parent
e011c9269a
commit
bc70527ecf
35 changed files with 356 additions and 317 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
pub const ADMIN_MODULE: &str = "pagetop-admin::module::admin";
|
||||
pub const MODULE_ADMIN: &str = "pagetop-admin::module::admin";
|
||||
|
||||
localize!("src/locales");
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ pub struct Admin;
|
|||
|
||||
impl ModuleTrait for Admin {
|
||||
fn handler(&self) -> &'static str {
|
||||
ADMIN_MODULE
|
||||
MODULE_ADMIN
|
||||
}
|
||||
|
||||
fn name(&self) -> String {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
pub const NODE_MODULE: &str = "pagetop-node::module::node";
|
||||
pub const MODULE_NODE: &str = "pagetop-node::module::node";
|
||||
|
||||
localize!("src/locales");
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ pub struct Node;
|
|||
|
||||
impl ModuleTrait for Node {
|
||||
fn handler(&self) -> &'static str {
|
||||
NODE_MODULE
|
||||
MODULE_NODE
|
||||
}
|
||||
|
||||
fn name(&self) -> String {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
pub const USER_MODULE: &str = "pagetop-user::module::user";
|
||||
pub const MODULE_USER: &str = "pagetop-user::module::user";
|
||||
|
||||
localize!("src/locales");
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ pub struct User;
|
|||
|
||||
impl ModuleTrait for User {
|
||||
fn handler(&self) -> &'static str {
|
||||
USER_MODULE
|
||||
MODULE_USER
|
||||
}
|
||||
|
||||
fn name(&self) -> String {
|
||||
|
|
|
|||
|
|
@ -1,44 +1,44 @@
|
|||
mod container;
|
||||
pub use container::{
|
||||
CONTAINER_COMPONENT, Container, ContainerType
|
||||
COMPONENT_CONTAINER, Container, ContainerType
|
||||
};
|
||||
|
||||
pub mod grid;
|
||||
|
||||
mod chunck;
|
||||
pub use chunck::{
|
||||
CHUNCK_COMPONENT, Chunck
|
||||
COMPONENT_CHUNCK, Chunck
|
||||
};
|
||||
mod icon;
|
||||
pub use icon::{
|
||||
ICON_COMPONENT, Icon
|
||||
COMPONENT_ICON, Icon
|
||||
};
|
||||
mod heading;
|
||||
pub use heading::{
|
||||
HEADING_COMPONENT, Heading, HeadingDisplay, HeadingType
|
||||
COMPONENT_HEADING, Heading, HeadingDisplay, HeadingType
|
||||
};
|
||||
mod paragraph;
|
||||
pub use paragraph::{
|
||||
PARAGRAPH_COMPONENT, Paragraph, ParagraphDisplay
|
||||
COMPONENT_PARAGRAPH, Paragraph, ParagraphDisplay
|
||||
};
|
||||
mod anchor;
|
||||
pub use anchor::{
|
||||
ANCHOR_COMPONENT, Anchor, AnchorIcon, AnchorTarget, AnchorType
|
||||
COMPONENT_ANCHOR, Anchor, AnchorIcon, AnchorTarget, AnchorType
|
||||
};
|
||||
mod block;
|
||||
pub use block::{
|
||||
BLOCK_COMPONENT, Block
|
||||
COMPONENT_BLOCK, Block
|
||||
};
|
||||
mod image;
|
||||
pub use image::{
|
||||
IMAGE_COMPONENT, Image
|
||||
COMPONENT_IMAGE, Image
|
||||
};
|
||||
mod menu;
|
||||
pub use menu::{
|
||||
MENU_COMPONENT, MENUITEM_COMPONENT, Menu, MenuItem, MenuItemType
|
||||
COMPONENT_MENU, COMPONENT_MENUITEM, Menu, MenuItem, MenuItemType
|
||||
};
|
||||
|
||||
pub mod form;
|
||||
pub use form::{
|
||||
FORM_COMPONENT, Form, FormMethod
|
||||
COMPONENT_FORM, Form, FormMethod
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const ANCHOR_COMPONENT: &str = "pagetop::component::anchor";
|
||||
pub const COMPONENT_ANCHOR: &str = "pagetop::component::anchor";
|
||||
|
||||
pub enum AnchorType {
|
||||
Button,
|
||||
|
|
@ -50,17 +50,17 @@ impl ComponentTrait for Anchor {
|
|||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
ANCHOR_COMPONENT
|
||||
}
|
||||
|
||||
fn is_renderable(&self) -> bool {
|
||||
(self.renderable)()
|
||||
COMPONENT_ANCHOR
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
self.weight
|
||||
}
|
||||
|
||||
fn is_renderable(&self, _: &InContext) -> bool {
|
||||
(self.renderable)()
|
||||
}
|
||||
|
||||
fn default_render(&self, context: &mut InContext) -> Markup {
|
||||
let target = match &self.target() {
|
||||
AnchorTarget::Blank => Some("_blank"),
|
||||
|
|
@ -107,13 +107,13 @@ impl Anchor {
|
|||
|
||||
// Anchor BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -164,13 +164,13 @@ impl Anchor {
|
|||
|
||||
// Anchor ALTER.
|
||||
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const BLOCK_COMPONENT: &str = "pagetop::component::block";
|
||||
pub const COMPONENT_BLOCK: &str = "pagetop::component::block";
|
||||
|
||||
pub struct Block {
|
||||
renderable: fn() -> bool,
|
||||
|
|
@ -26,17 +26,17 @@ impl ComponentTrait for Block {
|
|||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
BLOCK_COMPONENT
|
||||
}
|
||||
|
||||
fn is_renderable(&self) -> bool {
|
||||
(self.renderable)()
|
||||
COMPONENT_BLOCK
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
self.weight
|
||||
}
|
||||
|
||||
fn is_renderable(&self, _: &InContext) -> bool {
|
||||
(self.renderable)()
|
||||
}
|
||||
|
||||
fn default_render(&self, context: &mut InContext) -> Markup {
|
||||
let id = context.required_id::<Block>(self.id());
|
||||
html! {
|
||||
|
|
@ -65,13 +65,13 @@ impl Block {
|
|||
|
||||
// Block BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -102,13 +102,13 @@ impl Block {
|
|||
|
||||
// Block ALTER.
|
||||
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const CHUNCK_COMPONENT: &str = "pagetop::component::chunck";
|
||||
pub const COMPONENT_CHUNCK: &str = "pagetop::component::chunck";
|
||||
|
||||
pub struct Chunck {
|
||||
renderable: fn() -> bool,
|
||||
|
|
@ -20,17 +20,17 @@ impl ComponentTrait for Chunck {
|
|||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
CHUNCK_COMPONENT
|
||||
}
|
||||
|
||||
fn is_renderable(&self) -> bool {
|
||||
(self.renderable)()
|
||||
COMPONENT_CHUNCK
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
self.weight
|
||||
}
|
||||
|
||||
fn is_renderable(&self, _: &InContext) -> bool {
|
||||
(self.renderable)()
|
||||
}
|
||||
|
||||
fn default_render(&self, _: &mut InContext) -> Markup {
|
||||
html! { (*self.html()) }
|
||||
}
|
||||
|
|
@ -51,13 +51,13 @@ impl Chunck {
|
|||
|
||||
// Chunck BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -73,13 +73,13 @@ impl Chunck {
|
|||
|
||||
// Chunck ALTER.
|
||||
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const CONTAINER_COMPONENT: &str = "pagetop::component::container";
|
||||
pub const COMPONENT_CONTAINER: &str = "pagetop::component::container";
|
||||
|
||||
pub enum ContainerType { Header, Footer, Main, Section, Wrapper }
|
||||
|
||||
|
|
@ -30,17 +30,17 @@ impl ComponentTrait for Container {
|
|||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
CONTAINER_COMPONENT
|
||||
}
|
||||
|
||||
fn is_renderable(&self) -> bool {
|
||||
(self.renderable)()
|
||||
COMPONENT_CONTAINER
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
self.weight
|
||||
}
|
||||
|
||||
fn is_renderable(&self, _: &InContext) -> bool {
|
||||
(self.renderable)()
|
||||
}
|
||||
|
||||
fn default_render(&self, context: &mut InContext) -> Markup {
|
||||
match self.container_type() {
|
||||
ContainerType::Header => html! {
|
||||
|
|
@ -115,13 +115,13 @@ impl Container {
|
|||
|
||||
// Container BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -152,13 +152,13 @@ impl Container {
|
|||
|
||||
// Container ALTER.
|
||||
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
mod form;
|
||||
pub use form::{
|
||||
FORM_COMPONENT, Form, FormMethod
|
||||
COMPONENT_FORM, Form, FormMethod
|
||||
};
|
||||
|
||||
mod input;
|
||||
pub use input::{
|
||||
INPUT_COMPONENT, Input, InputType
|
||||
COMPONENT_INPUT, Input, InputType
|
||||
};
|
||||
mod hidden;
|
||||
pub use hidden::{
|
||||
HIDDEN_COMPONENT, Hidden
|
||||
COMPONENT_HIDDEN, Hidden
|
||||
};
|
||||
mod date;
|
||||
pub use date::{
|
||||
DATE_COMPONENT, Date
|
||||
COMPONENT_DATE, Date
|
||||
};
|
||||
mod button;
|
||||
pub use button::{
|
||||
BUTTON_COMPONENT, Button, ButtonType
|
||||
COMPONENT_BUTTON, Button, ButtonType
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const BUTTON_COMPONENT: &str = "pagetop::component::form::button";
|
||||
pub const COMPONENT_BUTTON: &str = "pagetop::component::form::button";
|
||||
|
||||
pub enum ButtonType {Button, Reset, Submit}
|
||||
|
||||
|
|
@ -33,17 +33,17 @@ impl ComponentTrait for Button {
|
|||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
BUTTON_COMPONENT
|
||||
}
|
||||
|
||||
fn is_renderable(&self) -> bool {
|
||||
(self.renderable)()
|
||||
COMPONENT_BUTTON
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
self.weight
|
||||
}
|
||||
|
||||
fn is_renderable(&self, _: &InContext) -> bool {
|
||||
(self.renderable)()
|
||||
}
|
||||
|
||||
fn default_render(&self, _: &mut InContext) -> Markup {
|
||||
let button_type = match self.button_type() {
|
||||
ButtonType::Button => "button",
|
||||
|
|
@ -104,13 +104,13 @@ impl Button {
|
|||
|
||||
// Button BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -146,13 +146,13 @@ impl Button {
|
|||
|
||||
// Button ALTER.
|
||||
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const DATE_COMPONENT: &str = "pagetop::component::form::date";
|
||||
pub const COMPONENT_DATE: &str = "pagetop::component::form::date";
|
||||
|
||||
pub struct Date {
|
||||
renderable : fn() -> bool,
|
||||
|
|
@ -41,17 +41,17 @@ impl ComponentTrait for Date {
|
|||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
DATE_COMPONENT
|
||||
}
|
||||
|
||||
fn is_renderable(&self) -> bool {
|
||||
(self.renderable)()
|
||||
COMPONENT_DATE
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
self.weight
|
||||
}
|
||||
|
||||
fn is_renderable(&self, _: &InContext) -> bool {
|
||||
(self.renderable)()
|
||||
}
|
||||
|
||||
fn default_render(&self, _: &mut InContext) -> Markup {
|
||||
let id = match self.name().get() {
|
||||
Some(name) => Some(concat_string!("edit-", name)),
|
||||
|
|
@ -104,13 +104,13 @@ impl Date {
|
|||
|
||||
// Date BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -176,13 +176,13 @@ impl Date {
|
|||
|
||||
// Date ALTER.
|
||||
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const FORM_COMPONENT: &str = "pagetop::component::form";
|
||||
pub const COMPONENT_FORM: &str = "pagetop::component::form";
|
||||
|
||||
pub enum FormMethod {Get, Post}
|
||||
|
||||
|
|
@ -32,17 +32,17 @@ impl ComponentTrait for Form {
|
|||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
FORM_COMPONENT
|
||||
}
|
||||
|
||||
fn is_renderable(&self) -> bool {
|
||||
(self.renderable)()
|
||||
COMPONENT_FORM
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
self.weight
|
||||
}
|
||||
|
||||
fn is_renderable(&self, _: &InContext) -> bool {
|
||||
(self.renderable)()
|
||||
}
|
||||
|
||||
fn default_render(&self, context: &mut InContext) -> Markup {
|
||||
let method = match self.method() {
|
||||
FormMethod::Get => None,
|
||||
|
|
@ -74,13 +74,13 @@ impl Form {
|
|||
|
||||
// Form BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -121,13 +121,13 @@ impl Form {
|
|||
|
||||
// Form ALTER.
|
||||
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const HIDDEN_COMPONENT: &str = "pagetop::component::form::hidden";
|
||||
pub const COMPONENT_HIDDEN: &str = "pagetop::component::form::hidden";
|
||||
|
||||
pub struct Hidden {
|
||||
weight: isize,
|
||||
|
|
@ -18,7 +18,7 @@ impl ComponentTrait for Hidden {
|
|||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
HIDDEN_COMPONENT
|
||||
COMPONENT_HIDDEN
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const INPUT_COMPONENT: &str = "pagetop::component::form::input";
|
||||
pub const COMPONENT_INPUT: &str = "pagetop::component::form::input";
|
||||
|
||||
pub enum InputType {Email, Password, Search, Telephone, Textfield, Url}
|
||||
|
||||
|
|
@ -51,17 +51,17 @@ impl ComponentTrait for Input {
|
|||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
INPUT_COMPONENT
|
||||
}
|
||||
|
||||
fn is_renderable(&self) -> bool {
|
||||
(self.renderable)()
|
||||
COMPONENT_INPUT
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
self.weight
|
||||
}
|
||||
|
||||
fn is_renderable(&self, _: &InContext) -> bool {
|
||||
(self.renderable)()
|
||||
}
|
||||
|
||||
fn default_render(&self, _: &mut InContext) -> Markup {
|
||||
let type_input = match self.input_type() {
|
||||
InputType::Email => "email",
|
||||
|
|
@ -163,13 +163,13 @@ impl Input {
|
|||
|
||||
// Input BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -250,13 +250,13 @@ impl Input {
|
|||
|
||||
// Input ALTER.
|
||||
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
mod row;
|
||||
pub use row::{
|
||||
ROW_COMPONENT, Row
|
||||
COMPONENT_ROW, Row
|
||||
};
|
||||
mod column;
|
||||
pub use column::{
|
||||
COLUMN_COMPONENT, Column, ColumnSize
|
||||
COMPONENT_COLUMN, Column, ColumnSize
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,20 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const COLUMN_COMPONENT: &str = "pagetop::component::grid::column";
|
||||
pub const COMPONENT_COLUMN: &str = "pagetop::component::grid::column";
|
||||
|
||||
const SIZE_DEFAULT: &str = "col-md";
|
||||
const SIZE_1_OF_12: &str = "col-md-1";
|
||||
const SIZE_2_OF_12: &str = "col-md-2";
|
||||
const SIZE_3_OF_12: &str = "col-md-3";
|
||||
const SIZE_4_OF_12: &str = "col-md-4";
|
||||
const SIZE_5_OF_12: &str = "col-md-5";
|
||||
const SIZE_6_OF_12: &str = "col-md-6";
|
||||
const SIZE_7_OF_12: &str = "col-md-7";
|
||||
const SIZE_8_OF_12: &str = "col-md-8";
|
||||
const SIZE_9_OF_12: &str = "col-md-9";
|
||||
const SIZE_10_OF_12: &str = "col-md-10";
|
||||
const SIZE_11_OF_12: &str = "col-md-11";
|
||||
const SIZE_12_OF_12: &str = "col-md-12";
|
||||
|
||||
pub enum ColumnSize {
|
||||
Default,
|
||||
|
|
@ -33,7 +47,7 @@ impl ComponentTrait for Column {
|
|||
renderable: render_always,
|
||||
weight : 0,
|
||||
id : IdentifierValue::new(),
|
||||
classes : Classes::new(),
|
||||
classes : Classes::new_with_default(SIZE_DEFAULT),
|
||||
size : ColumnSize::Default,
|
||||
components: ComponentsBundle::new(),
|
||||
template : "default".to_owned(),
|
||||
|
|
@ -41,33 +55,15 @@ impl ComponentTrait for Column {
|
|||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
COLUMN_COMPONENT
|
||||
}
|
||||
|
||||
fn is_renderable(&self) -> bool {
|
||||
(self.renderable)()
|
||||
COMPONENT_COLUMN
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
self.weight
|
||||
}
|
||||
|
||||
fn before_render(&mut self, _context: &mut InContext) {
|
||||
match self.size() {
|
||||
ColumnSize::Default => self.alter_classes(ClassesOp::SetDefault, "col-md"),
|
||||
ColumnSize::Is1of12 => self.alter_classes(ClassesOp::SetDefault, "col-md-1"),
|
||||
ColumnSize::Is2of12 => self.alter_classes(ClassesOp::SetDefault, "col-md-2"),
|
||||
ColumnSize::Is3of12 => self.alter_classes(ClassesOp::SetDefault, "col-md-3"),
|
||||
ColumnSize::Is4of12 => self.alter_classes(ClassesOp::SetDefault, "col-md-4"),
|
||||
ColumnSize::Is5of12 => self.alter_classes(ClassesOp::SetDefault, "col-md-5"),
|
||||
ColumnSize::Is6of12 => self.alter_classes(ClassesOp::SetDefault, "col-md-6"),
|
||||
ColumnSize::Is7of12 => self.alter_classes(ClassesOp::SetDefault, "col-md-7"),
|
||||
ColumnSize::Is8of12 => self.alter_classes(ClassesOp::SetDefault, "col-md-8"),
|
||||
ColumnSize::Is9of12 => self.alter_classes(ClassesOp::SetDefault, "col-md-9"),
|
||||
ColumnSize::Is10of12 => self.alter_classes(ClassesOp::SetDefault, "col-md-10"),
|
||||
ColumnSize::Is11of12 => self.alter_classes(ClassesOp::SetDefault, "col-md-11"),
|
||||
ColumnSize::IsFull => self.alter_classes(ClassesOp::SetDefault, "col-md-12"),
|
||||
};
|
||||
fn is_renderable(&self, _: &InContext) -> bool {
|
||||
(self.renderable)()
|
||||
}
|
||||
|
||||
fn default_render(&self, context: &mut InContext) -> Markup {
|
||||
|
|
@ -91,13 +87,13 @@ impl Column {
|
|||
|
||||
// Column BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -128,13 +124,13 @@ impl Column {
|
|||
|
||||
// Column ALTER.
|
||||
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -149,6 +145,21 @@ impl Column {
|
|||
}
|
||||
|
||||
pub fn alter_size(&mut self, size: ColumnSize) -> &mut Self {
|
||||
match size {
|
||||
ColumnSize::Default => self.alter_classes(ClassesOp::SetDefault, SIZE_DEFAULT),
|
||||
ColumnSize::Is1of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_1_OF_12),
|
||||
ColumnSize::Is2of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_2_OF_12),
|
||||
ColumnSize::Is3of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_3_OF_12),
|
||||
ColumnSize::Is4of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_4_OF_12),
|
||||
ColumnSize::Is5of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_5_OF_12),
|
||||
ColumnSize::Is6of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_6_OF_12),
|
||||
ColumnSize::Is7of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_7_OF_12),
|
||||
ColumnSize::Is8of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_8_OF_12),
|
||||
ColumnSize::Is9of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_9_OF_12),
|
||||
ColumnSize::Is10of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_10_OF_12),
|
||||
ColumnSize::Is11of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_11_OF_12),
|
||||
ColumnSize::IsFull => self.alter_classes(ClassesOp::SetDefault, SIZE_12_OF_12),
|
||||
};
|
||||
self.size = size;
|
||||
self
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const ROW_COMPONENT: &str = "pagetop::component::grid::row";
|
||||
pub const COMPONENT_ROW: &str = "pagetop::component::grid::row";
|
||||
|
||||
pub struct Row {
|
||||
renderable: fn() -> bool,
|
||||
|
|
@ -24,17 +24,17 @@ impl ComponentTrait for Row {
|
|||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
ROW_COMPONENT
|
||||
}
|
||||
|
||||
fn is_renderable(&self) -> bool {
|
||||
(self.renderable)()
|
||||
COMPONENT_ROW
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
self.weight
|
||||
}
|
||||
|
||||
fn is_renderable(&self, _: &InContext) -> bool {
|
||||
(self.renderable)()
|
||||
}
|
||||
|
||||
fn default_render(&self, context: &mut InContext) -> Markup {
|
||||
html! {
|
||||
div id=[self.id().get()] class=[self.classes().get()] {
|
||||
|
|
@ -56,13 +56,13 @@ impl Row {
|
|||
|
||||
// Row BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -88,13 +88,13 @@ impl Row {
|
|||
|
||||
// Row ALTER.
|
||||
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const HEADING_COMPONENT: &str = "pagetop::component::heading";
|
||||
pub const COMPONENT_HEADING: &str = "pagetop::component::heading";
|
||||
|
||||
pub enum HeadingType { H1, H2, H3, H4, H5, H6 }
|
||||
|
||||
|
|
@ -40,17 +40,17 @@ impl ComponentTrait for Heading {
|
|||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
HEADING_COMPONENT
|
||||
}
|
||||
|
||||
fn is_renderable(&self) -> bool {
|
||||
(self.renderable)()
|
||||
COMPONENT_HEADING
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
self.weight
|
||||
}
|
||||
|
||||
fn is_renderable(&self, _: &InContext) -> bool {
|
||||
(self.renderable)()
|
||||
}
|
||||
|
||||
fn default_render(&self, _: &mut InContext) -> Markup {
|
||||
let id = self.id().get();
|
||||
let classes = self.classes().get();
|
||||
|
|
@ -100,13 +100,13 @@ impl Heading {
|
|||
|
||||
// Heading BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -142,13 +142,13 @@ impl Heading {
|
|||
|
||||
// Heading ALTER.
|
||||
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const ICON_COMPONENT: &str = "pagetop::component::icon";
|
||||
pub const COMPONENT_ICON: &str = "pagetop::component::icon";
|
||||
|
||||
pub struct Icon {
|
||||
renderable: fn() -> bool,
|
||||
|
|
@ -15,33 +15,29 @@ impl ComponentTrait for Icon {
|
|||
renderable: render_always,
|
||||
weight : 0,
|
||||
icon_name : "question-circle-fill".to_owned(),
|
||||
classes : Classes::new(),
|
||||
classes : Classes::new_with_default("bi-question-circle-fill"),
|
||||
}
|
||||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
ICON_COMPONENT
|
||||
}
|
||||
|
||||
fn is_renderable(&self) -> bool {
|
||||
(self.renderable)()
|
||||
COMPONENT_ICON
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
self.weight
|
||||
}
|
||||
|
||||
fn before_render(&mut self, context: &mut InContext) {
|
||||
fn is_renderable(&self, _: &InContext) -> bool {
|
||||
(self.renderable)()
|
||||
}
|
||||
|
||||
fn default_render(&self, context: &mut InContext) -> Markup {
|
||||
context
|
||||
.alter(InContextOp::StyleSheet(AssetsOp::Add(
|
||||
StyleSheet::located("/theme/icons/bootstrap-icons.css")
|
||||
.with_version("1.8.2")
|
||||
)));
|
||||
|
||||
self.alter_classes(ClassesOp::SetDefault, concat_string!("bi-", self.icon_name()).as_str());
|
||||
}
|
||||
|
||||
fn default_render(&self, _context: &mut InContext) -> Markup {
|
||||
html! { i class=[self.classes().get()] {}; }
|
||||
}
|
||||
|
||||
|
|
@ -61,13 +57,13 @@ impl Icon {
|
|||
|
||||
// Icon BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -83,18 +79,19 @@ impl Icon {
|
|||
|
||||
// Icon ALTER.
|
||||
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_icon_name(&mut self, name: &str) -> &mut Self {
|
||||
self.icon_name = name.to_owned();
|
||||
self.alter_classes(ClassesOp::SetDefault, concat_string!("bi-", self.icon_name).as_str());
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const IMAGE_COMPONENT: &str = "pagetop::component::image";
|
||||
pub const COMPONENT_IMAGE: &str = "pagetop::component::image";
|
||||
|
||||
pub struct Image {
|
||||
renderable: fn() -> bool,
|
||||
|
|
@ -24,17 +24,17 @@ impl ComponentTrait for Image {
|
|||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
IMAGE_COMPONENT
|
||||
}
|
||||
|
||||
fn is_renderable(&self) -> bool {
|
||||
(self.renderable)()
|
||||
COMPONENT_IMAGE
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
self.weight
|
||||
}
|
||||
|
||||
fn is_renderable(&self, _: &InContext) -> bool {
|
||||
(self.renderable)()
|
||||
}
|
||||
|
||||
fn default_render(&self, _: &mut InContext) -> Markup {
|
||||
html! {
|
||||
img
|
||||
|
|
@ -60,13 +60,13 @@ impl Image {
|
|||
|
||||
// Image BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -92,13 +92,13 @@ impl Image {
|
|||
|
||||
// Image ALTER.
|
||||
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const MENU_COMPONENT: &str = "pagetop::component::menu";
|
||||
pub const MENUITEM_COMPONENT: &str = "pagetop::component::menu_item";
|
||||
pub const COMPONENT_MENU: &str = "pagetop::component::menu";
|
||||
pub const COMPONENT_MENUITEM: &str = "pagetop::component::menu_item";
|
||||
|
||||
pub enum MenuItemType {
|
||||
Label(String),
|
||||
|
|
@ -31,17 +31,17 @@ impl ComponentTrait for MenuItem {
|
|||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
MENUITEM_COMPONENT
|
||||
}
|
||||
|
||||
fn is_renderable(&self) -> bool {
|
||||
(self.renderable)()
|
||||
COMPONENT_MENUITEM
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
self.weight
|
||||
}
|
||||
|
||||
fn is_renderable(&self, _: &InContext) -> bool {
|
||||
(self.renderable)()
|
||||
}
|
||||
|
||||
fn default_render(&self, context: &mut InContext) -> Markup {
|
||||
match self.item_type() {
|
||||
MenuItemType::Label(label) => html! {
|
||||
|
|
@ -142,28 +142,28 @@ impl MenuItem {
|
|||
|
||||
// MenuItem BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
self
|
||||
}
|
||||
|
||||
// MenuItem ALTER.
|
||||
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
self
|
||||
}
|
||||
|
||||
// MenuItem ALTER.
|
||||
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
self
|
||||
}
|
||||
|
||||
// MenuItem GETTERS.
|
||||
|
||||
pub fn item_type(&self) -> &MenuItemType {
|
||||
|
|
@ -195,18 +195,18 @@ impl ComponentTrait for Menu {
|
|||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
MENU_COMPONENT
|
||||
}
|
||||
|
||||
fn is_renderable(&self) -> bool {
|
||||
(self.renderable)()
|
||||
COMPONENT_MENU
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
self.weight
|
||||
}
|
||||
|
||||
fn before_render(&mut self, context: &mut InContext) {
|
||||
fn is_renderable(&self, _: &InContext) -> bool {
|
||||
(self.renderable)()
|
||||
}
|
||||
|
||||
fn default_render(&self, context: &mut InContext) -> Markup {
|
||||
context
|
||||
.alter(InContextOp::StyleSheet(AssetsOp::Add(
|
||||
StyleSheet::located("/theme/menu/css/menu.css")
|
||||
|
|
@ -221,10 +221,9 @@ impl ComponentTrait for Menu {
|
|||
.with_version("1.1.1")
|
||||
)))
|
||||
.alter(InContextOp::AddJQuery);
|
||||
}
|
||||
|
||||
fn default_render(&self, context: &mut InContext) -> Markup {
|
||||
let id = context.required_id::<Menu>(self.id());
|
||||
|
||||
html! {
|
||||
ul id=(id) class=[self.classes().get()] {
|
||||
(self.items().render(context))
|
||||
|
|
@ -251,13 +250,13 @@ impl Menu {
|
|||
|
||||
// Menu BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -283,13 +282,13 @@ impl Menu {
|
|||
|
||||
// Menu ALTER.
|
||||
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const PARAGRAPH_COMPONENT: &str = "pagetop::component::paragraph";
|
||||
pub const COMPONENT_PARAGRAPH: &str = "pagetop::component::paragraph";
|
||||
|
||||
pub enum ParagraphDisplay {
|
||||
XxLarge,
|
||||
|
|
@ -35,17 +35,17 @@ impl ComponentTrait for Paragraph {
|
|||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
PARAGRAPH_COMPONENT
|
||||
}
|
||||
|
||||
fn is_renderable(&self) -> bool {
|
||||
(self.renderable)()
|
||||
COMPONENT_PARAGRAPH
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
self.weight
|
||||
}
|
||||
|
||||
fn is_renderable(&self, _: &InContext) -> bool {
|
||||
(self.renderable)()
|
||||
}
|
||||
|
||||
fn default_render(&self, _: &mut InContext) -> Markup {
|
||||
html! {
|
||||
p id=[self.id().get()] class=[self.classes().get()] { (*self.html()) }
|
||||
|
|
@ -68,13 +68,13 @@ impl Paragraph {
|
|||
|
||||
// Paragraph BUILDER.
|
||||
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.alter_weight(weight);
|
||||
pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self {
|
||||
self.alter_renderable(renderable);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -105,13 +105,13 @@ impl Paragraph {
|
|||
|
||||
// Paragraph ALTER.
|
||||
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
|
||||
self.weight = weight;
|
||||
pub fn alter_renderable(&mut self, renderable: fn() -> bool) -> &mut Self {
|
||||
self.renderable = renderable;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const DEMOPAGE_MODULE: &str = "pagetop::module::demopage";
|
||||
pub const MODULE_DEMOPAGE: &str = "pagetop::module::demopage";
|
||||
|
||||
localize!("src/base/module/demopage/locales");
|
||||
|
||||
|
|
@ -8,7 +8,7 @@ pub struct Demopage;
|
|||
|
||||
impl ModuleTrait for Demopage {
|
||||
fn handler(&self) -> &'static str {
|
||||
DEMOPAGE_MODULE
|
||||
MODULE_DEMOPAGE
|
||||
}
|
||||
|
||||
fn name(&self) -> String {
|
||||
|
|
@ -27,6 +27,9 @@ impl ModuleTrait for Demopage {
|
|||
async fn demo() -> app::Result<Markup> {
|
||||
Page::new()
|
||||
.with_title(l("page_title").as_str())
|
||||
.with_context(InContextOp::StyleSheet(AssetsOp::Add(
|
||||
StyleSheet::located("/theme/module/demopage/styles.css")
|
||||
)))
|
||||
.add_to("content", hello_world())
|
||||
.add_to("content", welcome())
|
||||
.add_to("content", about_pagetop())
|
||||
|
|
@ -40,6 +43,7 @@ fn hello_world() -> Container {
|
|||
.with_id("hello-world")
|
||||
.with_component(grid::Row::new()
|
||||
.with_column(grid::Column::new()
|
||||
.with_classes(ClassesOp::Add, "hello-col-text")
|
||||
.with_size(grid::ColumnSize::Is4of12)
|
||||
.with_component(Heading::h1(html! {
|
||||
(l("page_title"))
|
||||
|
|
@ -63,6 +67,7 @@ fn hello_world() -> Container {
|
|||
("Offered services")
|
||||
})
|
||||
.with_left_icon(Icon::with("card-checklist"))
|
||||
.with_classes(ClassesOp::Add, "services-link")
|
||||
)
|
||||
.with_component(Anchor::button("#", html! {
|
||||
("Get quote")
|
||||
|
|
@ -71,6 +76,7 @@ fn hello_world() -> Container {
|
|||
)
|
||||
)
|
||||
.with_column(grid::Column::new()
|
||||
.with_classes(ClassesOp::Add, "hello-col-image")
|
||||
.with_component(Image::image("/theme/images/demo-header.svg"))
|
||||
)
|
||||
)
|
||||
|
|
@ -78,13 +84,15 @@ fn hello_world() -> Container {
|
|||
|
||||
fn welcome() -> Container {
|
||||
Container::new()
|
||||
.with_id("visiting")
|
||||
.with_id("welcome")
|
||||
.with_component(grid::Row::new()
|
||||
.with_column(grid::Column::new()
|
||||
.with_classes(ClassesOp::Add, "welcome-col-image")
|
||||
.with_size(grid::ColumnSize::Is5of12)
|
||||
.with_component(Image::image("/theme/images/demo-visiting.svg"))
|
||||
)
|
||||
.with_column(grid::Column::new()
|
||||
.with_classes(ClassesOp::Add, "welcome-col-text")
|
||||
.with_component(Heading::h2(html! {
|
||||
(t("welcome_to", &args!["app" => SETTINGS.app.name.as_str()]))
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const ALINER_THEME: &str = "pagetop::theme::aliner";
|
||||
pub const THEME_ALINER: &str = "pagetop::theme::aliner";
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/aliner.rs"));
|
||||
|
||||
|
|
@ -8,7 +8,7 @@ pub struct Aliner;
|
|||
|
||||
impl ThemeTrait for Aliner {
|
||||
fn handler(&self) -> &'static str {
|
||||
ALINER_THEME
|
||||
THEME_ALINER
|
||||
}
|
||||
|
||||
fn configure_service(&self, cfg: &mut app::web::ServiceConfig) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const BOOTSIER_THEME: &str = "pagetop::theme::bootsier";
|
||||
pub const THEME_BOOTSIER: &str = "pagetop::theme::bootsier";
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/bootsier.rs"));
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ pub struct Bootsier;
|
|||
|
||||
impl ThemeTrait for Bootsier {
|
||||
fn handler(&self) -> &'static str {
|
||||
BOOTSIER_THEME
|
||||
THEME_BOOTSIER
|
||||
}
|
||||
|
||||
fn configure_service(&self, cfg: &mut app::web::ServiceConfig) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const BULMIX_THEME: &str = "pagetop::theme::bulmix";
|
||||
pub const THEME_BULMIX: &str = "pagetop::theme::bulmix";
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/bulmix.rs"));
|
||||
|
||||
|
|
@ -8,7 +8,7 @@ pub struct Bulmix;
|
|||
|
||||
impl ThemeTrait for Bulmix {
|
||||
fn handler(&self) -> &'static str {
|
||||
BULMIX_THEME
|
||||
THEME_BULMIX
|
||||
}
|
||||
|
||||
fn configure_service(&self, cfg: &mut app::web::ServiceConfig) {
|
||||
|
|
@ -34,14 +34,14 @@ impl ThemeTrait for Bulmix {
|
|||
_context: &mut InContext
|
||||
) {
|
||||
match component.handler() {
|
||||
ANCHOR_COMPONENT => {
|
||||
COMPONENT_ANCHOR => {
|
||||
let a = component_mut::<Anchor>(component);
|
||||
a.alter_classes(ClassesOp::SetDefault, match a.anchor_type() {
|
||||
AnchorType::Button => "button is-primary",
|
||||
_ => "",
|
||||
});
|
||||
},
|
||||
HEADING_COMPONENT => {
|
||||
COMPONENT_HEADING => {
|
||||
let h = component_mut::<Heading>(component);
|
||||
h.alter_classes(ClassesOp::SetDefault, match h.display() {
|
||||
HeadingDisplay::XxLarge => "title is-1",
|
||||
|
|
@ -53,7 +53,7 @@ impl ThemeTrait for Bulmix {
|
|||
HeadingDisplay::Subtitle => "subtitle",
|
||||
});
|
||||
},
|
||||
PARAGRAPH_COMPONENT => {
|
||||
COMPONENT_PARAGRAPH => {
|
||||
let p = component_mut::<Paragraph>(component);
|
||||
p.alter_classes(ClassesOp::SetDefault, match p.display() {
|
||||
ParagraphDisplay::XxLarge => "is-size-2",
|
||||
|
|
@ -64,7 +64,7 @@ impl ThemeTrait for Bulmix {
|
|||
ParagraphDisplay::Normal => "",
|
||||
});
|
||||
},
|
||||
grid::COLUMN_COMPONENT => {
|
||||
grid::COMPONENT_COLUMN => {
|
||||
let col = component_mut::<grid::Column>(component);
|
||||
col.alter_classes(ClassesOp::SetDefault, concat_string!("column", match col.size() {
|
||||
grid::ColumnSize::Default => "",
|
||||
|
|
@ -82,7 +82,7 @@ impl ThemeTrait for Bulmix {
|
|||
grid::ColumnSize::IsFull => " is-12",
|
||||
}, " content").as_str());
|
||||
},
|
||||
grid::ROW_COMPONENT => {
|
||||
grid::COMPONENT_ROW => {
|
||||
let row = component_mut::<grid::Row>(component);
|
||||
row.alter_classes(ClassesOp::SetDefault, "columns");
|
||||
},
|
||||
|
|
@ -96,7 +96,7 @@ impl ThemeTrait for Bulmix {
|
|||
_context: &mut InContext
|
||||
) -> Option<Markup> {
|
||||
match component.handler() {
|
||||
ICON_COMPONENT => {
|
||||
COMPONENT_ICON => {
|
||||
let icon = component_ref::<Icon>(component);
|
||||
Some(html! {
|
||||
span class="icon" {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub const MINIMAL_THEME: &str = "pagetop::theme::minimal";
|
||||
pub const THEME_MINIMAL: &str = "pagetop::theme::minimal";
|
||||
|
||||
pub struct Minimal;
|
||||
|
||||
impl ThemeTrait for Minimal {
|
||||
fn handler(&self) -> &'static str {
|
||||
MINIMAL_THEME
|
||||
THEME_MINIMAL
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
mod hook;
|
||||
pub use hook::{
|
||||
BEFORE_RENDER_COMPONENT_HOOK,
|
||||
HOOK_BEFORE_RENDER_COMPONENT,
|
||||
BeforeRenderComponentHook,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ static DEFAULT_THEME: Lazy<&dyn ThemeTrait> = Lazy::new(|| {
|
|||
});
|
||||
|
||||
pub enum InContextOp {
|
||||
SetTheme(&'static str),
|
||||
AddMetadata(&'static str, &'static str),
|
||||
Favicon(Option<Favicon>),
|
||||
SetTheme(&'static str),
|
||||
StyleSheet(AssetsOp<StyleSheet>),
|
||||
JavaScript(AssetsOp<JavaScript>),
|
||||
AddJQuery,
|
||||
|
|
@ -45,15 +45,15 @@ impl InContext {
|
|||
|
||||
pub fn alter(&mut self, op: InContextOp) -> &mut Self {
|
||||
match op {
|
||||
InContextOp::SetTheme(theme_name) => {
|
||||
self.theme = theme_by_single_name(theme_name).unwrap_or(*DEFAULT_THEME);
|
||||
},
|
||||
InContextOp::AddMetadata(name, content) => {
|
||||
self.metadata.push((name.to_owned(), content.to_owned()));
|
||||
},
|
||||
InContextOp::Favicon(favicon) => {
|
||||
self.favicon = favicon;
|
||||
},
|
||||
InContextOp::SetTheme(theme_name) => {
|
||||
self.theme = theme_by_single_name(theme_name).unwrap_or(*DEFAULT_THEME);
|
||||
},
|
||||
InContextOp::StyleSheet(css) => {
|
||||
self.stylesheets.alter(css);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::util;
|
||||
use crate::html::{Markup, html};
|
||||
use crate::core::hook::{hook_ref, run_hooks};
|
||||
use super::{BEFORE_RENDER_COMPONENT_HOOK, BeforeRenderComponentHook, InContext};
|
||||
use super::{HOOK_BEFORE_RENDER_COMPONENT, BeforeRenderComponentHook, InContext};
|
||||
|
||||
pub use std::any::Any as AnyComponent;
|
||||
|
||||
|
|
@ -18,16 +18,13 @@ pub trait ComponentTrait: AnyComponent + Send + Sync {
|
|||
None
|
||||
}
|
||||
|
||||
fn is_renderable(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
0
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn before_render(&mut self, context: &mut InContext) {
|
||||
fn is_renderable(&self, context: &InContext) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
|
|
@ -49,19 +46,16 @@ pub fn component_mut<C: 'static>(component: &mut dyn ComponentTrait) -> &mut C {
|
|||
}
|
||||
|
||||
pub fn render_component(component: &mut dyn ComponentTrait, context: &mut InContext) -> Markup {
|
||||
// Acciones del propio componente antes de renderizarlo.
|
||||
component.before_render(context);
|
||||
|
||||
// Acciones de los módulos antes de renderizar el componente.
|
||||
run_hooks(
|
||||
BEFORE_RENDER_COMPONENT_HOOK,
|
||||
HOOK_BEFORE_RENDER_COMPONENT,
|
||||
|hook| hook_ref::<BeforeRenderComponentHook>(&**hook).run(component, context)
|
||||
);
|
||||
|
||||
// Acciones del tema antes de renderizar el componente.
|
||||
context.theme().before_render_component(component, context);
|
||||
|
||||
match component.is_renderable() {
|
||||
match component.is_renderable(context) {
|
||||
true => match context.theme().render_component(component, context) {
|
||||
Some(html) => html,
|
||||
None => component.default_render(context)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::core::hook::{HookTrait, AnyHook};
|
||||
use super::{ComponentTrait, InContext};
|
||||
|
||||
pub const BEFORE_RENDER_COMPONENT_HOOK: &str = "pagetop::hook::before_render_component";
|
||||
pub const HOOK_BEFORE_RENDER_COMPONENT: &str = "pagetop::hook::before_render_component";
|
||||
|
||||
pub struct BeforeRenderComponentHook {
|
||||
hook: Option<fn(&mut dyn ComponentTrait, &mut InContext)>,
|
||||
|
|
@ -17,7 +17,7 @@ impl HookTrait for BeforeRenderComponentHook {
|
|||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
BEFORE_RENDER_COMPONENT_HOOK
|
||||
HOOK_BEFORE_RENDER_COMPONENT
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
mod hook;
|
||||
pub use hook::{
|
||||
BEFORE_RENDER_PAGE_HOOK,
|
||||
HOOK_BEFORE_RENDER_PAGE,
|
||||
BeforeRenderPageHook,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use crate::config::SETTINGS;
|
|||
use crate::html::*;
|
||||
use crate::core::hook::{hook_ref, run_hooks};
|
||||
use crate::core::component::*;
|
||||
use super::{BEFORE_RENDER_PAGE_HOOK, BeforeRenderPageHook};
|
||||
use super::{HOOK_BEFORE_RENDER_PAGE, BeforeRenderPageHook};
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ impl Page {
|
|||
pub fn render(&mut self) -> app::Result<Markup> {
|
||||
// Acciones de los módulos antes de renderizar la página.
|
||||
run_hooks(
|
||||
BEFORE_RENDER_PAGE_HOOK,
|
||||
HOOK_BEFORE_RENDER_PAGE,
|
||||
|hook| hook_ref::<BeforeRenderPageHook>(&**hook).run(self)
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::core::hook::{HookTrait, AnyHook};
|
||||
use super::Page;
|
||||
|
||||
pub const BEFORE_RENDER_PAGE_HOOK: &str = "pagetop::hook::before_render_page";
|
||||
pub const HOOK_BEFORE_RENDER_PAGE: &str = "pagetop::hook::before_render_page";
|
||||
|
||||
pub struct BeforeRenderPageHook {
|
||||
hook: Option<fn(&mut Page)>,
|
||||
|
|
@ -17,7 +17,7 @@ impl HookTrait for BeforeRenderPageHook {
|
|||
}
|
||||
|
||||
fn handler(&self) -> &'static str {
|
||||
BEFORE_RENDER_PAGE_HOOK
|
||||
HOOK_BEFORE_RENDER_PAGE
|
||||
}
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
|
|
|
|||
30
pagetop/static/theme/module/demopage/styles.css
Normal file
30
pagetop/static/theme/module/demopage/styles.css
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#hello-world {
|
||||
padding: 2em 5%;
|
||||
}
|
||||
#hello-world a {
|
||||
margin: .25em;
|
||||
}
|
||||
#hello-world a.services-link {
|
||||
padding-left: 1.5em;
|
||||
padding-right: 1.5em;
|
||||
border-radius: 1.5em;
|
||||
}
|
||||
#welcome {
|
||||
padding: 1em 5%;
|
||||
}
|
||||
#welcome .welcome-col-text {
|
||||
padding-left: 5%;
|
||||
}
|
||||
/* Responsiveness */
|
||||
@media (max-width: 992px) {
|
||||
#hello-world .hello-col-text {
|
||||
text-align: center;
|
||||
}
|
||||
#hello-world .hello-col-image {
|
||||
padding-top: 5%;
|
||||
}
|
||||
#welcome .welcome-col-text {
|
||||
text-align: center;
|
||||
padding-left: 0;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue