whisker-css 0.4.0

Type-safe CSS builder for Whisker. Mirrors the Lynx CSS surface.
Documentation

whisker-css

Type-safe CSS [Css] builder for Whisker, mirroring the Lynx CSS surface 1-to-1.

The crate is split into four layers:

  • [data_type] — the 11 data types Lynx exposes at https://lynxjs.org/api/css/data-type.html. Each is mapped to a Rust enum or struct with a [ToCss] implementation that round-trips back to its CSS source form.
  • [data_type_ext] — data types Lynx uses inline inside property pages but does not document independently (<integer>, <easing-function>, <position>, the 147 [NamedColor]s).
  • [keyword] — closed keyword enums for property values (Display, FlexDirection, …). Values Lynx explicitly rejects (position: static, overflow: scroll) are absent from the enums so they cause compile errors instead of silent runtime warnings.
  • [prop] — one method per CSS longhand property on [Css], each carrying a documentation link to the corresponding lynxjs.org/api/css/properties/<name> page.
  • [shorthand] — compound builders (Border, Background, Transform, Transition, Animation, Flex) for properties whose CSS shorthand combines multiple longhands.

Numeric literals get their unit through extension traits in [ext]: write px(8), 8.px(), or 0.5.rem() to construct a [data_type::Length].

use whisker_css::ext::*;
use whisker_css::{Css, FlexDirection, Color};

let s = Css::new()
    .display_flex()
    .flex_direction(FlexDirection::Column)
    .padding(px(12))
    .background_color(Color::hex(0x1A1A2E))
    .border_radius(px(10));