diff --git a/README.md b/README.md index 101d039..2273aba 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ Visit for full documentation. - [target-anchor-offset()](https://sass-butler.kasimir.dev/#basic-mixin-target-anchor-offset) - [@media](https://github.com/felix-berlin/sass-butler/blob/master/mixins/_breakpoint.scss) - [breakpoint()](https://sass-butler.kasimir.dev/#@media-mixin-breakpoint) + - [dark-mode-class()](https://sass-butler.kasimir.dev/#@media-mixin-dark-mode-class) - [feature()](https://sass-butler.kasimir.dev/#@media-mixin-feature) - [hover](https://sass-butler.kasimir.dev/#@media-mixin-hover) - [element](https://github.com/felix-berlin/sass-butler/blob/master/mixins/_element.scss) diff --git a/mixins.scss b/mixins.scss index 0cf16df..59a6a37 100644 --- a/mixins.scss +++ b/mixins.scss @@ -1,5 +1,6 @@ @forward './mixins/basic'; @forward './mixins/breakpoint'; +@forward './mixins/dark-mode-class'; @forward './mixins/element'; @forward './mixins/feature'; @forward './mixins/font'; diff --git a/mixins/_dark-mode-class.scss b/mixins/_dark-mode-class.scss new file mode 100644 index 0000000..8e3109d --- /dev/null +++ b/mixins/_dark-mode-class.scss @@ -0,0 +1,24 @@ +/// Use a predefined dark mode class to define dark mode styles. +/// @param {String} $element ['html'] +/// @param {String} $class ['dark'] +/// @group @media +/// @author Felix Scholze +/// @since v1.10.0 +/// +/// @example +/// .button { +/// @include dark-mode-class('body', 'dark-mode') { +/// color: #fff; +/// } +/// } +/// +/// @example CSS - Output CSS +/// body[class=dark-mode] .button { +/// color: #fff; +/// } +/// +@mixin dark-mode-class($element: 'html', $class: 'dark') { + #{$element}[class='#{$class}'] & { + @content; + } +}