diff --git a/examples/locale/en-US/theme-showcase.ftl b/examples/locale/en-US/theme-showcase.ftl
index 2a79de06..a33bb791 100644
--- a/examples/locale/en-US/theme-showcase.ftl
+++ b/examples/locale/en-US/theme-showcase.ftl
@@ -65,6 +65,63 @@ showcase_empty_table = A table without rows shows its message:
showcase_block_buttons = Buttons
+showcase_block_icons = Icons
+showcase_icons_sizes =
+ Icons of the example's own set, the same with any theme, and of PageTop
+ (icon::Core), which each theme may replace with its own. Their size follows the
+ font size and their color, the intent:
+showcase_icons_cards = Status cards with a large icon:
+showcase_card_switch = Living room switch
+showcase_card_outlet = Night outlet
+showcase_card_battery = Server battery
+showcase_card_active = Activated
+showcase_card_low = Low power
+showcase_icons_toolbar =
+ Icon-only buttons; the icon label names the button and shows up on hover:
+showcase_tag = Tag
+showcase_view = View
+showcase_comment_action = Comment
+showcase_notify = Notify
+showcase_pin = Pin
+showcase_hide = Hide
+showcase_align_left = Align left
+showcase_align_center = Center
+showcase_align_right = Align right
+showcase_align_justify = Justify
+showcase_bold = Bold
+showcase_italic = Italic
+showcase_underline = Underline
+showcase_icons_buttons =
+ Buttons with icon and text, with the icon at the start, at the end or on both sides:
+showcase_new = New
+showcase_filter = Filter
+showcase_insert_image = Insert image
+showcase_save = Save
+showcase_discard = Discard
+showcase_next = Next
+showcase_move_to = Move to
+showcase_icons_menus =
+ Menus with icons: options without an icon keep their space and the end icon sits at the edge.
+showcase_nav_start = Get started
+showcase_nav_styles = Styles
+showcase_nav_grid = Grid
+showcase_nav_folders = Folders
+showcase_nav_templates = Templates
+showcase_actions = Actions
+showcase_duplicate = Duplicate
+showcase_icons_table = Icons in a table:
+showcase_col_name = Name
+showcase_col_type = Type
+showcase_type_folder = Folder
+showcase_type_document = Document
+showcase_delete = Delete
+
+showcase_block_tiles = Access tiles
+showcase_tile_image = With a blurred background image under its color
+showcase_tile_color = Only with its accent color
+showcase_tile_no_icon = Without an icon
+showcase_tile_disabled = Disabled: dimmed and without a link
+
showcase_block_misc = Links, badges and pagination
showcase_link_text = A paragraph with a link in the middle of the text.
showcase_msg_info = An informative message.
diff --git a/examples/locale/es-ES/theme-showcase.ftl b/examples/locale/es-ES/theme-showcase.ftl
index 0ddce351..d33c23d7 100644
--- a/examples/locale/es-ES/theme-showcase.ftl
+++ b/examples/locale/es-ES/theme-showcase.ftl
@@ -65,6 +65,63 @@ showcase_empty_table = Una tabla sin filas muestra su mensaje:
showcase_block_buttons = Botones
+showcase_block_icons = Iconos
+showcase_icons_sizes =
+ Iconos del conjunto propio del ejemplo, iguales con cualquier tema, y de PageTop
+ (icon::Core), que cada tema puede sustituir por los suyos. Su tamaño sigue al de la
+ fuente y su color, a la intención:
+showcase_icons_cards = Tarjetas de estado con un icono grande:
+showcase_card_switch = Interruptor del salón
+showcase_card_outlet = Enchufe nocturno
+showcase_card_battery = Batería del servidor
+showcase_card_active = Activado
+showcase_card_low = Carga baja
+showcase_icons_toolbar =
+ Botones sólo con icono; la etiqueta del icono da nombre al botón y aparece al pasar por encima:
+showcase_tag = Etiquetar
+showcase_view = Ver
+showcase_comment_action = Comentar
+showcase_notify = Avisar
+showcase_pin = Fijar
+showcase_hide = Ocultar
+showcase_align_left = Alinear a la izquierda
+showcase_align_center = Centrar
+showcase_align_right = Alinear a la derecha
+showcase_align_justify = Justificar
+showcase_bold = Negrita
+showcase_italic = Cursiva
+showcase_underline = Subrayado
+showcase_icons_buttons =
+ Botones con icono y texto, con el icono al principio, al final o a los dos lados:
+showcase_new = Nuevo
+showcase_filter = Filtrar
+showcase_insert_image = Insertar imagen
+showcase_save = Guardar
+showcase_discard = Descartar
+showcase_next = Siguiente
+showcase_move_to = Mover a
+showcase_icons_menus =
+ Menús con iconos: las opciones sin icono dejan su hueco y el icono final va junto al borde.
+showcase_nav_start = Primeros pasos
+showcase_nav_styles = Estilos
+showcase_nav_grid = Rejilla
+showcase_nav_folders = Carpetas
+showcase_nav_templates = Plantillas
+showcase_actions = Acciones
+showcase_duplicate = Duplicar
+showcase_icons_table = Iconos en una tabla:
+showcase_col_name = Nombre
+showcase_col_type = Tipo
+showcase_type_folder = Carpeta
+showcase_type_document = Documento
+showcase_delete = Eliminar
+
+showcase_block_tiles = Recuadros de acceso
+showcase_tile_image = Con una imagen de fondo difuminada bajo su color
+showcase_tile_color = Sólo con su color de acento
+showcase_tile_no_icon = Sin icono
+showcase_tile_disabled = Deshabilitado: atenuado y sin enlace
+
showcase_block_misc = Enlaces, insignias y paginación
showcase_link_text = Un párrafo con un enlace en medio del texto.
showcase_msg_info = Un mensaje informativo.
diff --git a/examples/theme-showcase.rs b/examples/theme-showcase.rs
index 2b7a7b44..6f7e682e 100644
--- a/examples/theme-showcase.rs
+++ b/examples/theme-showcase.rs
@@ -24,37 +24,43 @@ impl Extension for ThemeShowcase {
// 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.
+ // Algunas opciones llevan icono; en el desplegable, las que no lo tienen dejan su hueco.
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::link(Lc::t("showcase_menu_home", &LOC), "/")
+ .with_active(true)
+ .with_icon_start(Icon::with(icon::Core::Home)),
+ )
.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_fields", &LOC), "#")
+ .with_icon_start(Icon::with(ShowcaseIcon::Pencil)),
+ )
.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(Lc::t("showcase_menu_messages", &LOC), "#")
+ .with_icon_start(Icon::with(ShowcaseIcon::Chat))
+ .with_icon_end(Icon::with(icon::Core::ChevronRight)),
+ )
.with_item(
dropdown::Item::link(Lc::t("showcase_menu_disabled", &LOC), "#")
.with_disabled(true),
),
))
- .with_item(nav::Item::link_blank(
- Lc::t("showcase_menu_docs", &LOC),
- "https://docs.rs/pagetop",
- ))
+ .with_item(
+ nav::Item::link_blank(Lc::t("showcase_menu_docs", &LOC), "https://docs.rs/pagetop")
+ .with_icon_end(Icon::with(ShowcaseIcon::External)),
+ )
.with_item(
nav::Item::link(Lc::t("showcase_menu_disabled", &LOC), "#").with_disabled(true),
);
@@ -90,6 +96,8 @@ async fn theme_showcase(request: HttpRequest) -> Result {
.with_child(checks_block())
.with_child(tables_block())
.with_child(buttons_block())
+ .with_child(icons_block())
+ .with_child(tiles_block())
.with_child(misc_block());
// Un mensaje de cada nivel, que muestra el listado del bloque de tablas entre su botón y la
@@ -445,6 +453,476 @@ fn buttons(outline: bool) -> Flex {
row
}
+// Conjunto de iconos propio del ejemplo, para mostrar cómo se integra uno: basta implementar
+// `From for icon::Source` para pasarlos a `Icon::with()`. Son SVG en línea y se ven
+// igual con cualquier tema, a diferencia de los de `icon::Core`, que cada tema puede sustituir por
+// los de su propio conjunto (Bootsier, por los de Bootstrap Icons).
+#[derive(Clone, Copy)]
+enum ShowcaseIcon {
+ AlertCircle,
+ AlignCenter,
+ AlignJustify,
+ AlignLeft,
+ AlignRight,
+ Bell,
+ Bold,
+ Chat,
+ CheckCircle,
+ Eye,
+ EyeOff,
+ External,
+ File,
+ Filter,
+ Folder,
+ Image,
+ Italic,
+ Lightbulb,
+ Pencil,
+ Pin,
+ Plug,
+ Search,
+ Tag,
+ Underline,
+}
+
+impl From for icon::Source {
+ fn from(icon: ShowcaseIcon) -> Self {
+ use ShowcaseIcon::*;
+
+ let shapes = match icon {
+ AlertCircle => html! {
+ circle cx="8" cy="8" r="6.5" {}
+ path d="M8 4.75v3.75M8 11.25v.01" {}
+ },
+ AlignCenter => html! { path d="M2 3.5h12M4 6.5h8M2 9.5h12M4 12.5h8" {} },
+ AlignJustify => html! { path d="M2 3.5h12M2 6.5h12M2 9.5h12M2 12.5h12" {} },
+ AlignLeft => html! { path d="M2 3.5h12M2 6.5h8M2 9.5h12M2 12.5h8" {} },
+ AlignRight => html! { path d="M2 3.5h12M6 6.5h8M2 9.5h12M6 12.5h8" {} },
+ Bell => html! { path d="M4 11.5V7a4 4 0 0 1 8 0v4.5l1 1H3zM6.5 14.5h3" {} },
+ Bold => html! {
+ path d="M4.5 2.5H9a2.75 2.75 0 0 1 0 5.5H4.5zM4.5 8h5a2.75 2.75 0 0 1 0 5.5h-5z" {}
+ },
+ Chat => html! { path d="M2.5 3.5h11V11H7l-3 2.5V11H2.5z" {} },
+ CheckCircle => html! {
+ circle cx="8" cy="8" r="6.5" {}
+ path d="M5 8.25l2 2 4-4" {}
+ },
+ Eye => html! {
+ path d="M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z" {}
+ circle cx="8" cy="8" r="2" {}
+ },
+ EyeOff => html! {
+ path d="M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z" {}
+ circle cx="8" cy="8" r="2" {}
+ path d="M2.5 2.5l11 11" {}
+ },
+ External => html! { path d="M9 2.5h4.5V7M13.5 2.5l-6 6M11.5 9.5v4h-9v-9h4" {} },
+ File => html! { path d="M3.5 1.5h6l3 3v10h-9zM9.5 1.5v3h3" {} },
+ Filter => html! { path d="M2 3h12l-4.5 5.5V13l-3-1.5v-3z" {} },
+ Folder => html! { path d="M1.5 3.5H6L7.5 5h7v7.5h-13z" {} },
+ Image => html! {
+ rect x="1.5" y="2.5" width="13" height="11" rx="1.5" {}
+ circle cx="10.5" cy="6" r="1.25" {}
+ path d="M1.5 11.5l4-4 3 3 2-2 4 4" {}
+ },
+ Italic => html! { path d="M7 2.5h5M4 13.5h5M10 2.5l-4 11" {} },
+ Lightbulb => html! {
+ path d="M6 11c0-.9-.4-1.5-1.2-2.3a4.25 4.25 0 1 1 6.4 0C10.4 9.5 10 10.1 10 11" {}
+ path d="M6 11h4M6.75 14h2.5" {}
+ },
+ Pencil => html! { path d="M10.5 2.5l3 3L6 13H3v-3zM9 4l3 3" {} },
+ Pin => html! { path d="M6 1.5h4M7 1.5v4L4.5 8.5h7L9 5.5v-4M8 8.5v6" {} },
+ Plug => {
+ html! { path d="M5.5 1.5v3M10.5 1.5v3M3.5 4.5h9V7a4.5 4.5 0 0 1-9 0zM8 11.5v3" {} }
+ }
+ Search => html! {
+ circle cx="7" cy="7" r="4.5" {}
+ path d="M10.5 10.5l3.5 3.5" {}
+ },
+ Tag => html! {
+ path d="M2.5 2.5h5l6 6-5 5-6-6z" {}
+ circle cx="5.5" cy="5.5" r="1" {}
+ },
+ Underline => html! { path d="M4.5 2.5V7a3.5 3.5 0 0 0 7 0V2.5M3 14.5h10" {} },
+ };
+ icon::Source::svg(
+ "0 0 16 16",
+ html! {
+ g
+ fill="none"
+ stroke="currentColor"
+ stroke-width="1.5"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ {
+ (shapes)
+ }
+ },
+ )
+ }
+}
+
+// Iconos en sus distintos usos: tamaños y colores, tarjetas de estado, barras de botones sólo con
+// icono, botones con icono y texto, y una tabla. Mezcla el conjunto propio con el de PageTop.
+fn icons_block() -> Block {
+ use ShowcaseIcon::*;
+
+ let row = || {
+ Flex::new()
+ .with_wrap(flex::Behavior::Wrap)
+ .with_align(align::Items::Center)
+ .with_gap(align::Gap::Both(UnitValue::RelRem(0.75)))
+ .with_prop(Margin::new().with_bottom(UnitValue::RelRem(1.5)))
+ };
+ let caption = |key: &'static str| {
+ Html::with(move |cx| {
+ html! {
+ p { (Lc::t(key, &LOC).using(cx)) }
+ }
+ })
+ };
+ // Botón sólo con icono: la etiqueta del icono es el nombre accesible del botón, y el texto
+ // emergente la muestra al pasar por encima.
+ let icon_button = |source: icon::Source, key: &'static str, style: button::Style| {
+ Button::plain(Lc::none())
+ .with_style(style)
+ .with_title(Lc::t(key, &LOC))
+ .with_icon_start(Icon::with(source).with_label(Lc::t(key, &LOC)))
+ };
+
+ // El tamaño sigue al de la fuente; el color, a la intención.
+ let mut sizes = row();
+ for size in [1.0, 1.5, 2.0, 2.5, 3.0] {
+ sizes = sizes.with_child(Icon::with(Lightbulb).with_size(UnitValue::RelRem(size)));
+ }
+ let mut colors = row();
+ for (source, intent) in [
+ (icon::Source::from(Pin), Intent::Primary),
+ (Bell.into(), Intent::Neutral),
+ (Chat.into(), Intent::Info),
+ (CheckCircle.into(), Intent::Success),
+ (AlertCircle.into(), Intent::Warning),
+ (icon::Core::Close.into(), Intent::Severe),
+ ] {
+ colors = colors.with_child(
+ Icon::with(source)
+ .with_size(UnitValue::RelRem(1.5))
+ .with_intent(intent),
+ );
+ }
+
+ // Tarjetas de estado: un icono grande de color, el nombre del aparato y su estado.
+ let card = |source: ShowcaseIcon, intent: Intent, title: &'static str, badge: Badge| {
+ Flex::new()
+ .with_direction(flex::Direction::Column)
+ .with_align(align::Items::Start)
+ .with_gap(align::Gap::Both(UnitValue::RelRem(0.5)))
+ .with_prop(Margin::new().with_bottom(UnitValue::RelRem(1.5)))
+ .with_child(
+ Icon::with(source)
+ .with_size(UnitValue::RelRem(2.5))
+ .with_intent(intent),
+ )
+ .with_child(Lc::t(title, &LOC))
+ .with_child(badge)
+ };
+ let cards = columns()
+ .with_child(card(
+ Lightbulb,
+ Intent::Warning,
+ "showcase_card_switch",
+ Badge::success(Lc::t("showcase_card_active", &LOC)),
+ ))
+ .with_child(card(
+ Plug,
+ Intent::Primary,
+ "showcase_card_outlet",
+ Badge::info(Lc::n("32 %")),
+ ))
+ .with_child(card(
+ AlertCircle,
+ Intent::Severe,
+ "showcase_card_battery",
+ Badge::severe(Lc::t("showcase_card_low", &LOC)),
+ ));
+
+ // Barra de acciones de una nota, con botones de estilo enlace. Su propio relleno ya los separa,
+ // así que la fila no añade hueco entre ellos.
+ let mut actions = row().with_gap(align::Gap::Both(UnitValue::Zero));
+ for (source, key) in [
+ (Pencil, "showcase_edit"),
+ (Tag, "showcase_tag"),
+ (Eye, "showcase_view"),
+ (Chat, "showcase_comment_action"),
+ (Bell, "showcase_notify"),
+ (Pin, "showcase_pin"),
+ (EyeOff, "showcase_hide"),
+ ] {
+ actions = actions.with_child(icon_button(source.into(), key, button::Style::Link));
+ }
+
+ // Grupos de formato de texto, con botones pequeños de contorno.
+ let format_group = |items: &[(ShowcaseIcon, &'static str)]| {
+ let mut group = Flex::new().with_gap(align::Gap::Both(UnitValue::RelRem(0.25)));
+ for (source, key) in items {
+ group = group.with_child(
+ icon_button(
+ (*source).into(),
+ key,
+ button::Style::Outline(Intent::Neutral),
+ )
+ .with_size(button::Size::Small),
+ );
+ }
+ group
+ };
+ let format = row()
+ .with_child(format_group(&[
+ (AlignLeft, "showcase_align_left"),
+ (AlignCenter, "showcase_align_center"),
+ (AlignRight, "showcase_align_right"),
+ (AlignJustify, "showcase_align_justify"),
+ ]))
+ .with_child(format_group(&[
+ (Bold, "showcase_bold"),
+ (Italic, "showcase_italic"),
+ (Underline, "showcase_underline"),
+ ]));
+
+ // Botones con icono y texto: al principio, al final o a los dos lados de la etiqueta.
+ let mut buttons = row();
+ for (start, key, end, style) in [
+ (
+ Some(icon::Source::from(icon::Core::Plus)),
+ "showcase_new",
+ None::,
+ button::Style::Solid(Intent::Primary),
+ ),
+ (
+ Some(Search.into()),
+ "showcase_search",
+ None,
+ button::Style::Outline(Intent::Primary),
+ ),
+ (
+ Some(Filter.into()),
+ "showcase_filter",
+ None,
+ button::Style::Outline(Intent::Neutral),
+ ),
+ (
+ Some(Image.into()),
+ "showcase_insert_image",
+ None,
+ button::Style::Outline(Intent::Neutral),
+ ),
+ (
+ Some(icon::Core::Check.into()),
+ "showcase_save",
+ None,
+ button::Style::Solid(Intent::Success),
+ ),
+ (
+ Some(icon::Core::Close.into()),
+ "showcase_discard",
+ None,
+ button::Style::Outline(Intent::Severe),
+ ),
+ (
+ None,
+ "showcase_next",
+ Some(icon::Core::ChevronRight.into()),
+ button::Style::Outline(Intent::Primary),
+ ),
+ (
+ Some(Folder.into()),
+ "showcase_move_to",
+ Some(icon::Core::ChevronDown.into()),
+ button::Style::Outline(Intent::Neutral),
+ ),
+ ] {
+ buttons = buttons.with_child(
+ Button::plain(Lc::t(key, &LOC))
+ .with_style(style)
+ .with_icon_start(start.map(Icon::with))
+ .with_icon_end(end.map(Icon::with)),
+ );
+ }
+
+ // Menú vertical, como una barra lateral, y menú desplegable de acciones. Las opciones sin icono
+ // dejan su hueco para que las etiquetas queden alineadas; el icono final va junto al borde.
+ let sidebar = Nav::new()
+ .with_layout(nav::Layout::Vertical)
+ .with_prop(FlexItem::new().with_size(flex::ItemSize::Custom(UnitValue::RelRem(14.0))))
+ .with_item(
+ nav::Item::link(Lc::t("showcase_nav_start", &LOC), "#")
+ .with_icon_start(Icon::with(Lightbulb)),
+ )
+ .with_item(
+ nav::Item::link(Lc::t("showcase_nav_styles", &LOC), "#")
+ .with_icon_start(Icon::with(Pencil)),
+ )
+ .with_item(nav::Item::link(Lc::t("showcase_nav_grid", &LOC), "#"))
+ .with_item(
+ nav::Item::link(Lc::t("showcase_nav_folders", &LOC), "#")
+ .with_icon_start(Icon::with(Folder))
+ .with_icon_end(Icon::with(icon::Core::ChevronRight)),
+ )
+ .with_item(
+ nav::Item::link(Lc::t("showcase_nav_templates", &LOC), "#")
+ .with_disabled(true)
+ .with_icon_start(Icon::with(File))
+ .with_icon_end(Icon::with(Pin)),
+ );
+ let actions_menu = Dropdown::new()
+ .with_title(Lc::t("showcase_actions", &LOC))
+ .with_button_style(button::Style::Outline(Intent::Neutral))
+ .with_item(
+ dropdown::Item::button(Lc::t("showcase_edit", &LOC))
+ .with_icon_start(Icon::with(Pencil)),
+ )
+ .with_item(
+ dropdown::Item::button(Lc::t("showcase_tag", &LOC)).with_icon_start(Icon::with(Tag)),
+ )
+ .with_item(dropdown::Item::button(Lc::t("showcase_duplicate", &LOC)))
+ .with_item(
+ dropdown::Item::button(Lc::t("showcase_pin", &LOC))
+ .with_icon_start(Icon::with(Pin))
+ .with_icon_end(Icon::with(icon::Core::Check)),
+ )
+ .with_item(dropdown::Item::divider())
+ .with_item(
+ dropdown::Item::button(Lc::t("showcase_delete", &LOC))
+ .with_icon_start(Icon::with(icon::Core::Close).with_intent(Intent::Severe)),
+ );
+ let menus = Flex::new()
+ .with_wrap(flex::Behavior::Wrap)
+ .with_align(align::Items::Start)
+ .with_gap(align::Gap::Both(UnitValue::RelRem(2.0)))
+ .with_prop(Margin::new().with_bottom(UnitValue::RelRem(1.5)))
+ .with_child(sidebar)
+ .with_child(actions_menu);
+
+ // Tabla con el tipo de cada fila en un icono y las acciones como botones sólo con icono.
+ let mut files = Table::new()
+ .with_column(Lc::t("showcase_col_name", &LOC))
+ .with_column(Lc::t("showcase_col_type", &LOC))
+ .with_column(Lc::t("showcase_col_actions", &LOC));
+ for (name, folder) in [
+ ("Backgrounds", true),
+ ("Shadows", true),
+ ("Document.txt", false),
+ ("Projects.draft", false),
+ ] {
+ let (source, kind) = match folder {
+ true => (Folder, "showcase_type_folder"),
+ false => (File, "showcase_type_document"),
+ };
+ files.alter_row(
+ table::Row::new()
+ .with_cell(table::Cell::new(
+ Flex::new()
+ .with_align(align::Items::Center)
+ .with_gap(align::Gap::Both(UnitValue::RelRem(0.5)))
+ .with_child(Icon::with(source).with_intent(Intent::Neutral))
+ .with_child(Lc::n(name)),
+ ))
+ .with_cell(Lc::t(kind, &LOC))
+ .with_cell(table::Cell::new(
+ Flex::new()
+ .with_child(icon_button(
+ Eye.into(),
+ "showcase_view",
+ button::Style::Link,
+ ))
+ .with_child(icon_button(
+ Pencil.into(),
+ "showcase_edit",
+ button::Style::Link,
+ ))
+ .with_child(icon_button(
+ icon::Core::Close.into(),
+ "showcase_delete",
+ button::Style::Link,
+ )),
+ )),
+ );
+ }
+
+ Block::new()
+ .with_title(Lc::t("showcase_block_icons", &LOC))
+ .with_child(caption("showcase_icons_sizes"))
+ .with_child(sizes)
+ .with_child(colors)
+ .with_child(caption("showcase_icons_cards"))
+ .with_child(cards)
+ .with_child(caption("showcase_icons_toolbar"))
+ .with_child(actions)
+ .with_child(format)
+ .with_child(caption("showcase_icons_buttons"))
+ .with_child(buttons)
+ .with_child(caption("showcase_icons_menus"))
+ .with_child(menus)
+ .with_child(caption("showcase_icons_table"))
+ .with_child(files)
+}
+
+// Un recuadro de acceso por color de acento, en la rejilla habitual de una portada (una, dos y tres
+// columnas). Alternan los casos: con la imagen de fondo que trae PageTop para `Intro` (difuminada
+// bajo el color) o sólo con el color, y con o sin descripción. Al final, uno sin icono y otro
+// deshabilitado.
+fn tiles_block() -> Block {
+ use Accent::*;
+
+ let tracks = |n| grid::Tracks::repeat(n, grid::AxisTrack::Fraction(1.0));
+ let mut grid = Grid::new()
+ .with_columns(tracks(1))
+ .with_columns_at(Breakpoint::Md, tracks(2))
+ .with_columns_at(Breakpoint::Lg, tracks(3))
+ .with_gap(align::Gap::Both(UnitValue::RelRem(1.5)));
+ let accents = [
+ (Blue, "Blue", Icon::with(ShowcaseIcon::Folder)),
+ (Orange, "Orange", Icon::with(ShowcaseIcon::Image)),
+ (Green, "Green", Icon::with(ShowcaseIcon::CheckCircle)),
+ (Purple, "Purple", Icon::with(ShowcaseIcon::Lightbulb)),
+ (Red, "Red", Icon::with(ShowcaseIcon::AlertCircle)),
+ (Teal, "Teal", Icon::with(ShowcaseIcon::Tag)),
+ (Indigo, "Indigo", Icon::with(ShowcaseIcon::Chat)),
+ (Pink, "Pink", Icon::with(ShowcaseIcon::Bell)),
+ (Yellow, "Yellow", Icon::with(ShowcaseIcon::Pin)),
+ (Cyan, "Cyan", Icon::with(ShowcaseIcon::Plug)),
+ (Lime, "Lime", Icon::with(ShowcaseIcon::Eye)),
+ (Magenta, "Magenta", Icon::with(ShowcaseIcon::Search)),
+ ];
+ for (i, (accent, name, icon)) in accents.into_iter().enumerate() {
+ let tile = Tile::link(Lc::n(name), "#")
+ .with_icon(icon)
+ .with_accent(accent);
+ grid = grid.with_child(match i % 3 {
+ 0 => tile
+ .with_description(Lc::t("showcase_tile_image", &LOC))
+ .with_image(image::Source::plain("/pagetop/img/intro-header-sm.jpg")),
+ 1 => tile.with_description(Lc::t("showcase_tile_color", &LOC)),
+ _ => tile,
+ });
+ }
+ grid = grid.with_child(
+ Tile::link(Lc::n("Gray"), "#")
+ .with_description(Lc::t("showcase_tile_no_icon", &LOC))
+ .with_accent(Gray),
+ );
+ grid = grid.with_child(
+ Tile::link(Lc::n("Disabled"), "#")
+ .with_description(Lc::t("showcase_tile_disabled", &LOC))
+ .with_icon(Icon::with(ShowcaseIcon::EyeOff))
+ .with_disabled(true),
+ );
+
+ Block::new()
+ .with_title(Lc::t("showcase_block_tiles", &LOC))
+ .with_child(grid)
+}
+
// Enlaces, insignias, paginación y mensajes, que también toman los colores del tema.
fn misc_block() -> Block {
let mut badges = Flex::new()