use-ui 0.1.0

Feature-gated facade crate for RustUse framework-neutral UI primitives
Documentation
use use_ui::{
    affordance::{Affordance, AffordanceSet},
    breakpoint::{Breakpoint, BreakpointName, BreakpointSet},
    component::{ComponentName, ComponentRole},
    design_token::{DesignToken, TokenCategory, TokenName, TokenValue},
    focus::{FocusState, TabIndex},
    interaction::InteractionState,
    layer::{LayerRole, LayerStack},
    layout::{Alignment, Direction},
    motion::{MotionDuration, MotionPreference},
    spacing::{SpacingScale, SpacingStep, SpacingValue},
    theme::ThemeMode,
    viewport::{ViewportClass, ViewportSize},
};

#[test]
fn facade_reexports_ui_primitives() {
    let state = InteractionState::Focused;
    let direction = Direction::Vertical;
    let alignment = Alignment::Center;
    let layer = LayerRole::Modal;
    let theme = ThemeMode::Dark;
    let affordance = Affordance::Clickable;
    let token = DesignToken::new(
        TokenName::new("primary"),
        TokenCategory::Color,
        TokenValue::text("#3366cc"),
    );
    let breakpoints = BreakpointSet::defaults();
    let viewport = ViewportSize::new(1024, 768);
    let component = ComponentName::new("button");
    let scale = SpacingScale::new(4);
    let stack = LayerStack::new(vec![LayerRole::Base, LayerRole::Popover, LayerRole::Modal]);

    assert!(state.is_focus_visible_candidate());
    assert_eq!(direction, Direction::Vertical);
    assert_eq!(alignment, Alignment::Center);
    assert!(layer.sits_above(LayerRole::Popover));
    assert_eq!(theme, ThemeMode::Dark);
    assert_eq!(affordance, Affordance::Clickable);
    assert_eq!(token.category(), TokenCategory::Color);
    assert_eq!(
        breakpoints.matching(800).map(Breakpoint::name),
        Some(BreakpointName::Md)
    );
    assert_eq!(viewport.class(), ViewportClass::Lg);
    assert_eq!(component.as_str(), "button");
    assert!(ComponentRole::Control.is_interactive_role());
    assert!(FocusState::Focused.has_focus());
    assert!(TabIndex::new(0).is_focusable());
    assert_eq!(scale.resolve(SpacingValue::from_step(SpacingStep::Lg)), 16);
    assert!(MotionPreference::NoPreference.allows_motion());
    assert_eq!(MotionDuration::from_millis(120).millis(), 120);
    assert_eq!(stack.top(), Some(LayerRole::Modal));

    let affordances = AffordanceSet::new(vec![Affordance::Clickable, Affordance::Dismissible]);
    assert!(affordances.contains(Affordance::Dismissible));
}