use super::*;
impl Default for LayoutStyle {
#[inline(always)]
fn default() -> Self {
Self {
display: Display::Flex,
position: Position::Relative,
flex_direction: FlexDirection::Row,
flex_wrap: FlexWrap::NoWrap,
justify_content: JustifyContent::Start,
align_items: AlignItems::Stretch,
align_self: AlignSelf::Auto,
overflow: Overflow::Visible,
flex_grow: 0.0,
flex_shrink: 1.0,
flex_basis: Length::Auto,
grid_columns: 1,
width: Length::Auto,
height: Length::Auto,
min_width: Length::Auto,
min_height: Length::Auto,
max_width: Length::Auto,
max_height: Length::Auto,
margin: Edges::default(),
padding: Edges::default(),
row_gap: 0.0,
column_gap: 0.0,
top: None,
right: None,
bottom: None,
left: None,
z_index: 0,
aspect_ratio: None,
}
}
}
impl Breakpoint {
#[must_use]
#[inline(always)]
pub fn from_width(width: f32) -> Self {
if width < 768.0 {
Self::Compact
} else if width < 1024.0 {
Self::Medium
} else {
Self::Expanded
}
}
#[must_use]
#[inline(always)]
pub fn is_compact(&self) -> bool {
*self == Self::Compact
}
}
impl LayoutStyle {
#[must_use]
#[inline(always)]
pub fn top_offset(&self) -> Option<f32> {
let Self { top, .. } = *self;
top
}
#[must_use]
#[inline(always)]
pub fn right_offset(&self) -> Option<f32> {
let Self { right, .. } = *self;
right
}
#[must_use]
#[inline(always)]
pub fn bottom_offset(&self) -> Option<f32> {
let Self { bottom, .. } = *self;
bottom
}
#[must_use]
#[inline(always)]
pub fn left_offset(&self) -> Option<f32> {
let Self { left, .. } = *self;
left
}
#[must_use]
#[inline(always)]
pub fn aspect_ratio_value(&self) -> Option<f32> {
let Self { aspect_ratio, .. } = *self;
aspect_ratio
}
}