feat: wire up stretch into place
This commit is contained in:
1 parent
e3171e8303
commit
dc34805ee6
14 files changed
+1430
-257
No files matched your search
@@ -0,0 +1,85 @@
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
let mut dom = VirtualDom::new(app);
|
||||
dom.rebuild();
|
||||
|
||||
rink::render_vdom(&dom).unwrap();
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
flex_direction: "column",
|
||||
// justify_content: "center",
|
||||
// align_items: "center",
|
||||
// flex_direction: "row",
|
||||
// background_color: "red",
|
||||
|
||||
p {
|
||||
background_color: "black",
|
||||
flex_direction: "column",
|
||||
justify_content: "center",
|
||||
align_items: "center",
|
||||
// height: "10%",
|
||||
"hi"
|
||||
"hi"
|
||||
"hi"
|
||||
}
|
||||
|
||||
li {
|
||||
background_color: "red",
|
||||
flex_direction: "column",
|
||||
justify_content: "center",
|
||||
align_items: "center",
|
||||
// height: "10%",
|
||||
"bib"
|
||||
"bib"
|
||||
"bib"
|
||||
"bib"
|
||||
"bib"
|
||||
"bib"
|
||||
"bib"
|
||||
"bib"
|
||||
}
|
||||
li {
|
||||
background_color: "blue",
|
||||
flex_direction: "column",
|
||||
justify_content: "center",
|
||||
align_items: "center",
|
||||
// height: "10%",
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
}
|
||||
p {
|
||||
background_color: "yellow",
|
||||
"asd"
|
||||
}
|
||||
p {
|
||||
background_color: "green",
|
||||
"asd"
|
||||
}
|
||||
p {
|
||||
background_color: "white",
|
||||
"asd"
|
||||
}
|
||||
p {
|
||||
background_color: "cyan",
|
||||
"asd"
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use dioxus::{core::ElementId, prelude::*};
|
||||
use rink::TuiNode;
|
||||
|
||||
fn main() {
|
||||
let mut dom = VirtualDom::new(app);
|
||||
dom.rebuild();
|
||||
|
||||
let mut layout = stretch2::Stretch::new();
|
||||
let mut nodes = HashMap::new();
|
||||
rink::collect_layout(&mut layout, &mut nodes, &dom, dom.base_scope().root_node());
|
||||
|
||||
let node = nodes
|
||||
.remove(&dom.base_scope().root_node().mounted_id())
|
||||
.unwrap();
|
||||
|
||||
layout
|
||||
.compute_layout(node.layout, stretch2::geometry::Size::undefined())
|
||||
.unwrap();
|
||||
|
||||
for (id, node) in nodes.drain() {
|
||||
println!("{:?}", layout.layout(node.layout));
|
||||
}
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
flex_direction: "column",
|
||||
|
||||
div {
|
||||
"hi"
|
||||
}
|
||||
div {
|
||||
"bi"
|
||||
"bi"
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// fn print_layout(mut nodes: HashMap<ElementId, TuiNode>, node: &VNode) {
|
||||
// match node {
|
||||
// VNode::Text(_) => todo!(),
|
||||
// VNode::Element(_) => todo!(),
|
||||
// VNode::Fragment(_) => todo!(),
|
||||
// VNode::Component(_) => todo!(),
|
||||
// VNode::Placeholder(_) => todo!(),
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,31 @@
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
let mut dom = VirtualDom::new(app);
|
||||
dom.rebuild();
|
||||
|
||||
rink::render_vdom(&dom).unwrap();
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
flex_direction: "column",
|
||||
border_width: "1px",
|
||||
|
||||
h1 { height: "2px", color: "green",
|
||||
"that's awesome!"
|
||||
}
|
||||
|
||||
ul {
|
||||
flex_direction: "column",
|
||||
padding_left: "3px",
|
||||
(0..10).map(|i| rsx!(
|
||||
"> hello {i}"
|
||||
))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
let mut dom = VirtualDom::new(app);
|
||||
dom.rebuild();
|
||||
|
||||
rink::render_vdom(&dom).unwrap();
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
flex_direction: "column",
|
||||
|
||||
div {
|
||||
width: "100%",
|
||||
height: "50%",
|
||||
flex_direction: "row",
|
||||
div {
|
||||
border_width: "1px",
|
||||
width: "50%",
|
||||
height: "100%",
|
||||
background_color: "red",
|
||||
justify_content: "center",
|
||||
align_items: "center",
|
||||
"[A]"
|
||||
}
|
||||
div {
|
||||
width: "50%",
|
||||
height: "100%",
|
||||
background_color: "black",
|
||||
justify_content: "center",
|
||||
align_items: "center",
|
||||
"[B]"
|
||||
}
|
||||
}
|
||||
|
||||
div {
|
||||
width: "100%",
|
||||
height: "50%",
|
||||
flex_direction: "row",
|
||||
div {
|
||||
width: "50%",
|
||||
height: "100%",
|
||||
background_color: "green",
|
||||
justify_content: "center",
|
||||
align_items: "center",
|
||||
"[C]"
|
||||
}
|
||||
div {
|
||||
width: "50%",
|
||||
height: "100%",
|
||||
background_color: "blue",
|
||||
justify_content: "center",
|
||||
align_items: "center",
|
||||
"[D]"
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
use stretch2::prelude::*;
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
let mut stretch = Stretch::new();
|
||||
|
||||
let child = stretch.new_node(
|
||||
Style {
|
||||
size: Size {
|
||||
width: Dimension::Percent(0.5),
|
||||
height: Dimension::Auto,
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
&[],
|
||||
)?;
|
||||
|
||||
let node = stretch.new_node(
|
||||
Style {
|
||||
size: Size {
|
||||
width: Dimension::Points(100.0),
|
||||
height: Dimension::Points(100.0),
|
||||
},
|
||||
justify_content: JustifyContent::Center,
|
||||
..Default::default()
|
||||
},
|
||||
&[child],
|
||||
)?;
|
||||
|
||||
stretch.compute_layout(node, Size::undefined())?;
|
||||
println!("node: {:#?}", stretch.layout(node)?);
|
||||
println!("child: {:#?}", stretch.layout(child)?);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
let mut dom = VirtualDom::new(app);
|
||||
dom.rebuild();
|
||||
|
||||
rink::render_vdom(&dom).unwrap();
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
flex_direction: "column",
|
||||
// justify_content: "center",
|
||||
// align_items: "center",
|
||||
// flex_direction: "row",
|
||||
// background_color: "red",
|
||||
|
||||
p {
|
||||
background_color: "black",
|
||||
flex_direction: "column",
|
||||
justify_content: "center",
|
||||
align_items: "center",
|
||||
// height: "10%",
|
||||
"hi"
|
||||
"hi"
|
||||
"hi"
|
||||
}
|
||||
|
||||
li {
|
||||
background_color: "red",
|
||||
flex_direction: "column",
|
||||
justify_content: "center",
|
||||
align_items: "center",
|
||||
// height: "10%",
|
||||
"bib"
|
||||
"bib"
|
||||
"bib"
|
||||
"bib"
|
||||
"bib"
|
||||
"bib"
|
||||
"bib"
|
||||
"bib"
|
||||
}
|
||||
li {
|
||||
background_color: "blue",
|
||||
flex_direction: "column",
|
||||
justify_content: "center",
|
||||
align_items: "center",
|
||||
// height: "10%",
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
"zib"
|
||||
}
|
||||
p {
|
||||
background_color: "yellow",
|
||||
"asd"
|
||||
}
|
||||
p {
|
||||
background_color: "green",
|
||||
"asd"
|
||||
}
|
||||
p {
|
||||
background_color: "white",
|
||||
"asd"
|
||||
}
|
||||
p {
|
||||
background_color: "cyan",
|
||||
"asd"
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user