viewport_units.rs

 1use gpui::{Div, Render};
 2use story::Story;
 3
 4use ui::prelude::*;
 5
 6pub struct ViewportUnitsStory;
 7
 8impl Render for ViewportUnitsStory {
 9    type Element = Div;
10
11    fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
12        Story::container().child(
13            div()
14                .flex()
15                .flex_row()
16                .child(
17                    div()
18                        .w_vw(0.5, cx)
19                        .h_vh(0.8, cx)
20                        .bg(gpui::red())
21                        .text_color(gpui::white())
22                        .child("50vw, 80vh"),
23                )
24                .child(
25                    div()
26                        .w_vw(0.25, cx)
27                        .h_vh(0.33, cx)
28                        .bg(gpui::green())
29                        .text_color(gpui::white())
30                        .child("25vw, 33vh"),
31                ),
32        )
33    }
34}