pax_example/
lib.rs

1#![allow(unused_imports)]
2
3pub mod website_desktop;
4pub mod website_mobile;
5
6use pax_lang::api::*;
7use pax_lang::*;
8use pax_std::components::Stacker;
9use pax_std::primitives::{Frame, Group, Image, Rectangle, Text};
10use pax_std::types::{Color, Fill, LinearGradient, StackerDirection};
11
12use crate::website_desktop::WebsiteDesktop;
13use crate::website_mobile::WebsiteMobile;
14
15#[derive(Pax)]
16#[main]
17#[inlined(
18    <Frame width=100% height=100% @did_mount=handle_did_mount @will_render=handle_will_render >
19     if container_width > 800.0  {
20        <WebsiteDesktop />
21    }
22    if container_width == 800.0 || container_width < 800.0 {
23        <WebsiteMobile />
24    }
25    </Frame>
26 )]
27pub struct Example {
28    pub container_width: Property<f64>,
29}
30
31impl Example {
32    pub fn handle_did_mount(&mut self, ctx: RuntimeContext) {
33        self.container_width.set(ctx.bounds_parent.0);
34    }
35
36    pub fn handle_will_render(&mut self, ctx: RuntimeContext) {
37        self.container_width.set(ctx.bounds_parent.0);
38    }
39}