Expand description
§whisker-css
Type-safe CSS Css builder for Whisker.
The crate is split into four layers:
data_type— reusable CSS value types represented as Rust enums and structs withToCssimplementations for diagnostics.data_type_ext— additional composite data types (<integer>,<easing-function>,<position>, the 147NamedColors).keyword— closed keyword enums for supported property values.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::builder()
.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::AnimationTarget;pub use crate::shorthand::Background;pub use crate::shorthand::BackgroundLayer;pub use crate::shorthand::Border;pub use crate::shorthand::Flex;pub use crate::shorthand::Keyframe;pub use crate::shorthand::Keyframes;pub use crate::shorthand::KeyframesBuildError;pub use crate::shorthand::KeyframesBuilder;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::BackdropFilter;pub use crate::value::BorderRadius;pub use crate::value::BoxShadow;pub use crate::value::ClipBox;pub use crate::value::ClipFillRule;pub use crate::value::ClipPath;pub use crate::value::ClipPathCommand;pub use crate::value::ClipPoint;pub use crate::value::FlexBasis;pub use crate::value::GridArea;pub use crate::value::GridLine;pub use crate::value::GridRepeatCount;pub use crate::value::GridTemplate;pub use crate::value::GridTemplateAreas;pub use crate::value::GridTemplateComponent;pub use crate::value::GridTrack;pub use crate::value::GridTrackMax;pub use crate::value::GridTrackMin;pub use crate::value::ImageRef;pub use crate::value::InsetPath;pub use crate::value::LineHeight;pub use crate::value::MotionPathCommand;pub use crate::value::MotionPathPoint;pub use crate::value::OffsetDistance;pub use crate::value::OffsetPath;pub use crate::value::OffsetRotate;pub use crate::value::Repeated;pub use crate::value::Size;pub use crate::value::VerticalAlignment;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§
- css
css!(name: value, …)— kwarg syntax for theCssbuilder.
Structs§
- Css
- A type-safe CSS style declaration block.
- CssProp
- One CSS declaration stored inside a
Css. - Custom
Property Name - A case-sensitive CSS custom-property name such as
--spacing. - Custom
Property Reference - A whole-value
var()reference retained until computed-style resolution. - Property
Metadata - Static metadata for one common style property.
- Style
Property Id - A non-zero stable identifier for a common style property.
Enums§
- Property
Origin - Where a property’s spelling originates.
- Style
Property - A common style property known to Whisker.
- Value
OrVariable - A literal typed value or a reference to an inherited custom property.
Traits§
- Custom
Property Value - A typed authoring value that can be stored in a CSS custom property.
- ToCss
- Format a value as canonical CSS source text.
Functions§
- custom_
var - Creates a typed
var(--name)reference. - custom_
var_ with_ fallback - Creates a typed
var(--name, <fallback>)reference.