This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lang-is() | |
// Creates selector matches any of language tags | |
// | |
// @param {list} $langs - List of labguage tags to match | |
// | |
// @example | |
// @include lang-is(ja, ko, zh) { | |
// font-kerning: none; | |
// } | |
// p { | |
// @include lang-is(ja, ko, zh) { | |
// font-family: sans-serif; | |
// } | |
// } | |
// | |
// @output | |
// :lang(ja), :lang(ko), :lang(zh) { | |
// font-kerning: none; | |
// } | |
// p:lang(ja), p:lang(ko), p:lang(zh) { | |
// font-family: serif; | |
// } | |
@mixin lang-is ($langs...) { | |
$selector: (); | |
$parent: if(&, "&", ""); | |
@each $lang in $langs { | |
$selector: append($selector, "#{$parent}:lang(#{$lang})", $separator: comma); | |
} | |
#{$selector} { | |
@content; | |
} | |
} | |
// lang-not() | |
// Creates selector does not matche any of language tags | |
// | |
// @param {list} $langs - List of labguage tags not to match | |
// | |
// @example | |
// @include lang-not(ja, ko, zh) { | |
// font-kerning: auto; | |
// } | |
// p { | |
// @include lang-not(ja, ko, zh) { | |
// font-family: serif; | |
// } | |
// } | |
// | |
// @output | |
// :not(:lang(ja)):not(:lang(ko)):not(:lang(zh)) { | |
// font-kerning: auto; | |
// } | |
// p:not(:lang(ja)):not(:lang(ko)):not(:lang(zh)) { | |
// font-family: serif; | |
// } | |
@mixin lang-not ($langs...) { | |
$selector: if(&, "&", ""); | |
@each $lang in $langs { | |
$selector: $selector + ":not(:lang(#{$lang}))"; | |
} | |
#{$selector} { | |
@content; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment