🎉 [bulmix] Saca tema del código base de PageTop
This commit is contained in:
parent
da4c1e097e
commit
541b024d8e
8 changed files with 192 additions and 0 deletions
23
pagetop-bulmix/Cargo.toml
Normal file
23
pagetop-bulmix/Cargo.toml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
[package]
|
||||
name = "pagetop-bulmix"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
|
||||
authors = [
|
||||
"Manuel Cillero <manuel@cillero.es>"
|
||||
]
|
||||
description = """\
|
||||
Theme for PageTop that uses the Bulma framework for page layout and component display.\
|
||||
"""
|
||||
homepage = "https://pagetop.cillero.es"
|
||||
repository = "https://github.com/manuelcillero/pagetop"
|
||||
license = "Apache-2.0 OR MIT"
|
||||
|
||||
[dependencies]
|
||||
pagetop = { path = "../pagetop", version = "0.0" }
|
||||
pagetop-jquery = { path = "../pagetop-jquery", version = "0.0" }
|
||||
static-files = "0.2.3"
|
||||
maud = "0.24.0"
|
||||
|
||||
[build-dependencies]
|
||||
pagetop-build = { path = "../pagetop-build", version = "0.0" }
|
||||
27
pagetop-bulmix/README.md
Normal file
27
pagetop-bulmix/README.md
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
Tema para **PageTop** que utiliza el *framework* [Bulma](https://bulma.io/) para la composición de
|
||||
páginas y visualización de componentes.
|
||||
|
||||
[PageTop](https://github.com/manuelcillero/pagetop/tree/main/pagetop), es un entorno de desarrollo
|
||||
basado en algunos de los *crates* más estables y populares del ecosistema Rust para proporcionar
|
||||
APIs, patrones de desarrollo y buenas prácticas para la creación de soluciones web SSR (*Server-Side
|
||||
Rendering*).
|
||||
|
||||
|
||||
# 🚧 Advertencia
|
||||
|
||||
**PageTop** sólo libera actualmente versiones de desarrollo. La API no es estable y los cambios son
|
||||
constantes. No puede considerarse preparado hasta que se libere la versión **0.1.0**.
|
||||
|
||||
|
||||
# 📜 Licencia
|
||||
|
||||
Este proyecto tiene licencia, de hecho tiene dos, puedes aplicar cualquiera de las siguientes a tu
|
||||
elección:
|
||||
|
||||
* Licencia Apache versión 2.0
|
||||
([LICENSE-APACHE](https://github.com/manuelcillero/pagetop/blob/main/LICENSE-APACHE) o
|
||||
[http://www.apache.org/licenses/LICENSE-2.0]).
|
||||
|
||||
* Licencia MIT
|
||||
([LICENSE-MIT](https://github.com/manuelcillero/pagetop/blob/main/LICENSE-MIT) o
|
||||
[http://opensource.org/licenses/MIT]).
|
||||
3
pagetop-bulmix/build.rs
Normal file
3
pagetop-bulmix/build.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() -> std::io::Result<()> {
|
||||
pagetop_build::bundle_resources("./static", "bulmix", None)
|
||||
}
|
||||
135
pagetop-bulmix/src/lib.rs
Normal file
135
pagetop-bulmix/src/lib.rs
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
pub_handle!(THEME_BULMIX);
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/bulmix.rs"));
|
||||
|
||||
pub struct Bulmix;
|
||||
|
||||
impl ModuleTrait for Bulmix {
|
||||
fn handle(&self) -> Handle {
|
||||
THEME_BULMIX
|
||||
}
|
||||
|
||||
fn theme(&self) -> Option<ThemeStaticRef> {
|
||||
Some(&Bulmix)
|
||||
}
|
||||
|
||||
fn dependencies(&self) -> Vec<ModuleStaticRef> {
|
||||
vec![&pagetop_jquery::JQuery]
|
||||
}
|
||||
|
||||
fn configure_service(&self, cfg: &mut server::web::ServiceConfig) {
|
||||
serve_static_files!(cfg, "/bulmix", bundle_bulmix);
|
||||
}
|
||||
}
|
||||
|
||||
impl ThemeTrait for Bulmix {
|
||||
fn before_render_page(&self, page: &mut Page) {
|
||||
page.alter_favicon(Some(Favicon::new().with_icon("/theme/favicon.ico")))
|
||||
.alter_context(ContextOp::AddStyleSheet(
|
||||
StyleSheet::located("/bulmix/css/bulma.min.css")
|
||||
.with_version("0.9.4")
|
||||
.with_weight(-99),
|
||||
));
|
||||
pagetop_jquery::JQuery::add_jquery(page.context());
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
fn before_render_component(
|
||||
&self,
|
||||
component: &mut dyn ComponentTrait,
|
||||
_rcx: &mut RenderContext,
|
||||
) {
|
||||
match component.handle() {
|
||||
COMPONENT_ANCHOR => {
|
||||
let a = component_mut::<Anchor>(component);
|
||||
a.alter_classes(
|
||||
ClassesOp::SetDefault,
|
||||
match a.anchor_type() {
|
||||
AnchorType::Button => "button is-primary",
|
||||
_ => "",
|
||||
},
|
||||
);
|
||||
}
|
||||
COMPONENT_HEADING => {
|
||||
let h = component_mut::<Heading>(component);
|
||||
h.alter_classes(
|
||||
ClassesOp::SetDefault,
|
||||
match h.display() {
|
||||
HeadingDisplay::XxLarge => "title is-1",
|
||||
HeadingDisplay::Large => "title is-2",
|
||||
HeadingDisplay::Medium => "title is-3",
|
||||
HeadingDisplay::Small => "title is-4",
|
||||
HeadingDisplay::XxSmall => "title is-5",
|
||||
HeadingDisplay::Normal => "title",
|
||||
HeadingDisplay::Subtitle => "subtitle",
|
||||
},
|
||||
);
|
||||
}
|
||||
COMPONENT_PARAGRAPH => {
|
||||
let p = component_mut::<Paragraph>(component);
|
||||
p.alter_classes(
|
||||
ClassesOp::SetDefault,
|
||||
match p.display() {
|
||||
ParagraphDisplay::XxLarge => "is-size-2",
|
||||
ParagraphDisplay::Large => "is-size-3",
|
||||
ParagraphDisplay::Medium => "is-size-4",
|
||||
ParagraphDisplay::Small => "is-size-5",
|
||||
ParagraphDisplay::XxSmall => "is-size-6",
|
||||
ParagraphDisplay::Normal => "",
|
||||
},
|
||||
);
|
||||
}
|
||||
grid::COMPONENT_COLUMN => {
|
||||
let col = component_mut::<grid::Column>(component);
|
||||
col.alter_classes(
|
||||
ClassesOp::SetDefault,
|
||||
concat_string!(
|
||||
"column",
|
||||
match col.size() {
|
||||
grid::ColumnSize::Default => "",
|
||||
grid::ColumnSize::Is1of12 => " is-1",
|
||||
grid::ColumnSize::Is2of12 => " is-2",
|
||||
grid::ColumnSize::Is3of12 => " is-3",
|
||||
grid::ColumnSize::Is4of12 => " is-4",
|
||||
grid::ColumnSize::Is5of12 => " is-5",
|
||||
grid::ColumnSize::Is6of12 => " is-6",
|
||||
grid::ColumnSize::Is7of12 => " is-7",
|
||||
grid::ColumnSize::Is8of12 => " is-8",
|
||||
grid::ColumnSize::Is9of12 => " is-9",
|
||||
grid::ColumnSize::Is10of12 => " is-10",
|
||||
grid::ColumnSize::Is11of12 => " is-11",
|
||||
grid::ColumnSize::IsFull => " is-12",
|
||||
},
|
||||
" content"
|
||||
)
|
||||
.as_str(),
|
||||
);
|
||||
}
|
||||
grid::COMPONENT_ROW => {
|
||||
let row = component_mut::<grid::Row>(component);
|
||||
row.alter_classes(ClassesOp::SetDefault, "columns");
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn render_component(
|
||||
&self,
|
||||
component: &dyn ComponentTrait,
|
||||
_rcx: &mut RenderContext,
|
||||
) -> Option<Markup> {
|
||||
match component.handle() {
|
||||
COMPONENT_ICON => {
|
||||
let icon = component_ref::<Icon>(component);
|
||||
Some(html! {
|
||||
span class="icon" {
|
||||
i class=[icon.classes().get()] {};
|
||||
}
|
||||
})
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
1
pagetop-bulmix/static/css/bulma-rtl.min.css
vendored
Normal file
1
pagetop-bulmix/static/css/bulma-rtl.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
pagetop-bulmix/static/css/bulma-rtl.min.css.map
Normal file
1
pagetop-bulmix/static/css/bulma-rtl.min.css.map
Normal file
File diff suppressed because one or more lines are too long
1
pagetop-bulmix/static/css/bulma.min.css
vendored
Normal file
1
pagetop-bulmix/static/css/bulma.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
pagetop-bulmix/static/css/bulma.min.css.map
Normal file
1
pagetop-bulmix/static/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