Expand description
§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 Rustenumorstructwith aToCssimplementation 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 147NamedColors).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 onCss, each carrying a documentation link to the correspondinglynxjs.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));Re-exports§
pub use crate::data_type::Angle;pub use crate::data_type::CalcExpr;pub use crate::data_type::Color;pub use crate::data_type::ColorStop;pub use crate::data_type::CssString;pub use crate::data_type::FitContent;pub use crate::data_type::Gradient;pub use crate::data_type::Length;pub use crate::data_type::LengthPercentage;pub use crate::data_type::LinearDirection;pub use crate::data_type::MaxContent;pub use crate::data_type::NamedColor;pub use crate::data_type::Number;pub use crate::data_type::Percentage;pub use crate::data_type::RadialShape;pub use crate::data_type::StopPosition;pub use crate::data_type::Time;pub use crate::data_type_ext::EasingFunction;pub use crate::data_type_ext::Integer;pub use crate::data_type_ext::Position;pub use crate::shorthand::Animation;pub use crate::shorthand::Background;pub use crate::shorthand::BackgroundLayer;pub use crate::shorthand::Border;pub use crate::shorthand::Flex;pub use crate::shorthand::Margin;pub use crate::shorthand::MarginValue;pub use crate::shorthand::Padding;pub use crate::shorthand::Transform;pub use crate::shorthand::TransformFn;pub use crate::shorthand::Transition;pub use crate::value::BorderRadius;pub use crate::value::FlexBasis;pub use crate::value::GridLine;pub use crate::value::GridTemplate;pub use crate::value::ImageRef;pub use crate::value::LineHeight;pub use crate::value::Repeated;pub use crate::value::Size;pub use crate::keyword::*;
Modules§
- data_
type - The 11 data types Lynx documents under https://lynxjs.org/api/css/data-type.html.
- data_
type_ ext - Data types Lynx uses inline inside property pages but does not
document independently. Adding them as Whisker types gives the
property builders a strongly-typed argument surface — for
example
z-indexis an<integer>even though Lynx never spells<integer>out on a dedicated data-type page. - ext
- Numeric-literal extension traits and free constructors.
- keyword
- Keyword enums used by property values.
- prop
- Per-property builder methods on
Css. - shorthand
- Compound shorthand builders for properties whose CSS shorthand combines multiple longhands.
- value
- Property-input composite value types.
Macros§
Structs§
Traits§
- ToCss
- Format a value as the CSS source text Lynx will parse.