Skip to main content

Crate hyperchad_transformer

Crate hyperchad_transformer 

Source
Expand description

Core UI transformation system with container models, layout calculations, and HTML generation.

This crate provides a comprehensive UI transformation system for building modern user interfaces. It includes a flexible container model, layout calculation engine, HTML generation, and tree traversal utilities.

§Features

  • Container System - Comprehensive UI container model with styling and layout properties
  • Layout Engine - Advanced layout calculation with flexbox and grid support (via layout feature)
  • HTML Generation - Complete HTML rendering with CSS generation (via html feature)
  • Calculation System - CSS calc() expressions with viewport units (vw, vh, dvw, dvh)
  • Element Types - Full HTML element support including semantic elements, forms, and media
  • Responsive Design - Conditional styling and responsive breakpoints via override system
  • Tree Traversal - Efficient container tree navigation and manipulation

§Example

use hyperchad_transformer::{Container, Element, Number};
use hyperchad_transformer::models::LayoutDirection;
use hyperchad_color::Color;

// Create a basic container with styling
let container = Container {
    element: Element::Div,
    width: Some(Number::from(300)),
    height: Some(Number::from(200)),
    background: Some(Color::from_hex("#f0f0f0")),
    direction: LayoutDirection::Column,
    padding_left: Some(Number::from(20)),
    padding_right: Some(Number::from(20)),
    ..Default::default()
};

// Generate HTML representation
let html = container.to_string();

§Main Entry Points

  • Container - The core UI container struct with styling and layout properties
  • Element - Enum representing different HTML element types
  • Number - Numeric values with unit support (px, %, vw, vh, calc expressions)
  • Calculation - Arithmetic expressions for CSS calc() support

§Re-exports

  • actions - Action system for interactive behaviors (re-exported from hyperchad_actions)
  • models - Layout and styling model types (re-exported from hyperchad_transformer_models)

Re-exports§

pub use hyperchad_actions as actions;
pub use hyperchad_transformer_models as models;

Modules§

html
HTML parsing and generation utilities (requires html feature). HTML parsing and generation utilities.
layout
Layout calculation engine for UI containers (requires layout feature). Layout calculation engine for UI containers.
parse
Parsing utilities for numeric values and CSS calculation expressions. Parsing utilities for numeric values and CSS calculation expressions.

Macros§

float_eq
Compares two floats for approximate equality within epsilon tolerance.
float_gt
Compares if float $a is greater than $b with epsilon tolerance.
float_gte
Compares if float $a is greater than or approximately equal to $b with epsilon tolerance.
float_lt
Compares if float $a is less than $b with epsilon tolerance.
float_lte
Compares if float $a is less than or approximately equal to $b with epsilon tolerance.
max_float
Returns the maximum of two float values.
min_float
Returns the minimum of two float values.
override_item
Pattern matches on OverrideItem variants and executes an action with the inner value.

Structs§

BfsPaths
Breadth-first search traversal paths for container trees.
BoolWrapper
Wrapper for boolean values with conditional logic support.
ConfigOverride
Configuration override applied when a condition is met.
Container
Represents a layout container with style properties and child elements.
Flex
Flexbox sizing configuration with grow, shrink, and basis values.
TableIter
Iterator over table rows and headings with immutable references.
TableIterMut
Iterator over table rows and headings with mutable references.
TextDecoration
Text decoration configuration including underline, overline, and strikethrough.

Enums§

Calculation
Represents a calculation expression that can be evaluated with context.
Element
HTML element type with associated properties.
HeaderSize
HTML heading level sizes.
Input
HTML input element types with associated properties.
MaybeReplaced
Represents a value that may have been replaced with a string.
Number
Represents a numeric value with optional unit or calculation.
OverrideCondition
Condition type for configuration overrides.
OverrideItem
Style property that can be overridden based on conditions.
ResponsiveTrigger
Conditions that trigger responsive layout changes.