naive-ui/styles/Badge.scss
2020-03-12 21:32:47 +08:00

169 lines
4.3 KiB
SCSS

@import './mixins/mixins.scss';
@mixin badge-type-mixin ($type) {
@include m($type + '-type') {
@include b(badge-sup) {
background-color: map-get($map: $--badge-background-color, $key: $type);
@include e(ripple-mask) {
background-color: map-get($map: $--badge-background-color, $key: $type);
}
}
@include m(processing) {
@include b(badge-sup) {
&::before {
animation-duration: 2s, 2s;
animation-timing-function: $--n-ease-out-cubic-bezier, $--n-ease-in-out-cubic-bezier;
animation-iteration-count: infinite, infinite;
}
}
@include not-m(dot) {
@include b(badge-sup) {
&::before {
animation-name: #{$theme}-#{$type}-badge-ripple--spread, #{$theme}-#{$type}-badge-ripple--opacity;
}
}
}
}
@include m(processing) {
@include m(dot) {
@include b(badge-sup) {
&::before {
animation-name: #{$theme}-#{$type}-dot-badge-ripple--spread, #{$theme}-#{$type}-badge-ripple--opacity;
}
}
}
}
}
}
@mixin badge-ripple-mixin($type) {
@keyframes #{$theme}-#{$type}-badge-ripple--spread {
0% {
background-color: map-get($map: $--badge-rippling-color, $key: $type);
transform: scale(0);
}
25% {
background-color: map-get($map: $--badge-rippling-color, $key: $type);
transform: scale(1);
}
100% {
background-color: map-get($map: $--badge-rippling-color, $key: $type);
transform: scale(1.25);
}
}
@keyframes #{$theme}-#{$type}-dot-badge-ripple--spread {
0% {
background-color: map-get($map: $--badge-rippling-color, $key: $type);
transform: scale(0);
}
25% {
background-color: map-get($map: $--badge-rippling-color, $key: $type);
transform: scale(1);
}
100% {
background-color: map-get($map: $--badge-rippling-color, $key: $type);
transform: scale(1.75);
}
}
@keyframes #{$theme}-#{$type}-badge-ripple--opacity {
0% {
opacity: 0;
}
25% {
opacity: $--badge-rippling-start-opacity;
}
100% {
opacity: 0;
}
}
}
@include themes-mixin {
@include badge-ripple-mixin('default');
@include badge-ripple-mixin('info');
@include badge-ripple-mixin('success');
@include badge-ripple-mixin('warning');
@include badge-ripple-mixin('error');
@include b(badge) {
@include once {
display: inline-flex;
position: relative;
vertical-align: middle;
@include m(as-is) {
@include b(badge-sup) {
@include fade-in-scale-up-transition(
badge,
left bottom,
$original-transform: translateX(0)
);
transform: translateX(0);
position: static;
}
}
@include m(dot) {
@include b(badge-sup) {
height: 8px;
width: 8px;
padding: 0;
min-width: 8px;
left: 100%;
bottom: calc(100% - 4px);
@include e(ripple-mask) {
border-radius: 4px;
}
&::before {
border-radius: 4px;
}
}
}
}
@include badge-type-mixin('default');
@include badge-type-mixin('info');
@include badge-type-mixin('success');
@include badge-type-mixin('warning');
@include badge-type-mixin('error');
}
@include once {
@include b(badge-sup) {
@include fade-in-scale-up-transition(
badge,
left bottom,
$original-transform: (translateX(-50%))
);
transition:
background-color .3s $--n-ease-in-out-cubic-bezier,
color .3s $--n-ease-in-out-cubic-bezier;
color: white;
position: absolute;
height: 18px;
line-height: 18px;
border-radius: 9px;
padding: 0 6px;
text-align: center;
font-size: 12px;
transform: translateX(-50%);
left: 100%;
bottom: calc(100% - 9px);
font-weight: $--n-strong-weight;
@include e(ripple-mask) {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border-radius: 9px;
}
&::before {
opacity: 0;
transform: scale(1);
border-radius: 9px;
content: "";
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
}
}
}