1use gpui::{Length, WindowContext};
2
3/// Returns a [`Length`] corresponding to the specified percentage of the viewport's width.
4///
5/// `percent` should be a value between `0.0` and `1.0`.
6pub fn vw(percent: f32, cx: &mut WindowContext) -> Length {
7 Length::from(cx.viewport_size().width * percent)
8}
9
10/// Returns a [`Length`] corresponding to the specified percentage of the viewport's height.
11///
12/// `percent` should be a value between `0.0` and `1.0`.
13pub fn vh(percent: f32, cx: &mut WindowContext) -> Length {
14 Length::from(cx.viewport_size().height * percent)
15}