Skip to content

Instantly share code, notes, and snippets.

@niktariy
Last active March 30, 2019 12:25
Show Gist options
  • Save niktariy/4a7d9a0dc73b7a407132d271cd4f632f to your computer and use it in GitHub Desktop.
Save niktariy/4a7d9a0dc73b7a407132d271cd4f632f to your computer and use it in GitHub Desktop.
Mixins in Sass VS Abandoned CSS @apply rule
> 1%
last 2 versions
/* Как могло бы быть в CSS*/
/* @apply https://tabatkins.github.io/specs/css-apply-rule/ */
:root {
--toolbar-theme: {
background-color: hsl(120, 70%, 95%);
border-radius: 4px;
border: 1px solid var(--theme-color late);
};
--toolbar-title-theme: {
color: green;
};
}
.toolbar {
@apply --toolbar-theme;
}
.toolbar > .title {
@apply --toolbar-title-theme;
}
// ----
// libsass (v3.5.4)
// ----
// Уже есть в препроцессорах
@mixin toolbar-theme($theme-color: late) {
background-color: hsl(120, 70%, 95%);
border-radius: 4px;
border: 1px solid $theme-color;
}
@mixin toolbar-title-theme($title-color: green) {
color: $title-color;
}
.toolbar {
@include toolbar-theme();
}
.toolbar > .title {
@include toolbar-title-theme();
}
.toolbar {
background-color: #e9fbe9;
border-radius: 4px;
border: 1px solid late;
}
.toolbar > .title {
color: green;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment