Skip to content

Instantly share code, notes, and snippets.

@dbox
Last active October 29, 2020 06:48
Show Gist options
  • Save dbox/56b31bee89fff85fd0d9ae1054884de6 to your computer and use it in GitHub Desktop.
Save dbox/56b31bee89fff85fd0d9ae1054884de6 to your computer and use it in GitHub Desktop.
postcss mixin
/* some pre-defined custom properties in my code */
:root {
--default-transition-duration: .2s;
--default-easing: ease-out;
}
/* define mixin */
@define mixin transition(--transition-property: all, --transition-duration: var(--default-transition-duration), --easing: var(--default-easing) ) {
transition: --transition-property --transition-duration --easing;
}
/*input */
.my-thing {
@mixin transition();
padding: 2%;
}
/*output */
.my-thing {
transition: all .2s ease-out;
padding: 2%;
}
/*input */
.my-other-thing {
@mixin transition(--transition-property: border);
}
/* output */
.my-other-thing {
transition: border .2s ease-out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment