Files
oak-gpui/crates/ui/src/utils/search_input.rs
T
Nate Butler 5397ca23a1 ui: More component previews, UI component cleanup (#25302)
- Don't require ui component docs (this isn't really working)
- Add more component previews
- Update component preview style & navigation

Release Notes:

- N/A
2025-02-21 09:20:53 -05:00

21 lines
645 B
Rust

use gpui::Pixels;
pub struct SearchInputWidth;
impl SearchInputWidth {
/// The containzer size in which the input stops filling the whole width.
pub const THRESHOLD_WIDTH: f32 = 1200.0;
/// The maximum width for the search input when the container is larger than the threshold.
pub const MAX_WIDTH: f32 = 1200.0;
/// Calculates the actual width in pixels based on the container width.
pub fn calc_width(container_width: Pixels) -> Pixels {
if container_width.0 < Self::THRESHOLD_WIDTH {
container_width
} else {
Pixels(container_width.0.min(Self::MAX_WIDTH))
}
}
}