#html #non-interactive #svg #pdf #html-rendering #generate

zen-rs

A library for generating non-interactive content like cards or files

7 releases

new 0.1.6 Jan 13, 2025
0.1.5 Jan 13, 2025

#33 in Rendering

Download history 805/week @ 2025-01-08

805 downloads per month

MIT license

130KB
1K SLoC

Library of Components for Generating Non-Interactive Pages/Cards/Files/Content

Components

  • Container
  • Text
    • As text (in HTML <div>)
    • As link (HTML only, <a>)
  • Icon

Available Renders

  • HTML (custom implementation)
  • PNG (conversion from SVG)
  • PDF (Skia)
  • SVG (Skia)
  • Leptos

Goals

  • Provide the minimal required support for renderer-specific features
  • Ensure maximum compatibility of element properties across all renderers
  • Offer a minimally comfortable set of components

Non-Goals

  • Full support for all available properties in all renderers
  • Interactivity (e.g., CSS animations)
  • Script support for HTML

Example (HTML)

use zen_rs::{
    aspects::Align, components::{github::github_outlined, h::mono_text_xl, Components}, layouts::html::HtmlBuilder, vstack
};

fn main() {
    let cc = complited_component();
    let html = HtmlBuilder::default().component(cc).build_as_html();
    std::fs::write("gh_not_ph.html", html).unwrap();
}

fn gh_not_ph() -> impl Into<Components> {
    vstack((
        vstack((
            vstack((
                github_outlined(),
                mono_text_xl("gh"),
                mono_text_xl("not ph"),
            ))
            .background_color((30, 200, 100, 100))
            .gap(4)
            .padding(16)
            .align_content(zen_rs::aspects::Align::Center)
            .flex(),))
            .flex()
            .border_size_t(2)
            .border_size_b(2)
            .border_color((255, 255, 255, 100))
            .border_radius(18),
        ))
        .flex()
        .width_full()
        .height_full()
        .align_items(Align::Center)
        .align_content(Align::Center)
        .background_color((0, 0, 0, 100))
}

that we got img

Contributing

If you would like to contribute, feel free to open an issue in the repository.

License

This project is licensed under the MIT License.

Dependencies