paxdotdev / pax

User interface engine with an integrated vector design tool, built in Rust
https://www.pax.dev/
Apache License 2.0
466 stars 23 forks source link

Contextual Components #188

Closed samuelselleck closed 4 months ago

samuelselleck commented 5 months ago

This adds support for contextual components using the local store, and converts Table and Path to contextual types:

Table:

<Table rows=4 columns=4>
    <Row y=1>
        <Rectangle fill=RED/>
    </Row>
    <Col x=1>
        <Rectangle fill=rgba(200, 30, 70, 100)/>
    </Col>
    <Span x=2 y=2 w=2 h=2>
        <Rectangle fill=rgba(200, 30, 250, 150)/>
    </Span>
    <Row y=3>
        <Text text="testing"/>
    </Row>
    <Cell x=0 y=3>
        <Rectangle fill=YELLOW/>
    </Cell>
</Table>

Path:

 <Path stroke={color: Color::RED, width: 5px}>
    <PathPoint x=0.0 y=0.0/>
    if self.jump {
        <PathLine/>
        <PathPoint x=100.0 y=400.0/>
    }
    <PathLine/>
    <PathPoint x=300.0 y=300.0/>
    <PathCurve x=500.0 y=300.0/>
    <PathPoint x=300.0 y=100.0/>
    <PathClose/>
</Path>
warfaj commented 5 months ago

Rebase then I can review.