https://github.com/yisar/soga
Tiny layout engine.
https://github.com/yisar/soga
Last synced: 9 months ago
JSON representation
Tiny layout engine.
- Host: GitHub
- URL: https://github.com/yisar/soga
- Owner: yisar
- License: mit
- Created: 2022-01-10T10:10:31.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-14T03:53:12.000Z (over 3 years ago)
- Last Synced: 2025-04-10T07:18:26.533Z (9 months ago)
- Language: Rust
- Homepage:
- Size: 86.9 KB
- Stars: 38
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# soga
Yoga alternative
[](https://github.com/yisar/soga/actions)
[](https://crates.io/crates/soga)
[](https://docs.rs/soga/)
[](https://github.com/yisar/deku)
### Test
```shell
cargo test
```
### Use
```rs
use crate::soga::green::*;
use crate::soga::red::*;
use crate::soga::flex::*;
fn make_tree() -> RedTree {
let tree: GreenTree = GreenTree::new("div", 10, 10) // 0 0 10 10
.push(
GreenTree::new("ul", 6, 6) // 0 0 6 6
.push(GreenTree::new("li", 0, 6).set("grow", "1")) // 0 0 1 6
.push(GreenTree::new("li", 0, 6).set("grow", "5")) // 1 0 5 6
)
.into();
tree.into()
}
fn main() {
let tree = make_tree();
let mut flexbox = FlexBox::new();
flexbox.layout(tree);
assert_eq!(flexbox.records[0].rect, [0, 0, 10, 10]);
}
```
### License
MIT ©yisar inspired by yoga.