naive-ui/styles/mixins/mixins.scss

117 lines
2.3 KiB
SCSS
Raw Normal View History

2019-09-17 19:21:36 +08:00
@import "config.scss";
@import "../themes/vars.scss";
@import "../themes/light.scss";
@import "../themes/default.scss";
2019-09-17 19:21:36 +08:00
/**
* BEM related mixins
*/
$B: null;
$BE: null;
2019-09-17 19:21:36 +08:00
$block-depth: 0;
@mixin b($block) {
2019-09-17 19:21:36 +08:00
$block-depth: $block-depth + 1 !global;
$temp-block: $B;
$temp-block-element: $BE;
$B: $namespace + "-" + $block !global;
$BE: $B!global;
2019-09-17 19:21:36 +08:00
@if $theme == null or $block-depth != 1 {
.#{$B} {
@content;
}
} @else {
.n-#{$theme}-theme.#{$B} {
@content
}
}
$B: $temp-block !global;
$BE: $temp-block-element !global;
2019-09-17 19:21:36 +08:00
$block-depth: $block-depth - 1 !global;
}
@mixin e($elements...) {
$temp-block-element: $BE;
$BEs: '';
@each $element in $elements {
$BE: $B + $element-separator + $element !global;
.#{$BE} {
2019-09-17 19:21:36 +08:00
@content;
}
}
$BE: $temp-block-element !global;
}
@mixin m($modifiers...) {
$BEMs: '';
@for $i from 0 to length($modifiers) {
$modifier: nth($modifiers, $i + 1);
@if $i == 0 {
$BEMs: '&.' + $BE + $modifier-separator + $modifier;
} @else {
$BEMs: $BEMs + ', &.' + $BE + $modifier-separator + $modifier;
}
}
#{$BEMs} {
2019-09-17 19:21:36 +08:00
@content;
}
}
@mixin not-m($modifier) {
$BEM: '';
$BEM: '.' + $BE + '--' + $modifier;
&:not(#{$BEM}) {
2019-09-17 19:21:36 +08:00
@content;
}
}
2019-09-17 19:21:36 +08:00
/**
* Theme related mixins
*/
$common-css-attrs-generated: false;
$theme: null;
$in-themes-mixin: false;
$theme-names: "default", "light";
@mixin themes-mixin() {
$in-themes-mixin: true !global;
$theme: null !global;
@include setup-default-theme();
@content;
$common-css-attrs-generated: true !global;
@each $theme-name in $theme-names {
2019-09-17 19:21:36 +08:00
@if $theme-name == 'light' {
$theme: $theme-name !global;
@include setup-default-theme();
@include setup-light-theme();
@content;
$theme: null !global;
} @else if $theme-name == 'default' {
$theme: $theme-name !global;
@include setup-default-theme();
@content;
$theme: null !global;
}
}
2019-09-17 19:21:36 +08:00
$common-css-attrs-generated: false !global;
$in-themes-mixin: false !global;
}
@mixin once() {
2019-09-17 19:21:36 +08:00
@if not $common-css-attrs-generated {
@content;
}
}
@mixin detachedContentWrapper {
position: fixed;
left: 0;
top: 0;
width: 0;
height: 0;
overflow: visible;
}
@mixin detachedContent {
position: fixed;
}