Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] Support dynamically created CSS variables using SCSS/Sass #109

Closed
Anoesj opened this issue Aug 31, 2023 · 3 comments
Closed

[Feat] Support dynamically created CSS variables using SCSS/Sass #109

Anoesj opened this issue Aug 31, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@Anoesj
Copy link

Anoesj commented Aug 31, 2023

In many of my projects, I use the following SCSS mixin to define colors:

/// Creates CSS var and some additional CSS vars for the hue, saturation
/// and lightness values of the given color.
/// Inspired by https://codyhouse.co/blog/post/how-to-combine-sass-color-functions-and-css-variables
///
/// @param {string} $css-var-name: The name of the CSS var.
/// @param {string} $hex-color-value: The hex color value.
/// @example scss - Usage
///   :root { @include declare-hsl-color(--color-primary, #ff0000); }
@mixin declare-hsl-color($css-var-name, $hex-color-value) {
   #{$css-var-name}: #{$hex-color-value};
   #{$css-var-name}-h: color.hue($hex-color-value);
   #{$css-var-name}-s: color.saturation($hex-color-value);
   #{$css-var-name}-l: color.lightness($hex-color-value);
}

When defining colors using this mixin (e.g. using :root { @include declare-hsl-color(--color-primary, #ff0000); }), this VSCode extension does not recognize the definition. Makes sense, because there is some dynamic stuff going on.

It would be nice if this extension somehow recognizes the definition or provides a way for developers to provide custom parsing rules. E.g. it'd be nice to be able to pass the extension a regex for dynamic CSS variable definitions.

@Anoesj Anoesj added the enhancement New feature or request label Aug 31, 2023
@phoenisx
Copy link
Contributor

phoenisx commented Sep 2, 2023

Are you looking for a feature like this: #92

I was planning to add support for injecting variables using some config file, but didn't get time recently.
If you are interested in the same feature, let me know we can close this one, in support for the above issue.

@Anoesj
Copy link
Author

Anoesj commented Sep 2, 2023

Replied over there 😄. It might work for my use case with the proposed changes.

@phoenisx
Copy link
Contributor

phoenisx commented Sep 3, 2023

Closing this in favour of #92

@phoenisx phoenisx closed this as completed Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants