Skip to content

Instantly share code, notes, and snippets.

@konstantindenerz
Last active March 18, 2021 10:33
Show Gist options
  • Save konstantindenerz/493942730c69c69f8a4811dea1e77919 to your computer and use it in GitHub Desktop.
Save konstantindenerz/493942730c69c69f8a4811dea1e77919 to your computer and use it in GitHub Desktop.
A WebStorm live template to generate CSS variables for a color definition with hsla() function
--color-$name$-h: $h$;
--color-$name$-s: $s$;
--color-$name$-l: $l$;
--color-$name$-hsl: var(--color-$name$-h), var(--color-$name$-s), var(--color-$name$-l);
--color-$name$: hsl(var(--color-$name$-hsl));
$END$
@konstantindenerz
Copy link
Author

How to add live template: https://www.jetbrains.com/help/webstorm/creating-and-editing-live-templates.html

The template above requires this list of variables:

Edit Template Variables

Name Expression Default value Skip if defined
name "name"
h "0"
s "100%"
l "50%"

Bind the template to CSS files > Declaration block (context)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment