search_input.rs

 1use gpui::Pixels;
 2
 3pub struct SearchInputWidth;
 4
 5impl SearchInputWidth {
 6    /// The container size in which the input stops filling the whole width.
 7    pub const THRESHOLD_WIDTH: f32 = 1200.0;
 8
 9    /// The maximum width for the search input when the container is larger than the threshold.
10    pub const MAX_WIDTH: f32 = 1200.0;
11
12    /// Calculates the actual width in pixels based on the container width.
13    pub fn calc_width(container_width: Pixels) -> Pixels {
14        if container_width.0 < Self::THRESHOLD_WIDTH {
15            container_width
16        } else {
17            Pixels(container_width.0.min(Self::MAX_WIDTH))
18        }
19    }
20}