tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81412 Definitions

⎇ b91874d4e34ecc9054b468a338ffcae6f61a1b4a benches/generated/justify_content_row_max_width_and_margin.rs Rust · 32 lines · 1.2 KB History Who touched what raw

Implement CSS Grid (#205) 6fd2c6bcb · Nico Burns ·

1pub fn compute() {
2    #[allow(unused_imports)]
3    use taffy::prelude::*;
4    let mut taffy = taffy::Taffy::new();
5    let node0 = taffy
6        .new_leaf(taffy::style::Style {
7            size: taffy::geometry::Size {
8                width: taffy::style::Dimension::Points(20f32),
9                height: taffy::style::Dimension::Points(20f32),
10            },
11            margin: taffy::geometry::Rect {
12                left: taffy::style::LengthPercentageAuto::Points(100f32),
13                right: zero(),
14                top: zero(),
15                bottom: zero(),
16            },
17            ..Default::default()
18        })
19        .unwrap();
20    let node = taffy
21        .new_with_children(
22            taffy::style::Style {
23                justify_content: Some(taffy::style::JustifyContent::Center),
24                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() },
25                max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), height: auto() },
26                ..Default::default()
27            },
28            &[node0],
29        )
30        .unwrap();
31    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
32}