diff --git a/crates/slag-core/src/decode.rs b/crates/slag-core/src/decode.rs index be238c9..36f2e28 100644 --- a/crates/slag-core/src/decode.rs +++ b/crates/slag-core/src/decode.rs @@ -283,6 +283,7 @@ fn apply_layout(style: &mut Style, props: &SteelVal) { style.flex_shrink_0 = prop_bool(props, "#:flex-shrink-0"); style.flex_wrap = prop_bool(props, "#:flex-wrap"); style.min_w_0 = prop_bool(props, "#:min-w-0"); + style.min_h_0 = prop_bool(props, "#:min-h-0"); match prop_string(props, "#:items").as_deref() { Some("center") => style.items_center = true, @@ -352,6 +353,7 @@ fn apply_box(style: &mut Style, props: &SteelVal) { } style.hover_bg = prop_string(props, "#:hover-bg"); style.hover_text = prop_string(props, "#:hover-color"); + style.hover_border = prop_string(props, "#:hover-border-color"); } #[inline(never)] diff --git a/crates/slag-core/src/element.rs b/crates/slag-core/src/element.rs index 8060cc0..6f690c7 100644 --- a/crates/slag-core/src/element.rs +++ b/crates/slag-core/src/element.rs @@ -87,6 +87,9 @@ pub struct Style { pub text_center: bool, pub truncate: bool, pub min_w_0: bool, + /// `min-height: 0` — lets a flex child (a scroll region especially) shrink + /// below its content height instead of pushing siblings out of the box. + pub min_h_0: bool, pub font_semibold: bool, pub font_weight: Option, // Positioning (for overlays, popovers, corner indicators). @@ -139,6 +142,10 @@ pub struct Style { // InteractiveElement; buttons keep gpui-component's built-in hover). pub hover_bg: Option, pub hover_text: Option, + /// Border color while hovered (the border width itself comes from the + /// plain style, so reserve the space with e.g. `#:border 2` and a + /// transparent resting color to avoid layout shift). + pub hover_border: Option, /// Makes a container a keyed vertical scroll region (persistent /// `ScrollHandle` per key, scrollbar rendered by gpui-component). pub scroll_key: Option, diff --git a/crates/slag-gpui/src/materialize.rs b/crates/slag-gpui/src/materialize.rs index a5494cc..92aded0 100644 --- a/crates/slag-gpui/src/materialize.rs +++ b/crates/slag-gpui/src/materialize.rs @@ -288,6 +288,9 @@ fn apply_style_base(mut el: T, s: &Style, theme: &Theme) -> T { if s.min_w_0 { el = el.min_w_0(); } + if s.min_h_0 { + el = el.min_h_0(); + } if s.font_semibold { el = el.font_weight(gpui::FontWeight::SEMIBOLD); } @@ -437,9 +440,10 @@ fn apply_style_extra2(mut el: T, s: &Style, theme: &Theme) -> T { /// `Styled` — buttons and other widgets keep gpui-component's built-in hover. #[inline(never)] fn apply_hover(mut el: gpui::Div, s: &Style, theme: &Theme) -> gpui::Div { - if s.hover_bg.is_some() || s.hover_text.is_some() { + if s.hover_bg.is_some() || s.hover_text.is_some() || s.hover_border.is_some() { let bg = s.hover_bg.as_ref().map(|t| token(theme, t)); let fg = s.hover_text.as_ref().map(|t| token(theme, t)); + let border = s.hover_border.as_ref().map(|t| token(theme, t)); el = el.hover(move |mut st| { if let Some(c) = bg { st = st.bg(c); @@ -447,6 +451,9 @@ fn apply_hover(mut el: gpui::Div, s: &Style, theme: &Theme) -> gpui::Div { if let Some(c) = fg { st = st.text_color(c); } + if let Some(c) = border { + st = st.border_color(c); + } st }); }