Compare commits
274 commits
main
...
pagetop-wo
| Author | SHA1 | Date | |
|---|---|---|---|
| d83f8b0f7f | |||
| 8761c50fbb | |||
| 105d5a81af | |||
| a29f0f2b75 | |||
| 0472e698ae | |||
| 4603152075 | |||
| 9c77a664f8 | |||
| 5172da65d6 | |||
| 9a78b79939 | |||
| 535e91b15b | |||
| 56b8725a52 | |||
| f04bcd505b | |||
| 3096ed7bfd | |||
| 84eef9ec4f | |||
| 030ac92e2f | |||
| a276a5f797 | |||
| e4a88b2150 | |||
| d8493291e4 | |||
| 0f71eba7ab | |||
| 7e7720bd49 | |||
| bdc94be92a | |||
| 698b917fb1 | |||
| a6d15ab211 | |||
| 947aef2f91 | |||
| f9ab1f55a3 | |||
| c7888c85ac | |||
| c940403869 | |||
| e2e2ccb31e | |||
| 87711e4a37 | |||
| d074f252a7 | |||
| a0416e5670 | |||
| 4062a57cff | |||
| d1f3ede963 | |||
| 9ba493c2c4 | |||
| 824dc4a3ab | |||
| ab2677be44 | |||
| 71ea609088 | |||
| 8e0c887ba6 | |||
| ecba7b2bd8 | |||
| 379450ec40 | |||
| b2dfb52d93 | |||
| 9afbafdefb | |||
| 574010374d | |||
| c9fdc7afc7 | |||
| a110dd0482 | |||
| 3fba1ca875 | |||
| 15a96a8310 | |||
| d7caf724dd | |||
| 3c6dea9728 | |||
| 1df91ce4c8 | |||
| f3228d6b59 | |||
| 5540c0c6a0 | |||
| 67118caef7 | |||
| 4c8eee3585 | |||
| 86d9f0e213 | |||
| 4c3f4dab1b | |||
| bd54980d0f | |||
| a9b1b3b2a3 | |||
| f2a052d66c | |||
| b2e9fe79e8 | |||
| ce9635f9a8 | |||
| b3a7d40930 | |||
| bae8358471 | |||
| 0bcc7e5236 | |||
| 3170f9a4d0 | |||
| 20050e4a67 | |||
| 9c52873d54 | |||
| c3f45e7688 | |||
| d1d3a62c8f | |||
| 98a71b6f51 | |||
| ddbc5c869f | |||
| d7efb80856 | |||
| 1577891fe3 | |||
| 53b73a0970 | |||
| d215e00daa | |||
| fd6030ee7d | |||
| 79655932d0 | |||
| d3a9be7550 | |||
| 728a5c83dc | |||
| 8a7a827259 | |||
| 8377ddb4c6 | |||
| 779e98eeb0 | |||
| 24ccb23048 | |||
| 27e3ff529e | |||
| 7793eb796c | |||
| 98a5768406 | |||
| cbe38136c9 | |||
| 58c48aad16 | |||
| d52cbdef3f | |||
| a6b50a8baf | |||
| 31f4c516e4 | |||
| e238db1a1b | |||
| 3512fed7e0 | |||
| 91f60a420d | |||
| 3355750922 | |||
| d80a6787c7 | |||
| 8690f994c3 | |||
| fc71a077ee | |||
| 144127776d | |||
| 08d673b89d | |||
| 03473b53e1 | |||
| 346714ab29 | |||
| f819181872 | |||
| 806ed9e0dc | |||
| f337119219 | |||
| 2299e63585 | |||
| 70744a51a5 | |||
| 35f2b66161 | |||
| c848b97450 | |||
| b5da11777a | |||
| 56a2471090 | |||
| c06efbd0d1 | |||
| 04502ef81e | |||
| 4cd75af8d2 | |||
| 90e4f85bd4 | |||
| 3df73f0551 | |||
| 5d199ef10d | |||
| dbdaeb6151 | |||
| 93cd3ba6c5 | |||
| 9e2fc2ccfa | |||
| 165cb49880 | |||
| f265f217bd | |||
| 3f3634fdab | |||
| 58d1fef4f1 | |||
| 5b2ddeb6cc | |||
| 58b4b4e036 | |||
| 1254e650f1 | |||
| 11c2bdffb1 | |||
| 6df71885cc | |||
| c47724bb68 | |||
| f8f023b513 | |||
| 16eec316c4 | |||
| 404739a3fd | |||
| 8651b91ab2 | |||
| c6cd4fcd7d | |||
| 9143f1eb26 | |||
| 5bf28ef4f0 | |||
| 307ca6f62c | |||
| dfff12881f | |||
| c2ec7568f0 | |||
| 3c3ffc91e6 | |||
| 50e4b42fe4 | |||
| 64113aff09 | |||
| 0b8f3f3000 | |||
| 8577ca8a59 | |||
| ee1b48ff3f | |||
| 28f1eee391 | |||
| 1e2d171805 | |||
| f2a7507317 | |||
| b163b7726e | |||
| 5939d33964 | |||
| ab1d4f0efb | |||
| a2b3ae2eb8 | |||
| 17e16652e4 | |||
| 4e4fdf7b10 | |||
| 0d38f2e9e7 | |||
| 1be3d88888 | |||
| c34dc02357 | |||
| bea4b3f30d | |||
| def0513246 | |||
| 043873a954 | |||
| 88acc08b5f | |||
| c0a5a8c3ab | |||
| eb63a7ef37 | |||
| 35ae5bb6a8 | |||
| da959183f6 | |||
| 434d31c5eb | |||
| 56a6691c87 | |||
| af53cd4b52 | |||
| 76c5cb9b76 | |||
| 3c67d9d04c | |||
| 99a4837e11 | |||
| c8654a5742 | |||
| d8f82ea1d2 | |||
| e24b9ab9de | |||
| 4ba66f5995 | |||
| 997017bb75 | |||
| b50d186fb1 | |||
| bb6855e41f | |||
| 1453764462 | |||
| fe2b2c176f | |||
| bf4c635e59 | |||
| 213aa18b12 | |||
| c3ff8a6ff8 | |||
| 745d492d5b | |||
| 05187c9343 | |||
| ed30b2ae17 | |||
| 946d335664 | |||
| e5431bc7d7 | |||
| 51e8b11090 | |||
| 3930499664 | |||
| 5842ea6efc | |||
| 17a9f0c9e0 | |||
| aa8c4100b0 | |||
| be10dd28a1 | |||
| 3198b74399 | |||
| 6bea4a5793 | |||
| 20b6c77c9e | |||
| 8cb5e035dc | |||
| 825283caa3 | |||
| ee57d6cacf | |||
| 12c14afbf6 | |||
| 3b01894024 | |||
| e8bba0803d | |||
| 502c00c891 | |||
| 1cab0ae9a0 | |||
| c49bf8f56a | |||
| 545a87fbb0 | |||
| 4cc72aac0e | |||
| 3e83f8e35e | |||
| fdd2dca280 | |||
| 1a3a295f18 | |||
| c91b1cd35c | |||
| 8ddc26dae1 | |||
| dc2ed27da4 | |||
| 747e64ce34 | |||
| ea0dc021ce | |||
| 9db1d4bab0 | |||
| 74dbcde5c5 | |||
| 7e6a9f8557 | |||
| 845d91d8c1 | |||
| ce6b4d2581 | |||
| 65c8a788c2 | |||
| 39f494539e | |||
| b9d9cdf601 | |||
| 8573aca29e | |||
| e7f2563967 | |||
| 55159f6d8f | |||
| af548b03c9 | |||
| 6f82da220b | |||
| 370bc8ee47 | |||
| e6b4661f21 | |||
| 5a8267032e | |||
| f6f78fddbe | |||
| 7a3419415e | |||
| 82e64238bd | |||
| eb3157c4a4 | |||
| 30151b6254 | |||
| 24bd13414c | |||
| 0e72d51276 | |||
| 771f61bf29 | |||
| 654618aa68 | |||
| 87ad78778d | |||
| bff7cf1b38 | |||
| 9e8cd77140 | |||
| 25713a8a13 | |||
| a26aa4d30a | |||
| c7b680a7f7 | |||
| 9b2d430d8b | |||
| 1139df6210 | |||
| 9354894b3a | |||
| 9acd8cc51a | |||
| aa8b109668 | |||
| 8aa4372bdf | |||
| 54d5b3e53d | |||
| 0e96bcce64 | |||
| 3120fd9a6f | |||
| ee6457acf6 | |||
| f37db56ec5 | |||
| 64db114eb0 | |||
| 9435678e01 | |||
| 26f1cda831 | |||
| d495c05b96 | |||
| dbf0894894 | |||
| 2202a2350c | |||
| 62219584b0 | |||
| 8d0103c257 | |||
| 1bd97d5705 | |||
| f27790c3a2 | |||
| 6376e3e88c | |||
| 38fd24453e | |||
| 511149caa7 | |||
| 41c4379bc3 | |||
| f9e87058d8 |
3
.gitignore
vendored
|
|
@ -1,6 +1,9 @@
|
|||
# Ignora directorios de compilación
|
||||
**/target
|
||||
|
||||
# Ignora directorios de archivos estáticos
|
||||
**/static
|
||||
|
||||
# Archivos de log
|
||||
**/log/*.log*
|
||||
|
||||
|
|
|
|||
14
CREDITS.md
|
|
@ -1,9 +1,9 @@
|
|||
# 🔃 Dependencias
|
||||
# Dependencias
|
||||
|
||||
PageTop está basado en [Rust](https://www.rust-lang.org/) y crece a hombros de gigantes aprovechando
|
||||
algunas de las librerías más robustas y populares del [ecosistema Rust](https://lib.rs/) como son:
|
||||
|
||||
* [Actix Web](https://actix.rs/) para los servicios web.
|
||||
* [Axum](https://github.com/tokio-rs/axum) para los servicios web.
|
||||
* [Config](https://docs.rs/config) para cargar y procesar las opciones de configuración.
|
||||
* [Tracing](https://github.com/tokio-rs/tracing) para la gestión de trazas y registro de eventos
|
||||
de la aplicación.
|
||||
|
|
@ -13,7 +13,7 @@ algunas de las librerías más robustas y populares del [ecosistema Rust](https:
|
|||
PageTop y sus extensiones.
|
||||
|
||||
|
||||
# 🗚 FIGfonts
|
||||
# FIGfonts
|
||||
|
||||
PageTop usa el *crate* [figlet-rs](https://crates.io/crates/figlet-rs) desarrollado por *yuanbohan*
|
||||
para mostrar un banner de presentación en el terminal con el nombre de la aplicación en caracteres
|
||||
|
|
@ -26,7 +26,13 @@ para mostrar un banner de presentación en el terminal con el nombre de la aplic
|
|||
* [starwars.flf](http://www.figlet.org/fontdb_example.cgi?font=starwars.flf) de *Ryan Youck*
|
||||
|
||||
|
||||
# 👾 Icono
|
||||
# Menús accesibles
|
||||
|
||||
El tema Basic de PageTop usa [Accessible Menu](https://github.com/NickDJM/accessible-menu),
|
||||
desarrollado por *Nick Milton*, para implementar la navegación de sus menús con soporte avanzado.
|
||||
|
||||
|
||||
# Icono
|
||||
|
||||
"La Mascota" sonriente es una simpática creación de [Webalys](https://www.iconfinder.com/webalys).
|
||||
Forma parte de su colección [Nasty Icons](https://www.iconfinder.com/iconsets/nasty), disponible en
|
||||
|
|
|
|||
808
Cargo.lock
generated
44
Cargo.toml
|
|
@ -9,24 +9,33 @@ members = [
|
|||
# Extensions
|
||||
"extensions/pagetop-aliner",
|
||||
"extensions/pagetop-bootsier",
|
||||
"extensions/pagetop-htmx",
|
||||
"extensions/pagetop-admin",
|
||||
"extensions/pagetop-cron",
|
||||
"extensions/pagetop-mail",
|
||||
"extensions/pagetop-seaorm",
|
||||
"extensions/pagetop-user",
|
||||
]
|
||||
|
||||
[workspace.package]
|
||||
repository = "https://git.cillero.es/manuelcillero/pagetop"
|
||||
homepage = "https://pagetop.cillero.es"
|
||||
edition = "2024"
|
||||
rust-version = "1.88"
|
||||
license = "MIT OR Apache-2.0"
|
||||
authors = ["Manuel Cillero <manuel@cillero.es>"]
|
||||
|
||||
[workspace.dependencies]
|
||||
argon2 = "0.5"
|
||||
async-trait = "0.1"
|
||||
axum = { version = "0.8" }
|
||||
base64ct = { version = "1.8", features = ["alloc"] }
|
||||
change-detection = "1.2"
|
||||
chrono = "0.4"
|
||||
chrono-tz = "0.10"
|
||||
colored = "3.1"
|
||||
concat-string = "1.0"
|
||||
config = { version = "0.15", default-features = false, features = ["toml"] }
|
||||
croner = { version = "4.0", default-features = false, features = ["chrono"] }
|
||||
figlet-rs = "1.0"
|
||||
fluent-templates = "0.14"
|
||||
getter-methods = "2.0"
|
||||
|
|
@ -34,41 +43,55 @@ grass = "0.13"
|
|||
indexmap = "2.14"
|
||||
indoc = "2.0"
|
||||
itoa = "1.0"
|
||||
lettre = { version = "0.11", default-features = false }
|
||||
mime_guess = "2.0"
|
||||
parking_lot = "0.12"
|
||||
minify-js = "0.6"
|
||||
pastey = "0.2"
|
||||
path-slash = "0.2"
|
||||
proc-macro2 = "1.0"
|
||||
proc-macro2-diagnostics = { version = "0.10", default-features = false }
|
||||
quote = "1.0"
|
||||
rand_core = { version = "0.6", features = ["getrandom"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
serde_qs = "1.1"
|
||||
sha2 = "0.11"
|
||||
syn = { version = "2.0", features = ["full", "extra-traits"] }
|
||||
tempfile = "3.27"
|
||||
terminal_size = "0.4"
|
||||
thiserror = "2.0"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
tower = { version = "0.5", features = ["util"] }
|
||||
tower-http = { version = "0.6", features = ["fs"] }
|
||||
tower-http = { version = "0.7", features = ["catch-panic", "fs", "set-header"] }
|
||||
tracing = "0.1"
|
||||
tracing-appender = "0.2"
|
||||
tracing-subscriber = { version = "0.3", features = ["json", "env-filter"] }
|
||||
unic-langid = { version = "0.9", features = ["macros"] }
|
||||
unicode-ident = "1.0"
|
||||
unicode-normalization = "0.1"
|
||||
unicode-security = "0.1"
|
||||
url = "2.5"
|
||||
zeroize = "1.8"
|
||||
# Helpers
|
||||
pagetop-build = { version = "0.3", path = "helpers/pagetop-build" }
|
||||
pagetop-macros = { version = "0.3", path = "helpers/pagetop-macros" }
|
||||
pagetop-minimal = { version = "0.1", path = "helpers/pagetop-minimal" }
|
||||
pagetop-statics = { version = "0.1", path = "helpers/pagetop-statics" }
|
||||
# Extensions
|
||||
pagetop-aliner = { version = "0.1", path = "extensions/pagetop-aliner" }
|
||||
pagetop-admin = { version = "0.1", path = "extensions/pagetop-admin" }
|
||||
pagetop-aliner = { version = "0.1", path = "extensions/pagetop-aliner" }
|
||||
pagetop-bootsier = { version = "0.1", path = "extensions/pagetop-bootsier" }
|
||||
pagetop-seaorm = { version = "0.0", path = "extensions/pagetop-seaorm" }
|
||||
pagetop-cron = { version = "0.1", path = "extensions/pagetop-cron" }
|
||||
pagetop-htmx = { version = "0.1", path = "extensions/pagetop-htmx" }
|
||||
pagetop-mail = { version = "0.1", path = "extensions/pagetop-mail" }
|
||||
pagetop-seaorm = { version = "0.0", path = "extensions/pagetop-seaorm" }
|
||||
pagetop-user = { version = "0.1", path = "extensions/pagetop-user" }
|
||||
# PageTop
|
||||
pagetop = { version = "0.5", path = "." }
|
||||
|
||||
[workspace.dependencies.sea-orm]
|
||||
version = "1.1"
|
||||
features = ["debug-print", "macros", "runtime-tokio-native-tls"]
|
||||
features = ["debug-print", "macros", "runtime-tokio-native-tls", "with-chrono"]
|
||||
default-features = false
|
||||
|
||||
[workspace.dependencies.sea-schema]
|
||||
|
|
@ -88,6 +111,7 @@ keywords = ["pagetop", "web", "framework", "frontend", "ssr"]
|
|||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
|
||||
|
|
@ -96,8 +120,10 @@ default = []
|
|||
testing = []
|
||||
|
||||
[dependencies]
|
||||
axum.workspace = true
|
||||
async-trait.workspace = true
|
||||
axum = { workspace = true, features = ["multipart"] }
|
||||
chrono.workspace = true
|
||||
chrono-tz.workspace = true
|
||||
colored.workspace = true
|
||||
config.workspace = true
|
||||
figlet-rs.workspace = true
|
||||
|
|
@ -105,12 +131,13 @@ fluent-templates.workspace = true
|
|||
getter-methods.workspace = true
|
||||
indexmap.workspace = true
|
||||
itoa.workspace = true
|
||||
parking_lot.workspace = true
|
||||
pagetop-macros.workspace = true
|
||||
pagetop-minimal.workspace = true
|
||||
pagetop-statics.workspace = true
|
||||
serde.workspace = true
|
||||
serde_qs.workspace = true
|
||||
terminal_size.workspace = true
|
||||
thiserror.workspace = true
|
||||
tokio.workspace = true
|
||||
tower.workspace = true
|
||||
tower-http.workspace = true
|
||||
|
|
@ -118,6 +145,7 @@ tracing.workspace = true
|
|||
tracing-appender.workspace = true
|
||||
tracing-subscriber.workspace = true
|
||||
unic-langid.workspace = true
|
||||
zeroize.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
pagetop-aliner.workspace = true
|
||||
|
|
|
|||
57
README.md
|
|
@ -1,6 +1,6 @@
|
|||
<div align="center">
|
||||
|
||||
<img src="https://git.cillero.es/manuelcillero/pagetop/raw/branch/main/static/banner.png" />
|
||||
<img src="https://git.cillero.es/manuelcillero/pagetop/raw/branch/main/assets/banner.png" />
|
||||
|
||||
<h1>PageTop</h1>
|
||||
|
||||
|
|
@ -11,9 +11,8 @@
|
|||
[](https://crates.io/crates/pagetop)
|
||||
[](https://git.cillero.es/manuelcillero/pagetop#licencia)
|
||||
|
||||
</div>
|
||||
|
||||
<br>
|
||||
</div>
|
||||
|
||||
PageTop reivindica la esencia de la web clásica usando [Rust](https://www.rust-lang.org/es) para la
|
||||
creación de soluciones web SSR (*renderizadas en el servidor*) basadas en HTML, CSS y JavaScript.
|
||||
|
|
@ -29,8 +28,7 @@ según las necesidades de cada proyecto, incluyendo:
|
|||
* **Temas** (*themes*): son extensiones que permiten modificar la apariencia de páginas y
|
||||
componentes.
|
||||
|
||||
|
||||
## ⚡️ Guía rápida
|
||||
## Guía rápida
|
||||
|
||||
La aplicación más sencilla de PageTop se ve así:
|
||||
|
||||
|
|
@ -39,43 +37,43 @@ use pagetop::prelude::*;
|
|||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::new().run()?.await
|
||||
Application::new().await.run().await
|
||||
}
|
||||
```
|
||||
|
||||
Este código arranca el servidor de PageTop. Con la configuración por defecto, muestra una página de
|
||||
bienvenida accesible desde un navegador local en la dirección `http://localhost:8080`.
|
||||
|
||||
Para personalizar el servicio, se puede crear una extensión de PageTop de la siguiente manera:
|
||||
Para personalizar el servicio, puedes crear una extensión de PageTop de la siguiente manera:
|
||||
|
||||
```rust,no_run
|
||||
use pagetop::prelude::*;
|
||||
|
||||
struct HelloWorld;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for HelloWorld {
|
||||
fn configure_service(&self, scfg: &mut service::web::ServiceConfig) {
|
||||
scfg.route("/", service::web::get().to(hello_world));
|
||||
fn configure_router(&self, routes: Routes) -> Routes {
|
||||
routes.public_route("/", web::get(hello_world))
|
||||
}
|
||||
}
|
||||
|
||||
async fn hello_world(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||
Page::new(request)
|
||||
.add_child(Html::with(|_| html! { h1 { "Hello World!" } }))
|
||||
.render()
|
||||
.with_child(Html::with(|_| html! { h1 { "Hello World!" } }))
|
||||
.render().await
|
||||
}
|
||||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::prepare(&HelloWorld).run()?.await
|
||||
Application::prepare(&HelloWorld).await.run().await
|
||||
}
|
||||
```
|
||||
|
||||
Este programa implementa una extensión llamada `HelloWorld` que sirve una página web en la ruta raíz
|
||||
(`/`) mostrando el texto "Hello world!" dentro de un elemento HTML `<h1>`.
|
||||
(`/`) mostrando el texto "Hello World!" dentro de un elemento HTML `<h1>`.
|
||||
|
||||
|
||||
## 📂 Proyecto
|
||||
## Proyecto
|
||||
|
||||
El código se organiza en un *workspace* donde actualmente se incluyen los siguientes subproyectos:
|
||||
|
||||
|
|
@ -103,6 +101,10 @@ El código se organiza en un *workspace* donde actualmente se incluyen los sigui
|
|||
|
||||
### Extensiones
|
||||
|
||||
* **[pagetop-admin](https://git.cillero.es/manuelcillero/pagetop/src/branch/main/extensions/pagetop-admin)**,
|
||||
páginas de ajustes del panel de administración que se guardan en la base de datos y se cambian
|
||||
desde el propio panel.
|
||||
|
||||
* **[pagetop-aliner](https://git.cillero.es/manuelcillero/pagetop/src/branch/main/extensions/pagetop-aliner)**,
|
||||
es un tema para demos y pruebas que muestra esquemáticamente la composición de las páginas HTML.
|
||||
|
||||
|
|
@ -110,11 +112,25 @@ El código se organiza en un *workspace* donde actualmente se incluyen los sigui
|
|||
tema basado en [Bootstrap](https://getbootstrap.com) para integrar su catálogo de estilos y
|
||||
componentes flexibles.
|
||||
|
||||
* **[pagetop-cron](https://git.cillero.es/manuelcillero/pagetop/src/branch/main/extensions/pagetop-cron)**,
|
||||
programa trabajos periódicos con expresiones cron o intervalos, y los ejecuta también bajo
|
||||
demanda.
|
||||
|
||||
* **[pagetop-htmx](https://git.cillero.es/manuelcillero/pagetop/src/branch/main/extensions/pagetop-htmx)**,
|
||||
integra [HTMX](https://htmx.org) para enriquecer las páginas con interacciones dinámicas sin
|
||||
escribir JavaScript.
|
||||
|
||||
* **[pagetop-mail](https://git.cillero.es/manuelcillero/pagetop/src/branch/main/extensions/pagetop-mail)**,
|
||||
envía correo electrónico por SMTP o *sendmail*, con plantillas traducidas, HTML y archivos
|
||||
adjuntos.
|
||||
|
||||
* **[pagetop-seaorm](https://git.cillero.es/manuelcillero/pagetop/src/branch/main/extensions/pagetop-seaorm)**,
|
||||
integra [SeaORM](https://www.sea-ql.org/SeaORM) para acceder a bases de datos relacionales.
|
||||
|
||||
* **[pagetop-user](https://git.cillero.es/manuelcillero/pagetop/src/branch/main/extensions/pagetop-user)**,
|
||||
gestiona usuarios, autenticación, roles y permisos, con su administración en el panel.
|
||||
|
||||
## 🧪 Pruebas
|
||||
## Pruebas
|
||||
|
||||
Para simplificar el flujo de trabajo, el repositorio incluye varios **alias de Cargo** declarados en
|
||||
`.cargo/config.toml`. Basta con ejecutarlos desde la raíz del proyecto:
|
||||
|
|
@ -134,15 +150,13 @@ Para simplificar el flujo de trabajo, el repositorio incluye varios **alias de C
|
|||
> * Los alias suprimen las trazas del registro de eventos. Para activarlas usa directamente
|
||||
> `cargo test`.
|
||||
|
||||
|
||||
## 🚧 Advertencia
|
||||
## Advertencia
|
||||
|
||||
**PageTop** es un proyecto personal para aprender [Rust](https://www.rust-lang.org/es) y conocer su
|
||||
ecosistema. Su API está sujeta a cambios frecuentes. No se recomienda su uso en producción, al menos
|
||||
hasta que se libere la versión **1.0.0**.
|
||||
|
||||
|
||||
## 📜 Licencia
|
||||
## Licencia
|
||||
|
||||
El código está disponible bajo una doble licencia:
|
||||
|
||||
|
|
@ -155,8 +169,7 @@ El código está disponible bajo una doble licencia:
|
|||
Puedes elegir la licencia que prefieras. Este enfoque de doble licencia es el estándar de facto en
|
||||
el ecosistema Rust.
|
||||
|
||||
|
||||
## ✨ Contribuir
|
||||
## Contribuir
|
||||
|
||||
PageTop mantiene **un único repositorio oficial**:
|
||||
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 83 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 180 KiB After Width: | Height: | Size: 180 KiB |
|
Before Width: | Height: | Size: 183 KiB After Width: | Height: | Size: 183 KiB |
45
assets/js/basic.dialog.init.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
// Abre y cierra los componentes `Dialog` de Basic (elemento `<dialog>` nativo) interpretando el
|
||||
// vocabulario de atributos `data-dialog-*`, común a todos los temas: Bootsier traduce estos mismos
|
||||
// nombres a los suyos propios (`data-bs-*`) en `setup()` para que el JS de Bootstrap los reconozca,
|
||||
// así el marcado de un disparador o de un botón de cierre es idéntico en los dos temas. Sin
|
||||
// dependencias: ni htmx, ni Bootstrap, ni ninguna otra librería.
|
||||
|
||||
// Abre el diálogo referenciado por `data-dialog-target` al pulsar un elemento con
|
||||
// `data-dialog-toggle="modal"`.
|
||||
document.addEventListener("click", function (event) {
|
||||
var toggle = event.target.closest('[data-dialog-toggle="modal"]');
|
||||
if (!toggle) {
|
||||
return;
|
||||
}
|
||||
var target = toggle.getAttribute("data-dialog-target");
|
||||
var dialog = target && document.querySelector(target);
|
||||
if (!(dialog instanceof HTMLDialogElement)) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
dialog.showModal();
|
||||
});
|
||||
|
||||
// Cierra el `<dialog>` ascendente más cercano al pulsar un elemento con
|
||||
// `data-dialog-dismiss="modal"`.
|
||||
document.addEventListener("click", function (event) {
|
||||
var dismiss = event.target.closest('[data-dialog-dismiss="modal"]');
|
||||
if (!dismiss) {
|
||||
return;
|
||||
}
|
||||
var dialog = dismiss.closest("dialog");
|
||||
if (dialog) {
|
||||
event.preventDefault();
|
||||
dialog.close();
|
||||
}
|
||||
});
|
||||
|
||||
// Cierra el diálogo al pulsar sobre el fondo (`::backdrop`): un clic ahí llega con el propio
|
||||
// `<dialog>` como `event.target`, porque el fondo no forma parte de su caja de contenido.
|
||||
document.querySelectorAll("dialog.dialog").forEach(function (dialog) {
|
||||
dialog.addEventListener("click", function (event) {
|
||||
if (event.target === dialog) {
|
||||
dialog.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
66
assets/js/basic.dropdown.init.js
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
// Conecta cada `Dropdown` (standalone o embebido en un `Nav`) con `accessible-menu` (ver
|
||||
// basic.menu.min.js), que añade los roles ARIA, el `aria-expanded` y la navegación por teclado
|
||||
// sobre el marcado ya generado en el servidor. Selecciona por clase, no por etiqueta, porque el
|
||||
// disparador es un `<button>` en un `Dropdown` independiente y un `<a>` cuando cuelga de un
|
||||
// `nav::Item::dropdown()`.
|
||||
document.querySelectorAll(".dropdown > .dropdown-toggle").forEach(function (toggle) {
|
||||
var container = toggle.parentElement;
|
||||
var menu = container.querySelector(":scope > .dropdown-menu");
|
||||
if (!menu) {
|
||||
return;
|
||||
}
|
||||
|
||||
new TopLinkDisclosureMenu({
|
||||
menuElement: menu,
|
||||
containerElement: container,
|
||||
controllerElement: toggle,
|
||||
// `Header`/`Divider`/`Label` no son interactivos: se excluyen de `menuItemSelector`
|
||||
// (si no, la librería asume que todo `<li>` tiene un enlace y lanza un TypeError al
|
||||
// intentar añadirle listeners de foco).
|
||||
menuItemSelector: "li:has(> a.dropdown-item, > button.dropdown-item)",
|
||||
menuLinkSelector: "a.dropdown-item, button.dropdown-item",
|
||||
// La navegación con flechas/Home/End es opcional en la librería (`false` por defecto);
|
||||
// se activa para igualar el comportamiento habitual de un menú desplegable.
|
||||
optionalKeySupport: true,
|
||||
});
|
||||
});
|
||||
|
||||
// Cada `TopLinkDisclosureMenu` es independiente: al hacer clic fuera sólo cierra su propio menú
|
||||
// (ver `_handleClick()` en accessible-menu), así que abrir un desplegable no cierra otro que ya
|
||||
// estuviera abierto en otra parte de la página. Se corrige aquí escuchando `accessibleMenuExpand`
|
||||
// -evento que la librería emite en cada apertura- y cerrando el resto de menús de nivel superior
|
||||
// ya registrados, vía `window.AccessibleMenu.menus`, el registro global que la propia librería
|
||||
// mantiene con todas las instancias (incluye las de `basic.menu.init.js`).
|
||||
document.addEventListener("accessibleMenuExpand", function (event) {
|
||||
var openedToggle = event.detail.toggle;
|
||||
var menus = (window.AccessibleMenu && window.AccessibleMenu.menus) || {};
|
||||
Object.values(menus).forEach(function (menu) {
|
||||
var controller = menu.elements.controller;
|
||||
if (controller && controller !== openedToggle) {
|
||||
controller.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// El cierre "al hacer clic fuera" que trae la librería no funciona para un `controllerElement` de
|
||||
// nivel superior como el nuestro: en `toggleToggle()` (accessible-menu), al abrir, hace
|
||||
// `menu.focusState = "self"` y a continuación `toggle.elements.controlledMenu.focusState =
|
||||
// "none"` -pensado para cuando el toggle abre un submenú hijo distinto del menú que lo contiene-,
|
||||
// pero aquí `menu` y `toggle.elements.controlledMenu` son el mismo objeto: la segunda asignación
|
||||
// deshace la primera. El cierre nativo de la librería depende de `focusState !== "none"`, así que
|
||||
// nunca se dispara aunque el menú esté abierto (`isOpen` sí queda correcto). Se sustituye aquí por
|
||||
// una comprobación propia basada sólo en `isOpen` y en la posición del clic.
|
||||
document.addEventListener("click", function (event) {
|
||||
var menus = (window.AccessibleMenu && window.AccessibleMenu.menus) || {};
|
||||
Object.values(menus).forEach(function (menu) {
|
||||
var controller = menu.elements.controller;
|
||||
if (
|
||||
controller &&
|
||||
controller.isOpen &&
|
||||
!menu.dom.menu.contains(event.target) &&
|
||||
!controller.dom.toggle.contains(event.target)
|
||||
) {
|
||||
controller.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
3
assets/js/basic.menu.min.js
vendored
Normal file
18
assets/js/basic.navbar.init.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Conecta cada botón `.navbar-toggle` con el contenido que controla (`aria-controls`), alternando
|
||||
// `aria-expanded` en el botón y la clase `.show` en el contenido. A diferencia de `Dropdown` no usa
|
||||
// `accessible-menu`: el contenido de una barra de navegación no es una única lista de elementos
|
||||
// (puede llevar varios `Nav`, texto, lo que sea), así que no encaja con el modelo de menú de esa
|
||||
// librería (ver `base/component/navbar/`).
|
||||
document.querySelectorAll(".navbar-toggle").forEach(function (toggle) {
|
||||
var id = toggle.getAttribute("aria-controls");
|
||||
var content = id && document.getElementById(id);
|
||||
if (!content) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggle.addEventListener("click", function () {
|
||||
var expanded = toggle.getAttribute("aria-expanded") === "true";
|
||||
toggle.setAttribute("aria-expanded", String(!expanded));
|
||||
content.classList.toggle("show", !expanded);
|
||||
});
|
||||
});
|
||||
114
assets/js/list-filter.js
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
// Señala en los filtros de listado (`ListFilter`) que se aplican con botón los campos cuyo valor ya
|
||||
// no coincide con el del filtro aplicado, para que el usuario sepa que el listado todavía no
|
||||
// corresponde a lo que muestra el formulario. Sólo pone y quita clases (`list-filter-changed` en el
|
||||
// contenedor de cada campo, `list-filter-pending` en el formulario) y el texto del aviso para
|
||||
// lectores de pantalla; el aspecto lo da cada tema. Sin dependencias.
|
||||
//
|
||||
// Actúa sólo en los formularios con el aviso `.list-filter-status`, que `ListFilter` no pinta
|
||||
// cuando los filtros se envían solos.
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
var FIELDS =
|
||||
'input:not([type="hidden"]):not([type="submit"])' +
|
||||
':not([type="button"]):not([type="reset"]), select, textarea';
|
||||
|
||||
// Opción que estaba elegida al aplicar el filtro. Un desplegable simple sin ninguna opción
|
||||
// marcada en el HTML muestra la primera.
|
||||
function wasSelected(select, option, index) {
|
||||
if (option.defaultSelected) {
|
||||
return true;
|
||||
}
|
||||
if (select.multiple) {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < select.options.length; i++) {
|
||||
if (select.options[i].defaultSelected) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return index === 0;
|
||||
}
|
||||
|
||||
// Indica si el campo tiene un valor distinto del que tenía al aplicar el filtro.
|
||||
function isChanged(field) {
|
||||
if (field.type === "checkbox" || field.type === "radio") {
|
||||
return field.checked !== field.defaultChecked;
|
||||
}
|
||||
if (field.tagName === "SELECT") {
|
||||
for (var i = 0; i < field.options.length; i++) {
|
||||
if (field.options[i].selected !== wasSelected(field, field.options[i], i)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return field.value !== field.defaultValue;
|
||||
}
|
||||
|
||||
// Toma los valores actuales como los del filtro aplicado. Hace falta cuando sólo se actualiza
|
||||
// el listado y el formulario no se vuelve a pintar.
|
||||
function commit(field) {
|
||||
if (field.type === "checkbox" || field.type === "radio") {
|
||||
field.defaultChecked = field.checked;
|
||||
} else if (field.tagName === "SELECT") {
|
||||
for (var i = 0; i < field.options.length; i++) {
|
||||
field.options[i].defaultSelected = field.options[i].selected;
|
||||
}
|
||||
} else {
|
||||
field.defaultValue = field.value;
|
||||
}
|
||||
}
|
||||
|
||||
function refresh(form) {
|
||||
var changed = [];
|
||||
form.querySelectorAll(FIELDS).forEach(function (field) {
|
||||
var container = field.closest(".form-field") || field;
|
||||
if (changed.indexOf(container) === -1 && isChanged(field)) {
|
||||
changed.push(container);
|
||||
}
|
||||
});
|
||||
form.querySelectorAll(".list-filter-changed").forEach(function (container) {
|
||||
if (changed.indexOf(container) === -1) {
|
||||
container.classList.remove("list-filter-changed");
|
||||
}
|
||||
});
|
||||
changed.forEach(function (container) {
|
||||
container.classList.add("list-filter-changed");
|
||||
});
|
||||
|
||||
var pending = changed.length > 0;
|
||||
form.classList.toggle("list-filter-pending", pending);
|
||||
// Sólo se cambia el texto al empezar o terminar los cambios pendientes, para que el lector
|
||||
// de pantalla lo anuncie una vez y no con cada pulsación.
|
||||
var status = form.querySelector(".list-filter-status");
|
||||
var text = pending ? status.getAttribute("data-pending") || "" : "";
|
||||
if (status.textContent !== text) {
|
||||
status.textContent = text;
|
||||
}
|
||||
}
|
||||
|
||||
function filterOf(element) {
|
||||
var form = element instanceof Element ? element.closest("form.list-filter") : null;
|
||||
return form && form.querySelector(".list-filter-status") ? form : null;
|
||||
}
|
||||
|
||||
function onChange(event) {
|
||||
var form = filterOf(event.target);
|
||||
if (form) {
|
||||
refresh(form);
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("input", onChange);
|
||||
document.addEventListener("change", onChange);
|
||||
|
||||
document.addEventListener("submit", function (event) {
|
||||
var form = filterOf(event.target);
|
||||
if (form) {
|
||||
form.querySelectorAll(FIELDS).forEach(commit);
|
||||
refresh(form);
|
||||
}
|
||||
});
|
||||
})();
|
||||
52
assets/js/list-view.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
// Anuncia a los lectores de pantalla el resumen de un listado (`ListView`, atributo
|
||||
// `data-summary`, p. ej. "23 resultados") cuando se actualiza sin recargar la página, al filtrar,
|
||||
// ordenar o cambiar de página. Un lector de pantalla no suele anunciar una zona `aria-live` que se
|
||||
// inserta de golpe, así que el aviso usa una única zona creada al cargar la página, y el listado
|
||||
// nuevo sólo le pasa su texto. Al cargar la página no anuncia nada. Sin dependencias: vale para
|
||||
// HTMX o para cualquier otra forma de actualizar sólo una parte de la página.
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
var SELECTOR = ".list-view[data-summary]";
|
||||
var REGION_ID = "list-view-status";
|
||||
|
||||
// La zona se busca por su identificador cada vez: si se restaura una página del historial
|
||||
// sustituyendo el contenido del `<body>` (como hace HTMX al volver atrás), la zona creada al
|
||||
// cargar desaparece y queda la copia restaurada.
|
||||
function region() {
|
||||
var element = document.getElementById(REGION_ID);
|
||||
if (!element) {
|
||||
element = document.createElement("div");
|
||||
element.id = REGION_ID;
|
||||
element.className = "visually-hidden";
|
||||
element.setAttribute("role", "status");
|
||||
document.body.appendChild(element);
|
||||
}
|
||||
return element;
|
||||
}
|
||||
region();
|
||||
|
||||
function announce(text) {
|
||||
var element = region();
|
||||
// Se vacía primero para que se anuncie también un texto igual al anterior.
|
||||
element.textContent = "";
|
||||
setTimeout(function () {
|
||||
element.textContent = text;
|
||||
}, 50);
|
||||
}
|
||||
|
||||
new MutationObserver(function (mutations) {
|
||||
mutations.forEach(function (mutation) {
|
||||
mutation.addedNodes.forEach(function (node) {
|
||||
if (!(node instanceof Element)) {
|
||||
return;
|
||||
}
|
||||
var list = node.matches(SELECTOR) ? node : node.querySelector(SELECTOR);
|
||||
if (list) {
|
||||
announce(list.getAttribute("data-summary"));
|
||||
}
|
||||
});
|
||||
});
|
||||
}).observe(document.body, { childList: true, subtree: true });
|
||||
})();
|
||||
47
assets/scss/basic.scss
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
// PageTop Basic theme styles.
|
||||
//
|
||||
// Compiled by `build.rs` into `static/css/basic.min.css`. Comments written with `//` never reach
|
||||
// the compiled file, so they can be as long as needed.
|
||||
//
|
||||
// The partials are emitted in the order they are loaded here, which matters when two rules tie on
|
||||
// specificity: the later one wins.
|
||||
|
||||
// Third-party reset (normalize.css v8.0.1, MIT), copied verbatim. It goes first so that every
|
||||
// rule of the theme can override it.
|
||||
@use "basic/normalize";
|
||||
|
||||
// Custom properties and base styles.
|
||||
@use "basic/root";
|
||||
@use "basic/base";
|
||||
|
||||
// Components, in alphabetical order. `buttons` must go before `dropdown` and `nav`, see the notes
|
||||
// in `basic/_buttons.scss`.
|
||||
@use "basic/badge";
|
||||
@use "basic/block";
|
||||
@use "basic/brand";
|
||||
@use "basic/breadcrumb";
|
||||
@use "basic/buttons";
|
||||
@use "basic/container";
|
||||
@use "basic/dialog";
|
||||
@use "basic/dropdown";
|
||||
@use "basic/form";
|
||||
@use "basic/image";
|
||||
@use "basic/list-filter";
|
||||
@use "basic/list-view";
|
||||
@use "basic/messages";
|
||||
@use "basic/nav";
|
||||
@use "basic/navbar";
|
||||
@use "basic/pager";
|
||||
@use "basic/table";
|
||||
|
||||
// Theme regions.
|
||||
@use "basic/regions";
|
||||
|
||||
// Frame of the administration pages.
|
||||
@use "basic/admin";
|
||||
|
||||
// Styles for the pages of the `pagetop-user` extension.
|
||||
@use "basic/user";
|
||||
|
||||
// Utilities go last so they win over any component rule they are combined with.
|
||||
@use "basic/utilities";
|
||||
51
assets/scss/basic/_admin.scss
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// Frame of an administration page (`AdminFrame`), painted by the `Admin` template around the
|
||||
// `Content` region: title with its action links, then the local tasks as tabs.
|
||||
|
||||
.admin-header {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: .5rem 1rem;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
.admin-page-title {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.admin-actions-list,
|
||||
.admin-tasks-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: .5rem;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.admin-action-link {
|
||||
display: inline-block;
|
||||
padding: .375rem .75rem;
|
||||
border: 1px solid var(--val-color--primary);
|
||||
border-radius: .375rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.admin-local-tasks {
|
||||
margin-bottom: 1rem;
|
||||
border-bottom: 1px solid var(--val-color--bg--muted);
|
||||
}
|
||||
|
||||
.admin-task a {
|
||||
display: block;
|
||||
padding: .5rem .75rem;
|
||||
margin-bottom: -1px;
|
||||
border-bottom: 2px solid transparent;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.admin-task-active a {
|
||||
border-bottom-color: var(--val-color--primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
21
assets/scss/basic/_badge.scss
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
.badge {
|
||||
display: inline-block;
|
||||
padding: 0.3em 0.6em;
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 600;
|
||||
line-height: 1;
|
||||
color: #fff;
|
||||
background-color: var(--val-color--secondary);
|
||||
border-radius: 0.375rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.badge-info,
|
||||
.badge-warning {
|
||||
color: #000;
|
||||
}
|
||||
.badge-primary { background-color: var(--val-color--primary); }
|
||||
.badge-neutral { background-color: var(--val-color--secondary); }
|
||||
.badge-success { background-color: var(--val-color--success); }
|
||||
.badge-info { background-color: var(--val-color--info); }
|
||||
.badge-warning { background-color: var(--val-color--warning); }
|
||||
.badge-severe { background-color: var(--val-color--danger); }
|
||||
25
assets/scss/basic/_base.scss
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
*, *::before, *::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: var(--val-font-family);
|
||||
font-size: var(--val-fs--base);
|
||||
font-weight: var(--val-fw--base);
|
||||
line-height: var(--val-lh--base);
|
||||
color: var(--val-color--text);
|
||||
background-color: var(--val-color--bg);
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
// Header, Aside, Content and Footer are stacked in that order, using the full available width, with
|
||||
// side padding (the same as containers) so the content never touches the edges of the screen.
|
||||
.wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-inline: 1rem;
|
||||
}
|
||||
4
assets/scss/basic/_block.scss
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
// Space below each block, so consecutive blocks (and what follows them) do not sit right together.
|
||||
.block {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
12
assets/scss/basic/_brand.scss
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
.brand {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
color: var(--val-color--text);
|
||||
font-size: 1.75rem;
|
||||
font-weight: 600;
|
||||
text-decoration: none;
|
||||
}
|
||||
.brand .image {
|
||||
display: flex;
|
||||
}
|
||||
26
assets/scss/basic/_breadcrumb.scss
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
.breadcrumb {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
list-style: none;
|
||||
margin: 0 0 1rem;
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
.breadcrumb-item + .breadcrumb-item {
|
||||
padding-left: 0.5rem;
|
||||
}
|
||||
.breadcrumb-item + .breadcrumb-item::before {
|
||||
float: left;
|
||||
padding-right: 0.5rem;
|
||||
color: var(--val-color--text--muted);
|
||||
content: "/";
|
||||
}
|
||||
.breadcrumb-item.active {
|
||||
color: var(--val-color--text--muted);
|
||||
}
|
||||
.breadcrumb-item a {
|
||||
color: var(--val-color--text);
|
||||
text-decoration: none;
|
||||
}
|
||||
.breadcrumb-item a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
25
assets/scss/basic/_breakpoints.scss
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// Breakpoints of the Basic theme, used to generate the responsive classes of `Container` and
|
||||
// `Navbar`. They match the default `Theme::breakpoint_entry()` table (`xs` has no minimum width, so
|
||||
// it is left out), so a child theme that renames or resizes the breakpoints must also redefine the
|
||||
// classes generated from them.
|
||||
//
|
||||
// This partial emits no CSS on its own.
|
||||
|
||||
$breakpoints: (
|
||||
sm: 576px,
|
||||
md: 768px,
|
||||
lg: 992px,
|
||||
xl: 1200px,
|
||||
xxl: 1400px,
|
||||
xxxl: 1920px,
|
||||
);
|
||||
|
||||
// Maximum width of `.container` and `.container-{name}` from each breakpoint on.
|
||||
$container-max-widths: (
|
||||
sm: 540px,
|
||||
md: 720px,
|
||||
lg: 960px,
|
||||
xl: 1140px,
|
||||
xxl: 1320px,
|
||||
xxxl: 1800px,
|
||||
);
|
||||
120
assets/scss/basic/_buttons.scss
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
// Base geometry of .dropdown-button/.dropdown-toggle (the rest is in `_dropdown.scss`). It is
|
||||
// declared here, before the button classes, so that .button-sm/.button-lg/.button-* win the
|
||||
// specificity tie against it when combined on the same element (CSS resolves a tie by order of
|
||||
// appearance in the file, not by the order of the classes in the HTML).
|
||||
.dropdown-button,
|
||||
.dropdown-toggle {
|
||||
padding: 0.5rem 0.75rem;
|
||||
font: inherit;
|
||||
color: var(--val-color--text);
|
||||
background-color: transparent;
|
||||
border: 1px solid var(--val-color--border);
|
||||
border-radius: 0.375rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.button {
|
||||
display: inline-block;
|
||||
padding: 0.5rem 1.25rem;
|
||||
font-size: var(--val-fs--base);
|
||||
font-weight: 600;
|
||||
line-height: var(--val-lh--base);
|
||||
color: #fff;
|
||||
background-color: var(--val-color--primary);
|
||||
border: 1px solid var(--val-color--primary);
|
||||
border-radius: 0.375rem;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
transition: background-color .15s ease-in-out, border-color .15s ease-in-out;
|
||||
}
|
||||
.button:hover {
|
||||
background-color: color-mix(in srgb, var(--val-color--primary) 85%, black);
|
||||
border-color: color-mix(in srgb, var(--val-color--primary) 85%, black);
|
||||
}
|
||||
.button:disabled,
|
||||
.button.disabled {
|
||||
opacity: 0.65;
|
||||
cursor: default;
|
||||
pointer-events: none;
|
||||
}
|
||||
.button::-moz-focus-inner {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.button-sm {
|
||||
padding: 0.25rem 0.75rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
.button-lg {
|
||||
padding: 0.75rem 1.5rem;
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.button-primary,
|
||||
.button-neutral,
|
||||
.button-success,
|
||||
.button-severe {
|
||||
color: #fff;
|
||||
}
|
||||
.button-info,
|
||||
.button-warning {
|
||||
color: #000;
|
||||
}
|
||||
.button-primary { background-color: var(--val-color--primary); border-color: var(--val-color--primary); }
|
||||
.button-neutral { background-color: var(--val-color--secondary); border-color: var(--val-color--secondary); }
|
||||
.button-success { background-color: var(--val-color--success); border-color: var(--val-color--success); }
|
||||
.button-info { background-color: var(--val-color--info); border-color: var(--val-color--info); }
|
||||
.button-warning { background-color: var(--val-color--warning); border-color: var(--val-color--warning); }
|
||||
.button-severe { background-color: var(--val-color--danger); border-color: var(--val-color--danger); }
|
||||
|
||||
.button-primary:hover { background-color: color-mix(in srgb, var(--val-color--primary) 85%, black); border-color: color-mix(in srgb, var(--val-color--primary) 85%, black); }
|
||||
.button-neutral:hover { background-color: color-mix(in srgb, var(--val-color--secondary) 85%, black); border-color: color-mix(in srgb, var(--val-color--secondary) 85%, black); }
|
||||
.button-success:hover { background-color: color-mix(in srgb, var(--val-color--success) 85%, black); border-color: color-mix(in srgb, var(--val-color--success) 85%, black); }
|
||||
.button-info:hover { background-color: color-mix(in srgb, var(--val-color--info) 85%, black); border-color: color-mix(in srgb, var(--val-color--info) 85%, black); }
|
||||
.button-warning:hover { background-color: color-mix(in srgb, var(--val-color--warning) 85%, black); border-color: color-mix(in srgb, var(--val-color--warning) 85%, black); }
|
||||
.button-severe:hover { background-color: color-mix(in srgb, var(--val-color--danger) 85%, black); border-color: color-mix(in srgb, var(--val-color--danger) 85%, black); }
|
||||
|
||||
.button-outline-primary,
|
||||
.button-outline-neutral,
|
||||
.button-outline-success,
|
||||
.button-outline-info,
|
||||
.button-outline-warning,
|
||||
.button-outline-severe {
|
||||
background-color: transparent;
|
||||
}
|
||||
.button-outline-primary { border-color: var(--val-color--primary); color: var(--val-color--primary); }
|
||||
.button-outline-neutral { border-color: var(--val-color--secondary); color: var(--val-color--secondary); }
|
||||
.button-outline-success { border-color: var(--val-color--success); color: var(--val-color--success); }
|
||||
.button-outline-info { border-color: var(--val-color--info); color: var(--val-color--info); }
|
||||
.button-outline-warning { border-color: var(--val-color--warning); color: var(--val-color--warning); }
|
||||
.button-outline-severe { border-color: var(--val-color--danger); color: var(--val-color--danger); }
|
||||
|
||||
.button-outline-primary:hover { background-color: var(--val-color--primary); border-color: var(--val-color--primary); color: #fff; }
|
||||
.button-outline-neutral:hover { background-color: var(--val-color--secondary); border-color: var(--val-color--secondary); color: #fff; }
|
||||
.button-outline-success:hover { background-color: var(--val-color--success); border-color: var(--val-color--success); color: #fff; }
|
||||
.button-outline-info:hover { background-color: var(--val-color--info); border-color: var(--val-color--info); color: #000; }
|
||||
.button-outline-warning:hover { background-color: var(--val-color--warning); border-color: var(--val-color--warning); color: #000; }
|
||||
.button-outline-severe:hover { background-color: var(--val-color--danger); border-color: var(--val-color--danger); color: #fff; }
|
||||
|
||||
.button-link {
|
||||
font-weight: 400;
|
||||
color: var(--val-color--primary);
|
||||
background-color: transparent;
|
||||
border-color: transparent;
|
||||
text-decoration: underline;
|
||||
}
|
||||
.button-link:hover {
|
||||
color: color-mix(in srgb, var(--val-color--primary) 85%, black);
|
||||
background-color: transparent;
|
||||
border-color: transparent;
|
||||
}
|
||||
.button-link:disabled,
|
||||
.button-link.disabled {
|
||||
color: var(--val-color--text--muted);
|
||||
}
|
||||
|
||||
.button-set {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
32
assets/scss/basic/_container.scss
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
@use "sass:list";
|
||||
@use "sass:map";
|
||||
@use "breakpoints" as bp;
|
||||
|
||||
// Classes added by the `Container` component from `Width`. All of them are centered and fill the
|
||||
// available width; `.container` and `.container-{name}` also get a maximum width from the
|
||||
// breakpoint they name (`.container` from the first one).
|
||||
|
||||
$named: ();
|
||||
@each $name in map.keys(bp.$breakpoints) {
|
||||
$named: list.append($named, ".container-#{$name}", comma);
|
||||
}
|
||||
|
||||
.container,
|
||||
.container-fluid,
|
||||
#{$named} {
|
||||
width: 100%;
|
||||
margin-inline: auto;
|
||||
padding-inline: 1rem;
|
||||
}
|
||||
|
||||
// From each breakpoint on, `.container` and every `.container-{name}` up to that breakpoint take
|
||||
// its maximum width, while the larger ones stay fluid until their own breakpoint is reached.
|
||||
$sized: (".container");
|
||||
@each $name, $width in bp.$breakpoints {
|
||||
$sized: list.append($sized, ".container-#{$name}", comma);
|
||||
@media (width >= $width) {
|
||||
#{$sized} {
|
||||
max-width: map.get(bp.$container-max-widths, $name);
|
||||
}
|
||||
}
|
||||
}
|
||||
57
assets/scss/basic/_dialog.scss
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
.dialog {
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
max-width: 32rem;
|
||||
color: var(--val-color--text);
|
||||
background-color: var(--val-color--bg);
|
||||
border: none;
|
||||
border-radius: 0.5rem;
|
||||
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
.dialog::backdrop {
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.dialog-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding: 1rem 1.25rem;
|
||||
border-bottom: 1px solid color-mix(in srgb, var(--val-color--border) 15%, var(--val-color--bg));
|
||||
}
|
||||
|
||||
.dialog-title {
|
||||
margin: 0;
|
||||
font-size: 1.125rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.dialog-close {
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
padding: 0;
|
||||
line-height: 1;
|
||||
color: var(--val-color--text--muted);
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.dialog-close::before {
|
||||
content: "\2715";
|
||||
}
|
||||
.dialog-close:hover {
|
||||
color: var(--val-color--text);
|
||||
}
|
||||
|
||||
.dialog-body {
|
||||
padding: 1.25rem;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.5rem;
|
||||
padding: 1rem 1.25rem;
|
||||
border-top: 1px solid color-mix(in srgb, var(--val-color--border) 15%, var(--val-color--bg));
|
||||
}
|
||||
93
assets/scss/basic/_dropdown.scss
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
.dropdown {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
// The base geometry of .dropdown-button/.dropdown-toggle lives at the top of `_buttons.scss`, which
|
||||
// is loaded before this partial, so that .button-sm/.button-lg/.button-* win the specificity tie
|
||||
// against it (CSS resolves a tie by order of appearance in the file, not by the order of the
|
||||
// classes in the HTML).
|
||||
.dropdown-toggle::after {
|
||||
content: "\25BC";
|
||||
display: inline-block;
|
||||
margin-left: 0.35em;
|
||||
font-size: 0.8em;
|
||||
transition: transform .15s ease-in-out;
|
||||
}
|
||||
.dropdown:has(> .dropdown-menu.show) > .dropdown-toggle::after {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.dropdown-menu {
|
||||
position: absolute;
|
||||
z-index: 1000;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
min-width: 12rem;
|
||||
margin: 0.25rem 0 0;
|
||||
padding: 0.5rem 0;
|
||||
list-style: none;
|
||||
background-color: var(--val-color--bg);
|
||||
border: 1px solid color-mix(in srgb, var(--val-color--border) 15%, var(--val-color--bg));
|
||||
border-radius: 0.375rem;
|
||||
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
|
||||
// Closed by default
|
||||
display: none;
|
||||
}
|
||||
.dropdown-menu.show {
|
||||
display: block;
|
||||
}
|
||||
// Anchors the menu's right edge to the button's right edge, so it opens inwards.
|
||||
.dropdown-menu-end {
|
||||
left: auto;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
// Options and headers stay on one line, so the menu grows to fit the longest one.
|
||||
.dropdown-item {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 0.375rem 1rem;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
color: var(--val-color--text);
|
||||
text-decoration: none;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
.dropdown-item:hover {
|
||||
background-color: color-mix(in srgb, var(--val-color--text) 8%, transparent);
|
||||
}
|
||||
.dropdown-item.active {
|
||||
color: var(--val-color--primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
.dropdown-item.disabled {
|
||||
color: var(--val-color--text--muted);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.dropdown-item-text {
|
||||
display: block;
|
||||
padding: 0.375rem 1rem;
|
||||
color: var(--val-color--text--muted);
|
||||
}
|
||||
|
||||
.dropdown-header {
|
||||
display: block;
|
||||
padding: 0.5rem 1rem 0.25rem;
|
||||
margin: 0;
|
||||
white-space: nowrap;
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 600;
|
||||
color: var(--val-color--text--muted);
|
||||
}
|
||||
|
||||
.dropdown-divider {
|
||||
height: 0;
|
||||
margin: 0.5rem 0;
|
||||
border: none;
|
||||
border-top: 1px solid var(--val-color--border);
|
||||
}
|
||||
130
assets/scss/basic/_form.scss
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
.form-required {
|
||||
color: var(--val-color--danger);
|
||||
margin-left: 0.25rem;
|
||||
}
|
||||
|
||||
// Fields are spaced below, as in Bootsier, so the first one of a form or a fieldset starts right
|
||||
// at its top; the last one leaves no gap.
|
||||
.form-field {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.form-field:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.form-text {
|
||||
font-size: 0.875rem;
|
||||
font-style: italic;
|
||||
line-height: 1.3;
|
||||
color: var(--val-color--text--muted);
|
||||
}
|
||||
|
||||
.form-field > select.form-select,
|
||||
.form-field > input.form-control,
|
||||
.form-field > input.form-range,
|
||||
.form-field > textarea.form-control {
|
||||
display: block;
|
||||
padding: 0.25rem 0.5rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
margin: 0 0 1rem;
|
||||
background: var(--val-color--bg);
|
||||
}
|
||||
fieldset > legend {
|
||||
background-color: var(--val-color--bg);
|
||||
border: 2px groove threedface;
|
||||
padding: 0 0.5em;
|
||||
}
|
||||
|
||||
.form-check {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
align-items: center;
|
||||
gap: 0.25rem 0.5rem;
|
||||
min-height: 1.5rem;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
.form-check-inline {
|
||||
display: inline-grid;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
.form-check-reverse {
|
||||
grid-template-columns: 1fr auto;
|
||||
text-align: right;
|
||||
}
|
||||
.form-check-reverse > .form-check-input {
|
||||
grid-column: 2;
|
||||
grid-row: 1;
|
||||
}
|
||||
// Help text goes below the label, aligned with it.
|
||||
.form-check > .form-text {
|
||||
grid-column: 2;
|
||||
}
|
||||
.form-check-reverse > .form-text {
|
||||
grid-column: 1;
|
||||
}
|
||||
.form-check-input {
|
||||
cursor: pointer;
|
||||
}
|
||||
.form-check-label {
|
||||
cursor: pointer;
|
||||
}
|
||||
.form-switch .form-check-input {
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
width: 2em;
|
||||
height: 1em;
|
||||
background-color: var(--val-color--switch-off);
|
||||
border-radius: 1em;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
transition: background-color .15s ease-in-out;
|
||||
}
|
||||
.form-switch .form-check-input::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
background-color: white;
|
||||
border-radius: 50%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
transition: transform .15s ease-in-out;
|
||||
box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
|
||||
}
|
||||
.form-switch .form-check-input:checked {
|
||||
background-color: var(--val-color--primary);
|
||||
}
|
||||
.form-switch .form-check-input:checked::after {
|
||||
transform: translateX(1em);
|
||||
}
|
||||
|
||||
input:disabled,
|
||||
input:disabled + label {
|
||||
cursor: default !important;
|
||||
}
|
||||
input:disabled + label {
|
||||
color: var(--val-color--text--muted);
|
||||
}
|
||||
|
||||
.form-field > select.form-select,
|
||||
.form-field > input.form-control,
|
||||
.form-field > textarea.form-control {
|
||||
border: 1px solid var(--val-color--border);
|
||||
border-radius: 0.375rem;
|
||||
background-color: #fff;
|
||||
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
|
||||
}
|
||||
.form-field > select.form-select:focus,
|
||||
.form-field > input.form-control:focus,
|
||||
.form-field > textarea.form-control:focus {
|
||||
outline: none;
|
||||
border-color: var(--val-color--primary);
|
||||
box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--val-color--primary) 25%, transparent);
|
||||
}
|
||||
15
assets/scss/basic/_image.scss
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
.image {
|
||||
vertical-align: middle;
|
||||
}
|
||||
.image-fluid {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
.image-thumbnail {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
padding: 0.25rem;
|
||||
background-color: var(--val-color--bg);
|
||||
border: 1px solid var(--val-color--border);
|
||||
border-radius: 0.375rem;
|
||||
}
|
||||
59
assets/scss/basic/_list-filter.scss
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
// List filters (ListFilter): fields and button on one row, wrapping when there is no room.
|
||||
.list-filter {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: 0.5rem 1rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.list-filter > .form-field {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
// Marks of changed filters not applied yet (filters with a button), set by `list-filter.js`. Only
|
||||
// colors and opacity change, never sizes: the dot always takes its room, hidden, so nothing moves
|
||||
// when it shows up. A vivid orange, set apart from the primary color of the button, darkened just
|
||||
// enough to keep a 3:1 contrast against the background. Every changed field gets the dot by its
|
||||
// label, once per field (on the title of a group); text fields and dropdowns also show a gray
|
||||
// background.
|
||||
.list-filter {
|
||||
--list-filter-mark: color-mix(in srgb, #fd7e14 85%, black);
|
||||
}
|
||||
|
||||
.list-filter .form-field > .form-label::after,
|
||||
.list-filter .form-field.form-check > .form-check-label::after {
|
||||
content: "\25CF" / "";
|
||||
margin-left: 0.25em;
|
||||
color: var(--list-filter-mark);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.list-filter .list-filter-changed > .form-label::after,
|
||||
.list-filter .list-filter-changed.form-check > .form-check-label::after {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.list-filter .list-filter-changed .form-control,
|
||||
.list-filter .list-filter-changed .form-select {
|
||||
background-color: color-mix(in srgb, var(--val-color--bg--muted) 60%, #fff);
|
||||
}
|
||||
|
||||
// Native checkboxes only take a color when checked; a switch is drawn by the theme.
|
||||
.list-filter .list-filter-changed .form-check-input {
|
||||
accent-color: var(--list-filter-mark);
|
||||
}
|
||||
|
||||
.list-filter .list-filter-changed.form-switch .form-check-input:checked {
|
||||
background-color: var(--list-filter-mark);
|
||||
}
|
||||
|
||||
.list-filter-pending > button[type="submit"] {
|
||||
background-color: var(--val-color--primary);
|
||||
border-color: var(--val-color--primary);
|
||||
}
|
||||
|
||||
.list-filter-pending > button[type="submit"]:hover {
|
||||
background-color: color-mix(in srgb, var(--val-color--primary) 85%, black);
|
||||
border-color: color-mix(in srgb, var(--val-color--primary) 85%, black);
|
||||
}
|
||||
8
assets/scss/basic/_list-view.scss
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// List view (ListView): action buttons above the table, then messages, table and pager.
|
||||
.list-view {
|
||||
margin: 1.5rem 0;
|
||||
}
|
||||
|
||||
.list-view-actions {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
24
assets/scss/basic/_messages.scss
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
.message {
|
||||
padding: 0.75rem 1rem;
|
||||
margin-bottom: 1rem;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 0.375rem;
|
||||
}
|
||||
|
||||
.message-info {
|
||||
color: color-mix(in srgb, var(--val-color--info) 40%, black);
|
||||
background-color: color-mix(in srgb, var(--val-color--info) 15%, var(--val-color--bg));
|
||||
border-color: color-mix(in srgb, var(--val-color--info) 40%, var(--val-color--bg));
|
||||
}
|
||||
|
||||
.message-warning {
|
||||
color: color-mix(in srgb, var(--val-color--warning) 40%, black);
|
||||
background-color: color-mix(in srgb, var(--val-color--warning) 15%, var(--val-color--bg));
|
||||
border-color: color-mix(in srgb, var(--val-color--warning) 40%, var(--val-color--bg));
|
||||
}
|
||||
|
||||
.message-error {
|
||||
color: color-mix(in srgb, var(--val-color--danger) 40%, black);
|
||||
background-color: color-mix(in srgb, var(--val-color--danger) 15%, var(--val-color--bg));
|
||||
border-color: color-mix(in srgb, var(--val-color--danger) 40%, var(--val-color--bg));
|
||||
}
|
||||
61
assets/scss/basic/_nav.scss
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
.nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
display: block;
|
||||
padding: 0.5rem 0.75rem;
|
||||
color: var(--val-color--text);
|
||||
text-decoration: none;
|
||||
border-radius: 0.375rem;
|
||||
}
|
||||
.nav-link:hover {
|
||||
background-color: color-mix(in srgb, var(--val-color--text) 8%, transparent);
|
||||
}
|
||||
.nav-link.active {
|
||||
color: var(--val-color--primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
.nav-link.disabled {
|
||||
color: var(--val-color--text--muted);
|
||||
pointer-events: none;
|
||||
}
|
||||
// The toggle of a dropdown inside a `Nav` looks like the other links: it drops the border that a
|
||||
// standalone `Dropdown` toggle has (see `_buttons.scss`).
|
||||
.nav-link.dropdown-toggle {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.nav-start {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.nav-center {
|
||||
justify-content: center;
|
||||
}
|
||||
.nav-end {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.nav-vertical {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
.nav-fill > .nav-item {
|
||||
flex: 1 1 auto;
|
||||
text-align: center;
|
||||
}
|
||||
.nav-justified > .nav-item {
|
||||
flex-basis: 0;
|
||||
flex-grow: 1;
|
||||
text-align: center;
|
||||
}
|
||||
121
assets/scss/basic/_navbar.scss
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
@use "breakpoints" as bp;
|
||||
|
||||
// No side padding, so the bar lines up with the rest of the page (fixed bars below get it back).
|
||||
.navbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
padding-block: 0.5rem;
|
||||
}
|
||||
|
||||
.navbar-toggle {
|
||||
display: none;
|
||||
padding: 0.25rem 0.5rem;
|
||||
font-size: 1.25rem;
|
||||
line-height: 1;
|
||||
color: inherit;
|
||||
background-color: transparent;
|
||||
border: 1px solid var(--val-color--border);
|
||||
border-radius: 0.375rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
.navbar-toggle::before {
|
||||
content: "\2630";
|
||||
}
|
||||
|
||||
// Pushes the toggle (`BrandLeft`) or the brand (`BrandRight`) to the far end of the bar.
|
||||
.brand ~ .navbar-toggle,
|
||||
.navbar-toggle ~ .brand {
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
|
||||
.navbar-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
// A bar without a toggle button never stacks its `.nav` items in a column, so they wrap onto
|
||||
// another line when they don't fit instead of overflowing the bar.
|
||||
.navbar-content .nav {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.navbar-text {
|
||||
color: var(--val-color--text--muted);
|
||||
}
|
||||
|
||||
// Navbar position, from the `navbar::Position` classes. `.navbar` has no background of its own, so
|
||||
// a bar taken out of the flow (fixed) or pinned while scrolling (sticky) gets one, or the content
|
||||
// passing underneath would show through.
|
||||
.navbar.fixed-top,
|
||||
.navbar.fixed-bottom,
|
||||
.navbar.sticky-top,
|
||||
.navbar.sticky-bottom {
|
||||
background-color: var(--val-color--bg);
|
||||
}
|
||||
// Fixed bars span the whole viewport, so they keep some side padding off its edges.
|
||||
.navbar.fixed-top,
|
||||
.navbar.fixed-bottom {
|
||||
position: fixed;
|
||||
right: 0;
|
||||
left: 0;
|
||||
z-index: 1030;
|
||||
padding-inline: 1rem;
|
||||
}
|
||||
.navbar.fixed-top {
|
||||
top: 0;
|
||||
}
|
||||
.navbar.fixed-bottom {
|
||||
bottom: 0;
|
||||
}
|
||||
.navbar.sticky-top,
|
||||
.navbar.sticky-bottom {
|
||||
position: sticky;
|
||||
z-index: 1020;
|
||||
}
|
||||
.navbar.sticky-top {
|
||||
top: 0;
|
||||
}
|
||||
.navbar.sticky-bottom {
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
// A navbar with a toggle button collapses below the breakpoint set by its `navbar-expand-{name}`
|
||||
// class, added by the `Navbar` component. `navbar-expand` alone (a breakpoint with no minimum
|
||||
// width) never collapses and needs no rules, since the base rules above are the expanded layout.
|
||||
//
|
||||
// While collapsed, the `.nav` items are stacked in a column, so a dropdown menu inside it is laid
|
||||
// out in the flow (`position: static`) to push down the following items instead of covering them.
|
||||
// A navbar without a toggle button has nothing to collapse: its `.nav` items stay in a row.
|
||||
@each $name, $width in bp.$breakpoints {
|
||||
@media (width < $width) {
|
||||
.navbar-expand-#{$name} {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.navbar-expand-#{$name}:has(.navbar-toggle) {
|
||||
.navbar-toggle {
|
||||
display: inline-block;
|
||||
}
|
||||
.navbar-content {
|
||||
order: 1;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
width: 100%;
|
||||
}
|
||||
.navbar-content.show {
|
||||
display: flex;
|
||||
}
|
||||
.nav {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
width: 100%;
|
||||
}
|
||||
.nav .dropdown-menu {
|
||||
position: static;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
140
assets/scss/basic/_pager.scss
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
.pager {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
margin: 1rem 0;
|
||||
padding: 0 1rem;
|
||||
}
|
||||
.pager-align-start {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.pager-align-center {
|
||||
justify-content: center;
|
||||
}
|
||||
.pager-align-end {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.pager-summary {
|
||||
color: var(--val-color--text--muted);
|
||||
font-size: 0.8125rem;
|
||||
align-self: flex-start;
|
||||
margin-inline-end: auto;
|
||||
}
|
||||
.pager-align-start .pager-summary {
|
||||
order: 1;
|
||||
margin-inline-end: 0;
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
.pager-align-center .pager-summary {
|
||||
order: 1;
|
||||
flex-basis: 100%;
|
||||
text-align: center;
|
||||
margin-inline-end: 0;
|
||||
}
|
||||
|
||||
// Cells wrap onto more lines when they don't fit, so a long pager never gets wider than the screen.
|
||||
.pagination {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.pagination a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 1.5rem;
|
||||
padding: 0.375rem 0.625rem;
|
||||
border-radius: 0.375rem;
|
||||
color: var(--val-color--text);
|
||||
text-decoration: none;
|
||||
}
|
||||
.pagination a:hover {
|
||||
background-color: color-mix(in srgb, var(--val-color--text) 8%, transparent);
|
||||
}
|
||||
.pagination .active a {
|
||||
color: #fff;
|
||||
background-color: var(--val-color--primary);
|
||||
}
|
||||
.pagination .disabled a {
|
||||
color: var(--val-color--text--muted);
|
||||
pointer-events: none;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.page-ellipsis {
|
||||
padding: 0.375rem 0.25rem;
|
||||
color: var(--val-color--text--muted);
|
||||
}
|
||||
|
||||
// .page-link-icon shows the navigation text of the previous/next buttons. The full accessible text
|
||||
// goes separately, in the link's aria-label. So replacing the visible text with other content does
|
||||
// not affect accessibility, e.g. to use "‹"/"›" you can apply:
|
||||
//
|
||||
// .page-link-icon {
|
||||
// display: inline-block;
|
||||
// font-size: 0;
|
||||
// }
|
||||
// .page-previous .page-link-icon::before {
|
||||
// content: "‹";
|
||||
// font-size: 1rem;
|
||||
// display: inline-block;
|
||||
// transform: translateY(-0.15em) scale(1.5);
|
||||
// }
|
||||
// .page-next .page-link-icon::before {
|
||||
// content: "›";
|
||||
// font-size: 1rem;
|
||||
// display: inline-block;
|
||||
// transform: translateY(-0.15em) scale(1.5);
|
||||
// }
|
||||
|
||||
.pager-jump {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
// The page number is a form field: without the bottom margin fields take elsewhere, so it lines up
|
||||
// with the button.
|
||||
.pager-jump-input {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.pager-jump:focus-within {
|
||||
border-radius: 0.375rem;
|
||||
box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--val-color--primary) 25%, transparent);
|
||||
}
|
||||
.pager-jump-input > input.form-control:focus,
|
||||
.pager-jump-button:focus {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
.pager-jump-input > input.form-control {
|
||||
width: calc(var(--pager-jump-width, 1ch) + 2.5rem);
|
||||
padding: 0.375rem 0.625rem;
|
||||
line-height: var(--val-lh--base);
|
||||
border: 0;
|
||||
border-start-end-radius: 0;
|
||||
border-end-end-radius: 0;
|
||||
background-color: var(--val-color--bg--muted);
|
||||
}
|
||||
.pager-jump-input > input.form-control {
|
||||
text-align: center;
|
||||
appearance: textfield;
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
.pager-jump-input > input.form-control::-webkit-outer-spin-button,
|
||||
.pager-jump-input > input.form-control::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
.pager-jump-button {
|
||||
padding: 0.375rem 0.625rem;
|
||||
border: 0;
|
||||
border-start-start-radius: 0;
|
||||
border-end-start-radius: 0;
|
||||
}
|
||||
.pager-jump-button:hover {
|
||||
background-color: color-mix(in srgb, var(--val-color--primary) 85%, black);
|
||||
}
|
||||
10
assets/scss/basic/_regions.scss
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// A region holding only comments (such as the mark of a deferred component that rendered nothing)
|
||||
// matches `:empty`, so it takes no space.
|
||||
.region:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.region-footer {
|
||||
padding: .75rem 0 3rem;
|
||||
text-align: center;
|
||||
}
|
||||
27
assets/scss/basic/_root.scss
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
:root {
|
||||
// Font families
|
||||
--val-font-sans: system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif;
|
||||
--val-font-serif: Georgia,"Times New Roman",serif;
|
||||
--val-font-monospace: SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
|
||||
--val-font-family: var(--val-font-sans);
|
||||
// Font size
|
||||
--val-fs--base: 1rem;
|
||||
// Font weight
|
||||
--val-fw--base: 400;
|
||||
// Line height
|
||||
--val-lh--base: 1.5;
|
||||
// Core Colors
|
||||
--val-color--primary: #0d6efd;
|
||||
--val-color--secondary: #6c757d;
|
||||
--val-color--success: #198754;
|
||||
--val-color--info: #0dcaf0;
|
||||
--val-color--warning: #ffc107;
|
||||
--val-color--danger: #dc3545;
|
||||
// Other Colors
|
||||
--val-color--bg: #fafafa;
|
||||
--val-color--bg--muted: #dee2e6;
|
||||
--val-color--text: #212529;
|
||||
--val-color--text--muted: color-mix(in srgb, var(--val-color--text) 50%, var(--val-color--bg));
|
||||
--val-color--switch-off: #adb5bd;
|
||||
--val-color--border: #212529;
|
||||
}
|
||||
51
assets/scss/basic/_table.scss
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
.table-responsive {
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 0.5rem 0.75rem;
|
||||
border-bottom: 1px solid color-mix(in srgb, var(--val-color--border) 15%, var(--val-color--bg));
|
||||
}
|
||||
|
||||
.table thead th {
|
||||
border-bottom-width: 2px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.table-sort {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
.table-sort:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.table-sort::after {
|
||||
content: "\25BC";
|
||||
margin-left: 0.25rem;
|
||||
font-size: 0.8em;
|
||||
opacity: 0.15;
|
||||
}
|
||||
.table-sort-asc::after {
|
||||
content: "\25B2";
|
||||
font-size: 0.8em;
|
||||
opacity: 1;
|
||||
}
|
||||
.table-sort-desc::after {
|
||||
content: "\25BC";
|
||||
font-size: 0.8em;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.table-empty {
|
||||
text-align: center;
|
||||
font-style: italic;
|
||||
color: var(--val-color--text--muted);
|
||||
}
|
||||
45
assets/scss/basic/_user.scss
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
.user-login-page {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 70vh;
|
||||
padding: 2rem 1rem;
|
||||
background: radial-gradient(
|
||||
ellipse 120% 60% at 50% -10%,
|
||||
color-mix(in srgb, var(--val-color--primary) 18%, var(--val-color--bg)) 0%,
|
||||
var(--val-color--bg) 70%
|
||||
);
|
||||
}
|
||||
|
||||
.user-login-card {
|
||||
width: 100%;
|
||||
max-width: 24rem;
|
||||
padding: 2rem;
|
||||
background-color: #fff;
|
||||
border-radius: 0.75rem;
|
||||
box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.user-login-card .form-label {
|
||||
margin-top: 1.25rem;
|
||||
}
|
||||
|
||||
.user-login-card .button {
|
||||
display: block;
|
||||
width: 100%;
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.user-form-error {
|
||||
padding: 0.625rem 0.875rem;
|
||||
margin-bottom: 1rem;
|
||||
color: #fff;
|
||||
background-color: var(--val-color--danger);
|
||||
border-radius: 0.375rem;
|
||||
}
|
||||
|
||||
.user-register-link,
|
||||
.user-reset-link {
|
||||
margin-top: 1rem;
|
||||
text-align: center;
|
||||
}
|
||||
12
assets/scss/basic/_utilities.scss
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Utility: visually hidden but still accessible to assistive technology
|
||||
.visually-hidden {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
border: 0;
|
||||
}
|
||||
522
assets/scss/intro.scss
Normal file
|
|
@ -0,0 +1,522 @@
|
|||
// Styles of the `Intro` component.
|
||||
//
|
||||
// Compiled by `build.rs` into `static/css/intro.min.css`, apart from `basic.scss`: the component
|
||||
// loads them on its own, whatever the active theme is.
|
||||
|
||||
:root {
|
||||
--intro-bg-img: url('/pagetop/img/intro-header.jpg');
|
||||
--intro-bg-img-set: image-set(url('/pagetop/img/intro-header.avif') type('image/avif'), url('/pagetop/img/intro-header.webp') type('image/webp'), var(--intro-bg-img) type('image/jpeg'));
|
||||
--intro-bg-img-sm: url('/pagetop/img/intro-header-sm.jpg');
|
||||
--intro-bg-img-sm-set: image-set(url('/pagetop/img/intro-header-sm.avif') type('image/avif'), url('/pagetop/img/intro-header-sm.webp') type('image/webp'), var(--intro-bg-img-sm) type('image/jpeg'));
|
||||
--intro-bg-color: #7a430e;
|
||||
--intro-bg-block-1: #ffb84b;
|
||||
--intro-bg-block-2: #ffc66f;
|
||||
--intro-bg-block-3: #ffd493;
|
||||
--intro-bg-block-4: #ffe3b7;
|
||||
--intro-bg-block-5: #fff1db;
|
||||
--intro-bg-block-6: #ffffff;
|
||||
--intro-color: #1a202c;
|
||||
--intro-color-gray: #e8e3da;
|
||||
--intro-color-link: #8b2500;
|
||||
--intro-focus-outline: 2px solid var(--intro-color-link);
|
||||
--intro-focus-outline-offset: 2px;
|
||||
--intro-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
body {
|
||||
overflow-x: clip;
|
||||
}
|
||||
|
||||
// Media queries: 768px and 992px match the default `Md` and `Lg` breakpoints of the core.
|
||||
|
||||
.intro {
|
||||
position: relative;
|
||||
color: var(--intro-color);
|
||||
background-color: var(--intro-bg-color);
|
||||
|
||||
left: 50%;
|
||||
right: 50%;
|
||||
margin-left: -50vw;
|
||||
margin-right: -50vw;
|
||||
width: 100vw;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.intro section {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
// Intro Header
|
||||
|
||||
.intro-header {
|
||||
display: flex;
|
||||
flex-direction: column-reverse;
|
||||
width: 100%;
|
||||
max-width: 80rem;
|
||||
margin: 0 auto;
|
||||
padding-bottom: 4rem;
|
||||
background-image: var(--intro-bg-img-sm);
|
||||
background-image: var(--intro-bg-img-sm-set);
|
||||
background-position: top center;
|
||||
background-position-y: -1rem;
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.intro-header-body {
|
||||
padding: 0;
|
||||
background: none;
|
||||
}
|
||||
.intro-header-title {
|
||||
margin: 0 0 0 1.5rem;
|
||||
text-align: left;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
color: #dceefb;
|
||||
padding: clamp(0rem, -5.4892rem + 23.4206vw, 9.5rem) 1rem 1rem;
|
||||
font-size: clamp(1.5rem, 0.7231rem + 3.3149vw, 3.375rem);
|
||||
font-style: italic;
|
||||
font-weight: 600;
|
||||
line-height: 110%;
|
||||
text-shadow: 0 0.125rem 0.1875rem rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
.intro-header-title > span {
|
||||
background: linear-gradient(180deg, #ddff95 30%, #ffb84b 100%);
|
||||
background-clip: text;
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
font-size: clamp(2.25rem, 1.3177rem + 3.9779vw, 6.5rem);
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
line-height: 135%;
|
||||
text-shadow: none;
|
||||
}
|
||||
.intro-header-img {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
text-align: right;
|
||||
width: 100%;
|
||||
}
|
||||
.intro-header-mascot {
|
||||
margin: 2rem;
|
||||
flex-shrink: 1;
|
||||
width: 280px;
|
||||
height: 280px;
|
||||
}
|
||||
@media (width >= 992px) {
|
||||
.intro-header {
|
||||
background-image: var(--intro-bg-img);
|
||||
background-image: var(--intro-bg-img-set);
|
||||
}
|
||||
.intro-header-title {
|
||||
padding: 0 2rem 2.6rem 2rem;
|
||||
}
|
||||
.intro-header-img {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.intro-header-mascot {
|
||||
margin-right: 12rem;
|
||||
}
|
||||
}
|
||||
|
||||
// Intro Content
|
||||
|
||||
.intro-content {
|
||||
height: auto;
|
||||
margin-top: 1.6rem;
|
||||
width: 100%;
|
||||
}
|
||||
.intro-content-body {
|
||||
box-sizing: border-box;
|
||||
max-width: 80rem;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
.intro-content-body:before,
|
||||
.intro-content-body:after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: linear-gradient(130deg, rgba(13, 44, 91, 0) 0%, #ddff95 77.4%);
|
||||
margin: 0 -1.2rem;
|
||||
filter: blur(2.75rem);
|
||||
opacity: 0.8;
|
||||
inset: unset;
|
||||
}
|
||||
.intro-content-body:before {
|
||||
top: -1rem;
|
||||
}
|
||||
.intro-content-body:after {
|
||||
bottom: -1rem;
|
||||
}
|
||||
@media (width < 768px) {
|
||||
.intro-content-body {
|
||||
margin-top: -9.8rem;
|
||||
}
|
||||
}
|
||||
@media (width >= 992px) {
|
||||
.intro-content {
|
||||
margin-top: 0;
|
||||
}
|
||||
.intro-content-body {
|
||||
margin-top: -5.7rem;
|
||||
}
|
||||
.intro-content-body:before,
|
||||
.intro-content-body:after {
|
||||
inset: 11.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.intro-button {
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.intro-button-link {
|
||||
background: #7f1d1d;
|
||||
background-image: linear-gradient(to bottom, rgba(255,0,0,0.8), rgba(255,255,255,0));
|
||||
background-position: top left, center;
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
border-radius: 0.75rem;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
font-size: 1.5rem;
|
||||
line-height: 1.3;
|
||||
text-decoration: none !important;
|
||||
transition: transform 0.3s ease-in-out !important;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
min-width: 28.875rem;
|
||||
min-height: 7.6875rem;
|
||||
outline: none;
|
||||
}
|
||||
.intro-button-link:focus-visible {
|
||||
outline: var(--intro-focus-outline);
|
||||
outline-offset: var(--intro-focus-outline-offset);
|
||||
}
|
||||
.intro-button-link::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: -13.125rem;
|
||||
left: -10rem;
|
||||
height: 26.25rem;
|
||||
width: 26.25rem;
|
||||
background: linear-gradient(135deg, #ec7bae 50.41%, #9600b8 70.41%);
|
||||
transform: rotate(45deg);
|
||||
transition: transform 0.3s ease-in-out;
|
||||
z-index: 5;
|
||||
}
|
||||
.intro-button-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
transition: all 0.5s ease-in-out;
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
padding: 1rem 1.5rem;
|
||||
text-align: left;
|
||||
color: white;
|
||||
font-size: 1.65rem;
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
line-height: 130.023%;
|
||||
letter-spacing: 0.0075rem;
|
||||
}
|
||||
.intro-button-text strong {
|
||||
font-size: 2.625rem;
|
||||
font-weight: 600;
|
||||
line-height: 130.023%;
|
||||
letter-spacing: 0.013125rem;
|
||||
}
|
||||
.intro-button-link span {
|
||||
position: absolute;
|
||||
display: block;
|
||||
pointer-events: none;
|
||||
}
|
||||
.intro-button-link span:nth-child(1) {
|
||||
height: 8px;
|
||||
width: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background: linear-gradient(to right, rgba(0, 0, 0, 0), #f6e58d);
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
transform: translateX(-100%);
|
||||
animation: span1 8s linear infinite;
|
||||
animation-delay: 1s;
|
||||
}
|
||||
@keyframes span1 {
|
||||
0% {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
100% {
|
||||
transform: translateX(100%);
|
||||
}
|
||||
}
|
||||
.intro-button-link span:nth-child(2) {
|
||||
width: 8px;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
right: 0;
|
||||
background: linear-gradient(to bottom, rgba(0, 0, 0, 0), #f6e58d);
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
transform: translateY(100%);
|
||||
animation: span2 4s linear infinite;
|
||||
animation-delay: 5s;
|
||||
}
|
||||
@keyframes span2 {
|
||||
0% {
|
||||
transform: translateY(-100%);
|
||||
}
|
||||
100% {
|
||||
transform: translateY(100%);
|
||||
}
|
||||
}
|
||||
.intro-button-link span:nth-child(3) {
|
||||
height: 8px;
|
||||
width: 100%;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
background: linear-gradient(to left, rgba(0, 0, 0, 0), #f6e58d);
|
||||
border-top-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
transform: translateX(100%);
|
||||
animation: span3 8s linear infinite;
|
||||
animation-delay: 7s;
|
||||
}
|
||||
@keyframes span3 {
|
||||
0% {
|
||||
transform: translateX(100%);
|
||||
}
|
||||
100% {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
}
|
||||
.intro-button-link:hover span {
|
||||
animation-play-state: paused;
|
||||
}
|
||||
@media (width < 768px) {
|
||||
.intro-header {
|
||||
padding-bottom: 9rem;;
|
||||
}
|
||||
.intro-button-link {
|
||||
height: 6.25rem;
|
||||
min-width: auto;
|
||||
border-radius: 0;
|
||||
}
|
||||
.intro-button-text {
|
||||
display: inline;
|
||||
padding-top: .5rem;
|
||||
}
|
||||
}
|
||||
@media (width >= 768px) {
|
||||
.intro-button {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
max-width: 29.375rem;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.intro-button-link:hover {
|
||||
transition: all .5s;
|
||||
transform: rotate(-3deg) scale(1.125);
|
||||
}
|
||||
}
|
||||
|
||||
.intro-text {
|
||||
z-index: 1;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
align-items: center;
|
||||
text-align: left;
|
||||
margin-bottom: 0;
|
||||
background: #fff;
|
||||
position: relative;
|
||||
}
|
||||
.intro-text-body {
|
||||
padding: 2.5rem 1.063rem 0.75rem;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
}
|
||||
.intro-text-lead {
|
||||
width: 100%;
|
||||
font-size: 1.5rem;
|
||||
margin: 0 0 1.5rem;
|
||||
}
|
||||
@media (width >= 768px) {
|
||||
.intro-button + .intro-text-body {
|
||||
padding-top: 7rem;
|
||||
}
|
||||
}
|
||||
@media (width >= 992px) {
|
||||
.intro-header {
|
||||
padding-bottom: 9rem;;
|
||||
}
|
||||
.intro-text,
|
||||
.intro-text-body {
|
||||
border-radius: 0.75rem;
|
||||
}
|
||||
.intro-text {
|
||||
box-shadow: var(--intro-shadow);
|
||||
max-width: min(60rem, 100vw - 4rem);
|
||||
margin: 0 auto 6rem;
|
||||
}
|
||||
.intro-text-narrow {
|
||||
max-width: min(50rem, 100vw - 4rem);
|
||||
}
|
||||
.intro-text-wide {
|
||||
max-width: min(67rem, 100vw - 4rem);
|
||||
}
|
||||
.intro-text-full {
|
||||
max-width: min(74rem, 100vw - 4rem);
|
||||
}
|
||||
.intro-text-body {
|
||||
padding-left: 4.5rem;
|
||||
padding-right: 4.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.intro-text-body .block {
|
||||
position: relative;
|
||||
}
|
||||
.intro-text-body .block-title {
|
||||
margin: 1em 0 .8em;
|
||||
}
|
||||
.intro-text-body .block-title span {
|
||||
display: inline-block;
|
||||
padding: 10px 30px 14px;
|
||||
margin: 30px 20px 0;
|
||||
background: white;
|
||||
border: 5px solid;
|
||||
border-radius: 30px;
|
||||
box-shadow: 0 0 0 5px white, inset 0 0 0 5px white;
|
||||
border-color: orangered;
|
||||
transform: rotate(-3deg) translateY(-25%);
|
||||
}
|
||||
.intro-text-body .block-title:before {
|
||||
content: "";
|
||||
height: 5px;
|
||||
position: absolute;
|
||||
top: 50px;
|
||||
left: -15%;
|
||||
width: 130%;
|
||||
z-index: -5;
|
||||
background: orangered;
|
||||
box-shadow: 0 0 0 5px white, 0 -10px 0 5px white;
|
||||
transform: rotate(2deg) translateY(-50%);
|
||||
transform-origin: top left;
|
||||
}
|
||||
.intro-text-body .block-title:after {
|
||||
content: "";
|
||||
height: 120%;
|
||||
position: absolute;
|
||||
top: 42px;
|
||||
left: -25%;
|
||||
width: 150%;
|
||||
z-index: -10;
|
||||
background: var(--intro-bg-block-1);
|
||||
transform: rotate(2deg);
|
||||
}
|
||||
.intro-text-body .block:nth-of-type(6n+1) .block-title:after {
|
||||
background: var(--intro-bg-block-1);
|
||||
}
|
||||
.intro-text-body .block:nth-of-type(6n+2) .block-title:after {
|
||||
background: var(--intro-bg-block-2);
|
||||
}
|
||||
.intro-text-body .block:nth-of-type(6n+3) .block-title:after {
|
||||
background: var(--intro-bg-block-3);
|
||||
}
|
||||
.intro-text-body .block:nth-of-type(6n+4) .block-title:after {
|
||||
background: var(--intro-bg-block-4);
|
||||
}
|
||||
.intro-text-body .block:nth-of-type(6n+5) .block-title:after {
|
||||
background: var(--intro-bg-block-5);
|
||||
}
|
||||
.intro-text-body .block:nth-of-type(6n+6) .block-title:after {
|
||||
background: var(--intro-bg-block-6);
|
||||
}
|
||||
|
||||
#intro-badges {
|
||||
min-height: 3.2rem;
|
||||
text-align: center;
|
||||
visibility: hidden;
|
||||
}
|
||||
#intro-badges img {
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
#intro-release:not([src]) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
// Intro Footer
|
||||
|
||||
.intro-footer {
|
||||
width: 100%;
|
||||
background-color: black;
|
||||
color: var(--intro-color-gray);
|
||||
padding-bottom: 2rem;
|
||||
}
|
||||
|
||||
.intro-footer-body {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
margin: 0 auto;
|
||||
padding: 0 10.625rem;
|
||||
max-width: 80rem;
|
||||
}
|
||||
.intro-footer-body a:visited {
|
||||
color: var(--intro-color-gray);
|
||||
}
|
||||
// The footer has its own dark surface, so its links don't inherit the theme's link colors.
|
||||
.intro-footer-links a {
|
||||
color: currentColor;
|
||||
text-decoration: underline;
|
||||
transition: font-size 0.2s, text-decoration-color 0.2s;
|
||||
}
|
||||
.intro-footer-links a:focus-visible {
|
||||
outline: var(--intro-focus-outline);
|
||||
outline-offset: var(--intro-focus-outline-offset);
|
||||
}
|
||||
.intro-footer-links a:hover,
|
||||
.intro-footer-links a:hover:visited {
|
||||
text-decoration-color: var(--intro-color-link);
|
||||
}
|
||||
.intro-footer-logo,
|
||||
.intro-footer-links {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
.intro-footer-logo {
|
||||
max-height: 12.625rem;
|
||||
}
|
||||
.intro-footer-logo svg {
|
||||
width: 100%;
|
||||
}
|
||||
.intro-footer-links {
|
||||
gap: 1.875rem;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 2rem;
|
||||
}
|
||||
@media (width < 768px) {
|
||||
.intro-footer-logo {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@media (width < 992px) {
|
||||
.intro-footer-body {
|
||||
padding: 0 1rem;
|
||||
}
|
||||
}
|
||||
36
build.rs
|
|
@ -1,6 +1,40 @@
|
|||
use pagetop_build::StaticFilesBundle;
|
||||
use pagetop_build::{StaticFilesBundle, compile_scss, copy_dir, copy_file, minify_js};
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
// Regenera `static/` desde cero sólo si hay cambios en `assets/`.
|
||||
println!("cargo:rerun-if-changed=assets");
|
||||
let _ = std::fs::remove_dir_all("static");
|
||||
|
||||
// Copia sin transformar. `assets/scss/` queda fuera porque sólo contiene fuentes SCSS.
|
||||
copy_file("assets/banner.png", "static/banner.png")?;
|
||||
copy_file("assets/favicon.ico", "static/favicon.ico")?;
|
||||
copy_dir("assets/img", "static/img")?;
|
||||
copy_dir("assets/js", "static/js")?;
|
||||
|
||||
// CSS: compila los estilos del tema Basic.
|
||||
compile_scss("assets/scss/basic.scss", "static/css/basic.min.css")?;
|
||||
|
||||
// CSS: compila los estilos del componente `Intro`, independientes del tema.
|
||||
compile_scss("assets/scss/intro.scss", "static/css/intro.min.css")?;
|
||||
|
||||
// JS: minifica el manejo de `Dialog` del tema Basic.
|
||||
minify_js(
|
||||
"assets/js/basic.dialog.init.js",
|
||||
"static/js/basic.dialog.min.js",
|
||||
)?;
|
||||
|
||||
// JS: minifica el aviso del resumen de `ListView` a los lectores de pantalla.
|
||||
minify_js("assets/js/list-view.js", "static/js/list-view.min.js")?;
|
||||
|
||||
// JS: minifica las marcas de cambios sin aplicar de `ListFilter`, independientes del tema.
|
||||
minify_js("assets/js/list-filter.js", "static/js/list-filter.min.js")?;
|
||||
|
||||
// JS: minifica la integración de `Dropdown` con `accessible-menu` del tema Basic.
|
||||
minify_js(
|
||||
"assets/js/basic.dropdown.init.js",
|
||||
"static/js/basic.dropdown.min.js",
|
||||
)?;
|
||||
|
||||
StaticFilesBundle::from_dir("./static", None)
|
||||
.with_name("assets")
|
||||
.build()
|
||||
|
|
|
|||
405
config/reference.toml
Normal file
|
|
@ -0,0 +1,405 @@
|
|||
# ==================================================================================================
|
||||
# Referencia de opciones de configuración de PageTop y sus extensiones.
|
||||
#
|
||||
# Este fichero NO se carga: sólo documenta todas las opciones disponibles con su valor por defecto.
|
||||
# Para usarlas, copia las que necesites en alguno de los ficheros de la cascada de configuración,
|
||||
# que se aplican en este orden (cada uno sobrescribe al anterior):
|
||||
#
|
||||
# 1. config/common.toml -> ajustes comunes a todos los entornos.
|
||||
# 2. config/{rm}.toml -> ajustes del modo de ejecución (p. ej. default.toml).
|
||||
# 3. config/local.{rm}.toml -> ajustes locales del modo de ejecución (no se versiona).
|
||||
# 4. config/local.toml -> ajustes locales para cualquier entorno (no se versiona).
|
||||
#
|
||||
# Donde {rm} es el valor de la variable de entorno PAGETOP_RUN_MODE ("default" si no se define o
|
||||
# está vacía). El directorio config/ puede cambiarse con la variable de entorno CONFIG_DIR (vacía
|
||||
# equivale a no definirla).
|
||||
#
|
||||
# Por último, las variables de entorno con el prefijo PAGETOP_ sobrescriben cualquier opción de los
|
||||
# ficheros: sección y clave en mayúsculas, con cada nivel separado por dos guiones bajos (p. ej.
|
||||
# PAGETOP_DATABASE__DB_PASS para db_pass de [database], o PAGETOP_MAIL__SMTP__PASSWORD para password
|
||||
# de [mail.smtp]). Una variable vacía equivale a no definirla. No sirven para listas ni para claves
|
||||
# con punto, como "mail.queue" en [cron.jobs."mail.queue"].
|
||||
#
|
||||
# Las opciones comentadas no tienen valor por defecto; se muestran con un valor de ejemplo.
|
||||
#
|
||||
# En las opciones del núcleo con valores fijos ("Full", "Nearest"...) da igual escribir el valor en
|
||||
# mayúsculas o minúsculas.
|
||||
#
|
||||
# Una clave desconocida dentro de una sección (p. ej. una errata) o un valor no válido impiden
|
||||
# arrancar la aplicación, con un mensaje que indica el problema. Una sección que no corresponde a
|
||||
# PageTop ni a ninguna extensión habilitada se ignora, con un aviso al arrancar.
|
||||
# ==================================================================================================
|
||||
|
||||
|
||||
# **< PageTop (núcleo) >****************************************************************************
|
||||
|
||||
[app]
|
||||
name = "PageTop App" # Nombre de la aplicación.
|
||||
#language = "es-ES" # Idioma predeterminado (BCP 47: "es-ES", "en-US"...). Sin
|
||||
# valor, o si no es válido, el idioma se negocia con otras
|
||||
# fuentes (cabecera Accept-Language, idioma de respaldo).
|
||||
lang_negotiation = "Full" # Estrategia para resolver el idioma de cada petición:
|
||||
# "Full" -> ?lang de la URL, idioma del usuario,
|
||||
# 'language', Accept-Language y respaldo.
|
||||
# "NoQuery" -> igual que "Full" pero sin ?lang.
|
||||
# "ConfigOnly" -> sólo 'language' o el idioma de respaldo
|
||||
# (no se ofrece elegir idioma al usuario).
|
||||
timezone = "UTC" # Zona horaria del sitio (IANA: "UTC", "Europe/Madrid"...);
|
||||
# da igual escribirla en mayúsculas o minúsculas.
|
||||
# Se aplica a anónimos y a usuarios sin zona horaria propia,
|
||||
# y a todos si 'timezone_per_user' es false.
|
||||
timezone_regions = "" # Regiones de las zonas horarias que se ofrecen, separadas
|
||||
# por comas (p. ej. "Europe, America"), elegidas entre
|
||||
# "Africa", "America", "Antarctica", "Arctic", "Asia",
|
||||
# "Atlantic", "Australia", "Europe", "Indian" y "Pacific".
|
||||
# "Etc" (Etc/UTC) se ofrece siempre. Si está vacío se ofrecen
|
||||
# todas. Los nombres desconocidos se ignoran con un aviso al
|
||||
# arrancar; si ninguno es válido se ofrecen todas, y se avisa
|
||||
# también si la región de 'timezone' queda fuera de las
|
||||
# ofrecidas. No cambia las zonas ya asignadas a los usuarios
|
||||
# (las conservan), sólo las nuevas elecciones. Es el valor
|
||||
# por defecto del selector de zona horaria; la aplicación
|
||||
# puede cambiarlo en un formulario concreto.
|
||||
timezone_order = "Nearest" # Orden de esas regiones al elegir zona horaria:
|
||||
# "Nearest" -> la del sitio primero, si tiene
|
||||
# región, y luego por cercanía de su
|
||||
# desfase horario.
|
||||
# "Alphabetical" -> por el nombre de la región traducido al
|
||||
# idioma de la página.
|
||||
# "Listed" -> en el orden de 'timezone_regions' (sin
|
||||
# regiones, como "Alphabetical").
|
||||
# Es el valor por defecto del selector de zona horaria; la
|
||||
# aplicación puede cambiarlo en un formulario concreto.
|
||||
timezone_per_user = true # Si cada usuario puede tener su propia zona horaria (true) o
|
||||
# se usa siempre 'timezone' (false). Con false no se ofrece
|
||||
# elegirla y la guardada se conserva por si se reactiva.
|
||||
theme = "Basic" # Tema predeterminado: "Basic" o el de una extensión enlazada
|
||||
# por la aplicación ("Aliner", "Bootsier"...). Si no está
|
||||
# habilitado se usa "Basic", con un aviso al arrancar.
|
||||
# Se aplica a anónimos y a usuarios sin tema propio, y a
|
||||
# todos si 'theme_per_user' es false.
|
||||
theme_per_user = false # Si cada usuario puede tener su propio tema (true) o se usa
|
||||
# siempre 'theme' (false). Con false no se ofrece elegirlo y
|
||||
# el guardado se conserva por si se activa.
|
||||
admin_path = "/admin" # Ruta raíz del panel de administración. Debe empezar por
|
||||
# "/", sin "/" final; cada tramo sólo admite letras y dígitos
|
||||
# ASCII, "-", "_", "." y "~" (sin ser "." ni ".."). Una no
|
||||
# válida impide arrancar.
|
||||
startup_banner = true # Muestra al arrancar un banner ASCII con el nombre de la
|
||||
# aplicación (true) o no (false).
|
||||
|
||||
[dev]
|
||||
pagetop_static_dir = "" # Directorio static/ de PageTop para servir sus archivos
|
||||
# estáticos desde disco (editables sin recompilar). Ruta
|
||||
# absoluta o relativa al proyecto (o, al ejecutar el binario,
|
||||
# al directorio de trabajo). Vacío -> se sirven los incluidos
|
||||
# en el binario.
|
||||
|
||||
[log]
|
||||
enabled = true # Activa (true) o desactiva (false) las trazas.
|
||||
tracing = "Info" # Filtro de trazas: "Error", "Warn", "Info", "Debug" o
|
||||
# "Trace", o combinaciones separadas por comas por módulo,
|
||||
# p. ej. "Info,pagetop=Debug,sqlx=Warn". Si no es válido se
|
||||
# usa "Info", con un aviso al arrancar.
|
||||
rolling = "Stdout" # Salida de las trazas:
|
||||
# "Stdout" -> terminal, sin archivos.
|
||||
# "Daily", "Hourly", "Minutely" -> archivos con rotación.
|
||||
# "Endless" -> un único archivo, sin rotación.
|
||||
path = "log" # Directorio de los archivos de traza (si rolling != Stdout).
|
||||
prefix = "tracing.log" # Prefijo de los archivos de traza (si rolling != Stdout).
|
||||
format = "Full" # Formato: "Full", "Compact", "Pretty" o "Json".
|
||||
|
||||
[server]
|
||||
bind_address = "localhost" # Dirección de enlace del servidor web.
|
||||
bind_port = 8080 # Puerto de escucha del servidor web.
|
||||
max_body_size = 2_097_152 # Tamaño máximo en bytes del cuerpo de una petición que se
|
||||
# lee entero en memoria (2 MiB): formularios, JSON... y la
|
||||
# suma de los campos de texto de un formulario con archivos.
|
||||
# Una petición mayor se rechaza con 413. 0 -> sin límite.
|
||||
client_ip_header = "" # Cabecera con la IP del cliente tras un proxy inverso:
|
||||
# "X-Forwarded-For", "X-Real-IP"... (con varias direcciones
|
||||
# vale la última; "Forwarded" no se admite). Vacía -> la IP
|
||||
# de la conexión. Sólo si todas las peticiones pasan por el
|
||||
# proxy y éste escribe siempre la cabecera.
|
||||
trusted_origins = [] # Otros orígenes desde los que un navegador puede enviar
|
||||
# peticiones que cambian estado (POST, PUT...), p. ej.
|
||||
# ["https://app.example.com"]. Sin ellos, se rechazan con 403
|
||||
# (protección CSRF). Formato: esquema://servidor[:puerto].
|
||||
secure_cookies = false # Marca las cookies como Secure, para que sólo viajen por
|
||||
# HTTPS. Activar si la aplicación se sirve por HTTPS, aunque
|
||||
# el HTTPS lo atienda un proxy inverso; si es por HTTP, el
|
||||
# navegador no las guardaría (algunos sí en localhost).
|
||||
|
||||
[upload]
|
||||
dir = "uploads" # Directorio de los archivos subidos, absoluto o relativo al
|
||||
# directorio de trabajo. Se crea al guardar el primero.
|
||||
max_request_size = 33_554_432 # Tamaño máximo en bytes de un envío 'multipart/form-data'
|
||||
# completo (32 MiB), con todos sus archivos y campos;
|
||||
# sustituye a 'server.max_body_size' en estas peticiones.
|
||||
# Para admitir varios archivos debe ser varias veces mayor
|
||||
# que 'max_file_size'. Uno mayor se rechaza con 413. 0 ->
|
||||
# sin límite.
|
||||
max_file_size = 8_388_608 # Tamaño máximo en bytes de cada archivo por separado
|
||||
# (8 MiB). La aplicación puede cambiarlo en una subida
|
||||
# concreta. 0 -> sólo limita 'max_request_size'.
|
||||
max_files = 20 # Número máximo de archivos de un mismo envío. La aplicación
|
||||
# puede cambiarlo en una subida concreta. 0 -> sin límite.
|
||||
|
||||
|
||||
# **< pagetop-seaorm >******************************************************************************
|
||||
|
||||
[database]
|
||||
db_type = "" # Motor: "mysql" (o "mariadb"), "postgres" (o "postgresql")
|
||||
# o "sqlite". Obligatorio: sin él la aplicación no arranca.
|
||||
db_name = "" # Nombre (mysql/postgres) o referencia (sqlite) de la BD.
|
||||
db_user = "" # Usuario de conexión (mysql/postgres).
|
||||
db_pass = "" # Contraseña de conexión (mysql/postgres).
|
||||
db_host = "localhost" # Servidor de la base de datos (mysql/postgres).
|
||||
#db_port = 5432 # Puerto (mysql/postgres). Sin valor -> 3306 para MySQL y
|
||||
# 5432 para PostgreSQL.
|
||||
max_pool_size = 5 # Número máximo de conexiones simultáneas.
|
||||
|
||||
|
||||
# **< pagetop-mail >********************************************************************************
|
||||
|
||||
[mail]
|
||||
transport = "log" # Entrega de los correos:
|
||||
# "smtp" -> servidor SMTP ([mail.smtp]).
|
||||
# "sendmail" -> programa sendmail local ([mail.sendmail]).
|
||||
# "file" -> un archivo .eml por correo ([mail.file]).
|
||||
# "log" -> se escriben en las trazas, sin enviarlos.
|
||||
# "memory" -> se guardan en memoria (sólo pruebas).
|
||||
#from = "Mi Aplicación <no-reply@example.com>"
|
||||
# Remitente por defecto, con o sin nombre. Sin valor, cada
|
||||
# correo debe indicar el suyo para enviarse (salvo con
|
||||
# "log"). Los de pagetop-user no lo indican: configúralo
|
||||
# siempre.
|
||||
#reply_to = "soporte@example.com"
|
||||
# Dirección de respuesta por defecto.
|
||||
#redirect_to = "pruebas@example.com"
|
||||
# Entrega todos los correos sólo a esta dirección, sin
|
||||
# cambiar sus cabeceras (entornos de pruebas o
|
||||
# preproducción).
|
||||
#base_url = "https://example.com"
|
||||
# URL pública para los enlaces de los correos. Sin valor,
|
||||
# http://{bind_address}:{bind_port} (sólo para desarrollo).
|
||||
previews = false # Vistas previas de los correos en /mail/preview. Sólo en
|
||||
# desarrollo: cualquiera que conozca la ruta las ve.
|
||||
delivery_timeout_secs = 300 # Tiempo máximo de cada entrega, en segundos (1 a 86400),
|
||||
# incluida la espera de turno. Recomendado: 300. Reducirlo
|
||||
# (60 o 120) con un servidor cercano y rápido detecta antes
|
||||
# los fallos, pero debe superar con holgura 2 x timeout_secs
|
||||
# de [mail.smtp], y da por fallidos más correos que un
|
||||
# servidor lento sí acepta (con la cola, se entregan por
|
||||
# duplicado). Aumentarlo sólo con servidores muy lentos o
|
||||
# adjuntos grandes: los correos retienen su turno más tiempo
|
||||
# y, con la cola, una entrega interrumpida espera el triple
|
||||
# de este tiempo para reintentarse.
|
||||
max_waiting = 100 # Correos que pueden esperar turno por cada envío simultáneo
|
||||
# (pool_max_size o max_concurrent); con más, la entrega falla
|
||||
# enseguida (con la feature "queue", send_later() los deja en
|
||||
# la cola). 0 -> ninguno espera. No se recomiendan valores
|
||||
# mayores: cada correo en espera ocupa memoria con sus
|
||||
# adjuntos, y la espera cuenta en delivery_timeout_secs, así
|
||||
# que los últimos fallarían igualmente. Con poca memoria o
|
||||
# adjuntos grandes, conviene reducirlo.
|
||||
|
||||
[mail.smtp] # Servidor SMTP (transport = "smtp").
|
||||
host = "localhost" # Servidor.
|
||||
#port = 587 # Puerto. Sin valor -> 465 con "tls", 587 con "starttls" y 25
|
||||
# en otro caso.
|
||||
security = "starttls" # Cifrado de la conexión:
|
||||
# "none" -> sin cifrar (servidores de pruebas).
|
||||
# "opportunistic" -> STARTTLS si el servidor lo ofrece.
|
||||
# "starttls" -> STARTTLS obligatorio (puerto 587).
|
||||
# "tls" -> cifrada desde el inicio (puerto 465).
|
||||
#username = "no-reply@example.com" # Usuario. Sin valor, no se autentica.
|
||||
#password = "secreto" # Contraseña. Mejor en config/local.toml (no se versiona).
|
||||
#hello_name = "example.com" # Nombre para EHLO. Sin valor, el nombre del equipo.
|
||||
timeout_secs = 60 # Espera máxima de cada orden al servidor, en segundos. Cada
|
||||
# entrega tiene además delivery_timeout_secs de [mail]. Con
|
||||
# security = "tls" no cubre el saludo TLS: un servidor que no
|
||||
# responde ahí retiene un envío simultáneo. Si el servidor lo
|
||||
# admite, es preferible security = "starttls".
|
||||
pool_max_size = 10 # Envíos simultáneos como máximo (los demás esperan turno, y
|
||||
# la espera cuenta en delivery_timeout_secs), y conexiones
|
||||
# que se conservan para reutilizarlas. Por cada envío esperan
|
||||
# como mucho max_waiting correos; con más, falla enseguida.
|
||||
accept_invalid_certs = false # Acepta certificados no válidos. PELIGROSO: sólo pruebas.
|
||||
|
||||
[mail.sendmail] # Programa sendmail (transport = "sendmail").
|
||||
#command = "/usr/sbin/sendmail" # Programa. Sin valor, "sendmail" del PATH.
|
||||
max_concurrent = 10 # Correos que se entregan a la vez, cada uno con su proceso
|
||||
# sendmail; los demás esperan turno (max_waiting por entrega
|
||||
# como mucho; con más, la entrega falla enseguida). Con un
|
||||
# servidor de correo local no se recomiendan valores mayores:
|
||||
# apenas aceleran el envío, porque acepta cada correo al
|
||||
# momento, y en una avalancha multiplican los procesos que
|
||||
# compiten con la aplicación por memoria y CPU, y los correos
|
||||
# en espera. Si el programa envía cada correo a un servidor
|
||||
# remoto (msmtp, ssmtp), no superar el límite de conexiones
|
||||
# simultáneas de ese servidor.
|
||||
|
||||
[mail.file] # Archivos de correo (transport = "file").
|
||||
dir = "mail" # Directorio de los archivos .eml. Se crea si no existe.
|
||||
max_concurrent = 10 # Correos que se guardan a la vez; los demás esperan turno
|
||||
# (max_waiting por cada uno como mucho; con más, la entrega
|
||||
# falla enseguida). No se recomiendan valores mayores: apenas
|
||||
# aceleran el guardado en el mismo disco, y en una avalancha
|
||||
# ocupan más hilos de la aplicación, compartidos con otras
|
||||
# tareas (p. ej. el cálculo de contraseñas), y más correos en
|
||||
# espera.
|
||||
|
||||
[mail.queue] # Cola de envío (sólo con la feature "queue"). El ritmo es el
|
||||
# del trabajo "mail.queue" en [cron.jobs."mail.queue"].
|
||||
batch_size = 50 # Correos como máximo en cada ejecución, uno tras otro.
|
||||
max_attempts = 5 # Intentos de cada correo, contando el primero.
|
||||
retry_base_secs = 60 # Espera tras el primer fallo; se duplica en cada intento,
|
||||
# hasta max_retry_secs.
|
||||
max_retry_secs = 86400 # Espera máxima entre dos intentos (1 a 31536000, un año).
|
||||
# Recomendado: 86400 (un día); con los demás valores por
|
||||
# defecto no se alcanza. Reducirlo reintenta antes tras una
|
||||
# caída larga, con más intentos mientras dura; aumentarlo
|
||||
# puede entregar correos con días de retraso, cuando quizá ya
|
||||
# no sirven (enlaces caducados).
|
||||
keep_failed_days = 30 # Días que se conservan los fallidos (0 = siempre).
|
||||
|
||||
|
||||
# **< pagetop-cron >********************************************************************************
|
||||
|
||||
[cron]
|
||||
mode = "internal" # Cómo se ejecutan los trabajos programados:
|
||||
# "internal" -> con el planificador de la
|
||||
# propia aplicación.
|
||||
# "external" -> cuando un programa externo (crontab,
|
||||
# systemd) llama a POST /cron con la cabecera
|
||||
# "Authorization: Bearer {trigger_token}".
|
||||
# "off" -> nunca de forma automática,
|
||||
# sólo bajo demanda.
|
||||
# Con varias instancias, "internal" sólo en una ("off" en las
|
||||
# demás), o "external" en todas.
|
||||
#trigger_token = "..." # Clave secreta del modo "external": 16 o más letras,
|
||||
# dígitos, "-" o "_" (p. ej. de "openssl rand -hex 32").
|
||||
# Mejor en config/local.toml.
|
||||
trigger_interval_secs = 60 # Segundos entre dos llamadas del modo "external": cada una
|
||||
# ejecuta lo programado en el último intervalo, así que debe
|
||||
# llegar una, y sólo una, por intervalo.
|
||||
shutdown_timeout_secs = 30 # Espera máxima, al detener la aplicación, a que terminen los
|
||||
# trabajos en curso.
|
||||
|
||||
[cron.jobs."shop.cleanup"] # Ajustes de un trabajo, por su clave (opcional).
|
||||
enabled = true # false -> no se ejecuta de forma automática.
|
||||
#schedule = "*/10 * * * *" # Sustituye su programación: expresión cron, "@daily",
|
||||
# "@every 5m" (cada 5 min) o "@delay 30s"
|
||||
# (30 s tras terminar).
|
||||
#timeout_secs = 600 # Sustituye su tiempo máximo por ejecución. 0 -> sin límite.
|
||||
|
||||
|
||||
# **< pagetop-user >********************************************************************************
|
||||
|
||||
[user]
|
||||
allow_registration = true # Permite que los visitantes creen su propia cuenta.
|
||||
require_email_verification = false # Las cuentas nuevas quedan pendientes ("Pending") en lugar
|
||||
# de activas hasta confirmar la dirección desde el enlace del
|
||||
# correo de verificación que se envía al registrarse.
|
||||
identity_policy = "strict" # Nombres de usuario que se aceptan:
|
||||
# "strict" -> letras ASCII sin tildes, dígitos, ".",
|
||||
# "_" y "-", de 3 a 32 caracteres.
|
||||
# "unicode" -> letras y dígitos de cualquier alfabeto,
|
||||
# sin mezclarlos, ".", "_" y "-",
|
||||
# de 3 a 32.
|
||||
# "permissive" -> como "unicode", más espacios simples, "'"
|
||||
# y "+", de 3 a 60.
|
||||
# Con cualquiera: nunca "@", sin distinguir mayúsculas y sin
|
||||
# nombres que se confundan con otro existente.
|
||||
|
||||
max_failed_logins = 5 # Intentos fallidos seguidos que bloquean la cuenta, también
|
||||
# los de la contraseña actual al cambiar la contraseña o el
|
||||
# email. Limita también los fallos de cada identificador
|
||||
# tecleado, exista o no la cuenta. Con un proveedor externo
|
||||
# (LDAP...), debe ser menor que su propio umbral de bloqueo.
|
||||
# 0 -> nunca.
|
||||
failed_login_window_secs = 900 # Segundos desde el último fallo en los que el siguiente se
|
||||
# suma al recuento (15 minutos); si no, empieza de nuevo.
|
||||
locked_for_secs = 600 # Duración del bloqueo de la cuenta en segundos (10 minutos).
|
||||
# Después se dispone otra vez de todos los intentos.
|
||||
|
||||
max_password_resets = 3 # Máximo de solicitudes de recuperación de contraseña de una
|
||||
# misma cuenta en un periodo de 'password_reset_window_secs'
|
||||
# segundos; las siguientes no envían correo. 0 -> sin límite.
|
||||
password_reset_window_secs = 3600 # Duración del periodo en segundos (1 hora).
|
||||
|
||||
max_email_changes = 3 # Máximo de cambios de email que puede pedir una misma cuenta
|
||||
# en un periodo de 'email_change_window_secs' segundos; los
|
||||
# siguientes dan error y no envían correo. 0 -> sin límite.
|
||||
email_change_window_secs = 3600 # Duración del periodo en segundos (1 hora).
|
||||
|
||||
max_ip_requests = 20 # Máximo de registros, recuperaciones de contraseña y cambios
|
||||
# de email desde una misma IP (IPv6 por su red /64) en un
|
||||
# periodo de 'ip_request_window_secs' segundos. Tras un proxy
|
||||
# inverso requiere 'server.client_ip_header'. Cada instancia
|
||||
# cuenta las suyas. 0 -> sin límite.
|
||||
ip_request_window_secs = 3600 # Duración del periodo en segundos (1 hora).
|
||||
max_ip_failed_logins = 30 # Máximo de inicios de sesión fallidos desde una misma IP en
|
||||
# un periodo de 'ip_failed_login_window_secs' segundos; los
|
||||
# siguientes se rechazan sin comprobar la contraseña. Frena
|
||||
# probar contraseñas en muchas cuentas. Sin IP conocida y
|
||||
# con un proveedor externo activo, es el máximo para todas
|
||||
# esas peticiones juntas. 0 -> sin límite.
|
||||
ip_failed_login_window_secs = 900 # Duración del periodo en segundos (15 minutos).
|
||||
|
||||
[user.login] # Inicio de sesión.
|
||||
sources = ["local"] # Fuentes que comprueban las credenciales, en orden: "local"
|
||||
# (la contraseña guardada en PageTop) y los proveedores de
|
||||
# autenticación declarados (p. ej. "ldap"). Uno desconocido
|
||||
# o repetido, o la lista vacía, impiden arrancar.
|
||||
local_fallback = "released" # Si "local" no está en 'sources', qué cuentas pueden aún
|
||||
# entrar con su contraseña local:
|
||||
# "none" -> ninguna.
|
||||
# "released" -> las que un proveedor libera.
|
||||
# "admins" -> además, cualquier administrador (acceso
|
||||
# de emergencia si el proveedor cae).
|
||||
strict = false # Dificulta que el navegador recuerde o autorrellene las
|
||||
# credenciales en el formulario de acceso.
|
||||
|
||||
[user.session] # Sesiones de usuario.
|
||||
cookie_name = "pagetop" # Nombre de la cookie de sesión. Se marca como Secure
|
||||
# según 'server.secure_cookies'.
|
||||
idle_secs = 7200 # Segundos sin uso tras los que caduca la sesión si no se
|
||||
# marca "recordarme" al acceder (2 horas). Se cuentan desde
|
||||
# la última petición.
|
||||
remember_idle_secs = 1209600 # Segundos sin uso tras los que caduca la sesión si se marca
|
||||
# "recordarme" al acceder (14 días). Se cuentan igual.
|
||||
write_interval_secs = 60 # Segundos mínimos entre dos escrituras de la misma sesión en
|
||||
# la base de datos para prorrogarla. La sesión puede caducar
|
||||
# hasta este tiempo antes de lo configurado. Subirlo (p. ej.
|
||||
# 180) reduce escrituras con mucho tráfico o una base de
|
||||
# datos lenta; bajarlo (o 0, escribir siempre) da más
|
||||
# precisión si las sesiones caducan tras pocos minutos sin
|
||||
# uso.
|
||||
|
||||
[user.password] # Contraseñas, cifradas con Argon2id. Si cambia cualquiera de
|
||||
# los tres costes, cada contraseña se vuelve a cifrar en el
|
||||
# siguiente acceso de su usuario.
|
||||
argon2_m_cost = 19456 # Coste de memoria en KiB.
|
||||
argon2_t_cost = 2 # Coste de tiempo (número de iteraciones).
|
||||
argon2_p_cost = 1 # Grado de paralelismo (número de hilos).
|
||||
min_length = 8 # Longitud mínima de las contraseñas, en caracteres.
|
||||
|
||||
[user.seed] # Primer administrador, creado si no existe ningún usuario.
|
||||
admin_username = "admin" # Nombre de usuario, válido según "identity_policy".
|
||||
admin_email = "admin@example.com" # Correo electrónico.
|
||||
#admin_password = "cambiar" # Contraseña. Sin valor -> se genera una aleatoria y se
|
||||
# muestra una sola vez por la salida estándar al crearlo.
|
||||
|
||||
[user.admin]
|
||||
list_page_size = 20 # Filas por página en los listados de administración
|
||||
# (usuarios, roles...).
|
||||
|
||||
|
||||
# **< pagetop-bootsier >****************************************************************************
|
||||
|
||||
[bootsier]
|
||||
max_width = "1440px" # Ancho máximo de la página ("100%", "90rem", "1440px"...).
|
||||
static_dir = "" # Directorio static/ de pagetop-bootsier para servir sus
|
||||
# archivos estáticos desde disco, como pagetop_static_dir.
|
||||
16
config/test.toml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
[app]
|
||||
name = "Testing"
|
||||
# Lets the tests check that a user's own theme is applied (it is off by default).
|
||||
theme_per_user = true
|
||||
|
||||
[server]
|
||||
bind_port = 9000
|
||||
trusted_origins = ["https://Trusted.example/"]
|
||||
secure_cookies = true
|
||||
|
||||
[upload]
|
||||
dir = "target/test-uploads"
|
||||
|
||||
[test]
|
||||
string_value = "Modified value"
|
||||
float_value = 8.7654
|
||||
|
|
@ -2,5 +2,5 @@ use pagetop::prelude::*;
|
|||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::new().run()?.await
|
||||
Application::new().await.run().await
|
||||
}
|
||||
|
|
|
|||
47
examples/basic-nav.rs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
struct NavDemo;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for NavDemo {
|
||||
fn dependencies(&self) -> Vec<ExtensionRef> {
|
||||
vec![&pagetop::base::extension::Welcome]
|
||||
}
|
||||
|
||||
async fn initialize(&self) -> Result<(), BoxError> {
|
||||
let main_nav = Nav::new()
|
||||
.with_item(nav::Item::link(Lc::n("Home"), "/"))
|
||||
.with_item(nav::Item::link_blank(
|
||||
Lc::n("Docs"),
|
||||
"https://docs.rs/pagetop",
|
||||
))
|
||||
.with_item(nav::Item::dropdown(
|
||||
Dropdown::new()
|
||||
.with_title(Lc::n("Tools"))
|
||||
.with_item(dropdown::Item::link(Lc::n("Generator"), "/tools/gen"))
|
||||
.with_item(dropdown::Item::link(Lc::n("Reports"), "/tools/reports"))
|
||||
.with_item(dropdown::Item::divider())
|
||||
.with_item(dropdown::Item::header(Lc::n("Danger zone")))
|
||||
.with_item(dropdown::Item::button(Lc::n("Reset settings"))),
|
||||
))
|
||||
.with_item(nav::Item::link_disabled(Lc::n("Disabled"), "#"));
|
||||
|
||||
let user_menu = Dropdown::new()
|
||||
.with_title(Lc::n("Account"))
|
||||
.with_item(dropdown::Item::label(Lc::n("Signed in as demo")))
|
||||
.with_item(dropdown::Item::divider())
|
||||
.with_item(dropdown::Item::link(Lc::n("Profile"), "/profile"))
|
||||
.with_item(dropdown::Item::link(Lc::n("Settings"), "/settings"))
|
||||
.with_item(dropdown::Item::divider())
|
||||
.with_item(dropdown::Item::button(Lc::n("Sign out")));
|
||||
|
||||
InRegion::Global(&CoreRegions::Header).add(main_nav);
|
||||
InRegion::Global(&CoreRegions::Aside).add(user_menu);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::prepare(&NavDemo).await.run().await
|
||||
}
|
||||
56
examples/basic-navbar.rs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
include_locales!(LOC from "examples/locale");
|
||||
|
||||
struct NavbarDemo;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for NavbarDemo {
|
||||
fn dependencies(&self) -> Vec<ExtensionRef> {
|
||||
vec![
|
||||
&pagetop_bootsier::Bootsier,
|
||||
&pagetop::base::extension::Welcome,
|
||||
]
|
||||
}
|
||||
|
||||
async fn initialize(&self) -> Result<(), BoxError> {
|
||||
let brand = Brand::new()
|
||||
.with_image(image::Source::logo(PageTopSvg::Color))
|
||||
.with_title(Lc::n("PageTop"))
|
||||
.with_route(Route::from("/"));
|
||||
|
||||
let main_nav = Nav::new()
|
||||
.with_item(nav::Item::link(Lc::t("navbar_home", &LOC), "/"))
|
||||
.with_item(nav::Item::link_blank(
|
||||
Lc::t("navbar_docs", &LOC),
|
||||
"https://docs.rs/pagetop",
|
||||
))
|
||||
.with_item(nav::Item::dropdown(
|
||||
Dropdown::new()
|
||||
.with_title(Lc::t("navbar_tools", &LOC))
|
||||
.with_item(dropdown::Item::link(
|
||||
Lc::t("navbar_generator", &LOC),
|
||||
"/tools/gen",
|
||||
))
|
||||
.with_item(dropdown::Item::link(
|
||||
Lc::t("navbar_reports", &LOC),
|
||||
"/tools/reports",
|
||||
)),
|
||||
))
|
||||
.with_item(nav::Item::link(Lc::t("navbar_active", &LOC), "/active").with_active(true))
|
||||
.with_item(nav::Item::link_disabled(
|
||||
Lc::t("navbar_disabled", &LOC),
|
||||
"#",
|
||||
));
|
||||
|
||||
let navbar = Navbar::brand_left(brand).with_item(navbar::Item::nav(main_nav));
|
||||
|
||||
InRegion::Global(&CoreRegions::Header).add(navbar);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::prepare(&NavbarDemo).await.run().await
|
||||
}
|
||||
|
|
@ -1,33 +1,31 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
use pagetop_bootsier::theme::*;
|
||||
|
||||
include_locales!(LOC from "examples/locale");
|
||||
|
||||
struct FormControls;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for FormControls {
|
||||
fn dependencies(&self) -> Vec<ExtensionRef> {
|
||||
vec![&pagetop_aliner::Aliner, &pagetop_bootsier::Bootsier]
|
||||
}
|
||||
|
||||
fn configure_router(&self, router: Router) -> Router {
|
||||
router.route("/", web::get(form_controls))
|
||||
fn configure_router(&self, routes: Routes) -> Routes {
|
||||
routes.public_route("/", web::get(form_controls).post(form_controls))
|
||||
}
|
||||
}
|
||||
|
||||
async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||
Page::new(request)
|
||||
.with_child(
|
||||
Intro::default()
|
||||
.with_opening(IntroOpening::Custom)
|
||||
.with_title(L10n::t("title", &LOC))
|
||||
.with_slogan(L10n::t("slogan", &LOC))
|
||||
.with_button(None::<(L10n, FnPathByContext)>)
|
||||
Intro::custom()
|
||||
.with_title(Lc::t("title", &LOC))
|
||||
.with_slogan(Lc::t("slogan", &LOC))
|
||||
// Bloque 1: casillas, interruptores y botones de opción.
|
||||
.with_child(
|
||||
Block::new()
|
||||
.with_title(L10n::t("block_selections", &LOC))
|
||||
.with_title(Lc::t("block_selections", &LOC))
|
||||
.with_child(
|
||||
Form::new()
|
||||
.with_id("form-selections")
|
||||
|
|
@ -36,69 +34,69 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
|||
// Casillas e interruptores (form::Checkbox).
|
||||
.with_child(
|
||||
form::Fieldset::new()
|
||||
.with_legend(L10n::t("fieldset_checkbox", &LOC))
|
||||
.with_description(L10n::t("desc_checkbox", &LOC))
|
||||
.with_legend(Lc::t("fieldset_checkbox", &LOC))
|
||||
.with_description(Lc::t("desc_checkbox", &LOC))
|
||||
.with_child(
|
||||
form::Checkbox::new()
|
||||
.with_name("accept_terms")
|
||||
.with_label(L10n::t("label_terms", &LOC))
|
||||
.with_label(Lc::t("label_terms", &LOC))
|
||||
.with_required(true),
|
||||
)
|
||||
.with_child(
|
||||
form::Checkbox::new()
|
||||
.with_name("accept_marketing")
|
||||
.with_label(L10n::t("label_marketing", &LOC))
|
||||
.with_label(Lc::t("label_marketing", &LOC))
|
||||
.with_checked(true)
|
||||
.with_inline(true),
|
||||
)
|
||||
.with_child(
|
||||
form::Checkbox::new()
|
||||
.with_name("newsletter")
|
||||
.with_label(L10n::t("label_newsletter", &LOC))
|
||||
.with_label(Lc::t("label_newsletter", &LOC))
|
||||
.with_inline(true),
|
||||
)
|
||||
.with_child(
|
||||
form::Checkbox::switch()
|
||||
.with_name("notifications")
|
||||
.with_label(L10n::t("label_notifications", &LOC))
|
||||
.with_label(Lc::t("label_notifications", &LOC))
|
||||
.with_checked(true)
|
||||
.with_reverse(true),
|
||||
)
|
||||
.with_child(
|
||||
form::Checkbox::switch()
|
||||
.with_name("dark_mode")
|
||||
.with_label(L10n::t("label_dark_mode", &LOC))
|
||||
.with_label(Lc::t("label_dark_mode", &LOC))
|
||||
.with_disabled(true),
|
||||
),
|
||||
)
|
||||
// Grupo de casillas de verificación (form::check::Field).
|
||||
.with_child(
|
||||
form::Fieldset::new()
|
||||
.with_legend(L10n::t("fieldset_checkgroup", &LOC))
|
||||
.with_legend(Lc::t("fieldset_checkgroup", &LOC))
|
||||
.with_child(
|
||||
form::check::Field::new()
|
||||
.with_name("interests")
|
||||
.with_label(L10n::t("label_interests", &LOC))
|
||||
.with_help_text(L10n::t("help_interests", &LOC))
|
||||
.with_label(Lc::t("label_interests", &LOC))
|
||||
.with_help_text(Lc::t("help_interests", &LOC))
|
||||
.with_item(
|
||||
form::check::Item::new(
|
||||
"rust",
|
||||
L10n::t("check_rust", &LOC),
|
||||
Lc::t("check_rust", &LOC),
|
||||
)
|
||||
.with_checked(true),
|
||||
)
|
||||
.with_item(form::check::Item::new(
|
||||
"web",
|
||||
L10n::t("check_web", &LOC),
|
||||
Lc::t("check_web", &LOC),
|
||||
))
|
||||
.with_item(form::check::Item::new(
|
||||
"ai",
|
||||
L10n::t("check_ai", &LOC),
|
||||
Lc::t("check_ai", &LOC),
|
||||
))
|
||||
.with_item(
|
||||
form::check::Item::new(
|
||||
"games",
|
||||
L10n::t("check_games", &LOC),
|
||||
Lc::t("check_games", &LOC),
|
||||
)
|
||||
.with_disabled(true),
|
||||
),
|
||||
|
|
@ -107,84 +105,87 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
|||
// Botones de opción (form::radio::Field).
|
||||
.with_child(
|
||||
form::Fieldset::new()
|
||||
.with_legend(L10n::t("fieldset_radio", &LOC))
|
||||
.with_legend(Lc::t("fieldset_radio", &LOC))
|
||||
.with_child(
|
||||
form::radio::Field::new()
|
||||
.with_name("frequency")
|
||||
.with_label(L10n::t("label_frequency", &LOC))
|
||||
.with_label(Lc::t("label_frequency", &LOC))
|
||||
.with_item(form::radio::Item::new(
|
||||
"daily",
|
||||
L10n::t("radio_daily", &LOC),
|
||||
Lc::t("radio_daily", &LOC),
|
||||
))
|
||||
.with_item(
|
||||
form::radio::Item::new(
|
||||
"weekly",
|
||||
L10n::t("radio_weekly", &LOC),
|
||||
Lc::t("radio_weekly", &LOC),
|
||||
)
|
||||
.with_checked(true),
|
||||
)
|
||||
.with_item(form::radio::Item::new(
|
||||
"monthly",
|
||||
L10n::t("radio_monthly", &LOC),
|
||||
Lc::t("radio_monthly", &LOC),
|
||||
))
|
||||
.with_item(
|
||||
form::radio::Item::new(
|
||||
"never",
|
||||
L10n::t("radio_never", &LOC),
|
||||
Lc::t("radio_never", &LOC),
|
||||
)
|
||||
.with_disabled(true),
|
||||
),
|
||||
),
|
||||
)
|
||||
// Campo oculto (form::Hidden).
|
||||
.with_child(form::Hidden::field("origin", "form-selections"))
|
||||
// Botonera de acciones.
|
||||
.with_child(
|
||||
form::Hidden::new()
|
||||
.with_name("origin")
|
||||
.with_value("form-selections"),
|
||||
)
|
||||
// Botones de acción.
|
||||
.with_child(
|
||||
Button::submit(L10n::t("btn_submit", &LOC))
|
||||
.with_color(ButtonColor::Background(Color::Primary)),
|
||||
)
|
||||
.with_child(
|
||||
Button::reset(L10n::t("btn_reset", &LOC))
|
||||
.with_color(ButtonColor::Outline(Color::Secondary)),
|
||||
)
|
||||
.with_child(
|
||||
Button::plain(L10n::t("btn_cancel", &LOC))
|
||||
.with_color(ButtonColor::Link),
|
||||
Flex::new()
|
||||
.with_wrap(flex::Behavior::Wrap)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5)))
|
||||
.with_child(
|
||||
Button::submit(Lc::t("btn_submit", &LOC))
|
||||
.with_style(button::Style::Solid(Intent::Primary)),
|
||||
)
|
||||
.with_child(
|
||||
Button::reset(Lc::t("btn_reset", &LOC)).with_style(
|
||||
button::Style::Outline(Intent::Neutral),
|
||||
),
|
||||
)
|
||||
.with_child(
|
||||
Button::plain(Lc::t("btn_cancel", &LOC))
|
||||
.with_style(button::Style::Link),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
// Bloque 2: campos de texto, multilínea y rango.
|
||||
.with_child(
|
||||
Block::new()
|
||||
.with_title(L10n::t("block_text", &LOC))
|
||||
.with_title(Lc::t("block_text", &LOC))
|
||||
.with_child(
|
||||
Form::new()
|
||||
.with_id("form-text")
|
||||
.with_action("/")
|
||||
.with_method(form::Method::Post)
|
||||
// Necesaria para enviar los archivos de form::File.
|
||||
.with_enctype(form::Enctype::Multipart)
|
||||
// Campos de texto (form::input::Field).
|
||||
.with_child(
|
||||
form::Fieldset::new()
|
||||
.with_legend(L10n::t("fieldset_text", &LOC))
|
||||
.with_legend(Lc::t("fieldset_text", &LOC))
|
||||
.with_child(
|
||||
form::input::Field::text()
|
||||
.with_name("name")
|
||||
.with_label(L10n::t("label_name", &LOC))
|
||||
.with_placeholder(L10n::t("placeholder_name", &LOC))
|
||||
.with_label(Lc::t("label_name", &LOC))
|
||||
.with_placeholder(Lc::t("placeholder_name", &LOC))
|
||||
.with_help_text(Lc::t("help_name", &LOC))
|
||||
.with_required(true),
|
||||
)
|
||||
.with_child(
|
||||
form::input::Field::email()
|
||||
.with_name("email")
|
||||
.with_label(L10n::t("label_email", &LOC))
|
||||
.with_placeholder(L10n::t(
|
||||
"placeholder_email",
|
||||
&LOC,
|
||||
))
|
||||
.with_label(Lc::t("label_email", &LOC))
|
||||
.with_placeholder(Lc::t("placeholder_email", &LOC))
|
||||
.with_help_text(Lc::t("help_email", &LOC))
|
||||
.with_autocomplete(
|
||||
Some(form::Autocomplete::email()),
|
||||
)
|
||||
|
|
@ -193,7 +194,7 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
|||
.with_child(
|
||||
form::input::Field::password()
|
||||
.with_name("password")
|
||||
.with_label(L10n::t("label_password", &LOC))
|
||||
.with_label(Lc::t("label_password", &LOC))
|
||||
.with_autocomplete(Some(
|
||||
form::Autocomplete::new_password(),
|
||||
))
|
||||
|
|
@ -202,23 +203,20 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
|||
.with_child(
|
||||
form::input::Field::telephone()
|
||||
.with_name("phone")
|
||||
.with_label(L10n::t("label_phone", &LOC))
|
||||
.with_placeholder(L10n::t(
|
||||
"placeholder_phone",
|
||||
&LOC,
|
||||
)),
|
||||
.with_label(Lc::t("label_phone", &LOC))
|
||||
.with_placeholder(Lc::t("placeholder_phone", &LOC)),
|
||||
)
|
||||
.with_child(
|
||||
form::input::Field::url()
|
||||
.with_name("website")
|
||||
.with_label(L10n::t("label_url", &LOC))
|
||||
.with_placeholder(L10n::t("placeholder_url", &LOC)),
|
||||
.with_label(Lc::t("label_url", &LOC))
|
||||
.with_placeholder(Lc::t("placeholder_url", &LOC)),
|
||||
)
|
||||
.with_child(
|
||||
form::input::Field::search()
|
||||
.with_name("search")
|
||||
.with_label(L10n::t("label_search", &LOC))
|
||||
.with_placeholder(L10n::t(
|
||||
.with_label(Lc::t("label_search", &LOC))
|
||||
.with_placeholder(Lc::t(
|
||||
"placeholder_search",
|
||||
&LOC,
|
||||
)),
|
||||
|
|
@ -227,230 +225,253 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
|||
// Área de texto (form::Textarea).
|
||||
.with_child(
|
||||
form::Fieldset::new()
|
||||
.with_legend(L10n::t("fieldset_textarea", &LOC))
|
||||
.with_legend(Lc::t("fieldset_textarea", &LOC))
|
||||
.with_child(
|
||||
form::Textarea::new()
|
||||
.with_name("comment")
|
||||
.with_label(L10n::t("label_comment", &LOC))
|
||||
.with_placeholder(L10n::t(
|
||||
.with_label(Lc::t("label_comment", &LOC))
|
||||
.with_placeholder(Lc::t(
|
||||
"placeholder_comment",
|
||||
&LOC,
|
||||
))
|
||||
.with_rows(Some(4))
|
||||
.with_help_text(L10n::t("help_comment", &LOC)),
|
||||
.with_help_text(Lc::t("help_comment", &LOC)),
|
||||
),
|
||||
)
|
||||
// Control deslizante (form::Range).
|
||||
.with_child(
|
||||
form::Fieldset::new()
|
||||
.with_legend(L10n::t("fieldset_range", &LOC))
|
||||
.with_legend(Lc::t("fieldset_range", &LOC))
|
||||
.with_child(
|
||||
form::Range::new()
|
||||
.with_name("rating")
|
||||
.with_label(L10n::t("label_rating", &LOC))
|
||||
.with_label(Lc::t("label_rating", &LOC))
|
||||
.with_min(Some(1.0))
|
||||
.with_max(Some(10.0))
|
||||
.with_step(Some(1.0))
|
||||
.with_value(Some(5.0))
|
||||
.with_help_text(L10n::t("help_rating", &LOC)),
|
||||
.with_help_text(Lc::t("help_rating", &LOC)),
|
||||
),
|
||||
)
|
||||
// Selección de archivos (form::File).
|
||||
.with_child(
|
||||
form::Fieldset::new()
|
||||
.with_legend(Lc::t("fieldset_file", &LOC))
|
||||
.with_child(
|
||||
form::File::new()
|
||||
.with_name("photo")
|
||||
.with_label(Lc::t("label_photo", &LOC))
|
||||
.with_accept("image/jpeg,image/png")
|
||||
.with_help_text(Lc::t("help_photo", &LOC)),
|
||||
)
|
||||
.with_child(
|
||||
form::File::new()
|
||||
.with_name("attachments")
|
||||
.with_label(Lc::t("label_attachments", &LOC))
|
||||
.with_accept(".pdf")
|
||||
.with_multiple(true)
|
||||
.with_help_text(Lc::t("help_attachments", &LOC)),
|
||||
),
|
||||
)
|
||||
// Campo oculto (form::Hidden).
|
||||
.with_child(form::Hidden::field("origin", "form-text"))
|
||||
// Botonera de acciones.
|
||||
.with_child(
|
||||
form::Hidden::new()
|
||||
.with_name("origin")
|
||||
.with_value("form-text"),
|
||||
)
|
||||
// Botones de acción.
|
||||
.with_child(
|
||||
Button::submit(L10n::t("btn_submit", &LOC))
|
||||
.with_color(ButtonColor::Background(Color::Primary)),
|
||||
)
|
||||
.with_child(
|
||||
Button::reset(L10n::t("btn_reset", &LOC))
|
||||
.with_color(ButtonColor::Outline(Color::Secondary)),
|
||||
)
|
||||
.with_child(
|
||||
Button::plain(L10n::t("btn_cancel", &LOC))
|
||||
.with_color(ButtonColor::Link),
|
||||
Flex::new()
|
||||
.with_wrap(flex::Behavior::Wrap)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5)))
|
||||
.with_child(
|
||||
Button::submit(Lc::t("btn_submit", &LOC))
|
||||
.with_style(button::Style::Solid(Intent::Primary)),
|
||||
)
|
||||
.with_child(
|
||||
Button::reset(Lc::t("btn_reset", &LOC)).with_style(
|
||||
button::Style::Outline(Intent::Neutral),
|
||||
),
|
||||
)
|
||||
.with_child(
|
||||
Button::plain(Lc::t("btn_cancel", &LOC))
|
||||
.with_style(button::Style::Link),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
// Bloque 3: listas de selección y etiquetas flotantes.
|
||||
.with_child(
|
||||
Block::new()
|
||||
.with_title(L10n::t("block_lists", &LOC))
|
||||
.with_title(
|
||||
if global::SETTINGS.app.theme.eq_ignore_ascii_case("bootsier") {
|
||||
Lc::t("block_lists_floating", &LOC)
|
||||
} else {
|
||||
Lc::t("block_lists", &LOC)
|
||||
},
|
||||
)
|
||||
.with_child(form_lists()),
|
||||
)
|
||||
// Bloque 4: diálogo modal.
|
||||
.with_child(
|
||||
Block::new()
|
||||
.with_title(Lc::t("block_dialog", &LOC))
|
||||
.with_child(
|
||||
Form::new()
|
||||
.with_id("form-lists")
|
||||
.with_action("/")
|
||||
.with_method(form::Method::Post)
|
||||
// Listas de selección (form::select::Field).
|
||||
.with_child(
|
||||
form::Fieldset::new()
|
||||
.with_legend(L10n::t("fieldset_select", &LOC))
|
||||
.with_child(
|
||||
form::select::Field::new()
|
||||
.with_name("language")
|
||||
.with_label(L10n::t("label_language", &LOC))
|
||||
.with_item(
|
||||
form::select::Item::new(
|
||||
"",
|
||||
L10n::t("select_choose", &LOC),
|
||||
)
|
||||
.with_selected(true),
|
||||
)
|
||||
.with_group(
|
||||
form::select::Group::new(L10n::t(
|
||||
"select_group_europe",
|
||||
&LOC,
|
||||
))
|
||||
.with_item(form::select::Item::new(
|
||||
"es",
|
||||
L10n::t("select_spanish", &LOC),
|
||||
))
|
||||
.with_item(form::select::Item::new(
|
||||
"fr",
|
||||
L10n::t("select_french", &LOC),
|
||||
)),
|
||||
)
|
||||
.with_group(
|
||||
form::select::Group::new(L10n::t(
|
||||
"select_group_americas",
|
||||
&LOC,
|
||||
))
|
||||
.with_item(form::select::Item::new(
|
||||
"en",
|
||||
L10n::t("select_english", &LOC),
|
||||
))
|
||||
.with_item(form::select::Item::new(
|
||||
"pt",
|
||||
L10n::t("select_portuguese", &LOC),
|
||||
)),
|
||||
)
|
||||
.with_item(
|
||||
form::select::Item::new(
|
||||
"xx",
|
||||
L10n::t("select_disabled", &LOC),
|
||||
)
|
||||
.with_disabled(true),
|
||||
)
|
||||
.with_required(true),
|
||||
)
|
||||
.with_child(
|
||||
form::select::Field::new()
|
||||
.with_name("technologies")
|
||||
.with_label(L10n::t("label_technologies", &LOC))
|
||||
.with_item(
|
||||
form::select::Item::new(
|
||||
"rust",
|
||||
L10n::n("Rust"),
|
||||
)
|
||||
.with_selected(true),
|
||||
)
|
||||
.with_item(
|
||||
form::select::Item::new(
|
||||
"python",
|
||||
L10n::n("Python"),
|
||||
)
|
||||
.with_selected(true),
|
||||
)
|
||||
.with_item(form::select::Item::new(
|
||||
"javascript",
|
||||
L10n::n("JavaScript"),
|
||||
))
|
||||
.with_item(form::select::Item::new(
|
||||
"go",
|
||||
L10n::n("Go"),
|
||||
))
|
||||
.with_item(form::select::Item::new(
|
||||
"typescript",
|
||||
L10n::n("TypeScript"),
|
||||
))
|
||||
.with_multiple(true)
|
||||
.with_rows(Some(4))
|
||||
.with_help_text(L10n::t("help_technologies", &LOC)),
|
||||
),
|
||||
Dialog::new()
|
||||
.with_id("delete-confirm")
|
||||
.with_title(Lc::t("dialog_delete_title", &LOC))
|
||||
.with_child(Html::with(|cx| {
|
||||
html! {
|
||||
p { (Lc::t("dialog_delete_body", &LOC).using(cx)) }
|
||||
}
|
||||
}))
|
||||
.with_footer(
|
||||
Button::plain(Lc::t("btn_ok", &LOC))
|
||||
.with_prop(PropsOp::set("data-dialog-dismiss", "modal"))
|
||||
.with_style(button::Style::Solid(Intent::Primary)),
|
||||
)
|
||||
// Etiquetas flotantes.
|
||||
.with_child(
|
||||
form::Fieldset::new()
|
||||
.with_legend(L10n::t("fieldset_floating", &LOC))
|
||||
.with_child(
|
||||
form::input::Field::text()
|
||||
.with_name("fl_name")
|
||||
.with_label(L10n::t("label_name", &LOC))
|
||||
.with_placeholder(L10n::t("placeholder_name", &LOC))
|
||||
.with_floating_label(true)
|
||||
.with_required(true),
|
||||
)
|
||||
.with_child(
|
||||
form::Textarea::new()
|
||||
.with_name("fl_comment")
|
||||
.with_label(L10n::t("label_comment", &LOC))
|
||||
.with_placeholder(L10n::t(
|
||||
"placeholder_comment",
|
||||
&LOC,
|
||||
))
|
||||
.with_floating_label(true),
|
||||
)
|
||||
.with_child(
|
||||
form::select::Field::new()
|
||||
.with_name("fl_country")
|
||||
.with_label(L10n::t("label_country", &LOC))
|
||||
.with_item(
|
||||
form::select::Item::new(
|
||||
"",
|
||||
L10n::t("select_choose", &LOC),
|
||||
)
|
||||
.with_selected(true),
|
||||
)
|
||||
.with_item(form::select::Item::new(
|
||||
"de",
|
||||
L10n::t("select_germany", &LOC),
|
||||
))
|
||||
.with_item(form::select::Item::new(
|
||||
"es",
|
||||
L10n::t("select_spain", &LOC),
|
||||
))
|
||||
.with_item(form::select::Item::new(
|
||||
"fr",
|
||||
L10n::t("select_france", &LOC),
|
||||
))
|
||||
.with_item(form::select::Item::new(
|
||||
"pt",
|
||||
L10n::t("select_portugal", &LOC),
|
||||
))
|
||||
.with_floating_label(true)
|
||||
.with_required(true),
|
||||
),
|
||||
)
|
||||
// Campo oculto (form::Hidden).
|
||||
.with_child(
|
||||
form::Hidden::new()
|
||||
.with_name("origin")
|
||||
.with_value("form-lists"),
|
||||
)
|
||||
// Botones de acción.
|
||||
.with_child(
|
||||
Button::submit(L10n::t("btn_submit", &LOC))
|
||||
.with_color(ButtonColor::Background(Color::Primary)),
|
||||
)
|
||||
.with_child(
|
||||
Button::reset(L10n::t("btn_reset", &LOC))
|
||||
.with_color(ButtonColor::Outline(Color::Secondary)),
|
||||
)
|
||||
.with_child(
|
||||
Button::plain(L10n::t("btn_cancel", &LOC))
|
||||
.with_color(ButtonColor::Link),
|
||||
.with_footer(
|
||||
Button::plain(Lc::t("btn_cancel", &LOC))
|
||||
.with_prop(PropsOp::set("data-dialog-dismiss", "modal"))
|
||||
.with_style(button::Style::Outline(Intent::Neutral)),
|
||||
),
|
||||
)
|
||||
.with_child(
|
||||
Button::plain(Lc::t("btn_delete", &LOC))
|
||||
.with_prop(PropsOp::set("data-dialog-toggle", "modal"))
|
||||
.with_prop(PropsOp::set("data-dialog-target", "#delete-confirm"))
|
||||
.with_style(button::Style::Solid(Intent::Severe)),
|
||||
),
|
||||
),
|
||||
)
|
||||
.render()
|
||||
.await
|
||||
}
|
||||
|
||||
fn form_lists() -> Form {
|
||||
let mut form = Form::new()
|
||||
.with_id("form-lists")
|
||||
.with_action("/")
|
||||
.with_method(form::Method::Post)
|
||||
// Listas de selección (form::select::Field).
|
||||
.with_child(
|
||||
form::Fieldset::new()
|
||||
.with_legend(Lc::t("fieldset_select", &LOC))
|
||||
.with_child(
|
||||
form::select::Field::new()
|
||||
.with_name("language")
|
||||
.with_label(Lc::t("label_language", &LOC))
|
||||
.with_item(
|
||||
form::select::Item::new("", Lc::t("select_choose", &LOC))
|
||||
.with_selected(true),
|
||||
)
|
||||
.with_group(
|
||||
form::select::Group::new(Lc::t("select_group_europe", &LOC))
|
||||
.with_item(form::select::Item::new(
|
||||
"es",
|
||||
Lc::t("select_spanish", &LOC),
|
||||
))
|
||||
.with_item(form::select::Item::new(
|
||||
"fr",
|
||||
Lc::t("select_french", &LOC),
|
||||
)),
|
||||
)
|
||||
.with_group(
|
||||
form::select::Group::new(Lc::t("select_group_americas", &LOC))
|
||||
.with_item(form::select::Item::new(
|
||||
"en",
|
||||
Lc::t("select_english", &LOC),
|
||||
))
|
||||
.with_item(form::select::Item::new(
|
||||
"pt",
|
||||
Lc::t("select_portuguese", &LOC),
|
||||
)),
|
||||
)
|
||||
.with_item(
|
||||
form::select::Item::new("xx", Lc::t("select_disabled", &LOC))
|
||||
.with_disabled(true),
|
||||
)
|
||||
.with_required(true),
|
||||
)
|
||||
.with_child(
|
||||
form::select::Field::new()
|
||||
.with_name("technologies")
|
||||
.with_label(Lc::t("label_technologies", &LOC))
|
||||
.with_item(
|
||||
form::select::Item::new("rust", Lc::n("Rust")).with_selected(true),
|
||||
)
|
||||
.with_item(
|
||||
form::select::Item::new("python", Lc::n("Python")).with_selected(true),
|
||||
)
|
||||
.with_item(form::select::Item::new("javascript", Lc::n("JavaScript")))
|
||||
.with_item(form::select::Item::new("go", Lc::n("Go")))
|
||||
.with_item(form::select::Item::new("typescript", Lc::n("TypeScript")))
|
||||
.with_multiple(true)
|
||||
.with_rows(Some(4))
|
||||
.with_help_text(Lc::t("help_technologies", &LOC)),
|
||||
),
|
||||
);
|
||||
|
||||
// Etiquetas flotantes: solo disponibles con el tema Bootsier.
|
||||
if global::SETTINGS.app.theme.eq_ignore_ascii_case("bootsier") {
|
||||
form = form.with_child(
|
||||
form::Fieldset::new()
|
||||
.with_legend(Lc::t("fieldset_floating", &LOC))
|
||||
.with_child(
|
||||
form::input::Field::text()
|
||||
.with_name("fl_name")
|
||||
.with_label(Lc::t("label_name", &LOC))
|
||||
.with_placeholder(Lc::t("placeholder_name", &LOC))
|
||||
.with_floating_label(true)
|
||||
.with_required(true),
|
||||
)
|
||||
.with_child(
|
||||
form::Textarea::new()
|
||||
.with_name("fl_comment")
|
||||
.with_label(Lc::t("label_comment", &LOC))
|
||||
.with_placeholder(Lc::t("placeholder_comment", &LOC))
|
||||
.with_floating_label(true),
|
||||
)
|
||||
.with_child(
|
||||
form::select::Field::new()
|
||||
.with_name("fl_country")
|
||||
.with_label(Lc::t("label_country", &LOC))
|
||||
.with_item(
|
||||
form::select::Item::new("", Lc::t("select_choose", &LOC))
|
||||
.with_selected(true),
|
||||
)
|
||||
.with_item(form::select::Item::new("de", Lc::t("select_germany", &LOC)))
|
||||
.with_item(form::select::Item::new("es", Lc::t("select_spain", &LOC)))
|
||||
.with_item(form::select::Item::new("fr", Lc::t("select_france", &LOC)))
|
||||
.with_item(form::select::Item::new(
|
||||
"pt",
|
||||
Lc::t("select_portugal", &LOC),
|
||||
))
|
||||
.with_floating_label(true)
|
||||
.with_required(true),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
form
|
||||
// Campo oculto (form::Hidden).
|
||||
.with_child(form::Hidden::field("origin", "form-lists"))
|
||||
// Botonera de acciones.
|
||||
.with_child(
|
||||
Flex::new()
|
||||
.with_wrap(flex::Behavior::Wrap)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5)))
|
||||
.with_child(
|
||||
Button::submit(Lc::t("btn_submit", &LOC))
|
||||
.with_style(button::Style::Solid(Intent::Primary)),
|
||||
)
|
||||
.with_child(
|
||||
Button::reset(Lc::t("btn_reset", &LOC))
|
||||
.with_style(button::Style::Outline(Intent::Neutral)),
|
||||
)
|
||||
.with_child(
|
||||
Button::plain(Lc::t("btn_cancel", &LOC)).with_style(button::Style::Link),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::prepare(&FormControls).run()?.await
|
||||
Application::prepare(&FormControls).await.run().await
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@ use pagetop::prelude::*;
|
|||
|
||||
struct HelloName;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for HelloName {
|
||||
fn configure_router(&self, router: Router) -> Router {
|
||||
router.route("/hello/{name}", web::get(hello_name))
|
||||
fn configure_router(&self, routes: Routes) -> Routes {
|
||||
routes.public_route("/hello/{name}", web::get(hello_name))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -19,9 +20,10 @@ async fn hello_name(
|
|||
}
|
||||
}))
|
||||
.render()
|
||||
.await
|
||||
}
|
||||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::prepare(&HelloName).run()?.await
|
||||
Application::prepare(&HelloName).await.run().await
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@ use pagetop::prelude::*;
|
|||
|
||||
struct HelloWorld;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for HelloWorld {
|
||||
fn configure_router(&self, router: Router) -> Router {
|
||||
router.route("/", web::get(hello_world))
|
||||
fn configure_router(&self, routes: Routes) -> Routes {
|
||||
routes.public_route("/", web::get(hello_world))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -16,9 +17,10 @@ async fn hello_world(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
|||
}
|
||||
}))
|
||||
.render()
|
||||
.await
|
||||
}
|
||||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::prepare(&HelloWorld).run()?.await
|
||||
Application::prepare(&HelloWorld).await.run().await
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,79 +4,79 @@ include_locales!(LOC from "examples/locale");
|
|||
|
||||
struct IntroColors;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for IntroColors {
|
||||
fn configure_router(&self, router: Router) -> Router {
|
||||
router.route("/", web::get(intro_colors))
|
||||
fn configure_router(&self, routes: Routes) -> Routes {
|
||||
routes.public_route("/", web::get(intro_colors))
|
||||
}
|
||||
}
|
||||
|
||||
async fn intro_colors(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||
Page::new(request)
|
||||
.with_child(
|
||||
Intro::default()
|
||||
.with_opening(IntroOpening::Custom)
|
||||
.with_title(L10n::n("PageTop"))
|
||||
.with_slogan(L10n::t("colors_slogan", &LOC))
|
||||
.with_button(None::<(L10n, FnPathByContext)>)
|
||||
Intro::custom()
|
||||
.with_title(Lc::n("PageTop"))
|
||||
.with_slogan(Lc::t("colors_slogan", &LOC))
|
||||
.with_child(
|
||||
Block::new()
|
||||
.with_title(L10n::t("colors_block", &LOC).with_arg("n", "1"))
|
||||
.with_title(Lc::t("colors_block", &LOC).with_arg("n", "1"))
|
||||
.with_child(Html::with(|cx| {
|
||||
html! {
|
||||
p { (L10n::t("colors_val_1", &LOC).using(cx)) }
|
||||
p { (Lc::t("colors_val_1", &LOC).using(cx)) }
|
||||
}
|
||||
})),
|
||||
)
|
||||
.with_child(
|
||||
Block::new()
|
||||
.with_title(L10n::t("colors_block", &LOC).with_arg("n", "2"))
|
||||
.with_title(Lc::t("colors_block", &LOC).with_arg("n", "2"))
|
||||
.with_child(Html::with(|cx| {
|
||||
html! {
|
||||
p { (L10n::t("colors_val_2", &LOC).using(cx)) }
|
||||
p { (Lc::t("colors_val_2", &LOC).using(cx)) }
|
||||
}
|
||||
})),
|
||||
)
|
||||
.with_child(
|
||||
Block::new()
|
||||
.with_title(L10n::t("colors_block", &LOC).with_arg("n", "3"))
|
||||
.with_title(Lc::t("colors_block", &LOC).with_arg("n", "3"))
|
||||
.with_child(Html::with(|cx| {
|
||||
html! {
|
||||
p { (L10n::t("colors_val_3", &LOC).using(cx)) }
|
||||
p { (Lc::t("colors_val_3", &LOC).using(cx)) }
|
||||
}
|
||||
})),
|
||||
)
|
||||
.with_child(
|
||||
Block::new()
|
||||
.with_title(L10n::t("colors_block", &LOC).with_arg("n", "4"))
|
||||
.with_title(Lc::t("colors_block", &LOC).with_arg("n", "4"))
|
||||
.with_child(Html::with(|cx| {
|
||||
html! {
|
||||
p { (L10n::t("colors_val_4", &LOC).using(cx)) }
|
||||
p { (Lc::t("colors_val_4", &LOC).using(cx)) }
|
||||
}
|
||||
})),
|
||||
)
|
||||
.with_child(
|
||||
Block::new()
|
||||
.with_title(L10n::t("colors_block", &LOC).with_arg("n", "5"))
|
||||
.with_title(Lc::t("colors_block", &LOC).with_arg("n", "5"))
|
||||
.with_child(Html::with(|cx| {
|
||||
html! {
|
||||
p { (L10n::t("colors_val_5", &LOC).using(cx)) }
|
||||
p { (Lc::t("colors_val_5", &LOC).using(cx)) }
|
||||
}
|
||||
})),
|
||||
)
|
||||
.with_child(
|
||||
Block::new()
|
||||
.with_title(L10n::t("colors_block", &LOC).with_arg("n", "6"))
|
||||
.with_title(Lc::t("colors_block", &LOC).with_arg("n", "6"))
|
||||
.with_child(Html::with(|cx| {
|
||||
html! {
|
||||
p { (L10n::t("colors_val_6", &LOC).using(cx)) }
|
||||
p { (Lc::t("colors_val_6", &LOC).using(cx)) }
|
||||
}
|
||||
})),
|
||||
),
|
||||
)
|
||||
.render()
|
||||
.await
|
||||
}
|
||||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::prepare(&IntroColors).run()?.await
|
||||
Application::prepare(&IntroColors).await.run().await
|
||||
}
|
||||
|
|
|
|||
270
examples/intro-datetime.rs
Normal file
|
|
@ -0,0 +1,270 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
include_locales!(LOC from "examples/locale");
|
||||
|
||||
struct IntroDatetime;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for IntroDatetime {
|
||||
fn configure_router(&self, routes: Routes) -> Routes {
|
||||
routes.public_route("/", web::get(intro_datetime))
|
||||
}
|
||||
}
|
||||
|
||||
async fn intro_datetime(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||
Page::new(request)
|
||||
.with_child(
|
||||
Intro::custom()
|
||||
.with_title(Lc::n("PageTop"))
|
||||
.with_slogan(Lc::t("datetime_slogan", &LOC))
|
||||
.with_child(world_block())
|
||||
.with_child(formats_block())
|
||||
.with_child(relative_block())
|
||||
.with_child(since_until_block()),
|
||||
)
|
||||
.render()
|
||||
.await
|
||||
}
|
||||
|
||||
// Zonas IANA de la demostración, con la clave de su etiqueta traducible.
|
||||
const ZONES: [(&str, &str); 4] = [
|
||||
("datetime_zone_utc", "UTC"),
|
||||
("datetime_zone_madrid", "Europe/Madrid"),
|
||||
("datetime_zone_mexico", "America/Mexico_City"),
|
||||
("datetime_zone_tokyo", "Asia/Tokyo"),
|
||||
];
|
||||
|
||||
// El mismo instante (`Utc::now()`) mostrado en cada zona de `ZONES`: fecha y hora combinadas
|
||||
// (`DateFormat::Medium` + `TimeFormat::Short`) y su equivalente ISO 8601, con el offset propio de
|
||||
// cada zona.
|
||||
fn world_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("datetime_block_world", &LOC))
|
||||
.with_child(Html::with(|cx| {
|
||||
let now = Utc::now();
|
||||
let rows: Vec<(Lc, String, String)> = ZONES
|
||||
.into_iter()
|
||||
.map(|(label_key, zone)| {
|
||||
let tz: Tz = zone.parse().expect("valid IANA timezone");
|
||||
let zone_cx = Context::default().with_langid(cx).with_timezone(tz);
|
||||
(
|
||||
Lc::t(label_key, &LOC),
|
||||
zone_cx.format_datetime(now, DateFormat::Medium, TimeFormat::Short),
|
||||
zone_cx.format_iso_datetime(now),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
html! {
|
||||
ul {
|
||||
@for (label, combined, iso) in &rows {
|
||||
li {
|
||||
strong { (label.using(cx)) ": " } (combined)
|
||||
" (ISO " code { (iso) } ")"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
// Combinaciones de `DateFormat`/`TimeFormat` sobre la zona horaria efectiva del visitante. Para
|
||||
// añadir un nuevo formato basta con ampliar el array correspondiente.
|
||||
fn formats_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("datetime_block_formats", &LOC))
|
||||
.with_child(Html::with(|cx| {
|
||||
let now = Utc::now();
|
||||
let today = now.with_timezone(&cx.timezone()).date_naive();
|
||||
|
||||
let dates: Vec<(&str, String)> = [
|
||||
("Short", DateFormat::Short),
|
||||
("Medium", DateFormat::Medium),
|
||||
("Long", DateFormat::Long),
|
||||
("Iso", DateFormat::Iso),
|
||||
("Custom(\"%d.%m.%Y\")", DateFormat::Custom("%d.%m.%Y")),
|
||||
]
|
||||
.into_iter()
|
||||
.map(|(label, format)| (label, cx.format_date(today, format)))
|
||||
.collect();
|
||||
|
||||
let times: Vec<(&str, String)> = [
|
||||
("Short", TimeFormat::Short),
|
||||
("Long", TimeFormat::Long),
|
||||
("Custom(\"%I:%M %p\")", TimeFormat::Custom("%I:%M %p")),
|
||||
]
|
||||
.into_iter()
|
||||
.map(|(label, format)| (label, cx.format_time(now, format)))
|
||||
.collect();
|
||||
|
||||
let combos: Vec<(&str, String)> = [
|
||||
("Short + Short", DateFormat::Short, TimeFormat::Short),
|
||||
("Medium + Short", DateFormat::Medium, TimeFormat::Short),
|
||||
("Long + Long", DateFormat::Long, TimeFormat::Long),
|
||||
("Long + Short", DateFormat::Long, TimeFormat::Short),
|
||||
("Iso + Long", DateFormat::Iso, TimeFormat::Long),
|
||||
]
|
||||
.into_iter()
|
||||
.map(|(label, date, time)| (label, cx.format_datetime(now, date, time)))
|
||||
.collect();
|
||||
|
||||
html! {
|
||||
h3 { (Lc::t("datetime_formats_date", &LOC).using(cx)) }
|
||||
ul {
|
||||
@for (label, value) in &dates {
|
||||
li { code { (label) } ": " (value) }
|
||||
}
|
||||
}
|
||||
h3 { (Lc::t("datetime_formats_time", &LOC).using(cx)) }
|
||||
ul {
|
||||
@for (label, value) in × {
|
||||
li { code { (label) } ": " (value) }
|
||||
}
|
||||
}
|
||||
h3 { (Lc::t("datetime_formats_combos", &LOC).using(cx)) }
|
||||
ul {
|
||||
@for (label, value) in &combos {
|
||||
li { code { (label) } ": " (value) }
|
||||
}
|
||||
}
|
||||
p {
|
||||
(Lc::t("datetime_formats_iso", &LOC).using(cx))
|
||||
" " code { (cx.format_iso_datetime(now)) }
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
// Casos ilustrativos de `RelativeFormat` sobre la zona horaria efectiva del visitante: hoy, un
|
||||
// desplazamiento simple de días, uno con el componente de meses en cero, uno con los tres
|
||||
// componentes y uno en el futuro -- siempre respecto al día actual. Añadir un caso nuevo es sólo
|
||||
// ampliar `samples`. La primera columna muestra la fecha seleccionada (no una etiqueta fija),
|
||||
// formateada con `DateFormat::Medium` en el idioma efectivo, para que se vea a qué fecha concreta
|
||||
// corresponde cada resultado relativo.
|
||||
fn relative_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("datetime_block_relative", &LOC))
|
||||
.with_child(Html::with(|cx| {
|
||||
let today = Utc::now().date_naive();
|
||||
|
||||
// Desplazamientos de meses/años construidos con `checked_sub_months()` (mismo mecanismo
|
||||
// que usa `RelativeFormat` por dentro), para que el resultado coincida exactamente con
|
||||
// el criterio de cada caso.
|
||||
let two_years_and_3_days_ago = today
|
||||
.checked_sub_months(Months::new(24))
|
||||
.expect("valid date")
|
||||
- Duration::days(3);
|
||||
let three_years_2_months_10_days_ago = today
|
||||
.checked_sub_months(Months::new(38))
|
||||
.expect("valid date")
|
||||
- Duration::days(10);
|
||||
|
||||
let samples = [
|
||||
today,
|
||||
today - Duration::days(3),
|
||||
two_years_and_3_days_ago,
|
||||
three_years_2_months_10_days_ago,
|
||||
today + Duration::days(5),
|
||||
];
|
||||
|
||||
let rows: Vec<(String, String, String, String)> = samples
|
||||
.into_iter()
|
||||
.map(|date| {
|
||||
let dt = at_noon(date);
|
||||
(
|
||||
cx.format_date(date, DateFormat::Medium),
|
||||
cx.format_relative(dt, RelativeFormat::Short),
|
||||
cx.format_relative(dt, RelativeFormat::Medium),
|
||||
cx.format_relative(dt, RelativeFormat::Long),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
html! {
|
||||
table style="width: 100%; border: 1px solid black;" {
|
||||
thead {
|
||||
tr {
|
||||
th { (Lc::t("datetime_relative_col_date", &LOC).using(cx)) }
|
||||
th { "Short" }
|
||||
th { "Medium" }
|
||||
th { "Long" }
|
||||
}
|
||||
}
|
||||
tbody {
|
||||
@for (date, short, medium, long) in &rows {
|
||||
tr {
|
||||
td { (date) }
|
||||
td { (short) }
|
||||
td { (medium) }
|
||||
td { (long) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
// Niveles de `DatePrecision` para `format_since()`/`format_until()`. Añadir un nivel nuevo es sólo
|
||||
// ampliar este array.
|
||||
const PRECISIONS: [(&str, DatePrecision); 3] = [
|
||||
("Short", DatePrecision::Short),
|
||||
("Medium", DatePrecision::Medium),
|
||||
("Long", DatePrecision::Long),
|
||||
];
|
||||
|
||||
// `format_since()`/`format_until()` sobre una única fecha de ejemplo: a diferencia de `DateFormat`,
|
||||
// lo que cambia entre niveles no es el estilo, sino la propia precisión revelada (sólo el mes, mes
|
||||
// y año, o fecha completa).
|
||||
fn since_until_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("datetime_block_since_until", &LOC))
|
||||
.with_child(Html::with(|cx| {
|
||||
let date = NaiveDate::from_ymd_opt(2026, 6, 3).unwrap();
|
||||
|
||||
let rows: Vec<(&str, String, String)> = PRECISIONS
|
||||
.into_iter()
|
||||
.map(|(label, precision)| {
|
||||
(
|
||||
label,
|
||||
cx.format_since(date, precision),
|
||||
cx.format_until(date, precision),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
html! {
|
||||
table style="width: 100%; border: 1px solid black;" {
|
||||
thead {
|
||||
tr {
|
||||
th { (Lc::t("datetime_since_until_col_precision", &LOC).using(cx)) }
|
||||
th { (Lc::t("datetime_since_until_col_since", &LOC).using(cx)) }
|
||||
th { (Lc::t("datetime_since_until_col_until", &LOC).using(cx)) }
|
||||
}
|
||||
}
|
||||
tbody {
|
||||
@for (label, since, until) in &rows {
|
||||
tr {
|
||||
td { (*label) }
|
||||
td { (since) }
|
||||
td { (until) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
// Mediodía, para evitar que el redondeo horario de la conversión de zona horaria empuje la fecha
|
||||
// civil resultante al día anterior o siguiente en zonas con un offset amplio.
|
||||
fn at_noon(date: NaiveDate) -> DateTime<Utc> {
|
||||
date.and_hms_opt(12, 0, 0)
|
||||
.expect("noon is always a valid time")
|
||||
.and_utc()
|
||||
}
|
||||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::prepare(&IntroDatetime).await.run().await
|
||||
}
|
||||
548
examples/intro-flex.rs
Normal file
|
|
@ -0,0 +1,548 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
include_locales!(LOC from "examples/locale");
|
||||
|
||||
struct IntroFlex;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for IntroFlex {
|
||||
fn dependencies(&self) -> Vec<ExtensionRef> {
|
||||
vec![&pagetop_bootsier::Bootsier]
|
||||
}
|
||||
|
||||
fn configure_router(&self, routes: Routes) -> Routes {
|
||||
routes.public_route("/", web::get(intro_flex))
|
||||
}
|
||||
}
|
||||
|
||||
async fn intro_flex(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||
Page::new(request)
|
||||
.with_assets(demo_box_styles())
|
||||
.with_assets(demo_row_styles())
|
||||
.with_child(
|
||||
Intro::custom()
|
||||
.with_title(Lc::n("PageTop"))
|
||||
.with_slogan(Lc::t("flex_slogan", &LOC))
|
||||
.with_child(direction_block())
|
||||
.with_child(justify_block())
|
||||
.with_child(align_block())
|
||||
.with_child(align_self_block())
|
||||
.with_child(align_content_block())
|
||||
.with_child(grow_shrink_block())
|
||||
.with_child(other_block()),
|
||||
)
|
||||
.render()
|
||||
.await
|
||||
}
|
||||
|
||||
fn direction_block() -> Block {
|
||||
let mut block = Block::new().with_title(Lc::t("flex_block_title_direction", &LOC));
|
||||
|
||||
let direction_variants: [(&str, Flex, &str); 4] = [
|
||||
("flex_title_direction_row", Flex::new(), "Flex::new()"),
|
||||
(
|
||||
"flex_title_direction_row_reverse",
|
||||
Flex::new().with_direction(flex::Direction::RowReverse),
|
||||
"Flex::new().with_direction(Direction::RowReverse)",
|
||||
),
|
||||
(
|
||||
"flex_title_direction_column",
|
||||
Flex::new().with_direction(flex::Direction::Column),
|
||||
"Flex::new().with_direction(Direction::Column)",
|
||||
),
|
||||
(
|
||||
"flex_title_direction_column_reverse",
|
||||
Flex::new().with_direction(flex::Direction::ColumnReverse),
|
||||
"Flex::new().with_direction(Direction::ColumnReverse)",
|
||||
),
|
||||
];
|
||||
for (title_key, flex, code) in direction_variants {
|
||||
block = block
|
||||
.with_child(caption(Lc::t(title_key, &LOC), Lc::n(code)))
|
||||
.with_child(
|
||||
demo_row(flex)
|
||||
.with_child(demo_box(flex_item("1")))
|
||||
.with_child(demo_box(flex_item("2")))
|
||||
.with_child(demo_box(flex_item("3"))),
|
||||
);
|
||||
}
|
||||
block
|
||||
}
|
||||
|
||||
fn justify_block() -> Block {
|
||||
let mut block = Block::new().with_title(Lc::t("flex_block_title_justify", &LOC));
|
||||
|
||||
let justify_variants: [(&str, flex::ContentJustify, &str); 6] = [
|
||||
(
|
||||
"flex_title_justify_start",
|
||||
flex::ContentJustify::Start,
|
||||
"Flex::new().with_justify(ContentJustify::Start)",
|
||||
),
|
||||
(
|
||||
"flex_title_justify_center",
|
||||
flex::ContentJustify::Center,
|
||||
"Flex::new().with_justify(ContentJustify::Center)",
|
||||
),
|
||||
(
|
||||
"flex_title_justify_end",
|
||||
flex::ContentJustify::End,
|
||||
"Flex::new().with_justify(ContentJustify::End)",
|
||||
),
|
||||
(
|
||||
"flex_title_justify_between",
|
||||
flex::ContentJustify::SpaceBetween,
|
||||
"Flex::new().with_justify(ContentJustify::SpaceBetween)",
|
||||
),
|
||||
(
|
||||
"flex_title_justify_around",
|
||||
flex::ContentJustify::SpaceAround,
|
||||
"Flex::new().with_justify(ContentJustify::SpaceAround)",
|
||||
),
|
||||
(
|
||||
"flex_title_justify_evenly",
|
||||
flex::ContentJustify::SpaceEvenly,
|
||||
"Flex::new().with_justify(ContentJustify::SpaceEvenly)",
|
||||
),
|
||||
];
|
||||
for (title_key, justify, code) in justify_variants {
|
||||
block = block
|
||||
.with_child(caption(Lc::t(title_key, &LOC), Lc::n(code)))
|
||||
.with_child(
|
||||
demo_row(
|
||||
Flex::new()
|
||||
.with_justify(justify)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_child(demo_box(flex_item("1")))
|
||||
.with_child(demo_box(flex_item("2")))
|
||||
.with_child(demo_box(flex_item("3"))),
|
||||
);
|
||||
}
|
||||
block
|
||||
}
|
||||
|
||||
fn align_block() -> Block {
|
||||
let mut block = Block::new().with_title(Lc::t("flex_block_title_align", &LOC));
|
||||
|
||||
let align_variants: [(&str, align::Items, &str); 4] = [
|
||||
(
|
||||
"flex_title_align_start",
|
||||
align::Items::Start,
|
||||
"Flex::new().with_align(align::Items::Start)",
|
||||
),
|
||||
(
|
||||
"flex_title_align_center",
|
||||
align::Items::Center,
|
||||
"Flex::new().with_align(align::Items::Center)",
|
||||
),
|
||||
(
|
||||
"flex_title_align_end",
|
||||
align::Items::End,
|
||||
"Flex::new().with_align(align::Items::End)",
|
||||
),
|
||||
(
|
||||
"flex_title_align_stretch",
|
||||
align::Items::Stretch,
|
||||
"Flex::new().with_align(align::Items::Stretch)",
|
||||
),
|
||||
];
|
||||
for (title_key, align, code) in align_variants {
|
||||
block = block
|
||||
.with_child(caption(Lc::t(title_key, &LOC), Lc::n(code)))
|
||||
.with_child(
|
||||
demo_row(
|
||||
Flex::new()
|
||||
.with_align(align)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_child(sized_box(Lc::t("flex_box_tall", &LOC), "2.5rem 1rem"))
|
||||
.with_child(demo_box(Lc::t("flex_box_medium", &LOC)))
|
||||
.with_child(sized_box(Lc::t("flex_box_short", &LOC), "0.15rem 1rem")),
|
||||
);
|
||||
}
|
||||
block
|
||||
.with_child(caption(
|
||||
Lc::t("flex_title_align_baseline", &LOC),
|
||||
Lc::n("Flex::new().with_align(align::Items::Baseline)"),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(
|
||||
Flex::new()
|
||||
.with_align(align::Items::Baseline)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_child(
|
||||
sized_box(Lc::t("flex_box_tall", &LOC), "2.5rem 1rem")
|
||||
.with_prop(PropsOp::add_style("font-size", "1.75rem")),
|
||||
)
|
||||
.with_child(demo_box(Lc::t("flex_box_medium", &LOC)))
|
||||
.with_child(sized_box(Lc::t("flex_box_short", &LOC), "0.15rem 1rem")),
|
||||
)
|
||||
}
|
||||
|
||||
fn align_self_block() -> Block {
|
||||
let mut block = Block::new().with_title(Lc::t("flex_block_title_align_self", &LOC));
|
||||
|
||||
let align_self_variants: [(&str, align::ItemSelf, &str); 4] = [
|
||||
(
|
||||
"flex_title_align_self_start",
|
||||
align::ItemSelf::Start,
|
||||
"FlexItem::new().with_align_self(align::ItemSelf::Start)",
|
||||
),
|
||||
(
|
||||
"flex_title_align_self_end",
|
||||
align::ItemSelf::End,
|
||||
"FlexItem::new().with_align_self(align::ItemSelf::End)",
|
||||
),
|
||||
(
|
||||
"flex_title_align_self_center",
|
||||
align::ItemSelf::Center,
|
||||
"FlexItem::new().with_align_self(align::ItemSelf::Center)",
|
||||
),
|
||||
(
|
||||
"flex_title_align_self_stretch",
|
||||
align::ItemSelf::Stretch,
|
||||
"FlexItem::new().with_align_self(align::ItemSelf::Stretch)",
|
||||
),
|
||||
];
|
||||
for (title_key, align_self, code) in align_self_variants {
|
||||
block = block
|
||||
.with_child(caption(Lc::t(title_key, &LOC), Lc::n(code)))
|
||||
.with_child(
|
||||
demo_row(
|
||||
Flex::new()
|
||||
.with_align(align::Items::Start)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_child(sized_box(Lc::t("flex_box_tall", &LOC), "2.5rem 1rem"))
|
||||
.with_child(
|
||||
demo_box(flex_item("1")).with_prop(FlexItem::new().with_align_self(align_self)),
|
||||
)
|
||||
.with_child(sized_box(Lc::t("flex_box_tall", &LOC), "2.5rem 1rem")),
|
||||
);
|
||||
}
|
||||
block
|
||||
.with_child(caption(
|
||||
Lc::t("flex_title_align_self_baseline", &LOC),
|
||||
Lc::n("FlexItem::new().with_align_self(align::ItemSelf::Baseline)"),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(
|
||||
Flex::new()
|
||||
.with_align(align::Items::Start)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_child(
|
||||
sized_box(Lc::t("flex_box_tall", &LOC), "2.5rem 1rem")
|
||||
.with_prop(PropsOp::add_style("font-size", "1.75rem")),
|
||||
)
|
||||
.with_child(
|
||||
demo_box(flex_item("1"))
|
||||
.with_prop(FlexItem::new().with_align_self(align::ItemSelf::Baseline)),
|
||||
)
|
||||
.with_child(sized_box(Lc::t("flex_box_tall", &LOC), "2.5rem 1rem")),
|
||||
)
|
||||
}
|
||||
|
||||
fn align_content_block() -> Block {
|
||||
let mut block = Block::new().with_title(Lc::t("flex_block_title_align_content", &LOC));
|
||||
|
||||
let align_content_variants: [(&str, align::Content, &str); 7] = [
|
||||
(
|
||||
"flex_title_align_content_start",
|
||||
align::Content::Start,
|
||||
"Flex::new().with_wrap(Behavior::Wrap).with_align_content(align::Content::Start)",
|
||||
),
|
||||
(
|
||||
"flex_title_align_content_end",
|
||||
align::Content::End,
|
||||
"Flex::new().with_wrap(Behavior::Wrap).with_align_content(align::Content::End)",
|
||||
),
|
||||
(
|
||||
"flex_title_align_content_center",
|
||||
align::Content::Center,
|
||||
"Flex::new().with_wrap(Behavior::Wrap).with_align_content(align::Content::Center)",
|
||||
),
|
||||
(
|
||||
"flex_title_align_content_between",
|
||||
align::Content::SpaceBetween,
|
||||
"Flex::new().with_wrap(Behavior::Wrap).with_align_content(align::Content::SpaceBetween)",
|
||||
),
|
||||
(
|
||||
"flex_title_align_content_around",
|
||||
align::Content::SpaceAround,
|
||||
"Flex::new().with_wrap(Behavior::Wrap).with_align_content(align::Content::SpaceAround)",
|
||||
),
|
||||
(
|
||||
"flex_title_align_content_evenly",
|
||||
align::Content::SpaceEvenly,
|
||||
"Flex::new().with_wrap(Behavior::Wrap).with_align_content(align::Content::SpaceEvenly)",
|
||||
),
|
||||
(
|
||||
"flex_title_align_content_stretch",
|
||||
align::Content::Stretch,
|
||||
"Flex::new().with_wrap(Behavior::Wrap).with_align_content(align::Content::Stretch)",
|
||||
),
|
||||
];
|
||||
for (title_key, align_content, code) in align_content_variants {
|
||||
let mut row = demo_row(
|
||||
Flex::new()
|
||||
.with_wrap(flex::Behavior::Wrap)
|
||||
.with_align_content(align_content)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_prop(PropsOp::add_style("max-width", "21rem"))
|
||||
.with_prop(PropsOp::add_style("min-height", "11rem"));
|
||||
for label in ["1", "2", "3", "4"] {
|
||||
row = row.with_child(
|
||||
sized_box(flex_item(label), "0.5rem 1rem")
|
||||
.with_prop(PropsOp::add_style("width", "9rem")),
|
||||
);
|
||||
}
|
||||
block = block
|
||||
.with_child(caption(Lc::t(title_key, &LOC), Lc::n(code)))
|
||||
.with_child(row);
|
||||
}
|
||||
block
|
||||
}
|
||||
|
||||
fn grow_shrink_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("flex_block_title_grow_shrink", &LOC))
|
||||
.with_child(caption(
|
||||
Lc::t("flex_title_grow", &LOC),
|
||||
Lc::n("FlexItem::new().with_grow(flex::ItemGrow::Is1)"),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(Flex::new().with_gap(align::Gap::Both(UnitValue::RelRem(0.5))))
|
||||
.with_child(demo_box(Lc::t("flex_box_fixed", &LOC)))
|
||||
.with_child(
|
||||
demo_box(Lc::t("flex_box_grows", &LOC))
|
||||
.with_prop(FlexItem::new().with_grow(flex::ItemGrow::Is1)),
|
||||
)
|
||||
.with_child(demo_box(Lc::t("flex_box_fixed", &LOC))),
|
||||
)
|
||||
.with_child(caption(
|
||||
Lc::t("flex_title_shrink", &LOC),
|
||||
Lc::n("FlexItem::new().with_shrink(flex::ItemShrink::Is0)"),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(Flex::new().with_gap(align::Gap::Both(UnitValue::RelRem(0.5))))
|
||||
.with_prop(PropsOp::add_style("max-width", "31rem"))
|
||||
.with_child(
|
||||
demo_box(flex_item("1")).with_prop(PropsOp::add_style("width", "10.5rem")),
|
||||
)
|
||||
.with_child(
|
||||
demo_box(flex_item("2"))
|
||||
.with_prop(PropsOp::add_style("width", "10.5rem"))
|
||||
.with_prop(FlexItem::new().with_shrink(flex::ItemShrink::Is0)),
|
||||
)
|
||||
.with_child(
|
||||
demo_box(flex_item("3")).with_prop(PropsOp::add_style("width", "10.5rem")),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fn other_block() -> Block {
|
||||
let mut block = Block::new().with_title(Lc::t("flex_block_title_other", &LOC));
|
||||
|
||||
block = block
|
||||
.with_child(caption(
|
||||
Lc::t("flex_title_push_end", &LOC),
|
||||
Lc::n("FlexItem::push_end()"),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(Flex::new().with_gap(align::Gap::Both(UnitValue::RelRem(0.5))))
|
||||
.with_child(demo_box(Lc::t("flex_box_start_1", &LOC)))
|
||||
.with_child(demo_box(Lc::t("flex_box_start_2", &LOC)))
|
||||
.with_child(demo_box(Lc::t("flex_box_end", &LOC)).with_prop(FlexItem::push_end())),
|
||||
);
|
||||
|
||||
let mut wrap_row = demo_row(
|
||||
Flex::new()
|
||||
.with_wrap(flex::Behavior::Wrap)
|
||||
.with_align_content(align::Content::SpaceBetween)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_prop(PropsOp::add_style("max-width", "20rem"))
|
||||
.with_prop(PropsOp::add_style("min-height", "11rem"));
|
||||
for label in ["1", "2", "3", "4", "5", "6", "7", "8"] {
|
||||
wrap_row = wrap_row.with_child(
|
||||
sized_box(flex_item(label), "0.5rem 1rem")
|
||||
.with_prop(PropsOp::add_style("width", "4rem")),
|
||||
);
|
||||
}
|
||||
block
|
||||
.with_child(caption(
|
||||
Lc::t("flex_title_wrap", &LOC),
|
||||
Lc::n(concat!(
|
||||
"Flex::new()",
|
||||
".with_wrap(Behavior::Wrap)",
|
||||
".with_align_content(align::Content::SpaceBetween)",
|
||||
)),
|
||||
))
|
||||
.with_child(wrap_row)
|
||||
.with_child(caption(
|
||||
Lc::t("flex_title_order", &LOC),
|
||||
Lc::n("FlexItem::new().with_order(ItemOrder::First) / .with_order(ItemOrder::Last)"),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(Flex::new().with_gap(align::Gap::Both(UnitValue::RelRem(0.5))))
|
||||
.with_child(
|
||||
demo_box(Lc::n("A"))
|
||||
.with_prop(FlexItem::new().with_order(flex::ItemOrder::Last)),
|
||||
)
|
||||
.with_child(demo_box(Lc::n("B")))
|
||||
.with_child(demo_box(Lc::n("C")))
|
||||
.with_child(demo_box(Lc::n("D")))
|
||||
.with_child(
|
||||
demo_box(Lc::n("E"))
|
||||
.with_prop(FlexItem::new().with_order(flex::ItemOrder::First)),
|
||||
),
|
||||
)
|
||||
.with_child(caption(
|
||||
Lc::t("flex_title_gap_none", &LOC),
|
||||
Lc::n("Flex::new() (align::Gap::None por defecto)"),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(Flex::new())
|
||||
.with_child(demo_box(flex_item("1")))
|
||||
.with_child(demo_box(flex_item("2")))
|
||||
.with_child(demo_box(flex_item("3"))),
|
||||
)
|
||||
.with_child(caption(
|
||||
Lc::t("flex_title_gap_some", &LOC),
|
||||
Lc::n("Flex::new().with_gap(align::Gap::Both(UnitValue::RelRem(1.5)))"),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(Flex::new().with_gap(align::Gap::Both(UnitValue::RelRem(1.5))))
|
||||
.with_child(demo_box(flex_item("1")))
|
||||
.with_child(demo_box(flex_item("2")))
|
||||
.with_child(demo_box(flex_item("3"))),
|
||||
)
|
||||
.with_child(caption(
|
||||
Lc::t("flex_title_grid_thirds", &LOC),
|
||||
Lc::n("FlexItem::new().with_size(flex::ItemSize::Percent33)"),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(Flex::new())
|
||||
.with_child(
|
||||
demo_box(Lc::n("1/3"))
|
||||
.with_prop(FlexItem::new().with_size(flex::ItemSize::Percent33)),
|
||||
)
|
||||
.with_child(
|
||||
demo_box(Lc::n("1/3"))
|
||||
.with_prop(FlexItem::new().with_size(flex::ItemSize::Percent33)),
|
||||
)
|
||||
.with_child(
|
||||
demo_box(Lc::n("1/3"))
|
||||
.with_prop(FlexItem::new().with_size(flex::ItemSize::Percent33)),
|
||||
),
|
||||
)
|
||||
.with_child(caption(
|
||||
Lc::t("flex_title_grid_offset", &LOC),
|
||||
Lc::n(concat!(
|
||||
"FlexItem::new()",
|
||||
".with_size(ItemSize::Percent50)",
|
||||
".with_offset(ItemOffset::Percent25)",
|
||||
)),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(Flex::new()).with_child(
|
||||
demo_box(Lc::t("flex_box_half_centered", &LOC)).with_prop(
|
||||
FlexItem::new()
|
||||
.with_size(flex::ItemSize::Percent50)
|
||||
.with_offset(flex::ItemOffset::Percent25),
|
||||
),
|
||||
),
|
||||
)
|
||||
.with_child(caption(
|
||||
Lc::t("flex_title_toolbar", &LOC),
|
||||
Lc::t("flex_desc_toolbar", &LOC),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(
|
||||
Flex::new()
|
||||
.with_align(align::Items::Center)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_child(demo_box(Lc::t("flex_box_file", &LOC)))
|
||||
.with_child(demo_box(Lc::t("flex_box_edit", &LOC)))
|
||||
.with_child(demo_box(Lc::t("flex_box_view", &LOC)))
|
||||
.with_child(demo_box(Lc::t("flex_box_profile", &LOC)).with_prop(FlexItem::push_end()))
|
||||
.with_child(demo_box(Lc::t("flex_box_logout", &LOC))),
|
||||
)
|
||||
}
|
||||
|
||||
// **< HELPERS >************************************************************************************
|
||||
|
||||
// Aspecto fijo de las cajas de muestra.
|
||||
fn demo_box_styles() -> AssetsOp {
|
||||
AssetsOp::add_responsive_styles(
|
||||
None,
|
||||
"flex-demo-box",
|
||||
[
|
||||
("background-color", "#0d6efd"),
|
||||
("color", "#fff"),
|
||||
("min-width", "3rem"),
|
||||
("width", "auto"),
|
||||
("max-width", "none"),
|
||||
("margin", "0"),
|
||||
("border-radius", "0.375rem"),
|
||||
("text-align", "center"),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
// Aspecto fijo de las filas de muestra.
|
||||
fn demo_row_styles() -> AssetsOp {
|
||||
AssetsOp::add_responsive_styles(
|
||||
None,
|
||||
"flex-demo-row",
|
||||
[
|
||||
("background-color", "#f1f3f5"),
|
||||
("width", "100%"),
|
||||
("max-width", "none"),
|
||||
("margin", "0 0 1.5rem"),
|
||||
("padding", "0.75rem"),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
// Caja con fondo azul y relleno vertical configurable, para mostrar diferencias de altura.
|
||||
fn sized_box(label: Lc, padding: &'static str) -> Container {
|
||||
Container::new()
|
||||
.with_prop(PropsOp::add_classes("flex-demo-box"))
|
||||
.with_prop(PropsOp::add_style("padding", padding))
|
||||
.with_child(Html::with(move |cx| html! { (label.using(cx)) }))
|
||||
}
|
||||
|
||||
// Caja con el relleno vertical estandar del resto de ejemplos.
|
||||
fn demo_box(label: Lc) -> Container {
|
||||
sized_box(label, "0.5rem 1rem")
|
||||
}
|
||||
|
||||
// Etiqueta "Flex item N" para las cajas que solo se distinguen por su posicion.
|
||||
fn flex_item(n: impl Into<CowStr>) -> Lc {
|
||||
Lc::t("flex_item_label", &LOC).with_arg("n", n)
|
||||
}
|
||||
|
||||
// Fila de demostracion con fondo gris para visualizar los limites del propio contenedor flex.
|
||||
fn demo_row(flex: Flex) -> Flex {
|
||||
flex.with_prop(PropsOp::add_classes("flex-demo-row"))
|
||||
}
|
||||
|
||||
// Titulo y fragmento de codigo que introducen cada demostracion.
|
||||
fn caption(title: Lc, code: Lc) -> Html {
|
||||
Html::with(move |cx| {
|
||||
html! {
|
||||
h3 { (title.using(cx)) }
|
||||
p { code { (code.using(cx)) } }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::prepare(&IntroFlex).await.run().await
|
||||
}
|
||||
543
examples/intro-grid.rs
Normal file
|
|
@ -0,0 +1,543 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
include_locales!(LOC from "examples/locale");
|
||||
|
||||
struct IntroGrid;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for IntroGrid {
|
||||
fn dependencies(&self) -> Vec<ExtensionRef> {
|
||||
vec![&pagetop_bootsier::Bootsier]
|
||||
}
|
||||
|
||||
fn configure_router(&self, routes: Routes) -> Routes {
|
||||
routes.public_route("/", web::get(intro_grid))
|
||||
}
|
||||
}
|
||||
|
||||
async fn intro_grid(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||
Page::new(request)
|
||||
.with_assets(demo_box_styles())
|
||||
.with_assets(demo_row_styles())
|
||||
.with_child(
|
||||
Intro::custom()
|
||||
.with_title(Lc::n("PageTop"))
|
||||
.with_slogan(Lc::t("grid_slogan", &LOC))
|
||||
.with_child(columns_block())
|
||||
.with_child(rows_gap_block())
|
||||
.with_child(placement_block())
|
||||
.with_child(alignment_block())
|
||||
.with_child(content_alignment_block())
|
||||
.with_child(item_alignment_block())
|
||||
.with_child(auto_flow_block())
|
||||
.with_child(auto_tracks_block())
|
||||
.with_child(responsive_block())
|
||||
.with_child(layout_block()),
|
||||
)
|
||||
.render()
|
||||
.await
|
||||
}
|
||||
|
||||
fn columns_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("grid_block_title_columns", &LOC))
|
||||
.with_child(caption(
|
||||
Lc::t("grid_title_columns_thirds", &LOC),
|
||||
Lc::n("Grid::new().with_columns(Tracks::repeat(3, AxisTrack::Fraction(1.0)))"),
|
||||
))
|
||||
.with_child(
|
||||
demo_grid(
|
||||
Grid::new()
|
||||
.with_columns(grid::Tracks::repeat(3, grid::AxisTrack::Fraction(1.0)))
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_child(demo_box(grid_box("1")))
|
||||
.with_child(demo_box(grid_box("2")))
|
||||
.with_child(demo_box(grid_box("3"))),
|
||||
)
|
||||
.with_child(caption(
|
||||
Lc::t("grid_title_columns_sidebar", &LOC),
|
||||
Lc::n(concat!(
|
||||
"Grid::new().with_columns(Tracks::new()",
|
||||
".with_track(AxisTrack::Fixed(UnitValue::Px(140)))",
|
||||
".with_track(AxisTrack::Fraction(1.0)))",
|
||||
)),
|
||||
))
|
||||
.with_child(
|
||||
demo_grid(
|
||||
Grid::new()
|
||||
.with_columns(
|
||||
grid::Tracks::new()
|
||||
.with_track(grid::AxisTrack::Fixed(UnitValue::Px(140)))
|
||||
.with_track(grid::AxisTrack::Fraction(1.0)),
|
||||
)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_child(demo_box(Lc::t("grid_box_sidebar", &LOC)))
|
||||
.with_child(demo_box(Lc::t("grid_box_content", &LOC))),
|
||||
)
|
||||
.with_child(caption(
|
||||
Lc::t("grid_title_columns_min_max", &LOC),
|
||||
Lc::n(concat!(
|
||||
"Grid::new().with_columns(Tracks::new()",
|
||||
".with_track(AxisTrack::MinContent)",
|
||||
".with_track(AxisTrack::Fraction(1.0))",
|
||||
".with_track(AxisTrack::MaxContent))",
|
||||
)),
|
||||
))
|
||||
.with_child(
|
||||
demo_grid(
|
||||
Grid::new()
|
||||
.with_columns(
|
||||
grid::Tracks::new()
|
||||
.with_track(grid::AxisTrack::MinContent)
|
||||
.with_track(grid::AxisTrack::Fraction(1.0))
|
||||
.with_track(grid::AxisTrack::MaxContent),
|
||||
)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_child(demo_box(Lc::t("grid_box_min_content", &LOC)))
|
||||
.with_child(demo_box(Lc::t("grid_box_fraction", &LOC)))
|
||||
.with_child(demo_box(Lc::t("grid_box_max_content", &LOC))),
|
||||
)
|
||||
}
|
||||
|
||||
fn rows_gap_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("grid_block_title_rows_gap", &LOC))
|
||||
.with_child(caption(
|
||||
Lc::t("grid_title_rows", &LOC),
|
||||
Lc::n(concat!(
|
||||
"Grid::new()",
|
||||
".with_columns(Tracks::repeat(2, AxisTrack::Fraction(1.0)))",
|
||||
".with_rows(Tracks::repeat(2, AxisTrack::Fixed(UnitValue::RelRem(3.0))))",
|
||||
)),
|
||||
))
|
||||
.with_child(
|
||||
demo_grid(
|
||||
Grid::new()
|
||||
.with_columns(grid::Tracks::repeat(2, grid::AxisTrack::Fraction(1.0)))
|
||||
.with_rows(grid::Tracks::repeat(
|
||||
2,
|
||||
grid::AxisTrack::Fixed(UnitValue::RelRem(3.0)),
|
||||
))
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_child(demo_box(grid_box("1")))
|
||||
.with_child(demo_box(grid_box("2")))
|
||||
.with_child(demo_box(grid_box("3")))
|
||||
.with_child(demo_box(grid_box("4"))),
|
||||
)
|
||||
.with_child(caption(
|
||||
Lc::t("grid_title_gap_distinct", &LOC),
|
||||
Lc::n(concat!(
|
||||
"Grid::new().with_gap(align::Gap::Distinct {",
|
||||
" row: UnitValue::RelRem(1.5), column: UnitValue::RelRem(0.25) })",
|
||||
)),
|
||||
))
|
||||
.with_child(
|
||||
demo_grid(
|
||||
Grid::new()
|
||||
.with_columns(grid::Tracks::repeat(3, grid::AxisTrack::Fraction(1.0)))
|
||||
.with_gap(align::Gap::Distinct {
|
||||
row: UnitValue::RelRem(1.5),
|
||||
column: UnitValue::RelRem(0.25),
|
||||
}),
|
||||
)
|
||||
.with_child(demo_box(grid_box("1")))
|
||||
.with_child(demo_box(grid_box("2")))
|
||||
.with_child(demo_box(grid_box("3")))
|
||||
.with_child(demo_box(grid_box("4")))
|
||||
.with_child(demo_box(grid_box("5")))
|
||||
.with_child(demo_box(grid_box("6"))),
|
||||
)
|
||||
}
|
||||
|
||||
fn placement_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("grid_block_title_placement", &LOC))
|
||||
.with_child(caption(
|
||||
Lc::t("grid_title_placement", &LOC),
|
||||
Lc::n(concat!(
|
||||
"GridItem::new().with_column(ItemPlacement::Span(2))",
|
||||
" / .with_column(ItemPlacement::Range(2, 4))",
|
||||
)),
|
||||
))
|
||||
.with_child(
|
||||
demo_grid(
|
||||
Grid::new()
|
||||
.with_columns(grid::Tracks::repeat(4, grid::AxisTrack::Fraction(1.0)))
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_child(demo_box(Lc::t("grid_box_plain", &LOC)))
|
||||
.with_child(
|
||||
demo_box(Lc::t("grid_box_span_2", &LOC))
|
||||
.with_prop(GridItem::new().with_column(grid::ItemPlacement::Span(2))),
|
||||
)
|
||||
.with_child(demo_box(Lc::t("grid_box_plain", &LOC)))
|
||||
.with_child(
|
||||
demo_box(Lc::t("grid_box_range", &LOC)).with_prop(
|
||||
GridItem::new()
|
||||
.with_column(grid::ItemPlacement::Range(2, 4))
|
||||
.with_row(grid::ItemPlacement::Line(2)),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fn alignment_block() -> Block {
|
||||
let mut block = Block::new().with_title(Lc::t("grid_block_title_alignment", &LOC));
|
||||
|
||||
let variants: [(&str, grid::DefaultJustify, align::Items, &str); 4] = [
|
||||
(
|
||||
"grid_title_alignment_start",
|
||||
grid::DefaultJustify::Start,
|
||||
align::Items::Start,
|
||||
concat!(
|
||||
"Grid::new().with_justify_items(DefaultJustify::Start)",
|
||||
".with_align_items(align::Items::Start)",
|
||||
),
|
||||
),
|
||||
(
|
||||
"grid_title_alignment_center",
|
||||
grid::DefaultJustify::Center,
|
||||
align::Items::Center,
|
||||
concat!(
|
||||
"Grid::new().with_justify_items(DefaultJustify::Center)",
|
||||
".with_align_items(align::Items::Center)",
|
||||
),
|
||||
),
|
||||
(
|
||||
"grid_title_alignment_end",
|
||||
grid::DefaultJustify::End,
|
||||
align::Items::End,
|
||||
concat!(
|
||||
"Grid::new().with_justify_items(DefaultJustify::End)",
|
||||
".with_align_items(align::Items::End)",
|
||||
),
|
||||
),
|
||||
(
|
||||
"grid_title_alignment_stretch",
|
||||
grid::DefaultJustify::Stretch,
|
||||
align::Items::Stretch,
|
||||
concat!(
|
||||
"Grid::new().with_justify_items(DefaultJustify::Stretch)",
|
||||
".with_align_items(align::Items::Stretch)",
|
||||
),
|
||||
),
|
||||
];
|
||||
for (title_key, justify_items, align_items, code) in variants {
|
||||
block = block
|
||||
.with_child(caption(Lc::t(title_key, &LOC), Lc::n(code)))
|
||||
.with_child(
|
||||
demo_grid(
|
||||
Grid::new()
|
||||
.with_columns(grid::Tracks::repeat(
|
||||
3,
|
||||
grid::AxisTrack::Fixed(UnitValue::Px(96)),
|
||||
))
|
||||
.with_rows(grid::Tracks::repeat(
|
||||
1,
|
||||
grid::AxisTrack::Fixed(UnitValue::RelRem(4.5)),
|
||||
))
|
||||
.with_justify_items(justify_items)
|
||||
.with_align_items(align_items)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_child(demo_box(grid_box("1")))
|
||||
.with_child(demo_box(grid_box("2")))
|
||||
.with_child(demo_box(grid_box("3"))),
|
||||
);
|
||||
}
|
||||
block
|
||||
}
|
||||
|
||||
fn content_alignment_block() -> Block {
|
||||
let mut block = Block::new().with_title(Lc::t("grid_block_title_content_alignment", &LOC));
|
||||
|
||||
let variants: [(&str, grid::ContentJustify, &str); 4] = [
|
||||
(
|
||||
"grid_title_content_alignment_start",
|
||||
grid::ContentJustify::Start,
|
||||
"Grid::new().with_justify_content(ContentJustify::Start)",
|
||||
),
|
||||
(
|
||||
"grid_title_content_alignment_center",
|
||||
grid::ContentJustify::Center,
|
||||
"Grid::new().with_justify_content(ContentJustify::Center)",
|
||||
),
|
||||
(
|
||||
"grid_title_content_alignment_between",
|
||||
grid::ContentJustify::SpaceBetween,
|
||||
"Grid::new().with_justify_content(ContentJustify::SpaceBetween)",
|
||||
),
|
||||
(
|
||||
"grid_title_content_alignment_evenly",
|
||||
grid::ContentJustify::SpaceEvenly,
|
||||
"Grid::new().with_justify_content(ContentJustify::SpaceEvenly)",
|
||||
),
|
||||
];
|
||||
for (title_key, justify_content, code) in variants {
|
||||
block = block
|
||||
.with_child(caption(Lc::t(title_key, &LOC), Lc::n(code)))
|
||||
.with_child(
|
||||
demo_grid(
|
||||
Grid::new()
|
||||
.with_columns(grid::Tracks::repeat(
|
||||
3,
|
||||
grid::AxisTrack::Fixed(UnitValue::Px(72)),
|
||||
))
|
||||
.with_justify_content(justify_content)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_prop(PropsOp::add_style("max-width", "26rem"))
|
||||
.with_child(demo_box(grid_box("1")))
|
||||
.with_child(demo_box(grid_box("2")))
|
||||
.with_child(demo_box(grid_box("3"))),
|
||||
);
|
||||
}
|
||||
block
|
||||
}
|
||||
|
||||
fn item_alignment_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("grid_block_title_item_alignment", &LOC))
|
||||
.with_child(caption(
|
||||
Lc::t("grid_title_item_alignment", &LOC),
|
||||
Lc::n(concat!(
|
||||
"GridItem::new()",
|
||||
".with_justify_self(ItemJustify::End)",
|
||||
".with_align_self(align::ItemSelf::End)",
|
||||
)),
|
||||
))
|
||||
.with_child(
|
||||
demo_grid(
|
||||
Grid::new()
|
||||
.with_columns(grid::Tracks::repeat(
|
||||
3,
|
||||
grid::AxisTrack::Fixed(UnitValue::Px(96)),
|
||||
))
|
||||
.with_rows(grid::Tracks::repeat(
|
||||
1,
|
||||
grid::AxisTrack::Fixed(UnitValue::RelRem(4.5)),
|
||||
))
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_child(demo_box(grid_box("1")))
|
||||
.with_child(
|
||||
demo_box(Lc::t("grid_box_overridden", &LOC)).with_prop(
|
||||
GridItem::new()
|
||||
.with_justify_self(grid::ItemJustify::End)
|
||||
.with_align_self(align::ItemSelf::End),
|
||||
),
|
||||
)
|
||||
.with_child(demo_box(grid_box("3"))),
|
||||
)
|
||||
}
|
||||
|
||||
fn auto_flow_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("grid_block_title_auto_flow", &LOC))
|
||||
.with_child(caption(
|
||||
Lc::t("grid_title_auto_flow_row", &LOC),
|
||||
Lc::n("Grid::new().with_auto_flow(AutoFlow::Row) (por defecto)"),
|
||||
))
|
||||
.with_child(dense_demo(grid::AutoFlow::Row))
|
||||
.with_child(caption(
|
||||
Lc::t("grid_title_auto_flow_dense", &LOC),
|
||||
Lc::n("Grid::new().with_auto_flow(AutoFlow::RowDense)"),
|
||||
))
|
||||
.with_child(dense_demo(grid::AutoFlow::RowDense))
|
||||
}
|
||||
|
||||
fn dense_demo(auto_flow: grid::AutoFlow) -> Grid {
|
||||
demo_grid(
|
||||
Grid::new()
|
||||
.with_columns(grid::Tracks::repeat(4, grid::AxisTrack::Fraction(1.0)))
|
||||
.with_auto_flow(auto_flow)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_child(
|
||||
demo_box(Lc::t("grid_box_span_2", &LOC))
|
||||
.with_prop(GridItem::new().with_column(grid::ItemPlacement::Span(2))),
|
||||
)
|
||||
.with_child(
|
||||
demo_box(Lc::t("grid_box_span_2", &LOC))
|
||||
.with_prop(GridItem::new().with_column(grid::ItemPlacement::Span(2))),
|
||||
)
|
||||
.with_child(demo_box(grid_box("1")))
|
||||
.with_child(demo_box(grid_box("2")))
|
||||
.with_child(demo_box(grid_box("3")))
|
||||
}
|
||||
|
||||
fn auto_tracks_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("grid_block_title_auto_tracks", &LOC))
|
||||
.with_child(caption(
|
||||
Lc::t("grid_title_auto_tracks", &LOC),
|
||||
Lc::n(concat!(
|
||||
"Grid::new()",
|
||||
".with_columns(Tracks::repeat(3, AxisTrack::Fraction(1.0)))",
|
||||
".with_auto_rows(AxisTrack::Fixed(UnitValue::RelRem(3.0)))",
|
||||
)),
|
||||
))
|
||||
.with_child(
|
||||
demo_grid(
|
||||
Grid::new()
|
||||
.with_columns(grid::Tracks::repeat(3, grid::AxisTrack::Fraction(1.0)))
|
||||
.with_auto_rows(grid::AxisTrack::Fixed(UnitValue::RelRem(3.0)))
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_child(demo_box(grid_box("1")))
|
||||
.with_child(demo_box(grid_box("2")))
|
||||
.with_child(demo_box(grid_box("3")))
|
||||
.with_child(demo_box(grid_box("4")))
|
||||
.with_child(demo_box(grid_box("5")))
|
||||
.with_child(demo_box(grid_box("6"))),
|
||||
)
|
||||
}
|
||||
|
||||
fn responsive_block() -> Block {
|
||||
let mut row = demo_grid(
|
||||
Grid::new()
|
||||
.with_columns(grid::Tracks::repeat(1, grid::AxisTrack::Fraction(1.0)))
|
||||
.with_columns_at(
|
||||
Breakpoint::Sm,
|
||||
grid::Tracks::repeat(2, grid::AxisTrack::Fraction(1.0)),
|
||||
)
|
||||
.with_columns_at(
|
||||
Breakpoint::Md,
|
||||
grid::Tracks::repeat(3, grid::AxisTrack::Fraction(1.0)),
|
||||
)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
);
|
||||
for n in 1..=6 {
|
||||
row = row.with_child(demo_box(card_label(n)));
|
||||
}
|
||||
Block::new()
|
||||
.with_title(Lc::t("grid_block_title_responsive", &LOC))
|
||||
.with_child(caption(
|
||||
Lc::t("grid_title_responsive", &LOC),
|
||||
Lc::n(concat!(
|
||||
"Grid::new()",
|
||||
".with_columns(Tracks::repeat(1, AxisTrack::Fraction(1.0)))",
|
||||
".with_columns_at(Breakpoint::Sm, Tracks::repeat(2, AxisTrack::Fraction(1.0)))",
|
||||
".with_columns_at(Breakpoint::Md, Tracks::repeat(3, AxisTrack::Fraction(1.0)))",
|
||||
)),
|
||||
))
|
||||
.with_child(row)
|
||||
}
|
||||
|
||||
fn layout_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("grid_block_title_layout", &LOC))
|
||||
.with_child(caption(
|
||||
Lc::t("grid_title_layout", &LOC),
|
||||
Lc::t("grid_desc_layout", &LOC),
|
||||
))
|
||||
.with_child(
|
||||
demo_grid(
|
||||
Grid::new()
|
||||
.with_columns(
|
||||
grid::Tracks::new()
|
||||
.with_track(grid::AxisTrack::Fixed(UnitValue::Px(120)))
|
||||
.with_track(grid::AxisTrack::Fraction(1.0))
|
||||
.with_track(grid::AxisTrack::Fixed(UnitValue::Px(120))),
|
||||
)
|
||||
.with_rows(
|
||||
grid::Tracks::new()
|
||||
.with_track(grid::AxisTrack::Auto)
|
||||
.with_track(grid::AxisTrack::Fraction(1.0))
|
||||
.with_track(grid::AxisTrack::Auto),
|
||||
)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_prop(PropsOp::add_style("min-height", "18rem"))
|
||||
.with_child(
|
||||
demo_box(Lc::t("grid_box_header", &LOC))
|
||||
.with_prop(GridItem::new().with_column(grid::ItemPlacement::Span(3))),
|
||||
)
|
||||
.with_child(demo_box(Lc::t("grid_box_nav", &LOC)))
|
||||
.with_child(demo_box(Lc::t("grid_box_content", &LOC)))
|
||||
.with_child(demo_box(Lc::t("grid_box_aside", &LOC)))
|
||||
.with_child(
|
||||
demo_box(Lc::t("grid_box_footer", &LOC))
|
||||
.with_prop(GridItem::new().with_column(grid::ItemPlacement::Span(3))),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
// **< HELPERS >************************************************************************************
|
||||
|
||||
// Aspecto fijo de las cajas de muestra: esquinas rectas y borde claro, a diferencia de las cajas
|
||||
// redondeadas de `intro-flex.rs`, para distinguir a simple vista los ejemplos de Grid de los de
|
||||
// Flex.
|
||||
fn demo_box_styles() -> AssetsOp {
|
||||
AssetsOp::add_responsive_styles(
|
||||
None,
|
||||
"grid-demo-box",
|
||||
[
|
||||
("background-color", "#0d6efd"),
|
||||
("color", "#fff"),
|
||||
("border", "2px solid #6ea8fe"),
|
||||
("min-width", "3rem"),
|
||||
("width", "auto"),
|
||||
("max-width", "none"),
|
||||
("margin", "0"),
|
||||
("text-align", "center"),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
// Aspecto fijo de las filas de muestra.
|
||||
fn demo_row_styles() -> AssetsOp {
|
||||
AssetsOp::add_responsive_styles(
|
||||
None,
|
||||
"grid-demo-row",
|
||||
[
|
||||
("background-color", "#f1f3f5"),
|
||||
("width", "100%"),
|
||||
("max-width", "none"),
|
||||
("margin", "0 0 1.5rem"),
|
||||
("padding", "0.75rem"),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
// Caja con el relleno vertical estandar del resto de ejemplos.
|
||||
fn demo_box(label: Lc) -> Container {
|
||||
Container::new()
|
||||
.with_prop(PropsOp::add_classes("grid-demo-box"))
|
||||
.with_prop(PropsOp::add_style("padding", "0.5rem 1rem"))
|
||||
.with_child(Html::with(move |cx| html! { (label.using(cx)) }))
|
||||
}
|
||||
|
||||
// Etiqueta "Box N" para las cajas que sólo se distinguen por su posición.
|
||||
fn grid_box(n: impl Into<CowStr>) -> Lc {
|
||||
Lc::t("grid_box_label", &LOC).with_arg("n", n)
|
||||
}
|
||||
|
||||
// Etiqueta "Tarjeta N" para las cajas de la rejilla responsive.
|
||||
fn card_label(n: usize) -> Lc {
|
||||
Lc::t("grid_box_card", &LOC).with_arg("n", n.to_string())
|
||||
}
|
||||
|
||||
// Rejilla de demostracion con fondo gris para visualizar los limites del propio contenedor grid.
|
||||
fn demo_grid(grid: Grid) -> Grid {
|
||||
grid.with_prop(PropsOp::add_classes("grid-demo-row"))
|
||||
}
|
||||
|
||||
// Titulo y fragmento de codigo que introducen cada demostracion.
|
||||
fn caption(title: Lc, code: Lc) -> Html {
|
||||
Html::with(move |cx| {
|
||||
html! {
|
||||
h3 { (title.using(cx)) }
|
||||
p { code { (code.using(cx)) } }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::prepare(&IntroGrid).await.run().await
|
||||
}
|
||||
263
examples/intro-responsive.rs
Normal file
|
|
@ -0,0 +1,263 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
include_locales!(LOC from "examples/locale");
|
||||
|
||||
struct IntroResponsive;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for IntroResponsive {
|
||||
fn dependencies(&self) -> Vec<ExtensionRef> {
|
||||
vec![&pagetop_bootsier::Bootsier]
|
||||
}
|
||||
|
||||
fn configure_router(&self, routes: Routes) -> Routes {
|
||||
routes.public_route("/", web::get(intro_responsive))
|
||||
}
|
||||
}
|
||||
|
||||
async fn intro_responsive(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||
Page::new(request)
|
||||
.with_assets(demo_box_styles())
|
||||
.with_assets(demo_row_styles())
|
||||
.with_assets(demo_code_styles())
|
||||
.with_child(
|
||||
Intro::custom()
|
||||
.with_title(Lc::n("PageTop"))
|
||||
.with_slogan(Lc::t("responsive_slogan", &LOC))
|
||||
.with_child(Html::with(|cx| {
|
||||
html! {
|
||||
p class="intro-text-lead" {
|
||||
(Lc::t("responsive_note", &LOC).using(cx))
|
||||
}
|
||||
}
|
||||
}))
|
||||
.with_child(activation_block())
|
||||
.with_child(direction_block())
|
||||
.with_child(grid_block())
|
||||
.with_child(justify_align_block())
|
||||
.with_child(order_block())
|
||||
.with_child(gap_grow_block()),
|
||||
)
|
||||
.render()
|
||||
.await
|
||||
}
|
||||
|
||||
fn activation_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("responsive_block_title_activation", &LOC))
|
||||
.with_child(caption(
|
||||
Lc::t("responsive_title_activation", &LOC),
|
||||
Lc::n("Flex::at(Breakpoint::Md)"),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(Flex::at(Breakpoint::Md).with_gap(align::Gap::Both(UnitValue::RelRem(0.5))))
|
||||
.with_child(demo_box(Lc::t("responsive_box_nav_home", &LOC)))
|
||||
.with_child(demo_box(Lc::t("responsive_box_nav_products", &LOC)))
|
||||
.with_child(demo_box(Lc::t("responsive_box_nav_about", &LOC)))
|
||||
.with_child(demo_box(Lc::t("responsive_box_nav_contact", &LOC))),
|
||||
)
|
||||
}
|
||||
|
||||
fn direction_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("responsive_block_title_direction", &LOC))
|
||||
.with_child(caption(
|
||||
Lc::t("responsive_title_direction", &LOC),
|
||||
Lc::n(concat!(
|
||||
"Flex::new()",
|
||||
".with_direction(Direction::Column)",
|
||||
".with_direction_at(Breakpoint::Md, Direction::RowReverse)",
|
||||
)),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(
|
||||
Flex::new()
|
||||
.with_direction(flex::Direction::Column)
|
||||
.with_direction_at(Breakpoint::Md, flex::Direction::RowReverse)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_child(sized_box(
|
||||
Lc::t("responsive_box_image", &LOC),
|
||||
"2.5rem 1rem",
|
||||
))
|
||||
.with_child(demo_box(Lc::t("responsive_box_text", &LOC))),
|
||||
)
|
||||
}
|
||||
|
||||
fn grid_block() -> Block {
|
||||
let mut row = demo_row(Flex::new().with_wrap(flex::Behavior::Wrap));
|
||||
for n in 1..=6 {
|
||||
row = row.with_child(
|
||||
Container::new()
|
||||
.with_prop(PropsOp::add_style("padding", "0.25rem"))
|
||||
.with_prop(
|
||||
FlexItem::new()
|
||||
.with_size(flex::ItemSize::Percent100)
|
||||
.with_size_at(Breakpoint::Sm, flex::ItemSize::Percent50)
|
||||
.with_size_at(Breakpoint::Md, flex::ItemSize::Percent33),
|
||||
)
|
||||
.with_child(demo_box(card_label(n))),
|
||||
);
|
||||
}
|
||||
Block::new()
|
||||
.with_title(Lc::t("responsive_block_title_grid", &LOC))
|
||||
.with_child(caption(
|
||||
Lc::t("responsive_title_grid", &LOC),
|
||||
Lc::n(concat!(
|
||||
"FlexItem::new()",
|
||||
".with_size(ItemSize::Percent100)",
|
||||
".with_size_at(Breakpoint::Sm, ItemSize::Percent50)",
|
||||
".with_size_at(Breakpoint::Md, ItemSize::Percent33)",
|
||||
)),
|
||||
))
|
||||
.with_child(row)
|
||||
}
|
||||
|
||||
fn justify_align_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("responsive_block_title_justify_align", &LOC))
|
||||
.with_child(caption(
|
||||
Lc::t("responsive_title_justify_align", &LOC),
|
||||
Lc::n(concat!(
|
||||
"Flex::new()",
|
||||
".with_justify(ContentJustify::Center)",
|
||||
".with_justify_at(Breakpoint::Md, ContentJustify::SpaceBetween)",
|
||||
".with_align(align::Items::Center)",
|
||||
)),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(
|
||||
Flex::new()
|
||||
.with_justify(flex::ContentJustify::Center)
|
||||
.with_justify_at(Breakpoint::Md, flex::ContentJustify::SpaceBetween)
|
||||
.with_align(align::Items::Center)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5))),
|
||||
)
|
||||
.with_child(demo_box(Lc::t("responsive_box_logo", &LOC)))
|
||||
.with_child(demo_box(Lc::t("responsive_box_menu", &LOC))),
|
||||
)
|
||||
}
|
||||
|
||||
fn order_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("responsive_block_title_order", &LOC))
|
||||
.with_child(caption(
|
||||
Lc::t("responsive_title_order", &LOC),
|
||||
Lc::n(concat!(
|
||||
"Flex::at(Breakpoint::Lg)",
|
||||
" + FlexItem::new().with_order_at(Breakpoint::Lg, ItemOrder::First)",
|
||||
)),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(Flex::at(Breakpoint::Lg).with_gap(align::Gap::Both(UnitValue::RelRem(0.5))))
|
||||
.with_child(demo_box(Lc::t("responsive_box_content", &LOC)))
|
||||
.with_child(demo_box(Lc::t("responsive_box_sidebar", &LOC)).with_prop(
|
||||
FlexItem::new().with_order_at(Breakpoint::Lg, flex::ItemOrder::First),
|
||||
)),
|
||||
)
|
||||
}
|
||||
|
||||
fn gap_grow_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("responsive_block_title_gap_grow", &LOC))
|
||||
.with_child(caption(
|
||||
Lc::t("responsive_title_gap_grow", &LOC),
|
||||
Lc::n(concat!(
|
||||
"Flex::new()",
|
||||
".with_gap(align::Gap::Both(RelRem(0.5)))",
|
||||
".with_gap_at(Breakpoint::Md, Gap::Both(RelRem(1.5)))",
|
||||
" + FlexItem::new().with_grow_at(Breakpoint::Md, ItemGrow::Is1)",
|
||||
)),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(
|
||||
Flex::new()
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5)))
|
||||
.with_gap_at(Breakpoint::Md, align::Gap::Both(UnitValue::RelRem(1.5))),
|
||||
)
|
||||
.with_child(demo_box(Lc::t("responsive_box_file", &LOC)))
|
||||
.with_child(demo_box(Lc::t("responsive_box_edit", &LOC)))
|
||||
.with_child(
|
||||
demo_box(Lc::t("responsive_box_search", &LOC))
|
||||
.with_prop(FlexItem::new().with_grow_at(Breakpoint::Md, flex::ItemGrow::Is1)),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
// **< HELPERS >************************************************************************************
|
||||
|
||||
// Aspecto fijo de las cajas de muestra.
|
||||
fn demo_box_styles() -> AssetsOp {
|
||||
AssetsOp::add_responsive_styles(
|
||||
None,
|
||||
"flex-demo-box",
|
||||
[
|
||||
("background-color", "#0d6efd"),
|
||||
("color", "#fff"),
|
||||
("min-width", "3rem"),
|
||||
("width", "auto"),
|
||||
("max-width", "none"),
|
||||
("margin", "0"),
|
||||
("border-radius", "0.375rem"),
|
||||
("text-align", "center"),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
// Aspecto fijo de las filas de muestra.
|
||||
fn demo_row_styles() -> AssetsOp {
|
||||
AssetsOp::add_responsive_styles(
|
||||
None,
|
||||
"flex-demo-row",
|
||||
[
|
||||
("background-color", "#f1f3f5"),
|
||||
("width", "100%"),
|
||||
("max-width", "none"),
|
||||
("margin", "0 0 1.5rem"),
|
||||
("padding", "0.75rem"),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
// Evita que los fragmentos de código largos desborden su contenedor.
|
||||
fn demo_code_styles() -> AssetsOp {
|
||||
AssetsOp::add_responsive_styles(None, "flex-demo-code", [("overflow-wrap", "anywhere")])
|
||||
}
|
||||
|
||||
// Caja con fondo azul y relleno vertical configurable, para mostrar diferencias de altura.
|
||||
fn sized_box(label: Lc, padding: &'static str) -> Container {
|
||||
Container::new()
|
||||
.with_prop(PropsOp::add_classes("flex-demo-box"))
|
||||
.with_prop(PropsOp::add_style("padding", padding))
|
||||
.with_child(Html::with(move |cx| html! { (label.using(cx)) }))
|
||||
}
|
||||
|
||||
// Caja con el relleno vertical estandar del resto de ejemplos.
|
||||
fn demo_box(label: Lc) -> Container {
|
||||
sized_box(label, "0.5rem 1rem")
|
||||
}
|
||||
|
||||
// Etiqueta "Tarjeta N" para las cajas de la rejilla responsive.
|
||||
fn card_label(n: usize) -> Lc {
|
||||
Lc::t("responsive_box_card", &LOC).with_arg("n", n.to_string())
|
||||
}
|
||||
|
||||
// Fila de demostracion con fondo gris para visualizar los limites del propio contenedor flex.
|
||||
fn demo_row(flex: Flex) -> Flex {
|
||||
flex.with_prop(PropsOp::add_classes("flex-demo-row"))
|
||||
}
|
||||
|
||||
// Titulo y fragmento de codigo que introducen cada demostracion.
|
||||
fn caption(title: Lc, code: Lc) -> Html {
|
||||
Html::with(move |cx| {
|
||||
html! {
|
||||
h3 { (title.using(cx)) }
|
||||
p { code class="flex-demo-code" { (code.using(cx)) } }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::prepare(&IntroResponsive).await.run().await
|
||||
}
|
||||
247
examples/intro-spacing.rs
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
include_locales!(LOC from "examples/locale");
|
||||
|
||||
struct IntroSpacing;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for IntroSpacing {
|
||||
fn dependencies(&self) -> Vec<ExtensionRef> {
|
||||
vec![&pagetop_bootsier::Bootsier]
|
||||
}
|
||||
|
||||
fn configure_router(&self, routes: Routes) -> Routes {
|
||||
routes.public_route("/", web::get(intro_spacing))
|
||||
}
|
||||
}
|
||||
|
||||
async fn intro_spacing(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||
Page::new(request)
|
||||
.with_assets(demo_box_styles())
|
||||
.with_assets(demo_row_styles())
|
||||
.with_assets(demo_code_styles())
|
||||
.with_child(
|
||||
Intro::custom()
|
||||
.with_title(Lc::n("PageTop"))
|
||||
.with_slogan(Lc::t("spacing_slogan", &LOC))
|
||||
.with_child(Html::with(|cx| {
|
||||
html! {
|
||||
p class="intro-text-lead" {
|
||||
(Lc::t("spacing_note", &LOC).using(cx))
|
||||
}
|
||||
}
|
||||
}))
|
||||
.with_child(padding_block())
|
||||
.with_child(layout_block())
|
||||
.with_child(responsive_block())
|
||||
.with_child(combined_block()),
|
||||
)
|
||||
.render()
|
||||
.await
|
||||
}
|
||||
|
||||
fn padding_block() -> Block {
|
||||
let mut block = Block::new().with_title(Lc::t("spacing_block_title_padding", &LOC));
|
||||
|
||||
let padding_variants: [(&str, UnitValue, &str); 3] = [
|
||||
(
|
||||
"spacing_title_uniform_small",
|
||||
UnitValue::RelRem(0.5),
|
||||
"Padding::new().with_all(UnitValue::RelRem(0.5))",
|
||||
),
|
||||
(
|
||||
"spacing_title_uniform_medium",
|
||||
UnitValue::RelRem(1.0),
|
||||
"Padding::new().with_all(UnitValue::RelRem(1.0))",
|
||||
),
|
||||
(
|
||||
"spacing_title_uniform_large",
|
||||
UnitValue::RelRem(2.0),
|
||||
"Padding::new().with_all(UnitValue::RelRem(2.0))",
|
||||
),
|
||||
];
|
||||
for (title_key, size, code) in padding_variants {
|
||||
block = block
|
||||
.with_child(caption(Lc::t(title_key, &LOC), Lc::n(code)))
|
||||
.with_child(
|
||||
demo_row(Flex::new().with_gap(align::Gap::Both(UnitValue::RelRem(0.5))))
|
||||
.with_child(demo_box(box_sample()).with_prop(Padding::new().with_all(size))),
|
||||
);
|
||||
}
|
||||
|
||||
block
|
||||
.with_child(caption(
|
||||
Lc::t("spacing_title_sides", &LOC),
|
||||
Lc::n(concat!(
|
||||
"Padding::new()",
|
||||
".with_top(UnitValue::RelRem(0.25))",
|
||||
".with_end(UnitValue::RelRem(2.5))",
|
||||
".with_bottom(UnitValue::RelRem(1.5))",
|
||||
".with_start(UnitValue::RelRem(0.5))",
|
||||
)),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(Flex::new()).with_child(
|
||||
demo_box(box_sample()).with_prop(
|
||||
Padding::new()
|
||||
.with_top(UnitValue::RelRem(0.25))
|
||||
.with_end(UnitValue::RelRem(2.5))
|
||||
.with_bottom(UnitValue::RelRem(1.5))
|
||||
.with_start(UnitValue::RelRem(0.5)),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fn layout_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("spacing_block_title_layout", &LOC))
|
||||
.with_child(caption(
|
||||
Lc::t("spacing_title_margin_gap", &LOC),
|
||||
Lc::n("Margin::new().with_x(UnitValue::RelRem(1.0))"),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(Flex::new())
|
||||
.with_child(demo_box(box_sample()))
|
||||
.with_child(
|
||||
demo_box(box_sample()).with_prop(Margin::new().with_x(UnitValue::RelRem(1.0))),
|
||||
)
|
||||
.with_child(demo_box(box_sample())),
|
||||
)
|
||||
.with_child(caption(
|
||||
Lc::t("spacing_title_margin_center", &LOC),
|
||||
Lc::n("Margin::new().with_x(UnitValue::Auto)"),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(Flex::new()).with_child(
|
||||
demo_box(box_sample())
|
||||
.with_prop(Margin::new().with_x(UnitValue::Auto))
|
||||
.with_prop(
|
||||
FlexItem::new().with_size(flex::ItemSize::Custom(UnitValue::RelRem(8.0))),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fn responsive_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("spacing_block_title_responsive", &LOC))
|
||||
.with_child(caption(
|
||||
Lc::t("spacing_title_responsive", &LOC),
|
||||
Lc::n(concat!(
|
||||
"Padding::new()",
|
||||
".with_all(UnitValue::RelRem(0.5))",
|
||||
".with_all_at(Breakpoint::Md, UnitValue::RelRem(2.0))",
|
||||
".with_all_at(Breakpoint::Lg, UnitValue::RelRem(4.0))",
|
||||
)),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(Flex::new()).with_child(
|
||||
demo_box(box_sample()).with_prop(
|
||||
Padding::new()
|
||||
.with_all(UnitValue::RelRem(0.5))
|
||||
.with_all_at(Breakpoint::Md, UnitValue::RelRem(2.0))
|
||||
.with_all_at(Breakpoint::Lg, UnitValue::RelRem(4.0)),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fn combined_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("spacing_block_title_combined", &LOC))
|
||||
.with_child(caption(
|
||||
Lc::t("spacing_title_combined", &LOC),
|
||||
Lc::n(concat!(
|
||||
"Container::new()",
|
||||
".with_prop(Margin::new().with_y(UnitValue::RelRem(1.0)))",
|
||||
".with_prop(Padding::new().with_all(UnitValue::RelRem(1.5)))",
|
||||
)),
|
||||
))
|
||||
.with_child(
|
||||
demo_row(Flex::new()).with_child(
|
||||
Container::new()
|
||||
.with_prop(PropsOp::add_classes("spacing-demo-box"))
|
||||
.with_prop(Margin::new().with_y(UnitValue::RelRem(1.0)))
|
||||
.with_prop(Padding::new().with_all(UnitValue::RelRem(1.5)))
|
||||
.with_child(
|
||||
Button::plain(Lc::t("spacing_box_card_button", &LOC))
|
||||
.with_style(button::Style::Solid(Intent::Warning)),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
// **< HELPERS >************************************************************************************
|
||||
|
||||
// Caja de muestra sin relleno ni margen propios, para que sólo se vea el efecto de `Margin`/
|
||||
// `Padding` aplicado en cada demostración.
|
||||
fn demo_box_styles() -> AssetsOp {
|
||||
AssetsOp::add_responsive_styles(
|
||||
None,
|
||||
"spacing-demo-box",
|
||||
[
|
||||
("background-color", "#0d6efd"),
|
||||
("color", "#fff"),
|
||||
("min-width", "3rem"),
|
||||
("width", "auto"),
|
||||
("max-width", "none"),
|
||||
("margin", "0"),
|
||||
("padding", "0"),
|
||||
("border-radius", "0.375rem"),
|
||||
("text-align", "center"),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
// Aspecto fijo de las filas de muestra.
|
||||
fn demo_row_styles() -> AssetsOp {
|
||||
AssetsOp::add_responsive_styles(
|
||||
None,
|
||||
"spacing-demo-row",
|
||||
[
|
||||
("background-color", "#f1f3f5"),
|
||||
("width", "100%"),
|
||||
("max-width", "none"),
|
||||
("margin", "0 0 1.5rem"),
|
||||
("padding", "0.75rem"),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
// Evita que los fragmentos de código largos desborden su contenedor.
|
||||
fn demo_code_styles() -> AssetsOp {
|
||||
AssetsOp::add_responsive_styles(None, "spacing-demo-code", [("overflow-wrap", "anywhere")])
|
||||
}
|
||||
|
||||
// Caja azul de muestra, sin relleno ni margen propios.
|
||||
fn demo_box(label: Lc) -> Container {
|
||||
Container::new()
|
||||
.with_prop(PropsOp::add_classes("spacing-demo-box"))
|
||||
.with_child(Html::with(move |cx| html! { (label.using(cx)) }))
|
||||
}
|
||||
|
||||
// Etiqueta genérica reutilizada en la mayoría de cajas de muestra.
|
||||
fn box_sample() -> Lc {
|
||||
Lc::t("spacing_box_sample", &LOC)
|
||||
}
|
||||
|
||||
// Fila de demostración con fondo gris para visualizar los límites de cada caja.
|
||||
fn demo_row(flex: Flex) -> Flex {
|
||||
flex.with_prop(PropsOp::add_classes("spacing-demo-row"))
|
||||
}
|
||||
|
||||
// Título y fragmento de código que introducen cada demostración.
|
||||
fn caption(title: Lc, code: Lc) -> Html {
|
||||
Html::with(move |cx| {
|
||||
html! {
|
||||
h3 { (title.using(cx)) }
|
||||
p { code class="spacing-demo-code" { (code.using(cx)) } }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::prepare(&IntroSpacing).await.run().await
|
||||
}
|
||||
7
examples/locale/en-US/basic-navbar.ftl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
navbar_home = Home
|
||||
navbar_docs = Docs
|
||||
navbar_tools = Tools
|
||||
navbar_generator = Generator
|
||||
navbar_reports = Reports
|
||||
navbar_active = Active page
|
||||
navbar_disabled = Disabled
|
||||
|
|
@ -2,7 +2,9 @@ title = Form controls
|
|||
slogan = Bootsier form components showcase
|
||||
block_selections = Checkboxes, switches and radio buttons
|
||||
block_text = Text fields, multiline and range
|
||||
block_lists = Select lists and floating labels
|
||||
block_lists = Selection lists
|
||||
block_lists_floating = Select lists and floating labels
|
||||
block_dialog = Modal dialog
|
||||
|
||||
fieldset_text = Text fields
|
||||
label_name = Full name
|
||||
|
|
@ -16,6 +18,8 @@ label_url = Website
|
|||
placeholder_url = https://example.com
|
||||
label_search = Search
|
||||
placeholder_search = Search term...
|
||||
help_name = Enter your full name as it appears on your ID.
|
||||
help_email = We will only use your email to send important notifications.
|
||||
|
||||
fieldset_textarea = Multiline text
|
||||
label_comment = Comment
|
||||
|
|
@ -69,6 +73,17 @@ fieldset_range = Slider
|
|||
label_rating = Overall rating
|
||||
help_rating = From 1 (very poor) to 10 (excellent).
|
||||
|
||||
fieldset_file = Files
|
||||
label_photo = Profile picture
|
||||
help_photo = JPEG or PNG image. This example does not save it.
|
||||
label_attachments = Attachments
|
||||
help_attachments = You can choose several PDF files.
|
||||
|
||||
btn_submit = Submit
|
||||
btn_reset = Reset
|
||||
btn_cancel = Cancel
|
||||
btn_ok = Ok
|
||||
btn_delete = Delete record
|
||||
|
||||
dialog_delete_title = Delete record
|
||||
dialog_delete_body = Are you sure you want to delete this record? This action cannot be undone.
|
||||
|
|
|
|||
21
examples/locale/en-US/intro-datetime.ftl
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
datetime_slogan = Timezones and date/time formats
|
||||
|
||||
datetime_block_world = The same instant, around the world
|
||||
datetime_zone_utc = UTC
|
||||
datetime_zone_madrid = Madrid (Europe/Madrid)
|
||||
datetime_zone_mexico = Mexico City (America/Mexico_City)
|
||||
datetime_zone_tokyo = Tokyo (Asia/Tokyo)
|
||||
|
||||
datetime_block_formats = DateFormat / TimeFormat combinations
|
||||
datetime_formats_date = DateFormat (date only)
|
||||
datetime_formats_time = TimeFormat (time only)
|
||||
datetime_formats_combos = format_datetime() combinations (date + time)
|
||||
datetime_formats_iso = format_iso_datetime():
|
||||
|
||||
datetime_block_relative = RelativeFormat
|
||||
datetime_relative_col_date = Date
|
||||
|
||||
datetime_block_since_until = DatePrecision (format_since / format_until)
|
||||
datetime_since_until_col_precision = Precision
|
||||
datetime_since_until_col_since = since
|
||||
datetime_since_until_col_until = until
|
||||
64
examples/locale/en-US/intro-flex.ftl
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
flex_slogan = Flexbox positioning
|
||||
flex_block_title_direction = Direction
|
||||
flex_block_title_justify = Justify content
|
||||
flex_block_title_align = Align items
|
||||
flex_block_title_align_self = Align self
|
||||
flex_block_title_align_content = Align content
|
||||
flex_block_title_grow_shrink = Grow and shrink
|
||||
flex_block_title_other = Other examples
|
||||
|
||||
flex_title_direction_row = Row
|
||||
flex_title_direction_row_reverse = Row reverse
|
||||
flex_title_direction_column = Column
|
||||
flex_title_direction_column_reverse = Column reverse
|
||||
flex_title_justify_start = Justify content: start
|
||||
flex_title_justify_center = Justify content: center
|
||||
flex_title_justify_end = Justify content: end
|
||||
flex_title_justify_between = Justify content: space between
|
||||
flex_title_justify_around = Justify content: space around
|
||||
flex_title_justify_evenly = Justify content: space evenly
|
||||
flex_title_align_start = Align items: start
|
||||
flex_title_align_center = Align items: center
|
||||
flex_title_align_end = Align items: end
|
||||
flex_title_align_stretch = Align items: stretch
|
||||
flex_title_align_baseline = Align items: baseline
|
||||
flex_title_align_self_start = Align self: start
|
||||
flex_title_align_self_end = Align self: end
|
||||
flex_title_align_self_center = Align self: center
|
||||
flex_title_align_self_stretch = Align self: stretch
|
||||
flex_title_align_self_baseline = Align self: baseline
|
||||
flex_title_align_content_start = Align content: start
|
||||
flex_title_align_content_end = Align content: end
|
||||
flex_title_align_content_center = Align content: center
|
||||
flex_title_align_content_between = Align content: space between
|
||||
flex_title_align_content_around = Align content: space around
|
||||
flex_title_align_content_evenly = Align content: space evenly
|
||||
flex_title_align_content_stretch = Align content: stretch
|
||||
flex_title_grow = Growth
|
||||
flex_title_shrink = Shrink
|
||||
flex_title_push_end = Automatic margin
|
||||
flex_title_wrap = Line wrapping across multiple rows
|
||||
flex_title_order = Visual order
|
||||
flex_title_gap_none = Without spacing
|
||||
flex_title_gap_some = With spacing
|
||||
flex_title_grid_thirds = Column grid: three thirds
|
||||
flex_title_grid_offset = Column grid: centered column with offset
|
||||
flex_title_toolbar = Composite structure: toolbar
|
||||
flex_desc_toolbar = FlexItem::push_end() on an intermediate item of the same Container with Flex
|
||||
|
||||
flex_item_label = Flex item { $n }
|
||||
|
||||
flex_box_tall = Tall
|
||||
flex_box_medium = Medium
|
||||
flex_box_short = Short
|
||||
flex_box_fixed = Fixed
|
||||
flex_box_grows = Grows to fill the space
|
||||
flex_box_start_1 = Start 1
|
||||
flex_box_start_2 = Start 2
|
||||
flex_box_end = End
|
||||
flex_box_half_centered = Half, centered
|
||||
flex_box_file = File
|
||||
flex_box_edit = Edit
|
||||
flex_box_view = View
|
||||
flex_box_profile = Profile
|
||||
flex_box_logout = Sign out
|
||||
49
examples/locale/en-US/intro-grid.ftl
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
grid_slogan = CSS Grid positioning
|
||||
grid_block_title_columns = Columns
|
||||
grid_block_title_rows_gap = Rows and gap
|
||||
grid_block_title_placement = Item placement
|
||||
grid_block_title_alignment = Align items
|
||||
grid_block_title_content_alignment = Justify content
|
||||
grid_block_title_item_alignment = Individual alignment
|
||||
grid_block_title_auto_flow = Auto-placement algorithm
|
||||
grid_block_title_auto_tracks = Implicit tracks
|
||||
grid_block_title_responsive = Responsive grid
|
||||
grid_block_title_layout = Composite structure: page layout
|
||||
|
||||
grid_title_columns_thirds = Three equal columns
|
||||
grid_title_columns_sidebar = Fixed sidebar + flexible content
|
||||
grid_title_columns_min_max = Min-content, fraction, max-content
|
||||
grid_title_rows = Fixed-height rows
|
||||
grid_title_gap_distinct = Different row and column spacing
|
||||
grid_title_placement = Column spanning and explicit ranges
|
||||
grid_title_alignment_start = Justify/align items: start
|
||||
grid_title_alignment_center = Justify/align items: center
|
||||
grid_title_alignment_end = Justify/align items: end
|
||||
grid_title_alignment_stretch = Justify/align items: stretch
|
||||
grid_title_content_alignment_start = Justify content: start
|
||||
grid_title_content_alignment_center = Justify content: center
|
||||
grid_title_content_alignment_between = Justify content: space between
|
||||
grid_title_content_alignment_evenly = Justify content: space evenly
|
||||
grid_title_item_alignment = Overriding the container's alignment on a single item
|
||||
grid_title_auto_flow_row = Default flow, leaves a gap
|
||||
grid_title_auto_flow_dense = Dense flow, fills the gap
|
||||
grid_title_auto_tracks = Equal-height implicit rows
|
||||
grid_title_responsive = One column on mobile, two on tablet, three on desktop
|
||||
grid_title_layout = Header and footer spanning three columns, flexible content area
|
||||
grid_desc_layout = Grid::new() with fixed side columns, a flexible center column and explicit spans
|
||||
|
||||
grid_box_label = Box { $n }
|
||||
grid_box_card = Card { $n }
|
||||
grid_box_sidebar = Sidebar
|
||||
grid_box_content = Content
|
||||
grid_box_min_content = Min-content
|
||||
grid_box_fraction = 1fr
|
||||
grid_box_max_content = Max-content
|
||||
grid_box_plain = Plain
|
||||
grid_box_span_2 = Spans 2 columns
|
||||
grid_box_range = Columns 2 to 3
|
||||
grid_box_overridden = Overridden
|
||||
grid_box_header = Header
|
||||
grid_box_nav = Navigation
|
||||
grid_box_aside = Aside
|
||||
grid_box_footer = Footer
|
||||
36
examples/locale/en-US/intro-responsive.ftl
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
responsive_slogan = Responsive behavior with Flex
|
||||
responsive_note = Resize your browser window to see how the boxes below react. The breakpoints used are the usual Bootstrap ones: sm from 576px, md from 768px, lg from 992px.
|
||||
|
||||
responsive_block_title_activation = Flex activation at a breakpoint
|
||||
responsive_block_title_direction = Direction change
|
||||
responsive_block_title_grid = Column grid
|
||||
responsive_block_title_justify_align = Justify and align
|
||||
responsive_block_title_order = Visual order
|
||||
responsive_block_title_gap_grow = Spacing and growth
|
||||
|
||||
responsive_title_activation = Stacked menu on mobile, in a row from md
|
||||
responsive_title_direction = Image and text stacked on mobile; in a row, image on the right, from md
|
||||
responsive_title_grid = From one column on mobile to three on desktop
|
||||
responsive_title_justify_align = Centered header on mobile, spread out from md
|
||||
responsive_title_order = Sidebar after the content on mobile, before it from lg
|
||||
responsive_title_gap_grow = Growing spacing and a search box that only grows from md
|
||||
|
||||
responsive_box_nav_home = Home
|
||||
responsive_box_nav_products = Products
|
||||
responsive_box_nav_about = About
|
||||
responsive_box_nav_contact = Contact
|
||||
|
||||
responsive_box_image = Image
|
||||
responsive_box_text = Text
|
||||
|
||||
responsive_box_card = Card { $n }
|
||||
|
||||
responsive_box_logo = Logo
|
||||
responsive_box_menu = Menu
|
||||
|
||||
responsive_box_content = Content
|
||||
responsive_box_sidebar = Sidebar
|
||||
|
||||
responsive_box_file = File
|
||||
responsive_box_edit = Edit
|
||||
responsive_box_search = Search
|
||||
19
examples/locale/en-US/intro-spacing.ftl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
spacing_slogan = Native margin and padding with Margin and Padding
|
||||
spacing_note = Margin and Padding have nothing to do with Flexbox: they apply to any component, whether its container uses Flexbox or not. They are combined with Flex here only to lay out the sample boxes in a row.
|
||||
|
||||
spacing_block_title_padding = Padding
|
||||
spacing_block_title_layout = Layout
|
||||
spacing_block_title_responsive = Padding at a breakpoint
|
||||
spacing_block_title_combined = Margin and padding combined
|
||||
|
||||
spacing_title_uniform_small = Small padding on all four sides
|
||||
spacing_title_uniform_medium = Medium padding on all four sides
|
||||
spacing_title_uniform_large = Large padding on all four sides
|
||||
spacing_title_sides = A different value per side, including the logical start/end sides
|
||||
spacing_title_margin_gap = The middle box's margin pushes its neighbours away, without using Gap
|
||||
spacing_title_margin_center = An automatic margin on both sides centers the box in the free space
|
||||
spacing_title_responsive = Padding grows from md onwards, and again from lg
|
||||
spacing_title_combined = Outer margin above/below and inner padding on all four sides, on a component with real content
|
||||
|
||||
spacing_box_sample = Content
|
||||
spacing_box_card_button = Accept
|
||||
|
|
@ -1,7 +1,30 @@
|
|||
menus_slogan = Navbars and menus
|
||||
menus_note = Narrow the browser window to see how the navbars with a toggle button collapse.
|
||||
|
||||
## Blocks
|
||||
|
||||
menus_block_title_menus = Menus and dropdowns
|
||||
menus_block_title_brand = Brand
|
||||
menus_block_title_content = Other content
|
||||
menus_block_title_colors = Color schemes
|
||||
menus_block_title_container = Containers
|
||||
menus_block_title_position = Placement
|
||||
menus_block_title_layout = Layout and toggle button
|
||||
menus_block_title_expand = Expand breakpoint
|
||||
menus_block_title_offcanvas = Content in a side panel (Offcanvas)
|
||||
|
||||
## Menus and dropdowns
|
||||
|
||||
menus_title_full = Menu with dropdown, headers, dividers and a second menu at the end
|
||||
|
||||
menus_item_home = Home
|
||||
menus_item_label = Label
|
||||
menus_item_link = Link
|
||||
menus_item_blank = External link
|
||||
menus_item_disabled = Disabled link
|
||||
menus_item_action = Action
|
||||
menus_item_another = Another action
|
||||
menus_item_something = Something else
|
||||
|
||||
menus_test_title = Dropdown
|
||||
|
||||
|
|
@ -21,3 +44,66 @@ menus_plugin_cache = Rust Plugin Cache
|
|||
|
||||
menus_item_sign_up = Sign up
|
||||
menus_item_login = Login
|
||||
|
||||
## Brand
|
||||
|
||||
menus_title_brand_link = Text only, as a link
|
||||
menus_title_brand_span = Text only, without a link
|
||||
menus_title_brand_image = Image only
|
||||
menus_title_brand_both = Image and text
|
||||
|
||||
## Other content
|
||||
|
||||
menus_title_form_search = Search form next to the brand
|
||||
menus_title_form_buttons = Buttons
|
||||
menus_title_form_group = Input group
|
||||
menus_title_text = Text
|
||||
menus_title_brand_and_text = Brand and text
|
||||
menus_title_nav_text = Menu and text
|
||||
|
||||
menus_search_label = Search
|
||||
menus_search_button = Search
|
||||
menus_button_main = Main button
|
||||
menus_button_small = Smaller button
|
||||
menus_group_placeholder = Username
|
||||
menus_text_inline = Navbar text
|
||||
|
||||
## Color schemes
|
||||
|
||||
menus_title_color_dark = Dark background
|
||||
menus_title_color_primary = Primary color with light text
|
||||
menus_title_color_light = Light theme background
|
||||
menus_title_color_custom = Custom color
|
||||
|
||||
## Containers
|
||||
|
||||
menus_title_container_full = Takes all the available width
|
||||
menus_title_container_max = Inside a container with a maximum width
|
||||
|
||||
## Placement
|
||||
|
||||
menus_position_note = Navbars are anchored to the frame of each example, not to the window, so they don't cover the rest of the page. Scroll the frames with sticky navbars.
|
||||
menus_title_position_fixed_top = Fixed top
|
||||
menus_title_position_fixed_bottom = Fixed bottom
|
||||
menus_title_position_sticky_top = Sticky top
|
||||
menus_title_position_sticky_bottom = Sticky bottom
|
||||
menus_filler = Page content. Fixed elements are taken out of the document flow, while sticky ones stay at the edge of the scrolling container.
|
||||
|
||||
## Layout
|
||||
|
||||
menus_title_layout_toggle = Toggle button only, no brand
|
||||
menus_title_layout_brand_left = Brand on the left and toggle button on the right
|
||||
menus_title_layout_brand_right = Toggle button on the left and brand on the right
|
||||
menus_title_layout_brand_always = Always visible brand, no toggle button
|
||||
|
||||
## Expand breakpoint
|
||||
|
||||
menus_title_expand = Expands from { $name } ({ $width })
|
||||
|
||||
## Offcanvas
|
||||
|
||||
menus_offcanvas_title = Main menu
|
||||
menus_title_offcanvas_start = Panel from the start, no brand
|
||||
menus_title_offcanvas_brand_left = Brand on the left and panel from the end
|
||||
menus_title_offcanvas_brand_right = Brand on the right and panel without backdrop
|
||||
menus_title_offcanvas_dark = Dark navbar and panel, with a static backdrop
|
||||
|
|
|
|||
72
examples/locale/en-US/theme-showcase.ftl
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
showcase_title = Theme showcase
|
||||
|
||||
showcase_menu_home = Home
|
||||
showcase_menu_components = Components
|
||||
showcase_menu_forms = Forms
|
||||
showcase_menu_fields = Fields
|
||||
showcase_menu_buttons = Buttons
|
||||
showcase_menu_others = Others
|
||||
showcase_menu_messages = Messages
|
||||
showcase_menu_disabled = Disabled
|
||||
showcase_menu_docs = Documentation
|
||||
showcase_menu_sign_up = Sign up
|
||||
showcase_menu_login = Log in
|
||||
|
||||
showcase_block_fields = Text fields and dropdowns
|
||||
showcase_name = Name
|
||||
showcase_name_help = Help text, smaller and lighter than the label.
|
||||
showcase_email = Email
|
||||
showcase_email_placeholder = name@example.com
|
||||
showcase_focus = With focus
|
||||
showcase_font = Font
|
||||
showcase_disabled = Disabled
|
||||
showcase_readonly = Read-only
|
||||
showcase_disabled_select = Disabled dropdown
|
||||
showcase_comment = Comment
|
||||
showcase_comment_placeholder = Write here...
|
||||
showcase_floating = Floating label
|
||||
|
||||
showcase_block_checks = Checks, switches and options
|
||||
showcase_checks = Checks
|
||||
showcase_check_off = Unchecked
|
||||
showcase_check_on = Checked
|
||||
showcase_check_disabled = Disabled
|
||||
showcase_switches = Switches
|
||||
showcase_switch_off = Off
|
||||
showcase_switch_on = On
|
||||
showcase_switch_disabled = Disabled
|
||||
showcase_options = Options
|
||||
showcase_option_small = Small
|
||||
showcase_option_medium = Medium
|
||||
showcase_option_large = Large
|
||||
showcase_options_help = The disabled option cannot be chosen.
|
||||
|
||||
showcase_filter_hint =
|
||||
Change a value without pressing "Filter": the filter marks the changed fields and highlights
|
||||
its button until it is applied.
|
||||
showcase_search = Search
|
||||
showcase_search_placeholder = Name or email...
|
||||
showcase_status = Status
|
||||
showcase_status_any = Any
|
||||
showcase_status_active = Active
|
||||
showcase_status_blocked = Blocked
|
||||
showcase_only_admins = Administrators only
|
||||
|
||||
showcase_block_tables = List filters and tables
|
||||
showcase_new_user = New user
|
||||
showcase_col_user = User
|
||||
showcase_col_email = Email
|
||||
showcase_col_status = Status
|
||||
showcase_col_last_access = Last access
|
||||
showcase_col_actions = Actions
|
||||
showcase_status_pending = Pending
|
||||
showcase_edit = Edit
|
||||
showcase_empty_table = A table without rows shows its message:
|
||||
|
||||
showcase_block_buttons = Buttons
|
||||
|
||||
showcase_block_misc = Links, badges and pagination
|
||||
showcase_link_text = A paragraph with <a href="#">a link</a> in the middle of the text.
|
||||
showcase_msg_info = An informative message.
|
||||
showcase_msg_warning = A warning message.
|
||||
showcase_msg_error = An error message.
|
||||
7
examples/locale/es-ES/basic-navbar.ftl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
navbar_home = Inicio
|
||||
navbar_docs = Documentación
|
||||
navbar_tools = Herramientas
|
||||
navbar_generator = Generador
|
||||
navbar_reports = Informes
|
||||
navbar_active = Página activa
|
||||
navbar_disabled = Deshabilitado
|
||||
|
|
@ -2,7 +2,9 @@ title = Controles de formulario
|
|||
slogan = Componentes Bootsier para formularios
|
||||
block_selections = Casillas, interruptores y botones de opción
|
||||
block_text = Campos de texto, multilínea y rango
|
||||
block_lists = Listas de selección y etiquetas flotantes
|
||||
block_lists = Listas de selección
|
||||
block_lists_floating = Listas de selección y etiquetas flotantes
|
||||
block_dialog = Diálogo modal
|
||||
|
||||
fieldset_text = Campos de texto
|
||||
label_name = Nombre completo
|
||||
|
|
@ -16,6 +18,8 @@ label_url = Sitio web
|
|||
placeholder_url = https://ejemplo.com
|
||||
label_search = Búsqueda
|
||||
placeholder_search = Término de búsqueda...
|
||||
help_name = Introduce tu nombre completo tal como aparece en tu documento de identidad.
|
||||
help_email = Solo usaremos tu correo para enviarte notificaciones importantes.
|
||||
|
||||
fieldset_textarea = Texto multilínea
|
||||
label_comment = Comentario
|
||||
|
|
@ -69,6 +73,17 @@ fieldset_range = Control deslizante
|
|||
label_rating = Valoración general
|
||||
help_rating = De 1 (muy malo) a 10 (excelente).
|
||||
|
||||
fieldset_file = Archivos
|
||||
label_photo = Foto de perfil
|
||||
help_photo = Imagen JPEG o PNG. En este ejemplo no se guarda.
|
||||
label_attachments = Documentos adjuntos
|
||||
help_attachments = Puedes elegir varios archivos PDF.
|
||||
|
||||
btn_submit = Enviar
|
||||
btn_reset = Restablecer
|
||||
btn_cancel = Cancelar
|
||||
btn_ok = Aceptar
|
||||
btn_delete = Eliminar registro
|
||||
|
||||
dialog_delete_title = Eliminar registro
|
||||
dialog_delete_body = ¿Seguro que quieres eliminar este registro? Esta acción no se puede deshacer.
|
||||
|
|
|
|||
21
examples/locale/es-ES/intro-datetime.ftl
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
datetime_slogan = Zonas horarias y formatos de fecha y hora
|
||||
|
||||
datetime_block_world = El mismo instante, alrededor del mundo
|
||||
datetime_zone_utc = UTC
|
||||
datetime_zone_madrid = Madrid (Europe/Madrid)
|
||||
datetime_zone_mexico = Ciudad de México (America/Mexico_City)
|
||||
datetime_zone_tokyo = Tokio (Asia/Tokyo)
|
||||
|
||||
datetime_block_formats = Combinaciones de DateFormat / TimeFormat
|
||||
datetime_formats_date = DateFormat (sólo fecha)
|
||||
datetime_formats_time = TimeFormat (sólo hora)
|
||||
datetime_formats_combos = Combinaciones de format_datetime() (fecha + hora)
|
||||
datetime_formats_iso = format_iso_datetime():
|
||||
|
||||
datetime_block_relative = RelativeFormat
|
||||
datetime_relative_col_date = Fecha
|
||||
|
||||
datetime_block_since_until = DatePrecision (format_since / format_until)
|
||||
datetime_since_until_col_precision = Precisión
|
||||
datetime_since_until_col_since = desde
|
||||
datetime_since_until_col_until = hasta
|
||||
64
examples/locale/es-ES/intro-flex.ftl
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
flex_slogan = Posicionamiento con Flexbox
|
||||
flex_block_title_direction = Dirección
|
||||
flex_block_title_justify = Justificación de contenido
|
||||
flex_block_title_align = Alineación de elementos
|
||||
flex_block_title_align_self = Alineación individual
|
||||
flex_block_title_align_content = Alineación de contenido
|
||||
flex_block_title_grow_shrink = Crecimiento y reducción
|
||||
flex_block_title_other = Otros ejemplos
|
||||
|
||||
flex_title_direction_row = Fila
|
||||
flex_title_direction_row_reverse = Fila invertida
|
||||
flex_title_direction_column = Columna
|
||||
flex_title_direction_column_reverse = Columna invertida
|
||||
flex_title_justify_start = Justificación: inicio
|
||||
flex_title_justify_center = Justificación: centro
|
||||
flex_title_justify_end = Justificación: final
|
||||
flex_title_justify_between = Justificación: espacio entre elementos
|
||||
flex_title_justify_around = Justificación: espacio alrededor de cada elemento
|
||||
flex_title_justify_evenly = Justificación: espacio repartido a partes iguales
|
||||
flex_title_align_start = Alineación: inicio
|
||||
flex_title_align_center = Alineación: centro
|
||||
flex_title_align_end = Alineación: final
|
||||
flex_title_align_stretch = Alineación: estirar
|
||||
flex_title_align_baseline = Alineación: línea base
|
||||
flex_title_align_self_start = Alineación individual: inicio
|
||||
flex_title_align_self_end = Alineación individual: final
|
||||
flex_title_align_self_center = Alineación individual: centro
|
||||
flex_title_align_self_stretch = Alineación individual: estirar
|
||||
flex_title_align_self_baseline = Alineación individual: línea base
|
||||
flex_title_align_content_start = Alineación de contenido: inicio
|
||||
flex_title_align_content_end = Alineación de contenido: final
|
||||
flex_title_align_content_center = Alineación de contenido: centro
|
||||
flex_title_align_content_between = Alineación de contenido: espacio entre líneas
|
||||
flex_title_align_content_around = Alineación de contenido: espacio alrededor de cada línea
|
||||
flex_title_align_content_evenly = Alineación de contenido: espacio repartido a partes iguales
|
||||
flex_title_align_content_stretch = Alineación de contenido: estirar
|
||||
flex_title_grow = Crecimiento
|
||||
flex_title_shrink = Reducción
|
||||
flex_title_push_end = Margen automático
|
||||
flex_title_wrap = Ajuste de línea con múltiples filas
|
||||
flex_title_order = Orden visual
|
||||
flex_title_gap_none = Sin espaciado
|
||||
flex_title_gap_some = Con espaciado
|
||||
flex_title_grid_thirds = Rejilla de columnas: tres tercios
|
||||
flex_title_grid_offset = Rejilla de columnas: columna centrada con desplazamiento
|
||||
flex_title_toolbar = Estructura compuesta: barra de herramientas
|
||||
flex_desc_toolbar = FlexItem::push_end() sobre un elemento intermedio del propio Container con Flex
|
||||
|
||||
flex_item_label = Flex ítem { $n }
|
||||
|
||||
flex_box_tall = Alto
|
||||
flex_box_medium = Medio
|
||||
flex_box_short = Bajo
|
||||
flex_box_fixed = Fijo
|
||||
flex_box_grows = Crece para llenar el espacio
|
||||
flex_box_start_1 = Inicio 1
|
||||
flex_box_start_2 = Inicio 2
|
||||
flex_box_end = Final
|
||||
flex_box_half_centered = Mitad, centrada
|
||||
flex_box_file = Archivo
|
||||
flex_box_edit = Editar
|
||||
flex_box_view = Ver
|
||||
flex_box_profile = Perfil
|
||||
flex_box_logout = Salir
|
||||
49
examples/locale/es-ES/intro-grid.ftl
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
grid_slogan = Posicionamiento con CSS Grid
|
||||
grid_block_title_columns = Columnas
|
||||
grid_block_title_rows_gap = Filas y espaciado
|
||||
grid_block_title_placement = Colocación de elementos
|
||||
grid_block_title_alignment = Alineación de elementos
|
||||
grid_block_title_content_alignment = Justificación de contenido
|
||||
grid_block_title_item_alignment = Alineación individual
|
||||
grid_block_title_auto_flow = Algoritmo de colocación automática
|
||||
grid_block_title_auto_tracks = Pistas implícitas
|
||||
grid_block_title_responsive = Rejilla responsive
|
||||
grid_block_title_layout = Estructura compuesta: maquetación de página
|
||||
|
||||
grid_title_columns_thirds = Tres columnas iguales
|
||||
grid_title_columns_sidebar = Barra lateral fija + contenido flexible
|
||||
grid_title_columns_min_max = Contenido mínimo, fracción, contenido máximo
|
||||
grid_title_rows = Filas de altura fija
|
||||
grid_title_gap_distinct = Espaciado distinto entre filas y columnas
|
||||
grid_title_placement = Columnas abarcadas y rangos explícitos
|
||||
grid_title_alignment_start = Justificación/alineación de elementos: inicio
|
||||
grid_title_alignment_center = Justificación/alineación de elementos: centro
|
||||
grid_title_alignment_end = Justificación/alineación de elementos: final
|
||||
grid_title_alignment_stretch = Justificación/alineación de elementos: estirar
|
||||
grid_title_content_alignment_start = Justificación de contenido: inicio
|
||||
grid_title_content_alignment_center = Justificación de contenido: centro
|
||||
grid_title_content_alignment_between = Justificación de contenido: espacio entre elementos
|
||||
grid_title_content_alignment_evenly = Justificación de contenido: espacio repartido a partes iguales
|
||||
grid_title_item_alignment = Sobrescribir la alineación del contenedor en un único elemento
|
||||
grid_title_auto_flow_row = Flujo por defecto, deja un hueco
|
||||
grid_title_auto_flow_dense = Flujo denso, rellena el hueco
|
||||
grid_title_auto_tracks = Filas implícitas de igual altura
|
||||
grid_title_responsive = Una columna en móvil, dos en tableta, tres en escritorio
|
||||
grid_title_layout = Cabecera y pie abarcando tres columnas, área de contenido flexible
|
||||
grid_desc_layout = Grid::new() con columnas laterales fijas, una columna central flexible y abarcados explícitos
|
||||
|
||||
grid_box_label = Caja { $n }
|
||||
grid_box_card = Tarjeta { $n }
|
||||
grid_box_sidebar = Barra lateral
|
||||
grid_box_content = Contenido
|
||||
grid_box_min_content = Contenido mínimo
|
||||
grid_box_fraction = 1fr
|
||||
grid_box_max_content = Contenido máximo
|
||||
grid_box_plain = Normal
|
||||
grid_box_span_2 = Abarca 2 columnas
|
||||
grid_box_range = Columnas 2 a 3
|
||||
grid_box_overridden = Sobrescrita
|
||||
grid_box_header = Cabecera
|
||||
grid_box_nav = Navegación
|
||||
grid_box_aside = Aparte
|
||||
grid_box_footer = Pie
|
||||
36
examples/locale/es-ES/intro-responsive.ftl
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
responsive_slogan = Comportamiento responsive con Flex
|
||||
responsive_note = Cambia el ancho de la ventana del navegador para ver cómo reaccionan las siguientes cajas. Los puntos de corte usados son los habituales de Bootstrap: sm a partir de 576px, md a partir de 768px, lg a partir de 992px.
|
||||
|
||||
responsive_block_title_activation = Activación de Flex por punto de corte
|
||||
responsive_block_title_direction = Cambio de dirección
|
||||
responsive_block_title_grid = Rejilla de columnas
|
||||
responsive_block_title_justify_align = Justificación y alineación
|
||||
responsive_block_title_order = Orden visual
|
||||
responsive_block_title_gap_grow = Espaciado y crecimiento
|
||||
|
||||
responsive_title_activation = Menú apilado en móvil, en fila a partir de md
|
||||
responsive_title_direction = Imagen y texto apilados en móvil; en fila, con la imagen a la derecha, a partir de md
|
||||
responsive_title_grid = De una columna en móvil a tres en escritorio
|
||||
responsive_title_justify_align = Cabecera centrada en móvil, distribuida a partir de md
|
||||
responsive_title_order = Barra lateral después del contenido en móvil, antes a partir de lg
|
||||
responsive_title_gap_grow = Espaciado creciente y buscador que sólo crece a partir de md
|
||||
|
||||
responsive_box_nav_home = Inicio
|
||||
responsive_box_nav_products = Productos
|
||||
responsive_box_nav_about = Nosotros
|
||||
responsive_box_nav_contact = Contacto
|
||||
|
||||
responsive_box_image = Imagen
|
||||
responsive_box_text = Texto
|
||||
|
||||
responsive_box_card = Tarjeta { $n }
|
||||
|
||||
responsive_box_logo = Logotipo
|
||||
responsive_box_menu = Menú
|
||||
|
||||
responsive_box_content = Contenido
|
||||
responsive_box_sidebar = Barra lateral
|
||||
|
||||
responsive_box_file = Archivo
|
||||
responsive_box_edit = Editar
|
||||
responsive_box_search = Buscador
|
||||
19
examples/locale/es-ES/intro-spacing.ftl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
spacing_slogan = Márgenes y relleno nativos con Margin y Padding
|
||||
spacing_note = Margin y Padding no tienen relación con Flexbox: se aplican sobre cualquier componente, use o no Flexbox su contenedor. Aquí se combinan con Flex sólo para colocar las cajas de muestra en fila.
|
||||
|
||||
spacing_block_title_padding = Rellenos
|
||||
spacing_block_title_layout = Composición
|
||||
spacing_block_title_responsive = Relleno por punto de corte
|
||||
spacing_block_title_combined = Margin y padding combinados
|
||||
|
||||
spacing_title_uniform_small = Relleno pequeño en los cuatro lados
|
||||
spacing_title_uniform_medium = Relleno medio en los cuatro lados
|
||||
spacing_title_uniform_large = Relleno grande en los cuatro lados
|
||||
spacing_title_sides = Un valor distinto para cada lado, incluidos los lados lógicos de inicio y fin
|
||||
spacing_title_margin_gap = El margen de la caja central empuja a sus vecinas, sin usar Gap
|
||||
spacing_title_margin_center = Un margen automático en ambos lados centra la caja en el espacio libre
|
||||
spacing_title_responsive = El relleno crece a partir de md, y de nuevo a partir de lg
|
||||
spacing_title_combined = Margen exterior arriba/abajo y relleno interno por los cuatro lados, sobre un componente con contenido real
|
||||
|
||||
spacing_box_sample = Contenido
|
||||
spacing_box_card_button = Aceptar
|
||||
|
|
@ -1,7 +1,30 @@
|
|||
menus_slogan = Barras de navegación y menús
|
||||
menus_note = Reduce el ancho de la ventana para ver cómo colapsan las barras que tienen botón de despliegue.
|
||||
|
||||
## Bloques
|
||||
|
||||
menus_block_title_menus = Menús y desplegables
|
||||
menus_block_title_brand = Marca de identidad
|
||||
menus_block_title_content = Otros contenidos
|
||||
menus_block_title_colors = Esquemas de color
|
||||
menus_block_title_container = Contenedores
|
||||
menus_block_title_position = Posición
|
||||
menus_block_title_layout = Disposición y botón de despliegue
|
||||
menus_block_title_expand = Punto de corte de expansión
|
||||
menus_block_title_offcanvas = Contenido en un panel lateral (Offcanvas)
|
||||
|
||||
## Menús y desplegables
|
||||
|
||||
menus_title_full = Menú con desplegable, cabeceras, separadores y un segundo menú al final
|
||||
|
||||
menus_item_home = Inicio
|
||||
menus_item_label = Etiqueta
|
||||
menus_item_link = Enlace
|
||||
menus_item_blank = Enlace externo
|
||||
menus_item_disabled = Enlace deshabilitado
|
||||
menus_item_blank = Externo
|
||||
menus_item_disabled = Deshabilitado
|
||||
menus_item_action = Acción
|
||||
menus_item_another = Otra acción
|
||||
menus_item_something = Algo más
|
||||
|
||||
menus_test_title = Desplegable
|
||||
|
||||
|
|
@ -21,3 +44,66 @@ menus_plugin_cache = Plugin Rust de caché
|
|||
|
||||
menus_item_sign_up = Registrarse
|
||||
menus_item_login = Iniciar sesión
|
||||
|
||||
## Marca de identidad
|
||||
|
||||
menus_title_brand_link = Sólo texto, como enlace
|
||||
menus_title_brand_span = Sólo texto, sin enlace
|
||||
menus_title_brand_image = Sólo imagen
|
||||
menus_title_brand_both = Imagen y texto
|
||||
|
||||
## Otros contenidos
|
||||
|
||||
menus_title_form_search = Formulario de búsqueda junto a la marca
|
||||
menus_title_form_buttons = Botones
|
||||
menus_title_form_group = Grupo de campos
|
||||
menus_title_text = Texto
|
||||
menus_title_brand_and_text = Marca y texto
|
||||
menus_title_nav_text = Menú y texto
|
||||
|
||||
menus_search_label = Buscar
|
||||
menus_search_button = Buscar
|
||||
menus_button_main = Botón principal
|
||||
menus_button_small = Botón pequeño
|
||||
menus_group_placeholder = Usuario
|
||||
menus_text_inline = Texto de la barra de navegación
|
||||
|
||||
## Esquemas de color
|
||||
|
||||
menus_title_color_dark = Fondo oscuro
|
||||
menus_title_color_primary = Color primario con texto claro
|
||||
menus_title_color_light = Fondo claro del tema
|
||||
menus_title_color_custom = Color personalizado
|
||||
|
||||
## Contenedores
|
||||
|
||||
menus_title_container_full = Ocupa todo el ancho disponible
|
||||
menus_title_container_max = Dentro de un contenedor de ancho máximo
|
||||
|
||||
## Posición
|
||||
|
||||
menus_position_note = Las barras se anclan al marco de cada ejemplo, no a la ventana, para no tapar el resto de la página. Desplaza el contenido de los marcos con barras pegajosas.
|
||||
menus_title_position_fixed_top = Fija arriba
|
||||
menus_title_position_fixed_bottom = Fija abajo
|
||||
menus_title_position_sticky_top = Pegajosa arriba
|
||||
menus_title_position_sticky_bottom = Pegajosa abajo
|
||||
menus_filler = Contenido de la página. Los elementos con posición fija salen del flujo del documento, y los pegajosos se quedan en el borde del contenedor que se desplaza.
|
||||
|
||||
## Disposición
|
||||
|
||||
menus_title_layout_toggle = Sólo botón de despliegue, sin marca
|
||||
menus_title_layout_brand_left = Marca a la izquierda y botón de despliegue a la derecha
|
||||
menus_title_layout_brand_right = Botón de despliegue a la izquierda y marca a la derecha
|
||||
menus_title_layout_brand_always = Marca siempre visible, sin botón de despliegue
|
||||
|
||||
## Punto de corte
|
||||
|
||||
menus_title_expand = Se expande a partir de { $name } ({ $width })
|
||||
|
||||
## Offcanvas
|
||||
|
||||
menus_offcanvas_title = Menú principal
|
||||
menus_title_offcanvas_start = Panel desde el inicio, sin marca
|
||||
menus_title_offcanvas_brand_left = Marca a la izquierda y panel desde el final
|
||||
menus_title_offcanvas_brand_right = Marca a la derecha y panel sin capa de fondo
|
||||
menus_title_offcanvas_dark = Barra y panel oscuros, con capa de fondo estática
|
||||
|
|
|
|||
72
examples/locale/es-ES/theme-showcase.ftl
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
showcase_title = Muestrario del tema
|
||||
|
||||
showcase_menu_home = Inicio
|
||||
showcase_menu_components = Componentes
|
||||
showcase_menu_forms = Formularios
|
||||
showcase_menu_fields = Campos
|
||||
showcase_menu_buttons = Botones
|
||||
showcase_menu_others = Otros
|
||||
showcase_menu_messages = Mensajes
|
||||
showcase_menu_disabled = Deshabilitado
|
||||
showcase_menu_docs = Documentación
|
||||
showcase_menu_sign_up = Registrarse
|
||||
showcase_menu_login = Iniciar sesión
|
||||
|
||||
showcase_block_fields = Campos de texto y listas
|
||||
showcase_name = Nombre
|
||||
showcase_name_help = Texto de ayuda, más pequeño y claro que la etiqueta.
|
||||
showcase_email = Correo electrónico
|
||||
showcase_email_placeholder = nombre@ejemplo.com
|
||||
showcase_focus = Con el foco
|
||||
showcase_font = Fuente
|
||||
showcase_disabled = Deshabilitado
|
||||
showcase_readonly = Sólo lectura
|
||||
showcase_disabled_select = Lista deshabilitada
|
||||
showcase_comment = Comentario
|
||||
showcase_comment_placeholder = Escribe aquí...
|
||||
showcase_floating = Etiqueta flotante
|
||||
|
||||
showcase_block_checks = Casillas, interruptores y opciones
|
||||
showcase_checks = Casillas
|
||||
showcase_check_off = Sin marcar
|
||||
showcase_check_on = Marcada
|
||||
showcase_check_disabled = Deshabilitada
|
||||
showcase_switches = Interruptores
|
||||
showcase_switch_off = Apagado
|
||||
showcase_switch_on = Encendido
|
||||
showcase_switch_disabled = Deshabilitado
|
||||
showcase_options = Opciones
|
||||
showcase_option_small = Pequeño
|
||||
showcase_option_medium = Mediano
|
||||
showcase_option_large = Grande
|
||||
showcase_options_help = La opción deshabilitada no se puede elegir.
|
||||
|
||||
showcase_filter_hint =
|
||||
Cambia algún valor sin pulsar «Filtrar»: el filtro marca los campos cambiados y destaca su
|
||||
botón hasta que se aplica.
|
||||
showcase_search = Buscar
|
||||
showcase_search_placeholder = Nombre o correo...
|
||||
showcase_status = Estado
|
||||
showcase_status_any = Cualquiera
|
||||
showcase_status_active = Activo
|
||||
showcase_status_blocked = Bloqueado
|
||||
showcase_only_admins = Sólo administradores
|
||||
|
||||
showcase_block_tables = Filtros de listados y tablas
|
||||
showcase_new_user = Nuevo usuario
|
||||
showcase_col_user = Usuario
|
||||
showcase_col_email = Correo electrónico
|
||||
showcase_col_status = Estado
|
||||
showcase_col_last_access = Último acceso
|
||||
showcase_col_actions = Acciones
|
||||
showcase_status_pending = Pendiente
|
||||
showcase_edit = Editar
|
||||
showcase_empty_table = Una tabla sin filas muestra su mensaje:
|
||||
|
||||
showcase_block_buttons = Botones
|
||||
|
||||
showcase_block_misc = Enlaces, insignias y paginación
|
||||
showcase_link_text = Un párrafo con <a href="#">un enlace</a> en medio del texto.
|
||||
showcase_msg_info = Un mensaje informativo.
|
||||
showcase_msg_warning = Un mensaje de aviso.
|
||||
showcase_msg_error = Un mensaje de error.
|
||||
|
|
@ -1,106 +1,783 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
use pagetop_bootsier::theme::*;
|
||||
|
||||
include_locales!(LOC from "examples/locale");
|
||||
|
||||
struct SuperMenu;
|
||||
struct NavbarMenus;
|
||||
|
||||
impl Extension for SuperMenu {
|
||||
#[async_trait]
|
||||
impl Extension for NavbarMenus {
|
||||
fn dependencies(&self) -> Vec<ExtensionRef> {
|
||||
vec![
|
||||
&pagetop_aliner::Aliner,
|
||||
&pagetop_bootsier::Bootsier,
|
||||
&pagetop::base::extension::Welcome,
|
||||
]
|
||||
vec![&pagetop_bootsier::Bootsier]
|
||||
}
|
||||
|
||||
fn initialize(&self) {
|
||||
let navbar_menu = Navbar::brand_left(navbar::Brand::new())
|
||||
.with_expand(BreakPoint::LG)
|
||||
.with_item(navbar::Item::nav(
|
||||
Nav::new()
|
||||
.with_item(nav::Item::link(L10n::t("menus_item_link", &LOC), |cx| {
|
||||
cx.route("/")
|
||||
}))
|
||||
.with_item(nav::Item::link_blank(
|
||||
L10n::t("menus_item_blank", &LOC),
|
||||
|_| "https://docs.rs/pagetop".into(),
|
||||
))
|
||||
.with_item(nav::Item::dropdown(
|
||||
Dropdown::new()
|
||||
.with_title(L10n::t("menus_test_title", &LOC))
|
||||
.with_item(dropdown::Item::header(L10n::t("menus_dev_header", &LOC)))
|
||||
.with_item(dropdown::Item::link(
|
||||
L10n::t("menus_dev_getting_started", &LOC),
|
||||
|cx| cx.route("/dev/getting-started"),
|
||||
))
|
||||
.with_item(dropdown::Item::link(
|
||||
L10n::t("menus_dev_guides", &LOC),
|
||||
|cx| cx.route("/dev/guides"),
|
||||
))
|
||||
.with_item(dropdown::Item::link_blank(
|
||||
L10n::t("menus_dev_forum", &LOC),
|
||||
|_| "https://forum.example.dev".into(),
|
||||
))
|
||||
.with_item(dropdown::Item::divider())
|
||||
.with_item(dropdown::Item::header(L10n::t("menus_sdk_header", &LOC)))
|
||||
.with_item(dropdown::Item::link(
|
||||
L10n::t("menus_sdk_rust", &LOC),
|
||||
|cx| cx.route("/dev/sdks/rust"),
|
||||
))
|
||||
.with_item(dropdown::Item::link(L10n::t("menus_sdk_js", &LOC), |cx| {
|
||||
cx.route("/dev/sdks/js")
|
||||
}))
|
||||
.with_item(dropdown::Item::link(
|
||||
L10n::t("menus_sdk_python", &LOC),
|
||||
|cx| cx.route("/dev/sdks/python"),
|
||||
))
|
||||
.with_item(dropdown::Item::divider())
|
||||
.with_item(dropdown::Item::header(L10n::t("menus_plugin_header", &LOC)))
|
||||
.with_item(dropdown::Item::link(
|
||||
L10n::t("menus_plugin_auth", &LOC),
|
||||
|cx| cx.route("/dev/sdks/rust/plugins/auth"),
|
||||
))
|
||||
.with_item(dropdown::Item::link(
|
||||
L10n::t("menus_plugin_cache", &LOC),
|
||||
|cx| cx.route("/dev/sdks/rust/plugins/cache"),
|
||||
))
|
||||
.with_item(dropdown::Item::divider())
|
||||
.with_item(dropdown::Item::label(L10n::t("menus_item_label", &LOC)))
|
||||
.with_item(dropdown::Item::link_disabled(
|
||||
L10n::t("menus_item_disabled", &LOC),
|
||||
|cx| cx.route("#"),
|
||||
)),
|
||||
))
|
||||
.with_item(nav::Item::link_disabled(
|
||||
L10n::t("menus_item_disabled", &LOC),
|
||||
|cx| cx.route("#"),
|
||||
)),
|
||||
))
|
||||
.with_item(navbar::Item::nav(
|
||||
Nav::new()
|
||||
.with_classes(
|
||||
ClassesOp::Add,
|
||||
classes::Margin::with(Side::Start, ScaleSize::Auto).to_class(),
|
||||
)
|
||||
.with_item(nav::Item::link(L10n::t("menus_item_sign_up", &LOC), |cx| {
|
||||
cx.route("/auth/sign-up")
|
||||
}))
|
||||
.with_item(nav::Item::link(L10n::t("menus_item_login", &LOC), |cx| {
|
||||
cx.route("/auth/login")
|
||||
})),
|
||||
));
|
||||
fn configure_router(&self, routes: Routes) -> Routes {
|
||||
routes.public_route("/", web::get(navbar_menus))
|
||||
}
|
||||
}
|
||||
|
||||
InRegion::Global(&DefaultRegion::Header).add(
|
||||
Container::new()
|
||||
.with_width(container::Width::FluidMax(UnitValue::RelRem(75.0)))
|
||||
.with_child(navbar_menu),
|
||||
async fn navbar_menus(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||
let page = Page::new(request)
|
||||
.with_assets(demo_title_styles())
|
||||
.with_assets(demo_code_styles())
|
||||
.with_assets(demo_frame_styles())
|
||||
.with_assets(demo_scroll_styles());
|
||||
|
||||
let mut intro = Intro::custom()
|
||||
.with_width(intro::Width::Full)
|
||||
.with_title(Lc::n("PageTop"))
|
||||
.with_slogan(Lc::t("menus_slogan", &LOC))
|
||||
.with_child(Html::with(|cx| {
|
||||
html! {
|
||||
p class="intro-text-lead" { (Lc::t("menus_note", &LOC).using(cx)) }
|
||||
}
|
||||
}))
|
||||
.with_child(menus_block())
|
||||
.with_child(brand_block())
|
||||
.with_child(container_block())
|
||||
.with_child(layout_block())
|
||||
.with_child(expand_block())
|
||||
.with_child(content_block())
|
||||
.with_child(position_block());
|
||||
|
||||
// Demostraciones asociadas a Bootsier: usan sus tipos, o clases y variables CSS de Bootstrap
|
||||
// que otros temas no definen. Sólo se muestran con el tema Bootsier activo.
|
||||
if is_bootsier() {
|
||||
intro = intro
|
||||
.with_child(colors_block())
|
||||
.with_child(offcanvas_block());
|
||||
}
|
||||
|
||||
page.with_child(intro).render().await
|
||||
}
|
||||
|
||||
// **< Menús >**************************************************************************************
|
||||
|
||||
fn menus_block() -> Block {
|
||||
let full_menu = Navbar::brand_left(demo_brand())
|
||||
.with_prop(light_bg())
|
||||
.with_expand(Breakpoint::Lg)
|
||||
.with_item(navbar::Item::nav(
|
||||
Nav::new()
|
||||
.with_item(nav::Item::link(Lc::t("menus_item_home", &LOC), "/").with_active(true))
|
||||
.with_item(nav::Item::link_blank(
|
||||
Lc::t("menus_item_blank", &LOC),
|
||||
"https://docs.rs/pagetop",
|
||||
))
|
||||
.with_item(nav::Item::dropdown(
|
||||
Dropdown::new()
|
||||
.with_title(Lc::t("menus_test_title", &LOC))
|
||||
.with_item(dropdown::Item::header(Lc::t("menus_dev_header", &LOC)))
|
||||
.with_item(dropdown::Item::link(
|
||||
Lc::t("menus_dev_getting_started", &LOC),
|
||||
"/dev/getting-started",
|
||||
))
|
||||
.with_item(dropdown::Item::link(
|
||||
Lc::t("menus_dev_guides", &LOC),
|
||||
"/dev/guides",
|
||||
))
|
||||
.with_item(dropdown::Item::link_blank(
|
||||
Lc::t("menus_dev_forum", &LOC),
|
||||
"https://forum.example.dev",
|
||||
))
|
||||
.with_item(dropdown::Item::divider())
|
||||
.with_item(dropdown::Item::header(Lc::t("menus_sdk_header", &LOC)))
|
||||
.with_item(dropdown::Item::link(
|
||||
Lc::t("menus_sdk_rust", &LOC),
|
||||
"/dev/sdks/rust",
|
||||
))
|
||||
.with_item(dropdown::Item::link(
|
||||
Lc::t("menus_sdk_js", &LOC),
|
||||
"/dev/sdks/js",
|
||||
))
|
||||
.with_item(dropdown::Item::link(
|
||||
Lc::t("menus_sdk_python", &LOC),
|
||||
"/dev/sdks/python",
|
||||
))
|
||||
.with_item(dropdown::Item::divider())
|
||||
.with_item(dropdown::Item::header(Lc::t("menus_plugin_header", &LOC)))
|
||||
.with_item(dropdown::Item::link(
|
||||
Lc::t("menus_plugin_auth", &LOC),
|
||||
"/dev/sdks/rust/plugins/auth",
|
||||
))
|
||||
.with_item(dropdown::Item::link(
|
||||
Lc::t("menus_plugin_cache", &LOC),
|
||||
"/dev/sdks/rust/plugins/cache",
|
||||
))
|
||||
.with_item(dropdown::Item::divider())
|
||||
.with_item(dropdown::Item::label(Lc::t("menus_item_label", &LOC)))
|
||||
.with_item(dropdown::Item::link_disabled(
|
||||
Lc::t("menus_item_disabled", &LOC),
|
||||
"#",
|
||||
)),
|
||||
))
|
||||
.with_item(nav::Item::link_disabled(
|
||||
Lc::t("menus_item_disabled", &LOC),
|
||||
"#",
|
||||
)),
|
||||
))
|
||||
.with_item(navbar::Item::nav(
|
||||
Nav::new()
|
||||
// Empuja este menú (y lo que le siga) al extremo final de la barra.
|
||||
.with_prop(FlexItem::push_end())
|
||||
.with_item(nav::Item::link(
|
||||
Lc::t("menus_item_sign_up", &LOC),
|
||||
"/auth/sign-up",
|
||||
))
|
||||
.with_item(nav::Item::link(
|
||||
Lc::t("menus_item_login", &LOC),
|
||||
"/auth/login",
|
||||
)),
|
||||
));
|
||||
|
||||
add_demo(
|
||||
Block::new().with_title(Lc::t("menus_block_title_menus", &LOC)),
|
||||
Lc::t("menus_title_full", &LOC),
|
||||
concat!(
|
||||
"Navbar::brand_left(brand)",
|
||||
".with_item(navbar::Item::nav(Nav::new()...with_item(nav::Item::dropdown(...))))",
|
||||
".with_item(navbar::Item::nav(Nav::new().with_prop(FlexItem::push_end())...))",
|
||||
),
|
||||
full_menu,
|
||||
)
|
||||
}
|
||||
|
||||
// **< Marca de identidad >*************************************************************************
|
||||
|
||||
fn brand_block() -> Block {
|
||||
// Una barra sin contenidos no se renderiza, así que la marca se añade como un elemento más.
|
||||
let brand_variants: [(&str, Brand, &str); 4] = [
|
||||
(
|
||||
"menus_title_brand_link",
|
||||
demo_brand(),
|
||||
"navbar::Item::brand(Brand::new().with_title(...).with_route(Route::from(\"/\")))",
|
||||
),
|
||||
(
|
||||
"menus_title_brand_span",
|
||||
demo_brand().with_route(None::<Route>),
|
||||
"navbar::Item::brand(Brand::new().with_title(...).with_route(None))",
|
||||
),
|
||||
(
|
||||
"menus_title_brand_image",
|
||||
Brand::new()
|
||||
.with_title(Lc::none())
|
||||
.with_image(demo_logo())
|
||||
.with_route(Route::from("/")),
|
||||
"navbar::Item::brand(Brand::new().with_title(Lc::none()).with_image(image))",
|
||||
),
|
||||
(
|
||||
"menus_title_brand_both",
|
||||
demo_brand().with_image(demo_logo()),
|
||||
"navbar::Item::brand(Brand::new().with_title(...).with_image(image))",
|
||||
),
|
||||
];
|
||||
|
||||
let mut block = Block::new().with_title(Lc::t("menus_block_title_brand", &LOC));
|
||||
for (title_key, brand, code) in brand_variants {
|
||||
block = add_demo(
|
||||
block,
|
||||
Lc::t(title_key, &LOC),
|
||||
code,
|
||||
Navbar::simple()
|
||||
.with_prop(light_bg())
|
||||
.with_item(navbar::Item::brand(brand)),
|
||||
);
|
||||
}
|
||||
block
|
||||
}
|
||||
|
||||
// **< Otros contenidos >***************************************************************************
|
||||
|
||||
fn content_block() -> Block {
|
||||
let gap = align::Gap::Both(UnitValue::RelRem(0.5));
|
||||
|
||||
let search_form = Form::new()
|
||||
.with_action("/")
|
||||
.with_method(form::Method::Get)
|
||||
.with_child(
|
||||
Flex::new()
|
||||
.with_align(align::Items::Center)
|
||||
.with_gap(gap)
|
||||
.with_child(
|
||||
form::input::Field::search()
|
||||
.with_name("q")
|
||||
.with_placeholder(Lc::t("menus_search_label", &LOC))
|
||||
// Sin el margen inferior con que algunos temas separan los campos.
|
||||
.with_prop(Margin::new().with_bottom(UnitValue::Zero)),
|
||||
)
|
||||
.with_child(
|
||||
Button::submit(Lc::t("menus_search_button", &LOC))
|
||||
.with_style(button::Style::Outline(Intent::Success)),
|
||||
),
|
||||
);
|
||||
|
||||
let buttons = Form::new().with_child(
|
||||
Flex::new()
|
||||
.with_align(align::Items::Center)
|
||||
.with_gap(gap)
|
||||
.with_child(
|
||||
Button::plain(Lc::t("menus_button_main", &LOC))
|
||||
.with_style(button::Style::Outline(Intent::Success)),
|
||||
)
|
||||
.with_child(
|
||||
Button::plain(Lc::t("menus_button_small", &LOC))
|
||||
.with_size(button::Size::Small)
|
||||
.with_style(button::Style::Outline(Intent::Neutral)),
|
||||
),
|
||||
);
|
||||
|
||||
let mut content_variants: Vec<(&str, Navbar, &str)> = vec![
|
||||
(
|
||||
"menus_title_form_search",
|
||||
Navbar::simple_brand_left(demo_brand()).with_item(navbar::Item::form(search_form)),
|
||||
"Navbar::simple_brand_left(brand).with_item(navbar::Item::form(Form::new()...))",
|
||||
),
|
||||
(
|
||||
"menus_title_form_buttons",
|
||||
Navbar::simple().with_item(navbar::Item::form(buttons)),
|
||||
"Navbar::simple().with_item(navbar::Item::form(Form::new()...))",
|
||||
),
|
||||
(
|
||||
"menus_title_text",
|
||||
Navbar::simple().with_item(navbar::Item::text(Lc::t("menus_text_inline", &LOC))),
|
||||
"Navbar::simple().with_item(navbar::Item::text(Lc::t(...)))",
|
||||
),
|
||||
(
|
||||
"menus_title_brand_and_text",
|
||||
Navbar::simple()
|
||||
.with_item(navbar::Item::brand(demo_brand()))
|
||||
.with_item(navbar::Item::text(Lc::t("menus_text_inline", &LOC))),
|
||||
concat!(
|
||||
"Navbar::simple().with_item(navbar::Item::brand(brand))",
|
||||
".with_item(navbar::Item::text(...))",
|
||||
),
|
||||
),
|
||||
(
|
||||
"menus_title_nav_text",
|
||||
Navbar::brand_left(demo_brand())
|
||||
.with_expand(Breakpoint::Lg)
|
||||
.with_item(navbar::Item::nav(
|
||||
demo_nav().with_prop(Margin::new().with_end(UnitValue::Auto)),
|
||||
))
|
||||
.with_item(navbar::Item::text(Lc::t("menus_text_inline", &LOC))),
|
||||
concat!(
|
||||
"Navbar::brand_left(brand).with_item(navbar::Item::nav(",
|
||||
"Nav::new().with_prop(Margin::new().with_end(UnitValue::Auto))...))",
|
||||
".with_item(navbar::Item::text(...))",
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
// El núcleo no tiene un componente de grupo de entrada, así que esta demostración usa clases de
|
||||
// Bootstrap y sólo se muestra con el tema Bootsier.
|
||||
if is_bootsier() {
|
||||
let input_group = Nav::new().with_item(nav::Item::html(Html::with(|cx| {
|
||||
html! {
|
||||
form {
|
||||
div class="input-group" {
|
||||
span class="input-group-text" { "@" }
|
||||
input
|
||||
class="form-control"
|
||||
type="text"
|
||||
placeholder=[Lc::t("menus_group_placeholder", &LOC).lookup(cx)]
|
||||
aria-label=[Lc::t("menus_group_placeholder", &LOC).lookup(cx)];
|
||||
}
|
||||
}
|
||||
}
|
||||
})));
|
||||
content_variants.insert(
|
||||
2,
|
||||
(
|
||||
"menus_title_form_group",
|
||||
Navbar::simple().with_item(navbar::Item::nav(input_group)),
|
||||
"Navbar::simple().with_item(navbar::Item::nav(Nav::new()...nav::Item::html(...)))",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
let mut block = Block::new().with_title(Lc::t("menus_block_title_content", &LOC));
|
||||
for (title_key, navbar, code) in content_variants {
|
||||
block = add_demo(
|
||||
block,
|
||||
Lc::t(title_key, &LOC),
|
||||
code,
|
||||
navbar.with_prop(light_bg()),
|
||||
);
|
||||
}
|
||||
block
|
||||
}
|
||||
|
||||
// **< Esquemas de color >**************************************************************************
|
||||
|
||||
fn colors_block() -> Block {
|
||||
let color_variants: [(&str, Vec<PropsOp>, &str); 4] = [
|
||||
(
|
||||
"menus_title_color_dark",
|
||||
vec![
|
||||
PropsOp::add_classes(class::Bg::with(BootsierColors::Dark)),
|
||||
PropsOp::set("data-bs-theme", "dark"),
|
||||
],
|
||||
concat!(
|
||||
"Navbar::brand_left(brand)",
|
||||
".with_prop(PropsOp::add_classes(class::Bg::with(BootsierColors::Dark)))",
|
||||
".with_prop(PropsOp::set(\"data-bs-theme\", \"dark\"))",
|
||||
),
|
||||
),
|
||||
(
|
||||
"menus_title_color_primary",
|
||||
vec![
|
||||
PropsOp::add_classes(class::Bg::with(BootsierColors::Primary)),
|
||||
PropsOp::set("data-bs-theme", "dark"),
|
||||
],
|
||||
concat!(
|
||||
"Navbar::brand_left(brand)",
|
||||
".with_prop(PropsOp::add_classes(class::Bg::with(BootsierColors::Primary)))",
|
||||
".with_prop(PropsOp::set(\"data-bs-theme\", \"dark\"))",
|
||||
),
|
||||
),
|
||||
(
|
||||
"menus_title_color_light",
|
||||
vec![light_bg()],
|
||||
concat!(
|
||||
"Navbar::brand_left(brand)",
|
||||
".with_prop(PropsOp::add_classes(class::Bg::with(class::BgColor::BodyTertiary)))",
|
||||
),
|
||||
),
|
||||
(
|
||||
"menus_title_color_custom",
|
||||
vec![PropsOp::add_style("background-color", "#e3f2fd")],
|
||||
concat!(
|
||||
"Navbar::brand_left(brand)",
|
||||
".with_prop(PropsOp::add_style(\"background-color\", \"#e3f2fd\"))",
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
let mut block = Block::new().with_title(Lc::t("menus_block_title_colors", &LOC));
|
||||
for (title_key, props, code) in color_variants {
|
||||
let mut navbar = Navbar::brand_left(demo_brand())
|
||||
.with_expand(Breakpoint::Lg)
|
||||
.with_item(navbar::Item::nav(demo_nav()));
|
||||
for op in props {
|
||||
navbar = navbar.with_prop(op);
|
||||
}
|
||||
block = add_demo(block, Lc::t(title_key, &LOC), code, navbar);
|
||||
}
|
||||
block
|
||||
}
|
||||
|
||||
// **< Contenedores >*******************************************************************************
|
||||
|
||||
fn container_block() -> Block {
|
||||
let navbar = || {
|
||||
Navbar::brand_left(demo_brand())
|
||||
.with_prop(light_bg())
|
||||
.with_expand(Breakpoint::Lg)
|
||||
.with_item(navbar::Item::nav(demo_nav()))
|
||||
};
|
||||
|
||||
let block = Block::new().with_title(Lc::t("menus_block_title_container", &LOC));
|
||||
let block = add_demo(
|
||||
block,
|
||||
Lc::t("menus_title_container_full", &LOC),
|
||||
"Navbar::brand_left(brand)...",
|
||||
navbar(),
|
||||
);
|
||||
add_demo(
|
||||
block,
|
||||
Lc::t("menus_title_container_max", &LOC),
|
||||
concat!(
|
||||
"Container::new()",
|
||||
".with_width(container::Width::FluidMax(UnitValue::RelRem(40.0)))",
|
||||
".with_child(Navbar::brand_left(brand)...)",
|
||||
),
|
||||
Container::new()
|
||||
.with_width(container::Width::FluidMax(UnitValue::RelRem(40.0)))
|
||||
.with_child(navbar()),
|
||||
)
|
||||
}
|
||||
|
||||
// **< Posición >***********************************************************************************
|
||||
|
||||
fn position_block() -> Block {
|
||||
let navbar = |position| {
|
||||
Navbar::simple()
|
||||
.with_position(position)
|
||||
.with_prop(light_bg())
|
||||
.with_item(navbar::Item::nav(demo_nav()))
|
||||
};
|
||||
|
||||
// Las barras fijas se anclan al marco y no a la ventana, para no tapar el resto de la página.
|
||||
let fixed_variants: [(&str, navbar::Position, &str); 2] = [
|
||||
(
|
||||
"menus_title_position_fixed_top",
|
||||
navbar::Position::FixedTop,
|
||||
"Navbar::simple().with_position(navbar::Position::FixedTop)",
|
||||
),
|
||||
(
|
||||
"menus_title_position_fixed_bottom",
|
||||
navbar::Position::FixedBottom,
|
||||
"Navbar::simple().with_position(navbar::Position::FixedBottom)",
|
||||
),
|
||||
];
|
||||
|
||||
let mut block = Block::new()
|
||||
.with_title(Lc::t("menus_block_title_position", &LOC))
|
||||
.with_child(Html::with(|cx| {
|
||||
html! {
|
||||
p { (Lc::t("menus_position_note", &LOC).using(cx)) }
|
||||
}
|
||||
}));
|
||||
for (title_key, position, code) in fixed_variants {
|
||||
block = add_demo(
|
||||
block,
|
||||
Lc::t(title_key, &LOC),
|
||||
code,
|
||||
Container::new()
|
||||
.with_width(container::Width::Fluid)
|
||||
.with_prop(PropsOp::add_classes("menus-demo-frame"))
|
||||
.with_child(navbar(position))
|
||||
.with_child(filler()),
|
||||
);
|
||||
}
|
||||
|
||||
// Con `sticky` la barra ocupa su lugar en el flujo y se queda pegada al borde del contenedor
|
||||
// que se desplaza (aquí un marco con scroll).
|
||||
block = add_demo(
|
||||
block,
|
||||
Lc::t("menus_title_position_sticky_top", &LOC),
|
||||
"Navbar::simple().with_position(navbar::Position::StickyTop)",
|
||||
Container::new()
|
||||
.with_width(container::Width::Fluid)
|
||||
.with_prop(PropsOp::add_classes("menus-demo-scroll"))
|
||||
.with_child(navbar(navbar::Position::StickyTop))
|
||||
.with_child(filler())
|
||||
.with_child(filler())
|
||||
.with_child(filler())
|
||||
.with_child(filler()),
|
||||
);
|
||||
add_demo(
|
||||
block,
|
||||
Lc::t("menus_title_position_sticky_bottom", &LOC),
|
||||
"Navbar::simple().with_position(navbar::Position::StickyBottom)",
|
||||
Container::new()
|
||||
.with_width(container::Width::Fluid)
|
||||
.with_prop(PropsOp::add_classes("menus-demo-scroll"))
|
||||
.with_child(filler())
|
||||
.with_child(filler())
|
||||
.with_child(filler())
|
||||
.with_child(filler())
|
||||
.with_child(navbar(navbar::Position::StickyBottom)),
|
||||
)
|
||||
}
|
||||
|
||||
// **< Disposición >********************************************************************************
|
||||
|
||||
fn layout_block() -> Block {
|
||||
let layout_variants: [(&str, Navbar, &str); 4] = [
|
||||
(
|
||||
"menus_title_layout_toggle",
|
||||
Navbar::simple_toggle(),
|
||||
"Navbar::simple_toggle()",
|
||||
),
|
||||
(
|
||||
"menus_title_layout_brand_left",
|
||||
Navbar::brand_left(demo_brand()),
|
||||
"Navbar::brand_left(brand)",
|
||||
),
|
||||
(
|
||||
"menus_title_layout_brand_right",
|
||||
Navbar::brand_right(demo_brand()),
|
||||
"Navbar::brand_right(brand)",
|
||||
),
|
||||
(
|
||||
"menus_title_layout_brand_always",
|
||||
Navbar::simple_brand_left(demo_brand()),
|
||||
"Navbar::simple_brand_left(brand)",
|
||||
),
|
||||
];
|
||||
|
||||
let mut block = Block::new().with_title(Lc::t("menus_block_title_layout", &LOC));
|
||||
for (title_key, navbar, code) in layout_variants {
|
||||
block = add_demo(
|
||||
block,
|
||||
Lc::t(title_key, &LOC),
|
||||
code,
|
||||
navbar
|
||||
.with_prop(light_bg())
|
||||
.with_expand(Breakpoint::Lg)
|
||||
.with_item(navbar::Item::nav(demo_nav())),
|
||||
);
|
||||
}
|
||||
block
|
||||
}
|
||||
|
||||
// **< Punto de corte >*****************************************************************************
|
||||
|
||||
fn expand_block() -> Block {
|
||||
let expand_variants: [(Lc, Breakpoint, &str); 5] = [
|
||||
(
|
||||
expand_title("sm", "576px"),
|
||||
Breakpoint::Sm,
|
||||
"Navbar::brand_left(brand).with_expand(Breakpoint::Sm)",
|
||||
),
|
||||
(
|
||||
expand_title("md", "768px"),
|
||||
Breakpoint::Md,
|
||||
"Navbar::brand_left(brand).with_expand(Breakpoint::Md)",
|
||||
),
|
||||
(
|
||||
expand_title("lg", "992px"),
|
||||
Breakpoint::Lg,
|
||||
"Navbar::brand_left(brand).with_expand(Breakpoint::Lg)",
|
||||
),
|
||||
(
|
||||
expand_title("xl", "1200px"),
|
||||
Breakpoint::Xl,
|
||||
"Navbar::brand_left(brand).with_expand(Breakpoint::Xl)",
|
||||
),
|
||||
(
|
||||
expand_title("xxl", "1400px"),
|
||||
Breakpoint::Xxl,
|
||||
"Navbar::brand_left(brand).with_expand(Breakpoint::Xxl)",
|
||||
),
|
||||
];
|
||||
|
||||
let mut block = Block::new().with_title(Lc::t("menus_block_title_expand", &LOC));
|
||||
for (title, breakpoint, code) in expand_variants {
|
||||
block = add_demo(
|
||||
block,
|
||||
title,
|
||||
code,
|
||||
Navbar::brand_left(demo_brand())
|
||||
.with_prop(light_bg())
|
||||
.with_expand(breakpoint)
|
||||
.with_item(navbar::Item::nav(demo_nav())),
|
||||
);
|
||||
}
|
||||
block
|
||||
}
|
||||
|
||||
fn expand_title(name: &'static str, width: &'static str) -> Lc {
|
||||
Lc::t("menus_title_expand", &LOC)
|
||||
.with_arg("name", name)
|
||||
.with_arg("width", width)
|
||||
}
|
||||
|
||||
// **< Offcanvas >**********************************************************************************
|
||||
|
||||
fn offcanvas_block() -> Block {
|
||||
let panel = |placement, backdrop| {
|
||||
bs::navbar::Panel::new()
|
||||
.with_title(Lc::t("menus_offcanvas_title", &LOC))
|
||||
.with_placement(placement)
|
||||
.with_backdrop(backdrop)
|
||||
};
|
||||
|
||||
let offcanvas_variants: [(&str, Navbar, &str); 4] = [
|
||||
(
|
||||
"menus_title_offcanvas_start",
|
||||
Navbar::offcanvas(panel(
|
||||
bs::offcanvas::Placement::Start,
|
||||
bs::offcanvas::Backdrop::Enabled,
|
||||
)),
|
||||
concat!(
|
||||
"Navbar::offcanvas(bs::navbar::Panel::new()",
|
||||
".with_placement(bs::offcanvas::Placement::Start))",
|
||||
),
|
||||
),
|
||||
(
|
||||
"menus_title_offcanvas_brand_left",
|
||||
Navbar::offcanvas_brand_left(
|
||||
demo_brand(),
|
||||
panel(
|
||||
bs::offcanvas::Placement::End,
|
||||
bs::offcanvas::Backdrop::Enabled,
|
||||
),
|
||||
),
|
||||
concat!(
|
||||
"Navbar::offcanvas_brand_left(brand, bs::navbar::Panel::new()",
|
||||
".with_placement(bs::offcanvas::Placement::End))",
|
||||
),
|
||||
),
|
||||
(
|
||||
"menus_title_offcanvas_brand_right",
|
||||
Navbar::offcanvas_brand_right(
|
||||
demo_brand(),
|
||||
panel(
|
||||
bs::offcanvas::Placement::Start,
|
||||
bs::offcanvas::Backdrop::Disabled,
|
||||
),
|
||||
),
|
||||
concat!(
|
||||
"Navbar::offcanvas_brand_right(brand, bs::navbar::Panel::new()",
|
||||
".with_backdrop(bs::offcanvas::Backdrop::Disabled))",
|
||||
),
|
||||
),
|
||||
(
|
||||
"menus_title_offcanvas_dark",
|
||||
Navbar::offcanvas_brand_left(
|
||||
demo_brand(),
|
||||
panel(
|
||||
bs::offcanvas::Placement::End,
|
||||
bs::offcanvas::Backdrop::Static,
|
||||
),
|
||||
)
|
||||
.with_prop(PropsOp::add_classes(class::Bg::with(BootsierColors::Dark)))
|
||||
.with_prop(PropsOp::set("data-bs-theme", "dark")),
|
||||
concat!(
|
||||
"Navbar::offcanvas_brand_left(brand, bs::navbar::Panel::new()",
|
||||
".with_backdrop(bs::offcanvas::Backdrop::Static))",
|
||||
".with_prop(PropsOp::set(\"data-bs-theme\", \"dark\"))",
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
let mut block = Block::new().with_title(Lc::t("menus_block_title_offcanvas", &LOC));
|
||||
for (title_key, navbar, code) in offcanvas_variants {
|
||||
let navbar = navbar
|
||||
.with_expand(Breakpoint::Lg)
|
||||
.with_item(navbar::Item::nav(demo_nav()));
|
||||
// La barra oscura ya define su propio fondo.
|
||||
let navbar = if title_key == "menus_title_offcanvas_dark" {
|
||||
navbar
|
||||
} else {
|
||||
navbar.with_prop(light_bg())
|
||||
};
|
||||
block = add_demo(block, Lc::t(title_key, &LOC), code, navbar);
|
||||
}
|
||||
block
|
||||
}
|
||||
|
||||
// **< HELPERS >************************************************************************************
|
||||
|
||||
// Marca de identidad de las demostraciones.
|
||||
fn demo_brand() -> Brand {
|
||||
Brand::new()
|
||||
.with_title(Lc::n("PageTop"))
|
||||
.with_route(Route::from("/"))
|
||||
}
|
||||
|
||||
// Logotipo de las demostraciones, con el tamaño habitual de una marca en una barra.
|
||||
fn demo_logo() -> Image {
|
||||
Image::with(image::Source::logo(PageTopSvg::Tile))
|
||||
.with_size(image::Size::Both(UnitValue::Px(36)))
|
||||
}
|
||||
|
||||
// Menú común a la mayoría de las demostraciones: activo, enlace, desplegable y deshabilitado.
|
||||
fn demo_nav() -> Nav {
|
||||
Nav::new()
|
||||
.with_item(nav::Item::link(Lc::t("menus_item_home", &LOC), "/").with_active(true))
|
||||
.with_item(nav::Item::link(Lc::t("menus_item_link", &LOC), "/link"))
|
||||
.with_item(nav::Item::dropdown(
|
||||
Dropdown::new()
|
||||
.with_title(Lc::t("menus_test_title", &LOC))
|
||||
.with_item(dropdown::Item::link(
|
||||
Lc::t("menus_item_action", &LOC),
|
||||
"/action",
|
||||
))
|
||||
.with_item(dropdown::Item::link(
|
||||
Lc::t("menus_item_another", &LOC),
|
||||
"/another",
|
||||
))
|
||||
.with_item(dropdown::Item::divider())
|
||||
.with_item(dropdown::Item::link(
|
||||
Lc::t("menus_item_something", &LOC),
|
||||
"/something",
|
||||
)),
|
||||
))
|
||||
.with_item(nav::Item::link_disabled(
|
||||
Lc::t("menus_item_disabled", &LOC),
|
||||
"#",
|
||||
))
|
||||
}
|
||||
|
||||
fn is_bootsier() -> bool {
|
||||
global::SETTINGS.app.theme.eq_ignore_ascii_case("bootsier")
|
||||
}
|
||||
|
||||
// Fondo claro para que las barras destaquen sobre el fondo de la página. Basic no da fondo a
|
||||
// `.navbar`, así que con otros temas se usa el color de fondo de Basic (o un gris claro si el tema
|
||||
// activo tampoco lo define).
|
||||
fn light_bg() -> PropsOp {
|
||||
if is_bootsier() {
|
||||
PropsOp::add_classes(class::Bg::with(class::BgColor::BodyTertiary))
|
||||
} else {
|
||||
PropsOp::add_style("background-color", "var(--val-color--bg, #f8f9fa)")
|
||||
}
|
||||
}
|
||||
|
||||
// Título y fragmento de código que introducen cada demostración, seguidos de ésta.
|
||||
fn add_demo(block: Block, title: Lc, code: &'static str, demo: impl Into<ChildOp>) -> Block {
|
||||
block
|
||||
.with_child(caption(title, Lc::n(code)))
|
||||
.with_child(demo)
|
||||
}
|
||||
|
||||
// Párrafo de relleno para que los marcos de demostración tengan contenido que desplazar.
|
||||
fn filler() -> Html {
|
||||
Html::with(|cx| {
|
||||
html! {
|
||||
p { (Lc::t("menus_filler", &LOC).using(cx)) }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Título y fragmento de código que introducen cada demostración.
|
||||
fn caption(title: Lc, code: Lc) -> Html {
|
||||
Html::with(move |cx| {
|
||||
html! {
|
||||
h3 class="menus-demo-title" { (title.using(cx)) }
|
||||
p { code class="menus-demo-code" { (code.using(cx)) } }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Separa el título de cada demostración de la barra (o marco) que le precede.
|
||||
fn demo_title_styles() -> AssetsOp {
|
||||
AssetsOp::add_responsive_styles(None, "menus-demo-title", [("margin-top", "1.5rem")])
|
||||
}
|
||||
|
||||
// Evita que los fragmentos de código largos desborden su contenedor.
|
||||
fn demo_code_styles() -> AssetsOp {
|
||||
AssetsOp::add_responsive_styles(None, "menus-demo-code", [("overflow-wrap", "anywhere")])
|
||||
}
|
||||
|
||||
// Marco de tamaño fijo para las barras con posición `fixed`.
|
||||
fn demo_frame_styles() -> AssetsOp {
|
||||
AssetsOp::add_responsive_styles(
|
||||
None,
|
||||
"menus-demo-frame",
|
||||
[
|
||||
("position", "relative"),
|
||||
// Un `transform` convierte al marco en el bloque contenedor de sus descendientes con
|
||||
// `position: fixed`, así la barra se ancla al marco en vez de a la ventana.
|
||||
("transform", "translateZ(0)"),
|
||||
("height", "12rem"),
|
||||
("padding", "4rem 1rem"),
|
||||
("overflow", "hidden"),
|
||||
("border", "1px solid #dee2e6"),
|
||||
("margin", "0 0 1.5rem"),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
// Marco de tamaño fijo con desplazamiento, para las barras con posición `sticky`.
|
||||
fn demo_scroll_styles() -> AssetsOp {
|
||||
AssetsOp::add_responsive_styles(
|
||||
None,
|
||||
"menus-demo-scroll",
|
||||
[
|
||||
("height", "12rem"),
|
||||
("overflow-y", "auto"),
|
||||
("padding", "0 1rem"),
|
||||
("border", "1px solid #dee2e6"),
|
||||
("margin", "0 0 1.5rem"),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::prepare(&SuperMenu).run()?.await
|
||||
Application::prepare(&NavbarMenus).await.run().await
|
||||
}
|
||||
|
|
|
|||
488
examples/theme-showcase.rs
Normal file
|
|
@ -0,0 +1,488 @@
|
|||
use pagetop::prelude::*;
|
||||
use pagetop_bootsier::theme::*;
|
||||
|
||||
include_locales!(LOC from "examples/locale");
|
||||
|
||||
struct ThemeShowcase;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for ThemeShowcase {
|
||||
fn dependencies(&self) -> Vec<ExtensionRef> {
|
||||
vec![&pagetop_bootsier::Bootsier]
|
||||
}
|
||||
|
||||
async fn initialize(&self) -> Result<(), BoxError> {
|
||||
let brand = Brand::new()
|
||||
.with_image(
|
||||
// Recuadro en el color primario de Bootsier (petróleo, `#0e6973`), con la línea
|
||||
// clara que elige el logotipo por contraste. Se ve igual en los dos modos de color.
|
||||
Image::with(image::Source::logo(PageTopSvg::TileRGB(14, 105, 115)))
|
||||
.with_size(image::Size::Both(UnitValue::Px(36))),
|
||||
)
|
||||
.with_title(Lc::n("PageTop"))
|
||||
.with_route(Route::from("/"));
|
||||
|
||||
// Menú completo: enlace activo, desplegable con secciones, enlace externo y deshabilitado.
|
||||
// Ocupa el espacio libre entre la marca y el menú de la cuenta, con sus opciones centradas.
|
||||
let main_menu = Nav::new()
|
||||
.with_layout(nav::Layout::Center)
|
||||
.with_prop(FlexItem::new().with_grow(flex::ItemGrow::Is1))
|
||||
.with_item(nav::Item::link(Lc::t("showcase_menu_home", &LOC), "/").with_active(true))
|
||||
.with_item(nav::Item::dropdown(
|
||||
Dropdown::new()
|
||||
.with_title(Lc::t("showcase_menu_components", &LOC))
|
||||
.with_item(dropdown::Item::header(Lc::t("showcase_menu_forms", &LOC)))
|
||||
.with_item(dropdown::Item::link(
|
||||
Lc::t("showcase_menu_fields", &LOC),
|
||||
"#",
|
||||
))
|
||||
.with_item(dropdown::Item::link(
|
||||
Lc::t("showcase_menu_buttons", &LOC),
|
||||
"#",
|
||||
))
|
||||
.with_item(dropdown::Item::divider())
|
||||
.with_item(dropdown::Item::header(Lc::t("showcase_menu_others", &LOC)))
|
||||
.with_item(dropdown::Item::link(
|
||||
Lc::t("showcase_menu_messages", &LOC),
|
||||
"#",
|
||||
))
|
||||
.with_item(dropdown::Item::link_disabled(
|
||||
Lc::t("showcase_menu_disabled", &LOC),
|
||||
"#",
|
||||
)),
|
||||
))
|
||||
.with_item(nav::Item::link_blank(
|
||||
Lc::t("showcase_menu_docs", &LOC),
|
||||
"https://docs.rs/pagetop",
|
||||
))
|
||||
.with_item(nav::Item::link_disabled(
|
||||
Lc::t("showcase_menu_disabled", &LOC),
|
||||
"#",
|
||||
));
|
||||
|
||||
// Menú de la cuenta al final de la barra y, con Bootsier, el selector de modo de color
|
||||
// (claro, oscuro o automático).
|
||||
let mut user_menu = Nav::new()
|
||||
.with_prop(FlexItem::push_end())
|
||||
.with_item(nav::Item::link(Lc::t("showcase_menu_sign_up", &LOC), "#"))
|
||||
.with_item(nav::Item::link(Lc::t("showcase_menu_login", &LOC), "#"));
|
||||
if is_bootsier() {
|
||||
user_menu = user_menu.with_item(bs::theme_toggle());
|
||||
}
|
||||
|
||||
let header = Navbar::brand_left(brand)
|
||||
.with_expand(Breakpoint::Lg)
|
||||
.with_item(navbar::Item::nav(main_menu))
|
||||
.with_item(navbar::Item::nav(user_menu));
|
||||
|
||||
InRegion::Global(&CoreRegions::Header).add(header);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn configure_router(&self, routes: Routes) -> Routes {
|
||||
routes.public_route("/", web::get(theme_showcase))
|
||||
}
|
||||
}
|
||||
|
||||
async fn theme_showcase(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||
let mut page = Page::new(request)
|
||||
.with_title(Lc::t("showcase_title", &LOC))
|
||||
.with_child(fields_block())
|
||||
.with_child(checks_block())
|
||||
.with_child(tables_block())
|
||||
.with_child(buttons_block())
|
||||
.with_child(misc_block());
|
||||
|
||||
// Un mensaje de cada nivel, que muestra el listado del bloque de tablas entre su botón y la
|
||||
// tabla, como haría con el aviso de un borrado.
|
||||
page.push_message(MessageLevel::Info, Lc::t("showcase_msg_info", &LOC));
|
||||
page.push_message(MessageLevel::Warning, Lc::t("showcase_msg_warning", &LOC));
|
||||
page.push_message(MessageLevel::Error, Lc::t("showcase_msg_error", &LOC));
|
||||
|
||||
page.render().await
|
||||
}
|
||||
|
||||
// Bootsier aporta piezas propias que otros temas no tienen: el selector de modo de color, las
|
||||
// etiquetas flotantes y los botones de los colores claro y oscuro de su paleta.
|
||||
fn is_bootsier() -> bool {
|
||||
global::SETTINGS.app.theme.eq_ignore_ascii_case("bootsier")
|
||||
}
|
||||
|
||||
// Rejilla de una columna en pantallas pequeñas, dos a partir de `Md` y tres a partir de `Lg`. Sin
|
||||
// hueco entre filas: ya separa los campos su propio margen.
|
||||
fn columns() -> Grid {
|
||||
let tracks = |n| grid::Tracks::repeat(n, grid::AxisTrack::Fraction(1.0));
|
||||
Grid::new()
|
||||
.with_columns(tracks(1))
|
||||
.with_columns_at(Breakpoint::Md, tracks(2))
|
||||
.with_columns_at(Breakpoint::Lg, tracks(3))
|
||||
.with_gap(align::Gap::Distinct {
|
||||
row: UnitValue::None,
|
||||
column: UnitValue::RelRem(1.5),
|
||||
})
|
||||
}
|
||||
|
||||
// Campos de texto y listas en sus distintos estados.
|
||||
fn fields_block() -> Block {
|
||||
let mut grid = columns()
|
||||
.with_child(
|
||||
form::input::Field::text()
|
||||
.with_name("name")
|
||||
.with_label(Lc::t("showcase_name", &LOC))
|
||||
.with_value("Ana García")
|
||||
.with_help_text(Lc::t("showcase_name_help", &LOC))
|
||||
.with_required(true),
|
||||
)
|
||||
.with_child(
|
||||
form::input::Field::email()
|
||||
.with_name("email")
|
||||
.with_label(Lc::t("showcase_email", &LOC))
|
||||
.with_placeholder(Lc::t("showcase_email_placeholder", &LOC)),
|
||||
)
|
||||
.with_child(
|
||||
form::input::Field::text()
|
||||
.with_name("focus")
|
||||
.with_label(Lc::t("showcase_focus", &LOC))
|
||||
.with_value("1200")
|
||||
.with_autofocus(true),
|
||||
)
|
||||
.with_child(
|
||||
form::select::Field::new()
|
||||
.with_name("font")
|
||||
.with_label(Lc::t("showcase_font", &LOC))
|
||||
.with_item(form::select::Item::new(
|
||||
"playfair",
|
||||
Lc::n("Playfair Display"),
|
||||
))
|
||||
.with_item(form::select::Item::new("source", Lc::n("Source Sans 3")))
|
||||
.with_item(form::select::Item::new("roboto", Lc::n("Roboto"))),
|
||||
)
|
||||
.with_child(
|
||||
form::input::Field::text()
|
||||
.with_name("disabled")
|
||||
.with_label(Lc::t("showcase_disabled", &LOC))
|
||||
.with_value("Ana García")
|
||||
.with_disabled(true),
|
||||
)
|
||||
.with_child(
|
||||
form::input::Field::email()
|
||||
.with_name("readonly")
|
||||
.with_label(Lc::t("showcase_readonly", &LOC))
|
||||
.with_value("ana@example.com")
|
||||
.with_readonly(true),
|
||||
)
|
||||
.with_child(
|
||||
form::select::Field::new()
|
||||
.with_name("disabled_font")
|
||||
.with_label(Lc::t("showcase_disabled_select", &LOC))
|
||||
.with_item(form::select::Item::new(
|
||||
"playfair",
|
||||
Lc::n("Playfair Display"),
|
||||
))
|
||||
.with_disabled(true),
|
||||
)
|
||||
.with_child(
|
||||
form::Textarea::new()
|
||||
.with_name("comment")
|
||||
.with_label(Lc::t("showcase_comment", &LOC))
|
||||
.with_placeholder(Lc::t("showcase_comment_placeholder", &LOC)),
|
||||
);
|
||||
if is_bootsier() {
|
||||
grid = grid.with_child(
|
||||
form::input::Field::text()
|
||||
.with_name("floating")
|
||||
.with_label(Lc::t("showcase_floating", &LOC))
|
||||
.with_value("Ana García")
|
||||
.with_floating_label(true),
|
||||
);
|
||||
}
|
||||
|
||||
// El último campo no tiene margen inferior y, si es el más alto de su fila, la rejilla acaba en
|
||||
// su borde. El margen de la rejilla repone ese espacio, como el que dejan debajo los demás
|
||||
// bloques.
|
||||
Block::new()
|
||||
.with_title(Lc::t("showcase_block_fields", &LOC))
|
||||
.with_child(grid.with_prop(Margin::new().with_bottom(UnitValue::RelRem(1.0))))
|
||||
}
|
||||
|
||||
// Casillas, interruptores y botones de opción, marcados, sin marcar y deshabilitados.
|
||||
fn checks_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("showcase_block_checks", &LOC))
|
||||
.with_child(
|
||||
columns()
|
||||
.with_child(
|
||||
form::Fieldset::new()
|
||||
.with_legend(Lc::t("showcase_checks", &LOC))
|
||||
.with_child(
|
||||
form::Checkbox::new()
|
||||
.with_name("check_off")
|
||||
.with_label(Lc::t("showcase_check_off", &LOC)),
|
||||
)
|
||||
.with_child(
|
||||
form::Checkbox::new()
|
||||
.with_name("check_on")
|
||||
.with_label(Lc::t("showcase_check_on", &LOC))
|
||||
.with_checked(true),
|
||||
)
|
||||
.with_child(
|
||||
form::Checkbox::new()
|
||||
.with_name("check_disabled")
|
||||
.with_label(Lc::t("showcase_check_disabled", &LOC))
|
||||
.with_disabled(true),
|
||||
),
|
||||
)
|
||||
.with_child(
|
||||
form::Fieldset::new()
|
||||
.with_legend(Lc::t("showcase_switches", &LOC))
|
||||
.with_child(
|
||||
form::Checkbox::switch()
|
||||
.with_name("switch_off")
|
||||
.with_label(Lc::t("showcase_switch_off", &LOC)),
|
||||
)
|
||||
.with_child(
|
||||
form::Checkbox::switch()
|
||||
.with_name("switch_on")
|
||||
.with_label(Lc::t("showcase_switch_on", &LOC))
|
||||
.with_checked(true),
|
||||
)
|
||||
.with_child(
|
||||
form::Checkbox::switch()
|
||||
.with_name("switch_disabled")
|
||||
.with_label(Lc::t("showcase_switch_disabled", &LOC))
|
||||
.with_disabled(true),
|
||||
),
|
||||
)
|
||||
.with_child(
|
||||
form::Fieldset::new()
|
||||
.with_legend(Lc::t("showcase_options", &LOC))
|
||||
.with_child(
|
||||
form::radio::Field::new()
|
||||
.with_name("size")
|
||||
.with_item(form::radio::Item::new(
|
||||
"small",
|
||||
Lc::t("showcase_option_small", &LOC),
|
||||
))
|
||||
.with_item(
|
||||
form::radio::Item::new(
|
||||
"medium",
|
||||
Lc::t("showcase_option_medium", &LOC),
|
||||
)
|
||||
.with_checked(true),
|
||||
)
|
||||
.with_item(
|
||||
form::radio::Item::new(
|
||||
"large",
|
||||
Lc::t("showcase_option_large", &LOC),
|
||||
)
|
||||
.with_disabled(true),
|
||||
)
|
||||
.with_help_text(Lc::t("showcase_options_help", &LOC)),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
// Filtro de listado, listado completo (botón de acción, tabla con cabeceras ordenables y
|
||||
// paginador) y tabla vacía.
|
||||
fn tables_block() -> Block {
|
||||
// Columna ordenable; `dir` marca la que determina el orden vigente.
|
||||
let sortable = |key: &'static str, sort: &str, dir: Option<SortDir>| {
|
||||
table::Column::new(Lc::t(key, &LOC))
|
||||
.with_sort(table::SortLink::new(util::join!("/?sort=", sort)).with_dir(dir))
|
||||
};
|
||||
|
||||
let mut users = Table::new()
|
||||
.with_column(sortable("showcase_col_user", "user", Some(SortDir::Asc)))
|
||||
.with_column(sortable("showcase_col_email", "email", None))
|
||||
.with_column(Lc::t("showcase_col_status", &LOC))
|
||||
.with_column(sortable("showcase_col_last_access", "access", None))
|
||||
.with_column(Lc::t("showcase_col_actions", &LOC));
|
||||
for (user, email, status, access) in [
|
||||
("ana", "ana@example.com", "active", "2026-11-14 09:12"),
|
||||
("bruno", "bruno@example.com", "pending", "-"),
|
||||
("carmen", "carmen@example.com", "active", "2026-11-13 18:40"),
|
||||
("david", "david@example.com", "blocked", "2026-10-02 11:05"),
|
||||
] {
|
||||
let badge = match status {
|
||||
"active" => Badge::success(Lc::t("showcase_status_active", &LOC)),
|
||||
"pending" => Badge::warning(Lc::t("showcase_status_pending", &LOC)),
|
||||
_ => Badge::severe(Lc::t("showcase_status_blocked", &LOC)),
|
||||
};
|
||||
users.alter_row(
|
||||
table::Row::new()
|
||||
.with_cell(user)
|
||||
.with_cell(email)
|
||||
.with_cell(table::Cell::new(badge))
|
||||
.with_cell(access)
|
||||
.with_cell(table::Cell::new(
|
||||
Button::anchor(Lc::t("showcase_edit", &LOC), "#")
|
||||
.with_style(button::Style::Link),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
let list = ListView::new()
|
||||
.with_id("showcase-users")
|
||||
.with_action(
|
||||
Button::anchor(Lc::t("showcase_new_user", &LOC), "#")
|
||||
.with_style(button::Style::Solid(Intent::Primary)),
|
||||
)
|
||||
.with_table(users)
|
||||
.with_pager(
|
||||
Pager::new()
|
||||
.with_base_path("/")
|
||||
.with_current_page(1)
|
||||
.with_items_per_page(4)
|
||||
.with_total_items(14),
|
||||
);
|
||||
|
||||
// Sin filas, la tabla muestra su mensaje predeterminado.
|
||||
let empty = Table::new()
|
||||
.with_column(Lc::t("showcase_col_user", &LOC))
|
||||
.with_column(Lc::t("showcase_col_email", &LOC))
|
||||
.with_column(Lc::t("showcase_col_status", &LOC));
|
||||
|
||||
Block::new()
|
||||
.with_title(Lc::t("showcase_block_tables", &LOC))
|
||||
.with_child(Html::with(|cx| {
|
||||
html! {
|
||||
p { (Lc::t("showcase_filter_hint", &LOC).using(cx)) }
|
||||
}
|
||||
}))
|
||||
// El filtro va fuera del listado: si se reemplazara con él, el campo de búsqueda perdería
|
||||
// el foco al actualizar sólo el listado.
|
||||
.with_child(
|
||||
ListFilter::new()
|
||||
.with_filter_action("/")
|
||||
.with_field(
|
||||
form::input::Field::search()
|
||||
.with_name("q")
|
||||
.with_label(Lc::t("showcase_search", &LOC))
|
||||
.with_placeholder(Lc::t("showcase_search_placeholder", &LOC)),
|
||||
)
|
||||
.with_field(
|
||||
form::select::Field::new()
|
||||
.with_name("status")
|
||||
.with_label(Lc::t("showcase_status", &LOC))
|
||||
.with_item(form::select::Item::new(
|
||||
"",
|
||||
Lc::t("showcase_status_any", &LOC),
|
||||
))
|
||||
.with_item(form::select::Item::new(
|
||||
"active",
|
||||
Lc::t("showcase_status_active", &LOC),
|
||||
))
|
||||
.with_item(form::select::Item::new(
|
||||
"blocked",
|
||||
Lc::t("showcase_status_blocked", &LOC),
|
||||
)),
|
||||
)
|
||||
.with_field(
|
||||
form::Checkbox::new()
|
||||
.with_name("admins")
|
||||
.with_label(Lc::t("showcase_only_admins", &LOC)),
|
||||
),
|
||||
)
|
||||
.with_child(list)
|
||||
.with_child(Html::with(|cx| {
|
||||
html! {
|
||||
p { (Lc::t("showcase_empty_table", &LOC).using(cx)) }
|
||||
}
|
||||
}))
|
||||
.with_child(empty)
|
||||
}
|
||||
|
||||
// Botones macizos y de contorno de todas las intenciones.
|
||||
fn buttons_block() -> Block {
|
||||
Block::new()
|
||||
.with_title(Lc::t("showcase_block_buttons", &LOC))
|
||||
.with_child(
|
||||
Flex::new()
|
||||
.with_direction(flex::Direction::Column)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5)))
|
||||
.with_prop(Margin::new().with_bottom(UnitValue::RelRem(1.5)))
|
||||
.with_child(buttons(false))
|
||||
.with_child(buttons(true)),
|
||||
)
|
||||
}
|
||||
|
||||
// Una fila con un botón por intención. Con Bootsier, también los colores claro y oscuro de su
|
||||
// paleta, que no corresponden a ninguna intención. El estilo enlace sólo va en la fila maciza.
|
||||
fn buttons(outline: bool) -> Flex {
|
||||
let style = |intent| match outline {
|
||||
false => button::Style::Solid(intent),
|
||||
true => button::Style::Outline(intent),
|
||||
};
|
||||
|
||||
let mut row = Flex::new()
|
||||
.with_wrap(flex::Behavior::Wrap)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5)));
|
||||
for (label, intent) in [
|
||||
("Primary", Intent::Primary),
|
||||
("Neutral", Intent::Neutral),
|
||||
("Info", Intent::Info),
|
||||
("Success", Intent::Success),
|
||||
("Warning", Intent::Warning),
|
||||
("Severe", Intent::Severe),
|
||||
] {
|
||||
row = row.with_child(Button::plain(Lc::n(label)).with_style(style(intent)));
|
||||
}
|
||||
if is_bootsier() {
|
||||
for (label, color) in [
|
||||
("Light", BootsierColors::Light),
|
||||
("Dark", BootsierColors::Dark),
|
||||
] {
|
||||
row = row.with_child(
|
||||
Button::plain(Lc::n(label))
|
||||
.with_style(style(Intent::Neutral))
|
||||
.with_color(color),
|
||||
);
|
||||
}
|
||||
}
|
||||
if !outline {
|
||||
row = row.with_child(Button::plain(Lc::n("Link")).with_style(button::Style::Link));
|
||||
}
|
||||
row
|
||||
}
|
||||
|
||||
// Enlaces, insignias, paginación y mensajes, que también toman los colores del tema.
|
||||
fn misc_block() -> Block {
|
||||
let mut badges = Flex::new()
|
||||
.with_wrap(flex::Behavior::Wrap)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5)));
|
||||
for badge in [
|
||||
Badge::primary(Lc::n("Primary")),
|
||||
Badge::neutral(Lc::n("Neutral")),
|
||||
Badge::info(Lc::n("Info")),
|
||||
Badge::success(Lc::n("Success")),
|
||||
Badge::warning(Lc::n("Warning")),
|
||||
Badge::severe(Lc::n("Severe")),
|
||||
] {
|
||||
badges = badges.with_child(badge);
|
||||
}
|
||||
|
||||
Block::new()
|
||||
.with_title(Lc::t("showcase_block_misc", &LOC))
|
||||
.with_child(Html::with(|cx| {
|
||||
html! {
|
||||
p { (Lc::t("showcase_link_text", &LOC).using(cx)) }
|
||||
}
|
||||
}))
|
||||
.with_child(badges)
|
||||
// Con 50 páginas y la actual en medio aparecen todas sus piezas: anterior y siguiente, las
|
||||
// elipsis de los tramos ocultos a cada lado, el resumen y el formulario para saltar a una
|
||||
// página.
|
||||
.with_child(
|
||||
Pager::new()
|
||||
.with_base_path("/")
|
||||
.with_current_page(24)
|
||||
.with_items_per_page(10)
|
||||
.with_total_items(500),
|
||||
)
|
||||
}
|
||||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::prepare(&ThemeShowcase).await.run().await
|
||||
}
|
||||
20
extensions/pagetop-admin/Cargo.toml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
[package]
|
||||
name = "pagetop-admin"
|
||||
description = "Ajustes guardados en la base de datos para el panel de administración de PageTop."
|
||||
version = "0.1.0"
|
||||
categories = ["web-programming", "development-tools"]
|
||||
keywords = ["pagetop", "admin", "cms", "settings", "ssr"]
|
||||
|
||||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
|
||||
[dependencies]
|
||||
pagetop.workspace = true
|
||||
pagetop-seaorm.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
thiserror.workspace = true
|
||||
201
extensions/pagetop-admin/LICENSE-APACHE
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2026 Manuel Cillero
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
21
extensions/pagetop-admin/LICENSE-MIT
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2026 Manuel Cillero
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
132
extensions/pagetop-admin/README.md
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
<div align="center">
|
||||
|
||||
<h1>PageTop Admin</h1>
|
||||
|
||||
<p>Ajustes guardados en la base de datos para el panel de administración de <strong>PageTop</strong>.</p>
|
||||
|
||||
[](https://docs.rs/pagetop-admin)
|
||||
[](https://crates.io/crates/pagetop-admin)
|
||||
[](https://crates.io/crates/pagetop-admin)
|
||||
[](https://git.cillero.es/manuelcillero/pagetop/src/branch/main/extensions/pagetop-admin#licencia)
|
||||
|
||||
</div>
|
||||
|
||||
## Sobre PageTop
|
||||
|
||||
[PageTop](https://docs.rs/pagetop) es un entorno de desarrollo que reivindica la esencia de la web
|
||||
clásica para crear soluciones web SSR (*renderizadas en el servidor*) modulares, extensibles y
|
||||
configurables, basadas en HTML, CSS y JavaScript.
|
||||
|
||||
## Descripción general
|
||||
|
||||
Añade al panel de administración de PageTop **ajustes que se guardan en la base de datos** y que un
|
||||
administrador cambia desde el propio panel, con la aplicación en marcha.
|
||||
|
||||
## Qué aporta
|
||||
|
||||
- **Páginas de ajustes sin código propio.** Una extensión describe los campos con un
|
||||
`SettingsSchema` y declara la página con `DeclareConfigForms`. `pagetop-admin` monta su ruta,
|
||||
pinta el formulario con los valores guardados y guarda lo que se envía, salvo que falte algún
|
||||
campo obligatorio o llegue vacío.
|
||||
- **El almacén de los valores.** La tabla `settings`, que crea al arrancar, y las funciones del
|
||||
módulo `settings` para leerlos (`settings::get_or()` y compañía) y escribirlos desde código.
|
||||
- **El formulario** (`ConfigForm`), por si una página propia quiere mostrar el de un esquema.
|
||||
|
||||
## En qué se apoya
|
||||
|
||||
El panel en sí es de PageTop (el módulo `pagetop::admin`): su página de inicio, sus secciones, la
|
||||
navegación, las migas de pan y la plantilla de administración (`Page::admin()`). Cada página de
|
||||
ajustes es una `AdminPage` del núcleo, así que aparece en el panel como cualquier otra, con su
|
||||
sección y su permiso, y se pinta con cualquier tema. Una extensión que sólo añade páginas propias al
|
||||
panel, sin ajustes, no necesita `pagetop-admin`.
|
||||
|
||||
## Cuándo usarlo
|
||||
|
||||
Para valores que decide quien administra el sitio y que cambian con el tiempo: un aviso en la
|
||||
portada, un número de plazas, abrir o cerrar las inscripciones... Lo que fija quien despliega la
|
||||
aplicación (la base de datos, el servidor de correo, los límites) va en los archivos de
|
||||
configuración (ver el módulo `pagetop::config`), que no se pueden cambiar desde el panel y exigen
|
||||
reiniciar.
|
||||
|
||||
Los valores que envía el formulario se guardan como texto, también los de los campos numéricos y las
|
||||
casillas (`"42"`, `"true"`): se leen como `String` y se convierten al usarlos.
|
||||
|
||||
## Guía rápida
|
||||
|
||||
**Añade la dependencia** a tu `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
pagetop-admin = "..."
|
||||
```
|
||||
|
||||
Los ajustes se guardan con `pagetop-seaorm`: la aplicación elige el motor de base de datos con su
|
||||
*feature* (`postgres`, `mysql` o `sqlite`) y configura la conexión en la sección `[database]`.
|
||||
|
||||
**Declara la extensión** como dependencia de la tuya (`&pagetop_admin::Admin`); si no, sus páginas
|
||||
de ajustes no se montan. Después **declara tus páginas de ajustes**, cada una con su permiso:
|
||||
|
||||
```rust,no_run
|
||||
use pagetop::prelude::*;
|
||||
use pagetop_admin::prelude::*;
|
||||
|
||||
pub struct MyApp;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for MyApp {
|
||||
fn dependencies(&self) -> Vec<ExtensionRef> {
|
||||
vec![&pagetop_admin::Admin]
|
||||
}
|
||||
|
||||
fn actions(&self) -> Vec<ActionBox> {
|
||||
actions![DeclareConfigForms::new(declare_forms)]
|
||||
}
|
||||
}
|
||||
|
||||
fn declare_forms(bag: &mut ConfigFormBag) {
|
||||
bag.add(ConfigFormPage {
|
||||
page: AdminPage::new("config/myapp", "config", Lc::n("My App"), &MyPermission::Config)
|
||||
.with_description(Lc::n("Name of the site.")),
|
||||
schema: SettingsSchema::new("myapp").with_field(
|
||||
SettingField::text("site_name", Lc::n("Site name")).with_required(true),
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
enum MyPermission {
|
||||
Config,
|
||||
}
|
||||
|
||||
impl Permission for MyPermission {
|
||||
fn key(&self) -> CowStr {
|
||||
match self {
|
||||
Self::Config => "myapp:config".into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Los valores se guardan con la clave `<ámbito>.<campo>`.
|
||||
async fn site_name() -> String {
|
||||
pagetop_admin::settings::get_or("myapp.site_name", String::new()).await
|
||||
}
|
||||
```
|
||||
|
||||
## Advertencia
|
||||
|
||||
**PageTop** es un proyecto personal para aprender [Rust](https://www.rust-lang.org/es) y conocer su
|
||||
ecosistema. Su API está sujeta a cambios frecuentes. No se recomienda su uso en producción, al menos
|
||||
hasta que se libere la versión **1.0.0**.
|
||||
|
||||
## Licencia
|
||||
|
||||
El código está disponible bajo una doble licencia:
|
||||
|
||||
* **Licencia MIT**
|
||||
([LICENSE-MIT](LICENSE-MIT) o también https://opensource.org/licenses/MIT)
|
||||
|
||||
* **Licencia Apache, Versión 2.0**
|
||||
([LICENSE-APACHE](LICENSE-APACHE) o también https://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
Puedes elegir la licencia que prefieras. Este enfoque de doble licencia es el estándar de facto en
|
||||
el ecosistema Rust.
|
||||
119
extensions/pagetop-admin/src/action.rs
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
//! Acción para declarar páginas de ajustes que `pagetop-admin` pinta y guarda por sí solo.
|
||||
|
||||
use pagetop::prelude::*;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::OnceLock;
|
||||
|
||||
use crate::settings::SettingsSchema;
|
||||
|
||||
// **< ConfigFormPage >*****************************************************************************
|
||||
|
||||
/// Página de ajustes del panel: una [`AdminPage`] y el esquema de su formulario.
|
||||
///
|
||||
/// `pagetop-admin` la añade al registro del panel como cualquier otra página, monta su ruta y
|
||||
/// responde a su `GET` (el formulario con los valores guardados) y a su `POST` (los guarda en la
|
||||
/// base de datos). La extensión que la declara no registra ninguna ruta.
|
||||
#[derive(Clone)]
|
||||
pub struct ConfigFormPage {
|
||||
/// Página del panel, con su ruta relativa a la raíz del panel.
|
||||
pub page: AdminPage,
|
||||
/// Esquema del formulario.
|
||||
pub schema: SettingsSchema,
|
||||
}
|
||||
|
||||
/// Bolsa de páginas de ajustes para [`DeclareConfigForms`].
|
||||
pub struct ConfigFormBag {
|
||||
forms: Vec<ConfigFormPage>,
|
||||
}
|
||||
|
||||
impl ConfigFormBag {
|
||||
/// Añade una página de ajustes.
|
||||
pub fn add(&mut self, form: ConfigFormPage) {
|
||||
self.forms.push(form);
|
||||
}
|
||||
}
|
||||
|
||||
// **< DeclareConfigForms >*************************************************************************
|
||||
|
||||
/// Tipo de función para declarar páginas de ajustes.
|
||||
pub type FnActionDeclareConfigForms = fn(bag: &mut ConfigFormBag);
|
||||
|
||||
/// Acción para declarar páginas de ajustes que gestiona `pagetop-admin` (ver [`ConfigFormPage`]).
|
||||
///
|
||||
/// # Ejemplo
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// use pagetop::prelude::*;
|
||||
/// use pagetop_admin::prelude::*;
|
||||
///
|
||||
/// #[derive(Clone, Copy, Debug)]
|
||||
/// enum MyPermission {
|
||||
/// Config,
|
||||
/// }
|
||||
///
|
||||
/// impl Permission for MyPermission {
|
||||
/// fn key(&self) -> CowStr {
|
||||
/// "myapp:config".into()
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn declare_forms(bag: &mut ConfigFormBag) {
|
||||
/// bag.add(ConfigFormPage {
|
||||
/// page: AdminPage::new("config/myapp", "config", Lc::n("My App"), &MyPermission::Config)
|
||||
/// .with_description(Lc::n("Configure My App.")),
|
||||
/// schema: SettingsSchema::new("myapp.config").with_field(
|
||||
/// SettingField::text("site_name", Lc::n("Site name")).with_required(true),
|
||||
/// ),
|
||||
/// });
|
||||
/// }
|
||||
/// // En Extension::actions():
|
||||
/// // DeclareConfigForms::new(declare_forms)
|
||||
/// ```
|
||||
pub struct DeclareConfigForms {
|
||||
f: FnActionDeclareConfigForms,
|
||||
weight: Weight,
|
||||
}
|
||||
|
||||
impl ActionDispatcher for DeclareConfigForms {
|
||||
fn weight(&self) -> Weight {
|
||||
self.weight
|
||||
}
|
||||
}
|
||||
|
||||
impl DeclareConfigForms {
|
||||
/// Registra una nueva acción para declarar páginas de ajustes.
|
||||
pub fn new(f: FnActionDeclareConfigForms) -> Self {
|
||||
DeclareConfigForms { f, weight: 0 }
|
||||
}
|
||||
|
||||
/// Opcional. Acciones con pesos más bajos se aplican antes. Se pueden usar valores negativos.
|
||||
pub fn with_weight(mut self, value: Weight) -> Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
// **< Registro de las páginas de ajustes >*********************************************************
|
||||
|
||||
// Esquemas de las páginas de ajustes, por su ruta relativa a la raíz del panel.
|
||||
static CONFIG_FORMS: OnceLock<BTreeMap<String, SettingsSchema>> = OnceLock::new();
|
||||
|
||||
// Añade las páginas de ajustes al registro del panel. `pagetop-admin` lo registra como una acción
|
||||
// `DeclareAdminPages`, así que se ejecuta una sola vez, cuando el núcleo construye el registro.
|
||||
pub(crate) fn declare_config_form_pages(bag: &mut AdminPageBag) {
|
||||
let mut forms = ConfigFormBag { forms: Vec::new() };
|
||||
dispatch_actions(|action: &DeclareConfigForms| (action.f)(&mut forms));
|
||||
let mut schemas = BTreeMap::new();
|
||||
for form in forms.forms {
|
||||
schemas.insert(form.page.path().to_owned(), form.schema);
|
||||
bag.add(form.page);
|
||||
}
|
||||
let _ = CONFIG_FORMS.set(schemas);
|
||||
}
|
||||
|
||||
// Esquemas de las páginas de ajustes, por su ruta relativa a la raíz del panel.
|
||||
pub(crate) fn config_forms() -> &'static BTreeMap<String, SettingsSchema> {
|
||||
static EMPTY: BTreeMap<String, SettingsSchema> = BTreeMap::new();
|
||||
CONFIG_FORMS.get().unwrap_or(&EMPTY)
|
||||
}
|
||||
5
extensions/pagetop-admin/src/component.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
//! Componentes de renderizado del panel de administración.
|
||||
|
||||
mod config_form;
|
||||
|
||||
pub use config_form::ConfigForm;
|
||||
189
extensions/pagetop-admin/src/component/config_form.rs
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
use crate::LOCALES_ADMIN;
|
||||
use crate::settings::{SettingFieldType, SettingsSchema, get_or};
|
||||
|
||||
/// Formulario de un [`SettingsSchema`], con los valores guardados en la tabla `settings`.
|
||||
///
|
||||
/// En las páginas declaradas con [`DeclareConfigForms`](crate::action::DeclareConfigForms),
|
||||
/// `pagetop-admin` lo muestra y guarda lo que se envía. En una página propia sólo lo muestra: el
|
||||
/// envío llega a la ruta de la página, o a la de [`with_action_path()`](Self::with_action_path), y
|
||||
/// lo guarda su *handler* (ver [`settings::set()`](crate::settings::set)).
|
||||
///
|
||||
/// # Ejemplo
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// use pagetop::prelude::*;
|
||||
/// use pagetop_admin::component::ConfigForm;
|
||||
/// use pagetop_admin::settings::{SettingField, SettingsSchema};
|
||||
///
|
||||
/// async fn settings_handler(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||
/// let schema = SettingsSchema::new("myapp.general")
|
||||
/// .with_field(SettingField::text("site_name", Lc::n("Site name")).with_required(true));
|
||||
///
|
||||
/// Page::admin(request)
|
||||
/// .with_title(Lc::n("General settings"))
|
||||
/// .with_child(ConfigForm::with_schema(schema))
|
||||
/// .render()
|
||||
/// .await
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(AutoDefault, Clone, Debug, Getters)]
|
||||
pub struct ConfigForm {
|
||||
/// Devuelve el esquema del formulario, si se ha establecido uno.
|
||||
schema: Option<SettingsSchema>,
|
||||
/// Devuelve la ruta de destino del formulario, si se ha personalizado.
|
||||
action_path: Option<Route>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Component for ConfigForm {
|
||||
fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
async fn prepare(&self, cx: &mut Context) -> Result<Markup, ComponentError> {
|
||||
let Some(schema) = self.schema() else {
|
||||
return Ok(html! {});
|
||||
};
|
||||
|
||||
let action = match self.action_path() {
|
||||
Some(route) => route.resolve(cx),
|
||||
None => cx.route(cx.request().map(|r| r.path()).unwrap_or("/")),
|
||||
};
|
||||
|
||||
// Pre-computa los valores de BD para cada campo antes del macro html! (que es síncrono). El
|
||||
// formulario guarda todos los valores como texto (`"42"`, `"true"`), así que se leen como
|
||||
// texto también los de los campos numéricos y las casillas.
|
||||
struct FieldVals {
|
||||
raw_val: String,
|
||||
checked: bool,
|
||||
}
|
||||
let mut prepared: Vec<FieldVals> = Vec::with_capacity(schema.fields().len());
|
||||
for field in schema.fields() {
|
||||
let key = schema.key_for(field.name());
|
||||
let raw_val =
|
||||
get_or::<String>(&key, field.default_value().cloned().unwrap_or_default()).await;
|
||||
let checked = raw_val == "true";
|
||||
prepared.push(FieldVals { raw_val, checked });
|
||||
}
|
||||
|
||||
Ok(html! {
|
||||
form class="admin-config-form" method="post" action=(action) {
|
||||
@for (i, field) in schema.fields().iter().enumerate() {
|
||||
@let pf = &prepared[i];
|
||||
div class="admin-form-field" {
|
||||
label class="admin-form-label" for=(field.name()) {
|
||||
(field.label().using(cx))
|
||||
}
|
||||
@match field.field_type() {
|
||||
SettingFieldType::Text { max_length } => {
|
||||
@if let Some(max) = max_length {
|
||||
input class="admin-form-input"
|
||||
type="text"
|
||||
id=(field.name())
|
||||
name=(field.name())
|
||||
value=(&pf.raw_val)
|
||||
maxlength=(max)
|
||||
required[*field.required()];
|
||||
} @else {
|
||||
input class="admin-form-input"
|
||||
type="text"
|
||||
id=(field.name())
|
||||
name=(field.name())
|
||||
value=(&pf.raw_val)
|
||||
required[*field.required()];
|
||||
}
|
||||
}
|
||||
SettingFieldType::Number { min, max } => {
|
||||
@if let (Some(lo), Some(hi)) = (min, max) {
|
||||
input class="admin-form-input"
|
||||
type="number"
|
||||
id=(field.name())
|
||||
name=(field.name())
|
||||
value=(&pf.raw_val)
|
||||
min=(lo)
|
||||
max=(hi)
|
||||
required[*field.required()];
|
||||
} @else if let Some(lo) = min {
|
||||
input class="admin-form-input"
|
||||
type="number"
|
||||
id=(field.name())
|
||||
name=(field.name())
|
||||
value=(&pf.raw_val)
|
||||
min=(lo)
|
||||
required[*field.required()];
|
||||
} @else if let Some(hi) = max {
|
||||
input class="admin-form-input"
|
||||
type="number"
|
||||
id=(field.name())
|
||||
name=(field.name())
|
||||
value=(&pf.raw_val)
|
||||
max=(hi)
|
||||
required[*field.required()];
|
||||
} @else {
|
||||
input class="admin-form-input"
|
||||
type="number"
|
||||
id=(field.name())
|
||||
name=(field.name())
|
||||
value=(&pf.raw_val)
|
||||
required[*field.required()];
|
||||
}
|
||||
}
|
||||
SettingFieldType::Boolean => {
|
||||
input class="admin-form-checkbox"
|
||||
type="checkbox"
|
||||
id=(field.name())
|
||||
name=(field.name())
|
||||
value="true"
|
||||
checked[pf.checked];
|
||||
}
|
||||
SettingFieldType::Select { options } => {
|
||||
select class="admin-form-select"
|
||||
id=(field.name())
|
||||
name=(field.name())
|
||||
required[*field.required()]
|
||||
{
|
||||
@for (val, label) in options {
|
||||
@if &pf.raw_val == val {
|
||||
option value=(val) selected { (label.using(cx)) }
|
||||
} @else {
|
||||
option value=(val) { (label.using(cx)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@if !field.help_text().is_none() {
|
||||
small class="admin-form-help" { (field.help_text().using(cx)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
div class="admin-form-actions" {
|
||||
button class="admin-btn admin-btn-primary" type="submit" {
|
||||
(Lc::t("config-save-label", &LOCALES_ADMIN).using(cx))
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl ConfigForm {
|
||||
/// Crea el componente con el [`SettingsSchema`] dado.
|
||||
#[builder_skip]
|
||||
pub fn with_schema(schema: SettingsSchema) -> Self {
|
||||
ConfigForm {
|
||||
schema: Some(schema),
|
||||
..Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// Establece la ruta a la que se envía el formulario, o `None` para enviarlo a la de la
|
||||
/// página.
|
||||
pub fn with_action_path(mut self, path: impl Into<Option<Route>>) -> Self {
|
||||
self.action_path = path.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
3
extensions/pagetop-admin/src/entity.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
//! Entidades SeaORM de `pagetop-admin`.
|
||||
|
||||
pub(crate) mod setting;
|
||||
18
extensions/pagetop-admin/src/entity/setting.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
use pagetop_seaorm::db::*;
|
||||
|
||||
/// Entidad SeaORM para la tabla `settings`.
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
||||
#[sea_orm(table_name = "settings")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub key: String,
|
||||
pub scope: String,
|
||||
pub value: String,
|
||||
pub updated_at: DateTimeUtc,
|
||||
pub updated_by: Option<i32>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, DeriveRelation, EnumIter)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
14
extensions/pagetop-admin/src/error.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
use thiserror::Error;
|
||||
|
||||
/// Errores que puede producir la extensión `pagetop-admin`.
|
||||
#[derive(Debug, Error)]
|
||||
pub enum AdminError {
|
||||
#[error("settings DB error: {0}")]
|
||||
DbError(#[from] pagetop_seaorm::db::DbErr),
|
||||
|
||||
#[error("settings serialization error: {0}")]
|
||||
SerializeError(#[from] serde_json::Error),
|
||||
|
||||
#[error("setting key not found: {0}")]
|
||||
NotFound(String),
|
||||
}
|
||||
130
extensions/pagetop-admin/src/handlers.rs
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use pagetop::prelude::*;
|
||||
|
||||
use crate::LOCALES_ADMIN;
|
||||
use crate::action::config_forms;
|
||||
use crate::component::ConfigForm;
|
||||
use crate::settings::{self, SettingFieldType, SettingsSchema};
|
||||
|
||||
// **< Config form >********************************************************************************
|
||||
|
||||
// Página del registro y esquema de la página de ajustes de la petición.
|
||||
fn config_form_page(
|
||||
request: &HttpRequest,
|
||||
) -> Result<(&'static AdminPage, &'static SettingsSchema), ErrorPage> {
|
||||
let not_found = || ErrorPage::NotFound(request.clone());
|
||||
let path = strip_admin_path(request.path()).ok_or_else(not_found)?;
|
||||
let page = AdminRegistry::global().page(path).ok_or_else(not_found)?;
|
||||
let schema = config_forms().get(path).ok_or_else(not_found)?;
|
||||
Ok((page, schema))
|
||||
}
|
||||
|
||||
// **< Config form - GET >**************************************************************************
|
||||
|
||||
// GET de una página de ajustes: el formulario con los valores guardados.
|
||||
pub async fn config_form_get(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||
let (page, schema) = config_form_page(&request)?;
|
||||
|
||||
Page::admin(request)
|
||||
.with_title(page.title().clone())
|
||||
.with_child(ConfigForm::with_schema(schema.clone()))
|
||||
.render()
|
||||
.await
|
||||
}
|
||||
|
||||
// **< Config form - POST >*************************************************************************
|
||||
|
||||
// POST de una página de ajustes: guarda los valores enviados y vuelve a mostrar el formulario con
|
||||
// un mensaje. Si falta algún campo obligatorio no guarda ninguno.
|
||||
pub async fn config_form_post(
|
||||
request: HttpRequest,
|
||||
web::Form(data): web::Form<HashMap<String, String>>,
|
||||
) -> Result<Markup, ErrorPage> {
|
||||
let (page, schema) = config_form_page(&request)?;
|
||||
let mut admin = Page::admin(request).with_title(page.title().clone());
|
||||
|
||||
let (level, message) = match submitted_values(schema, &data) {
|
||||
None => (MessageLevel::Error, "config-required"),
|
||||
Some(values) => {
|
||||
let user_id = admin.current_user().id();
|
||||
let mut saved = true;
|
||||
for (key, value) in values {
|
||||
if let Err(error) = settings::set(&key, &value, schema.scope(), user_id).await {
|
||||
trace::error!("Failed to save the setting \"{key}\": {error}");
|
||||
saved = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if saved {
|
||||
(MessageLevel::Info, "config-saved-ok")
|
||||
} else {
|
||||
(MessageLevel::Error, "config-saved-error")
|
||||
}
|
||||
}
|
||||
};
|
||||
admin.push_message(level, Lc::t(message, &LOCALES_ADMIN));
|
||||
|
||||
admin
|
||||
.with_child(ConfigForm::with_schema(schema.clone()))
|
||||
.render()
|
||||
.await
|
||||
}
|
||||
|
||||
// Clave y valor de cada campo del esquema en el envío, o `None` si falta un campo obligatorio o
|
||||
// llega vacío. Una casilla sin marcar no se envía, así que vale `"false"`.
|
||||
fn submitted_values(
|
||||
schema: &SettingsSchema,
|
||||
data: &HashMap<String, String>,
|
||||
) -> Option<Vec<(String, String)>> {
|
||||
let mut values = Vec::with_capacity(schema.fields().len());
|
||||
for field in schema.fields() {
|
||||
let value = match (field.field_type(), data.get(field.name())) {
|
||||
(SettingFieldType::Boolean, value) => value.map_or("false", String::as_str),
|
||||
(_, Some(value)) if !value.trim().is_empty() => value,
|
||||
(_, _) if *field.required() => return None,
|
||||
(_, value) => value.map_or("", String::as_str),
|
||||
};
|
||||
values.push((schema.key_for(field.name()), value.to_owned()));
|
||||
}
|
||||
Some(values)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::settings::SettingField;
|
||||
|
||||
fn schema() -> SettingsSchema {
|
||||
SettingsSchema::new("garden")
|
||||
.with_field(SettingField::text("name", Lc::n("Name")).with_required(true))
|
||||
.with_field(SettingField::text("notice", Lc::n("Notice")))
|
||||
.with_field(SettingField::boolean("open", Lc::n("Open")))
|
||||
}
|
||||
|
||||
fn data(pairs: &[(&str, &str)]) -> HashMap<String, String> {
|
||||
pairs
|
||||
.iter()
|
||||
.map(|(k, v)| (k.to_string(), v.to_string()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn values_are_keyed_by_scope_and_an_unchecked_box_is_false() {
|
||||
let values = submitted_values(&schema(), &data(&[("name", "Ours"), ("notice", "")]));
|
||||
assert_eq!(
|
||||
values.unwrap(),
|
||||
[
|
||||
("garden.name".to_owned(), "Ours".to_owned()),
|
||||
("garden.notice".to_owned(), String::new()),
|
||||
("garden.open".to_owned(), "false".to_owned()),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn a_required_field_missing_or_blank_saves_nothing() {
|
||||
assert!(submitted_values(&schema(), &data(&[("notice", "Hi")])).is_none());
|
||||
assert!(submitted_values(&schema(), &data(&[("name", " ")])).is_none());
|
||||
}
|
||||
}
|
||||
182
extensions/pagetop-admin/src/lib.rs
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
/*!
|
||||
<div align="center">
|
||||
|
||||
<h1>PageTop Admin</h1>
|
||||
|
||||
<p>Ajustes guardados en la base de datos para el panel de administración de <strong>PageTop</strong>.</p>
|
||||
|
||||
[](https://docs.rs/pagetop-admin)
|
||||
[](https://crates.io/crates/pagetop-admin)
|
||||
[](https://crates.io/crates/pagetop-admin)
|
||||
[](https://git.cillero.es/manuelcillero/pagetop/src/branch/main/extensions/pagetop-admin#licencia)
|
||||
|
||||
</div>
|
||||
|
||||
## Sobre PageTop
|
||||
|
||||
[PageTop](https://docs.rs/pagetop) es un entorno de desarrollo que reivindica la esencia de la web
|
||||
clásica para crear soluciones web SSR (*renderizadas en el servidor*) modulares, extensibles y
|
||||
configurables, basadas en HTML, CSS y JavaScript.
|
||||
|
||||
## Descripción general
|
||||
|
||||
Añade al panel de administración de PageTop **ajustes que se guardan en la base de datos** y que un
|
||||
administrador cambia desde el propio panel, con la aplicación en marcha.
|
||||
|
||||
## Qué aporta
|
||||
|
||||
- **Páginas de ajustes sin código propio.** Una extensión describe los campos con un
|
||||
[`SettingsSchema`] y declara la página con [`DeclareConfigForms`]. `pagetop-admin` monta su ruta,
|
||||
pinta el formulario con los valores guardados y guarda lo que se envía, salvo que falte algún
|
||||
campo obligatorio o llegue vacío.
|
||||
- **El almacén de los valores.** La tabla `settings`, que crea al arrancar, y las funciones del
|
||||
módulo [`settings`](mod@settings) para leerlos ([`settings::get_or()`] y compañía) y
|
||||
escribirlos desde código.
|
||||
- **El formulario** ([`ConfigForm`]), por si una página propia quiere mostrar el de un esquema.
|
||||
|
||||
## En qué se apoya
|
||||
|
||||
El panel en sí es de PageTop (el módulo [`pagetop::admin`]): su página de inicio, sus secciones, la
|
||||
navegación, las migas de pan y la plantilla de administración ([`Page::admin()`]). Cada página de
|
||||
ajustes es una [`AdminPage`] del núcleo, así que aparece en el panel como cualquier otra, con su
|
||||
sección y su permiso, y se pinta con cualquier tema. Una extensión que sólo añade páginas propias al
|
||||
panel, sin ajustes, no necesita `pagetop-admin`.
|
||||
|
||||
## Cuándo usarlo
|
||||
|
||||
Para valores que decide quien administra el sitio y que cambian con el tiempo: un aviso en la
|
||||
portada, un número de plazas, abrir o cerrar las inscripciones... Lo que fija quien despliega la
|
||||
aplicación (la base de datos, el servidor de correo, los límites) va en los archivos de
|
||||
configuración (ver [`pagetop::config`]), que no se pueden cambiar desde el panel y exigen
|
||||
reiniciar.
|
||||
|
||||
Los valores que envía el formulario se guardan como texto, también los de los campos numéricos y las
|
||||
casillas (`"42"`, `"true"`): se leen como `String` y se convierten al usarlos.
|
||||
|
||||
## Guía rápida
|
||||
|
||||
**Añade la dependencia** a tu `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
pagetop-admin = "..."
|
||||
```
|
||||
|
||||
Los ajustes se guardan con `pagetop-seaorm`: la aplicación elige el motor de base de datos con su
|
||||
*feature* (`postgres`, `mysql` o `sqlite`) y configura la conexión en la sección `[database]`.
|
||||
|
||||
**Declara la extensión** como dependencia de la tuya (`&pagetop_admin::Admin`); si no, sus páginas
|
||||
de ajustes no se montan. Después **declara tus páginas de ajustes**, cada una con su permiso:
|
||||
|
||||
```rust,no_run
|
||||
use pagetop::prelude::*;
|
||||
use pagetop_admin::prelude::*;
|
||||
|
||||
pub struct MyApp;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for MyApp {
|
||||
fn dependencies(&self) -> Vec<ExtensionRef> {
|
||||
vec![&pagetop_admin::Admin]
|
||||
}
|
||||
|
||||
fn actions(&self) -> Vec<ActionBox> {
|
||||
actions![DeclareConfigForms::new(declare_forms)]
|
||||
}
|
||||
}
|
||||
|
||||
fn declare_forms(bag: &mut ConfigFormBag) {
|
||||
bag.add(ConfigFormPage {
|
||||
page: AdminPage::new("config/myapp", "config", Lc::n("My App"), &MyPermission::Config)
|
||||
.with_description(Lc::n("Name of the site.")),
|
||||
schema: SettingsSchema::new("myapp").with_field(
|
||||
SettingField::text("site_name", Lc::n("Site name")).with_required(true),
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
enum MyPermission {
|
||||
Config,
|
||||
}
|
||||
|
||||
impl Permission for MyPermission {
|
||||
fn key(&self) -> CowStr {
|
||||
match self {
|
||||
Self::Config => "myapp:config".into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Los valores se guardan con la clave `<ámbito>.<campo>`.
|
||||
async fn site_name() -> String {
|
||||
pagetop_admin::settings::get_or("myapp.site_name", String::new()).await
|
||||
}
|
||||
```
|
||||
*/
|
||||
|
||||
use pagetop::prelude::*;
|
||||
use pagetop_seaorm::install_migrations;
|
||||
|
||||
include_locales!(LOCALES_ADMIN);
|
||||
|
||||
pub mod action;
|
||||
pub mod component;
|
||||
pub mod error;
|
||||
pub mod settings;
|
||||
|
||||
pub(crate) mod entity;
|
||||
pub(crate) mod handlers;
|
||||
pub(crate) mod migration;
|
||||
|
||||
pub use action::{ConfigFormBag, ConfigFormPage, DeclareConfigForms};
|
||||
pub use component::ConfigForm;
|
||||
pub use settings::{SettingField, SettingFieldType, SettingsSchema};
|
||||
|
||||
/// Prelude de `pagetop-admin`.
|
||||
pub mod prelude {
|
||||
pub use crate::action::{ConfigFormBag, ConfigFormPage, DeclareConfigForms};
|
||||
pub use crate::component::ConfigForm;
|
||||
pub use crate::error::AdminError;
|
||||
pub use crate::settings::{SettingField, SettingFieldType, SettingsSchema};
|
||||
}
|
||||
|
||||
// **< Extension >**********************************************************************************
|
||||
|
||||
/// Implementa la extensión `pagetop-admin`.
|
||||
pub struct Admin;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for Admin {
|
||||
fn name(&self) -> Lc {
|
||||
Lc::t("extension_name", &LOCALES_ADMIN)
|
||||
}
|
||||
|
||||
fn description(&self) -> Lc {
|
||||
Lc::t("extension_description", &LOCALES_ADMIN)
|
||||
}
|
||||
|
||||
fn dependencies(&self) -> Vec<ExtensionRef> {
|
||||
vec![&pagetop_seaorm::SeaORM]
|
||||
}
|
||||
|
||||
fn actions(&self) -> Vec<ActionBox> {
|
||||
actions![pagetop::base::action::admin::DeclareAdminPages::new(
|
||||
action::declare_config_form_pages
|
||||
)]
|
||||
}
|
||||
|
||||
async fn initialize(&self) -> Result<(), BoxError> {
|
||||
install_migrations!(m20260629_000001_create_settings)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn configure_router(&self, routes: Routes) -> Routes {
|
||||
action::config_forms().keys().fold(routes, |routes, path| {
|
||||
routes.admin_route(
|
||||
path,
|
||||
web::get(handlers::config_form_get).post(handlers::config_form_post),
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
8
extensions/pagetop-admin/src/locale/en-US/common.ftl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
extension_name = PageTop Admin
|
||||
extension_description = Settings stored in the database for the PageTop administration panel.
|
||||
|
||||
# Config form
|
||||
config-save-label = Save configuration
|
||||
config-saved-ok = Configuration saved.
|
||||
config-saved-error = Could not save configuration.
|
||||
config-required = Fill in the required fields. Nothing was saved.
|
||||
8
extensions/pagetop-admin/src/locale/es-ES/common.ftl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
extension_name = PageTop Admin
|
||||
extension_description = Ajustes guardados en la base de datos para el panel de administración de PageTop.
|
||||
|
||||
# Config form
|
||||
config-save-label = Guardar configuración
|
||||
config-saved-ok = Configuración guardada.
|
||||
config-saved-error = No se pudo guardar la configuración.
|
||||
config-required = Rellena los campos obligatorios. No se ha guardado nada.
|
||||
3
extensions/pagetop-admin/src/migration.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
//! Migraciones de base de datos de `pagetop-admin`.
|
||||
|
||||
pub(crate) mod m20260629_000001_create_settings;
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
use pagetop_seaorm::migration::*;
|
||||
|
||||
/// Tabla `settings`: almacén clave-valor JSON para configuración persistente.
|
||||
pub struct Migration;
|
||||
|
||||
#[pagetop::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(Settings::Table)
|
||||
.if_not_exists()
|
||||
.col(string_len(Settings::Key, 190).primary_key())
|
||||
.col(string_len(Settings::Scope, 64))
|
||||
.col(text(Settings::Value))
|
||||
.col(timestamp(Settings::UpdatedAt).default(Expr::current_timestamp()))
|
||||
.col(integer_null(Settings::UpdatedBy))
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
manager
|
||||
.create_index(
|
||||
Index::create()
|
||||
.name("idx_settings_scope")
|
||||
.table(Settings::Table)
|
||||
.col(Settings::Scope)
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(Settings::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum Settings {
|
||||
Table,
|
||||
Key,
|
||||
Scope,
|
||||
Value,
|
||||
UpdatedAt,
|
||||
UpdatedBy,
|
||||
}
|
||||