naive-ui/styles/mixins/mixins.scss

135 lines
2.7 KiB
SCSS
Raw Normal View History

2020-02-11 18:11:51 +08:00
@import 'config.scss';
@import '../themes/dark/index.scss';
@import '../themes/light/index.scss';
@import '../themes/common.scss';
@import '../themes/transition.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;
@function block ($block: null) {
@if $block {
2020-02-11 18:11:51 +08:00
@return $namespace + '-' + $block;
} @else if $B {
@return $B;
}
2019-12-09 15:12:53 +08:00
}
@mixin b($block) {
2019-09-17 19:21:36 +08:00
$block-depth: $block-depth + 1 !global;
$temp-block: $B;
$temp-block-element: $BE;
2020-02-11 18:11:51 +08:00
$B: $namespace + '-' + $block !global;
$BE: $B!global;
2019-10-09 17:38:08 +08:00
@if (not $common-css-attrs-generated) or $block-depth != 1 {
2019-09-17 19:21:36 +08:00
.#{$B} {
@content;
}
} @else {
2020-02-11 17:19:00 +08:00
.#{$namespace}-#{$theme}-theme.#{$B} {
2019-09-17 19:21:36 +08:00
@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: '';
2020-02-11 18:11:51 +08:00
$BEM: '.' + $BE + $modifier-separator + $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;
2020-02-11 18:11:51 +08:00
$theme-names: 'dark', 'light';
/** wait for sass to support dynamic @include mixins */
$default-theme: 'light';
2019-09-17 19:21:36 +08:00
@mixin themes-mixin() {
$in-themes-mixin: true !global;
$theme: 'light' !global;
2020-02-11 18:11:51 +08:00
@include setup-light-theme();
2019-09-17 19:21:36 +08:00
@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-light-theme();
@content;
$theme: null !global;
} @else if $theme-name == 'dark' {
2019-09-17 19:21:36 +08:00
$theme: $theme-name !global;
2019-09-24 12:43:56 +08:00
@include setup-dark-theme();
2019-09-17 19:21:36 +08:00
@content;
$theme: null !global;
}
}
2019-09-17 19:21:36 +08:00
$common-css-attrs-generated: false !global;
$in-themes-mixin: false !global;
2019-10-09 17:38:08 +08:00
$theme: null !global;
}
@mixin as-form-item {
2020-02-11 17:19:00 +08:00
&.#{$namespace}-form-item {
2020-02-13 22:06:22 +08:00
.#{$namespace}-form-item-blank {
@content;
}
}
}
@mixin with-status ($status) {
2020-02-11 18:11:51 +08:00
&.#{$namespace}-form-item-blank#{$modifier-separator}#{$status} {
@content;
}
}
@mixin as-modal-content {
&.#{$namespace}-modal-content, &.#{$namespace}-drawer {
@content;
}
}
@mixin once() {
2019-09-17 19:21:36 +08:00
@if not $common-css-attrs-generated {
@content;
}
}