Skip to content

Commit

Permalink
Add grid (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmoulton authored Jan 1, 2024
1 parent 533ca7d commit a41be63
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ indexmap = "2"
rustc-hash = "1.1.0"
smallvec = "1.10.0"
educe = "0.4.20"
taffy = "0.3.18"
taffy = {version = "0.3.18", features = ["grid"]}
rfd = { version = "0.11.4", default-features = false, features = [
"xdg-portal",
] }
Expand Down
24 changes: 22 additions & 2 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ pub use taffy::style::{
};
use taffy::{
geometry::Size,
prelude::Rect,
style::{LengthPercentage, Style as TaffyStyle},
prelude::{GridPlacement, Line, Rect},
style::{LengthPercentage, Style as TaffyStyle, TrackSizingFunction},
};

use crate::context::InteractionState;
Expand Down Expand Up @@ -76,6 +76,9 @@ impl StylePropValue for FlexDirection {}
impl StylePropValue for FlexWrap {}
impl StylePropValue for AlignItems {}
impl StylePropValue for AlignContent {}
impl StylePropValue for TrackSizingFunction {}
impl<T: StylePropValue> StylePropValue for Line<T> {}
impl StylePropValue for GridPlacement {}
impl StylePropValue for CursorStyle {}
impl StylePropValue for BoxShadow {}
impl StylePropValue for String {}
Expand All @@ -98,6 +101,15 @@ impl<T: StylePropValue> StylePropValue for Option<T> {
})
}
}
impl<T: StylePropValue> StylePropValue for Vec<T> {
fn debug_view(&self) -> Option<Box<dyn View>> {
None
}

fn interpolate(&self, _other: &Self, _value: f64) -> Option<Self> {
None
}
}
impl StylePropValue for Px {
fn debug_view(&self) -> Option<Box<dyn View>> {
Some(Box::new(text(format!("{} px", self.0))))
Expand Down Expand Up @@ -1027,6 +1039,10 @@ define_builtin_props!(
JustifySelf justify_self: Option<AlignItems> {} = None,
AlignItemsProp align_items: Option<AlignItems> {} = None,
AlignContentProp align_content: Option<AlignContent> {} = None,
GridTemplateRows grid_template_rows: Vec<TrackSizingFunction> {} = Vec::new(),
GridTemplateColumns grid_template_columns: Vec<TrackSizingFunction> {} = Vec::new(),
GridRow grid_row: Line<GridPlacement> {} = Line::default(),
GridColumn grid_column: Line<GridPlacement> {} = Line::default(),
AlignSelf align_self: Option<AlignItems> {} = None,
BorderLeft border_left: Px {} = Px(0.0),
BorderTop border_top: Px {} = Px(0.0),
Expand Down Expand Up @@ -1644,6 +1660,10 @@ impl Style {
bottom: style.inset_bottom().into(),
},
gap: style.gap(),
grid_template_rows: style.grid_template_rows(),
grid_template_columns: style.grid_template_columns(),
grid_row: style.grid_row(),
grid_column: style.grid_column(),
..Default::default()
}
}
Expand Down

0 comments on commit a41be63

Please sign in to comment.