Añade el tema Bulmix basado en el framework Bulma
This commit is contained in:
parent
2476b2b9c8
commit
5aee113f54
18 changed files with 113 additions and 70 deletions
|
|
@ -6,6 +6,7 @@ description = """\
|
||||||
#theme = "Aliner"
|
#theme = "Aliner"
|
||||||
#theme = "Minimal"
|
#theme = "Minimal"
|
||||||
theme = "Bootsier"
|
theme = "Bootsier"
|
||||||
|
#theme = "Bulmix"
|
||||||
language = "es-ES"
|
language = "es-ES"
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
|
|
|
||||||
|
|
@ -22,14 +22,15 @@ categories = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
doc-comment = "0.3.3"
|
concat-string = "1.0.1"
|
||||||
downcast-rs = "1.2.0"
|
doc-comment = "0.3.3"
|
||||||
figlet-rs = "0.1.3"
|
downcast-rs = "1.2.0"
|
||||||
futures = "0.3.21"
|
figlet-rs = "0.1.3"
|
||||||
once_cell = "1.10.0"
|
futures = "0.3.21"
|
||||||
substring = "1.4.5"
|
once_cell = "1.10.0"
|
||||||
term_size = "0.3.2"
|
substring = "1.4.5"
|
||||||
url = "2.2.2"
|
term_size = "0.3.2"
|
||||||
|
url = "2.2.2"
|
||||||
|
|
||||||
config_rs = { package = "config", version = "0.11.0", features = ["toml"] }
|
config_rs = { package = "config", version = "0.11.0", features = ["toml"] }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,12 @@ fn main() {
|
||||||
)
|
)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
resource_dir("./static/bulmix")
|
||||||
|
.with_generated_filename(
|
||||||
|
Path::new(env::var("OUT_DIR").unwrap().as_str())
|
||||||
|
.join("bulmix.rs")
|
||||||
|
)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ impl Application {
|
||||||
theme::register_theme(&base::theme::aliner::AlinerTheme);
|
theme::register_theme(&base::theme::aliner::AlinerTheme);
|
||||||
theme::register_theme(&base::theme::minimal::MinimalTheme);
|
theme::register_theme(&base::theme::minimal::MinimalTheme);
|
||||||
theme::register_theme(&base::theme::bootsier::BootsierTheme);
|
theme::register_theme(&base::theme::bootsier::BootsierTheme);
|
||||||
|
theme::register_theme(&base::theme::bulmix::BulmixTheme);
|
||||||
|
|
||||||
// Ejecuta la función de inicio de la aplicación.
|
// Ejecuta la función de inicio de la aplicación.
|
||||||
trace::info!("Calling application bootstrap");
|
trace::info!("Calling application bootstrap");
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ pub struct Column {
|
||||||
renderable: fn() -> bool,
|
renderable: fn() -> bool,
|
||||||
weight : i8,
|
weight : i8,
|
||||||
id : OptIden,
|
id : OptIden,
|
||||||
|
classes : Classes,
|
||||||
components: PageContainer,
|
components: PageContainer,
|
||||||
template : String,
|
template : String,
|
||||||
}
|
}
|
||||||
|
|
@ -15,6 +16,7 @@ impl PageComponent for Column {
|
||||||
renderable: always,
|
renderable: always,
|
||||||
weight : 0,
|
weight : 0,
|
||||||
id : OptIden::none(),
|
id : OptIden::none(),
|
||||||
|
classes : Classes::some(vec!["col"]),
|
||||||
components: PageContainer::new(),
|
components: PageContainer::new(),
|
||||||
template : "default".to_owned(),
|
template : "default".to_owned(),
|
||||||
}
|
}
|
||||||
|
|
@ -30,7 +32,7 @@ impl PageComponent for Column {
|
||||||
|
|
||||||
fn default_render(&self, assets: &mut PageAssets) -> Markup {
|
fn default_render(&self, assets: &mut PageAssets) -> Markup {
|
||||||
html! {
|
html! {
|
||||||
div id=[&self.id.option()] class="col" {
|
div id=[&self.id.option()] class=[&self.classes.option()] {
|
||||||
(self.components.render(assets))
|
(self.components.render(assets))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -56,6 +58,11 @@ impl Column {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn add_classes(mut self, classes: Vec<&str>) -> Self {
|
||||||
|
self.classes.add_classes(classes);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn add(mut self, component: impl PageComponent) -> Self {
|
pub fn add(mut self, component: impl PageComponent) -> Self {
|
||||||
self.components.add(component);
|
self.components.add(component);
|
||||||
self
|
self
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ pub struct Row {
|
||||||
renderable: fn() -> bool,
|
renderable: fn() -> bool,
|
||||||
weight : i8,
|
weight : i8,
|
||||||
id : OptIden,
|
id : OptIden,
|
||||||
|
classes : Classes,
|
||||||
columns : PageContainer,
|
columns : PageContainer,
|
||||||
template : String,
|
template : String,
|
||||||
}
|
}
|
||||||
|
|
@ -15,6 +16,7 @@ impl PageComponent for Row {
|
||||||
renderable: always,
|
renderable: always,
|
||||||
weight : 0,
|
weight : 0,
|
||||||
id : OptIden::none(),
|
id : OptIden::none(),
|
||||||
|
classes : Classes::some(vec!["row"]),
|
||||||
columns : PageContainer::new(),
|
columns : PageContainer::new(),
|
||||||
template : "default".to_owned(),
|
template : "default".to_owned(),
|
||||||
}
|
}
|
||||||
|
|
@ -30,7 +32,7 @@ impl PageComponent for Row {
|
||||||
|
|
||||||
fn default_render(&self, assets: &mut PageAssets) -> Markup {
|
fn default_render(&self, assets: &mut PageAssets) -> Markup {
|
||||||
html! {
|
html! {
|
||||||
div id=[&self.id.option()] class="row" {
|
div id=[&self.id.option()] class=[&self.classes.option()] {
|
||||||
(self.columns.render(assets))
|
(self.columns.render(assets))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -56,6 +58,11 @@ impl Row {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn add_classes(mut self, classes: Vec<&str>) -> Self {
|
||||||
|
self.classes.add_classes(classes);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn add_column(mut self, column: grid::Column) -> Self {
|
pub fn add_column(mut self, column: grid::Column) -> Self {
|
||||||
self.columns.add(column);
|
self.columns.add(column);
|
||||||
self
|
self
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ impl ModuleTrait for DemopageModule {
|
||||||
|
|
||||||
async fn demo() -> app::Result<Markup> {
|
async fn demo() -> app::Result<Markup> {
|
||||||
Page::new()
|
Page::new()
|
||||||
.using_theme("Bootsier")
|
.using_theme("Bulmix")
|
||||||
.with_title(l("page_title").as_str())
|
.with_title(l("page_title").as_str())
|
||||||
.add_to("content", hello_world())
|
.add_to("content", hello_world())
|
||||||
.add_to("content", hello_world_original())
|
.add_to("content", hello_world_original())
|
||||||
|
|
|
||||||
34
pagetop/src/base/theme/bulmix/mod.rs
Normal file
34
pagetop/src/base/theme/bulmix/mod.rs
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
use crate::prelude::*;
|
||||||
|
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/bulmix.rs"));
|
||||||
|
|
||||||
|
pub struct BulmixTheme;
|
||||||
|
|
||||||
|
impl ThemeTrait for BulmixTheme {
|
||||||
|
fn name(&self) -> &'static str {
|
||||||
|
"Bulmix"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fullname(&self) -> String {
|
||||||
|
"Bulmix".to_owned()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn configure_theme(&self, cfg: &mut app::web::ServiceConfig) {
|
||||||
|
theme_static_files!(cfg, "/bulmix");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn before_render_page(&self, page: &mut Page) {
|
||||||
|
page.assets()
|
||||||
|
.with_favicon(
|
||||||
|
Favicon::new()
|
||||||
|
.with_icon("/theme/favicon.png")
|
||||||
|
)
|
||||||
|
.add_stylesheet(
|
||||||
|
StyleSheet::source(
|
||||||
|
"/bulmix/css/bulma.min.css?ver=0.9.3"
|
||||||
|
)
|
||||||
|
.with_weight(-99)
|
||||||
|
)
|
||||||
|
.add_jquery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
pub mod aliner;
|
pub mod aliner;
|
||||||
pub mod bootsier;
|
|
||||||
pub mod minimal;
|
pub mod minimal;
|
||||||
|
pub mod bootsier;
|
||||||
|
pub mod bulmix;
|
||||||
|
|
|
||||||
|
|
@ -1,63 +1,48 @@
|
||||||
pub struct Classes {
|
use crate::concat_string;
|
||||||
classes: Vec<String>,
|
|
||||||
option : Option<String>,
|
pub struct Classes(Option<String>);
|
||||||
updated: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Classes {
|
impl Classes {
|
||||||
pub fn none() -> Self {
|
pub fn none() -> Self {
|
||||||
Classes {
|
Classes(None)
|
||||||
classes: Vec::new(),
|
|
||||||
option : None,
|
|
||||||
updated: true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn some_class(class: &str) -> Self {
|
pub fn some(classes: Vec<&str>) -> Self {
|
||||||
let mut c = Classes::none();
|
|
||||||
c.add_class(class);
|
|
||||||
c
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn some_classes(classes: Vec<String>) -> Self {
|
|
||||||
let mut c = Classes::none();
|
let mut c = Classes::none();
|
||||||
c.add_classes(classes);
|
c.add_classes(classes);
|
||||||
c
|
c
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_class(&mut self, class: &str) {
|
pub fn add_classes(&mut self, classes: Vec<&str>) {
|
||||||
let class = class.trim().replace(" ", "_");
|
|
||||||
if !class.is_empty() && !self.classes.iter().any(|c| *c == class) {
|
|
||||||
self.classes.push(class.to_owned());
|
|
||||||
self.updated = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn add_classes(&mut self, classes: Vec<String>) {
|
|
||||||
for class in classes.iter() {
|
for class in classes.iter() {
|
||||||
self.add_class(class);
|
self.add_class(class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn classes(&mut self) -> &str {
|
fn add_class(&mut self, class: &str) {
|
||||||
match self.option() {
|
let class = class.trim().replace(" ", "_");
|
||||||
|
if !class.is_empty() {
|
||||||
|
match &self.0 {
|
||||||
|
None => self.0 = Some(class),
|
||||||
|
Some(classes) => if !classes.split(" ").any(|c| *c == class) {
|
||||||
|
self.0 = Some(concat_string!(classes, " ", class))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn classes(&self) -> &str {
|
||||||
|
match &self.0 {
|
||||||
Some(classes) => classes.as_str(),
|
Some(classes) => classes.as_str(),
|
||||||
None => "",
|
None => "",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_classes(&self) -> bool {
|
pub fn has_classes(&self) -> bool {
|
||||||
self.classes.len() > 0
|
self.0 != None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn option(&mut self) -> &Option<String> {
|
pub fn option(&self) -> &Option<String> {
|
||||||
if !self.updated {
|
&self.0
|
||||||
self.option = match self.classes.len() {
|
|
||||||
0 => None,
|
|
||||||
_ => Some(self.classes.join(" ")),
|
|
||||||
};
|
|
||||||
self.updated = true;
|
|
||||||
}
|
|
||||||
&self.option
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,9 @@ impl OptAttr {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn some(value: &str) -> Self {
|
pub fn some(value: &str) -> Self {
|
||||||
let value = value.trim();
|
let mut o = OptAttr::none();
|
||||||
match value.is_empty() {
|
o.with_value(value);
|
||||||
true => OptAttr(None),
|
o
|
||||||
false => OptAttr(Some(value.to_owned())),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_value(&mut self, value: &str) {
|
pub fn with_value(&mut self, value: &str) {
|
||||||
|
|
@ -29,10 +27,7 @@ impl OptAttr {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_value(&self) -> bool {
|
pub fn has_value(&self) -> bool {
|
||||||
match &self.0 {
|
self.0 != None
|
||||||
Some(_) => true,
|
|
||||||
None => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn option(&self) -> &Option<String> {
|
pub fn option(&self) -> &Option<String> {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,12 @@ impl OptIden {
|
||||||
OptIden(None)
|
OptIden(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn some(id: &str) -> Self {
|
||||||
|
let mut o = OptIden::none();
|
||||||
|
o.with_value(id);
|
||||||
|
o
|
||||||
|
}
|
||||||
|
|
||||||
pub fn with_value(&mut self, id: &str) {
|
pub fn with_value(&mut self, id: &str) {
|
||||||
let id = id.trim();
|
let id = id.trim();
|
||||||
self.0 = match id.is_empty() {
|
self.0 = match id.is_empty() {
|
||||||
|
|
@ -21,10 +27,7 @@ impl OptIden {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_value(&self) -> bool {
|
pub fn has_value(&self) -> bool {
|
||||||
match &self.0 {
|
self.0 != None
|
||||||
Some(_) => true,
|
|
||||||
None => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn option(&self) -> &Option<String> {
|
pub fn option(&self) -> &Option<String> {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
// Local.
|
// Local.
|
||||||
|
|
||||||
|
pub(crate) use concat_string::concat_string;
|
||||||
pub(crate) use doc_comment::doc_comment;
|
pub(crate) use doc_comment::doc_comment;
|
||||||
pub(crate) use once_cell::sync::Lazy;
|
pub(crate) use once_cell::sync::Lazy;
|
||||||
pub(crate) use futures::executor::block_on as run_now;
|
pub(crate) use futures::executor::block_on as run_now;
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ impl<'a> Page<'a> {
|
||||||
},
|
},
|
||||||
title : OptAttr::none(),
|
title : OptAttr::none(),
|
||||||
description : OptAttr::none(),
|
description : OptAttr::none(),
|
||||||
body_classes: Classes::some_class("body"),
|
body_classes: Classes::some(vec!["body"]),
|
||||||
assets : PageAssets::new(),
|
assets : PageAssets::new(),
|
||||||
regions : COMPONENTS.read().unwrap().clone(),
|
regions : COMPONENTS.read().unwrap().clone(),
|
||||||
template : "default".to_owned(),
|
template : "default".to_owned(),
|
||||||
|
|
@ -97,12 +97,7 @@ impl<'a> Page<'a> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_body_class(&mut self, class: &str) -> &mut Self {
|
pub fn add_body_classes(&mut self, classes: Vec<&str>) -> &mut Self {
|
||||||
self.body_classes.add_class(class);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn add_body_classes(&mut self, classes: Vec<String>) -> &mut Self {
|
|
||||||
self.body_classes.add_classes(classes);
|
self.body_classes.add_classes(classes);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
pagetop/static/bulmix/css/bulma-rtl.min.css
vendored
Normal file
1
pagetop/static/bulmix/css/bulma-rtl.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
pagetop/static/bulmix/css/bulma-rtl.min.css.map
Normal file
1
pagetop/static/bulmix/css/bulma-rtl.min.css.map
Normal file
File diff suppressed because one or more lines are too long
1
pagetop/static/bulmix/css/bulma.min.css
vendored
Normal file
1
pagetop/static/bulmix/css/bulma.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
pagetop/static/bulmix/css/bulma.min.css.map
Normal file
1
pagetop/static/bulmix/css/bulma.min.css.map
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue