diff --git a/toolkit-examples/Cargo.toml b/toolkit-examples/Cargo.toml index b7e04a2..24733e2 100644 --- a/toolkit-examples/Cargo.toml +++ b/toolkit-examples/Cargo.toml @@ -13,7 +13,7 @@ anyhow = "1.0.35" env_logger = "0.8.2" hyaenidae-toolkit = { version = "0.1.0", path = "../toolkit" } mime = "0.3.16" -minify-html = "0.3.9" +minify-html = "0.4.0" [build-dependencies] ructe = { version = "0.13.0", features = ["mime03", "sass"] } diff --git a/toolkit-examples/src/main.rs b/toolkit-examples/src/main.rs index be50881..8cd012b 100644 --- a/toolkit-examples/src/main.rs +++ b/toolkit-examples/src/main.rs @@ -40,16 +40,20 @@ async fn try_index() -> anyhow::Result { } fn rendered( - f: impl FnOnce(&mut Cursor>) -> std::io::Result<()>, + f: impl FnOnce(&mut Cursor<&mut Vec>) -> std::io::Result<()>, ) -> anyhow::Result { - let mut cursor = Cursor::new(vec![]); - (f)(&mut cursor)?; - let mut html = cursor.into_inner(); - let len = minify_html::in_place(&mut html, &minify_html::Cfg { minify_js: false }) - .map_err(|_| anyhow::anyhow!("Truncate error"))?; - html.truncate(len); + let mut bytes = vec![]; + (f)(&mut Cursor::new(&mut bytes))?; + minify_html::truncate( + &mut bytes, + &minify_html::Cfg { + minify_js: false, + minify_css: false, + }, + ) + .map_err(|_| anyhow::anyhow!("Truncate error"))?; Ok(HttpResponse::Ok() .content_type(mime::TEXT_HTML.essence_str()) - .body(html)) + .body(bytes)) } diff --git a/toolkit-examples/templates/demo.rs.html b/toolkit-examples/templates/demo.rs.html index a141e03..4d289f9 100644 --- a/toolkit-examples/templates/demo.rs.html +++ b/toolkit-examples/templates/demo.rs.html @@ -1,12 +1,13 @@ -@use hyaenidae_toolkit::{templates::{card, card_body, centered, code}, Card}; +@use hyaenidae_toolkit::{templates::{card, card_body, card_title, centered, code}, Card}; @(title: &str, description: &str, example: &[&str], body: Content)
  • @:centered(false, { @:card(&Card::full_width(), { -

    @title

    - }, { + @:card_title({ +

    @title

    + }) @:card_body({

    @description

    diff --git a/toolkit-examples/templates/index.rs.html b/toolkit-examples/templates/index.rs.html index 1e551c3..e89fc78 100644 --- a/toolkit-examples/templates/index.rs.html +++ b/toolkit-examples/templates/index.rs.html @@ -1,4 +1,4 @@ -@use hyaenidae_toolkit::{Button, Card, Link, TextInput, templates::{button, button_group, card, card_body, code, link, text_input, statics::toolkit_css}}; +@use hyaenidae_toolkit::{Button, Card, Link, TextInput, templates::{button, button_group, card, card_body, card_title, code, link, text_input, statics::toolkit_css}}; @use super::{demo, section, statics::layout_css}; @() @@ -144,10 +144,11 @@ @:section("Card", "Card template", { @:demo("Card", "Create a card with a Title and Body", &[ "@:card(&Card::new(), {", - "
    ", - "

    Title

    ", - "
    ", - "}, {", + " @:card_title({", + "
    ", + "

    Title

    ", + "
    ", + " })", " @:card_body({", "
    ", "

    Body

    ", @@ -156,10 +157,11 @@ "})", ], { @:card(&Card::new(), { -
    -

    Title

    -
    - }, { + @:card_title({ +
    +

    Title

    +
    + }) @:card_body({

    Body

    @@ -169,10 +171,11 @@ }) @:demo("Card", "Create a full-width card with a Title and Body. This card loses its border radius and left & right borders when the viewport width is under 700px", &[ "@:card(&Card::full_width(), {", - "

    ", - "

    Title

    ", - "
    ", - "}, {", + " @:card_title({", + "
    ", + "

    Title

    ", + "
    ", + " })", " @:card_body({", "
    ", "

    Body

    ", @@ -181,10 +184,11 @@ "})", ], { @:card(&Card::full_width(), { -
    -

    Title

    -
    - }, { + @:card_title({ +
    +

    Title

    +
    + }) @:card_body({

    Body