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 = "Minimal"
|
||||
theme = "Bootsier"
|
||||
#theme = "Bulmix"
|
||||
language = "es-ES"
|
||||
|
||||
[database]
|
||||
|
|
|
|||
|
|
@ -22,14 +22,15 @@ categories = [
|
|||
]
|
||||
|
||||
[dependencies]
|
||||
doc-comment = "0.3.3"
|
||||
downcast-rs = "1.2.0"
|
||||
figlet-rs = "0.1.3"
|
||||
futures = "0.3.21"
|
||||
once_cell = "1.10.0"
|
||||
substring = "1.4.5"
|
||||
term_size = "0.3.2"
|
||||
url = "2.2.2"
|
||||
concat-string = "1.0.1"
|
||||
doc-comment = "0.3.3"
|
||||
downcast-rs = "1.2.0"
|
||||
figlet-rs = "0.1.3"
|
||||
futures = "0.3.21"
|
||||
once_cell = "1.10.0"
|
||||
substring = "1.4.5"
|
||||
term_size = "0.3.2"
|
||||
url = "2.2.2"
|
||||
|
||||
config_rs = { package = "config", version = "0.11.0", features = ["toml"] }
|
||||
|
||||
|
|
|
|||
|
|
@ -27,4 +27,12 @@ fn main() {
|
|||
)
|
||||
.build()
|
||||
.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::minimal::MinimalTheme);
|
||||
theme::register_theme(&base::theme::bootsier::BootsierTheme);
|
||||
theme::register_theme(&base::theme::bulmix::BulmixTheme);
|
||||
|
||||
// Ejecuta la función de inicio de la aplicación.
|
||||
trace::info!("Calling application bootstrap");
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ pub struct Column {
|
|||
renderable: fn() -> bool,
|
||||
weight : i8,
|
||||
id : OptIden,
|
||||
classes : Classes,
|
||||
components: PageContainer,
|
||||
template : String,
|
||||
}
|
||||
|
|
@ -15,6 +16,7 @@ impl PageComponent for Column {
|
|||
renderable: always,
|
||||
weight : 0,
|
||||
id : OptIden::none(),
|
||||
classes : Classes::some(vec!["col"]),
|
||||
components: PageContainer::new(),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
|
|
@ -30,7 +32,7 @@ impl PageComponent for Column {
|
|||
|
||||
fn default_render(&self, assets: &mut PageAssets) -> Markup {
|
||||
html! {
|
||||
div id=[&self.id.option()] class="col" {
|
||||
div id=[&self.id.option()] class=[&self.classes.option()] {
|
||||
(self.components.render(assets))
|
||||
}
|
||||
}
|
||||
|
|
@ -56,6 +58,11 @@ impl Column {
|
|||
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 {
|
||||
self.components.add(component);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ pub struct Row {
|
|||
renderable: fn() -> bool,
|
||||
weight : i8,
|
||||
id : OptIden,
|
||||
classes : Classes,
|
||||
columns : PageContainer,
|
||||
template : String,
|
||||
}
|
||||
|
|
@ -15,6 +16,7 @@ impl PageComponent for Row {
|
|||
renderable: always,
|
||||
weight : 0,
|
||||
id : OptIden::none(),
|
||||
classes : Classes::some(vec!["row"]),
|
||||
columns : PageContainer::new(),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
|
|
@ -30,7 +32,7 @@ impl PageComponent for Row {
|
|||
|
||||
fn default_render(&self, assets: &mut PageAssets) -> Markup {
|
||||
html! {
|
||||
div id=[&self.id.option()] class="row" {
|
||||
div id=[&self.id.option()] class=[&self.classes.option()] {
|
||||
(self.columns.render(assets))
|
||||
}
|
||||
}
|
||||
|
|
@ -56,6 +58,11 @@ impl Row {
|
|||
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 {
|
||||
self.columns.add(column);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ impl ModuleTrait for DemopageModule {
|
|||
|
||||
async fn demo() -> app::Result<Markup> {
|
||||
Page::new()
|
||||
.using_theme("Bootsier")
|
||||
.using_theme("Bulmix")
|
||||
.with_title(l("page_title").as_str())
|
||||
.add_to("content", hello_world())
|
||||
.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 bootsier;
|
||||
pub mod minimal;
|
||||
pub mod bootsier;
|
||||
pub mod bulmix;
|
||||
|
|
|
|||
|
|
@ -1,63 +1,48 @@
|
|||
pub struct Classes {
|
||||
classes: Vec<String>,
|
||||
option : Option<String>,
|
||||
updated: bool,
|
||||
}
|
||||
use crate::concat_string;
|
||||
|
||||
pub struct Classes(Option<String>);
|
||||
|
||||
impl Classes {
|
||||
pub fn none() -> Self {
|
||||
Classes {
|
||||
classes: Vec::new(),
|
||||
option : None,
|
||||
updated: true,
|
||||
}
|
||||
Classes(None)
|
||||
}
|
||||
|
||||
pub fn some_class(class: &str) -> Self {
|
||||
let mut c = Classes::none();
|
||||
c.add_class(class);
|
||||
c
|
||||
}
|
||||
|
||||
pub fn some_classes(classes: Vec<String>) -> Self {
|
||||
pub fn some(classes: Vec<&str>) -> Self {
|
||||
let mut c = Classes::none();
|
||||
c.add_classes(classes);
|
||||
c
|
||||
}
|
||||
|
||||
pub fn add_class(&mut self, class: &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>) {
|
||||
pub fn add_classes(&mut self, classes: Vec<&str>) {
|
||||
for class in classes.iter() {
|
||||
self.add_class(class);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn classes(&mut self) -> &str {
|
||||
match self.option() {
|
||||
fn add_class(&mut self, class: &str) {
|
||||
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(),
|
||||
None => "",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_classes(&self) -> bool {
|
||||
self.classes.len() > 0
|
||||
self.0 != None
|
||||
}
|
||||
|
||||
pub fn option(&mut self) -> &Option<String> {
|
||||
if !self.updated {
|
||||
self.option = match self.classes.len() {
|
||||
0 => None,
|
||||
_ => Some(self.classes.join(" ")),
|
||||
};
|
||||
self.updated = true;
|
||||
}
|
||||
&self.option
|
||||
pub fn option(&self) -> &Option<String> {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,9 @@ impl OptAttr {
|
|||
}
|
||||
|
||||
pub fn some(value: &str) -> Self {
|
||||
let value = value.trim();
|
||||
match value.is_empty() {
|
||||
true => OptAttr(None),
|
||||
false => OptAttr(Some(value.to_owned())),
|
||||
}
|
||||
let mut o = OptAttr::none();
|
||||
o.with_value(value);
|
||||
o
|
||||
}
|
||||
|
||||
pub fn with_value(&mut self, value: &str) {
|
||||
|
|
@ -29,10 +27,7 @@ impl OptAttr {
|
|||
}
|
||||
|
||||
pub fn has_value(&self) -> bool {
|
||||
match &self.0 {
|
||||
Some(_) => true,
|
||||
None => false,
|
||||
}
|
||||
self.0 != None
|
||||
}
|
||||
|
||||
pub fn option(&self) -> &Option<String> {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,12 @@ impl OptIden {
|
|||
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) {
|
||||
let id = id.trim();
|
||||
self.0 = match id.is_empty() {
|
||||
|
|
@ -21,10 +27,7 @@ impl OptIden {
|
|||
}
|
||||
|
||||
pub fn has_value(&self) -> bool {
|
||||
match &self.0 {
|
||||
Some(_) => true,
|
||||
None => false,
|
||||
}
|
||||
self.0 != None
|
||||
}
|
||||
|
||||
pub fn option(&self) -> &Option<String> {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
// Local.
|
||||
|
||||
pub(crate) use concat_string::concat_string;
|
||||
pub(crate) use doc_comment::doc_comment;
|
||||
pub(crate) use once_cell::sync::Lazy;
|
||||
pub(crate) use futures::executor::block_on as run_now;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ impl<'a> Page<'a> {
|
|||
},
|
||||
title : OptAttr::none(),
|
||||
description : OptAttr::none(),
|
||||
body_classes: Classes::some_class("body"),
|
||||
body_classes: Classes::some(vec!["body"]),
|
||||
assets : PageAssets::new(),
|
||||
regions : COMPONENTS.read().unwrap().clone(),
|
||||
template : "default".to_owned(),
|
||||
|
|
@ -97,12 +97,7 @@ impl<'a> Page<'a> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn add_body_class(&mut self, class: &str) -> &mut Self {
|
||||
self.body_classes.add_class(class);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn add_body_classes(&mut self, classes: Vec<String>) -> &mut Self {
|
||||
pub fn add_body_classes(&mut self, classes: Vec<&str>) -> &mut Self {
|
||||
self.body_classes.add_classes(classes);
|
||||
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