From dc4def532765b78acf713713b71c99b2dcb5ca83 Mon Sep 17 00:00:00 2001 From: ovalkonia <60359793+ovalkonia@users.noreply.github.com> Date: Sun, 25 Aug 2024 17:14:35 +0300 Subject: [PATCH] Add scss support for style property (#1121) * Add scss support for the ':style' widget property * Add changelog entry for the scss support for the ':style' property --------- Co-authored-by: ElKowar --- CHANGELOG.md | 1 + crates/eww/src/widgets/widget_definitions.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f9d2051..2e9fedbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ All notable changes to eww will be listed here, starting at changes since versio - Add `:fill-svg` and `:preserve-aspect-ratio` properties to images (By: hypernova7, w-lfchen) - Add `:truncate` property to labels, disabled by default (except in cases where truncation would be enabled in version `0.5.0` and before) (By: Rayzeq). - Add support for `:hover` css selectors for tray items (By: zeapoz) +- Add scss support for the `:style` widget property (By: ovalkonia) - Add `min` and `max` function calls to simplexpr (By: ovalkonia) ## [0.6.0] (21.04.2024) diff --git a/crates/eww/src/widgets/widget_definitions.rs b/crates/eww/src/widgets/widget_definitions.rs index b83c6815..39686b02 100644 --- a/crates/eww/src/widgets/widget_definitions.rs +++ b/crates/eww/src/widgets/widget_definitions.rs @@ -209,10 +209,10 @@ pub(super) fn resolve_widget_attrs(bargs: &mut BuilderArgs, gtk_widget: >k::Wi prop(visible: as_bool = true) { if visible { gtk_widget.show(); } else { gtk_widget.hide(); } }, - // @prop style - inline css style applied to the widget + // @prop style - inline scss style applied to the widget prop(style: as_string) { gtk_widget.reset_style(); - css_provider.load_from_data(format!("* {{ {} }}", style).as_bytes())?; + css_provider.load_from_data(grass::from_string(format!("* {{ {} }}", style), &grass::Options::default())?.as_bytes())?; gtk_widget.style_context().add_provider(&css_provider, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION) }, // @prop css - scss code applied to the widget, i.e.: `button {color: red;}`