viewport_units.rs

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