naive-ui/styles/Badge.scss

206 lines
5.1 KiB
SCSS
Raw Normal View History

2019-08-07 11:40:23 +08:00
@import './mixins/mixins.scss';
@import './themes/vars.scss';
2019-08-07 11:40:23 +08:00
2019-10-09 17:38:08 +08:00
@keyframes n-badge-number-fade-up-in {
2019-10-08 19:06:23 +08:00
from {
transform: translateY(60%);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
2019-10-09 17:38:08 +08:00
@keyframes n-badge-number-fade-down-in {
2019-10-08 19:06:23 +08:00
from {
transform: translateY(-60%);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
2019-10-09 17:38:08 +08:00
@keyframes n-badge-number-fade-up-out {
2019-10-08 19:06:23 +08:00
from {
transform: translateY(0%);
opacity: 1;
}
to {
transform: translateY(-60%);
opacity: 0;
}
}
2019-10-09 17:38:08 +08:00
@keyframes n-badge-number-fade-down-out {
2019-10-08 19:06:23 +08:00
from {
transform: translateY(0%);
opacity: 1;
}
to {
transform: translateY(60%);
opacity: 0;
}
}
2019-10-09 17:38:08 +08:00
@mixin badge-type-mixin ($type) {
@include m($type + '-type') {
@include b(badge-sup) {
background-color: map-get($map: $--badge-background-color, $key: $type);
2019-10-08 19:06:23 +08:00
}
2019-10-09 17:38:08 +08:00
@include m(processing) {
@include b(badge-sup) {
&::after {
animation-name: #{$theme}-#{$type}-badge-ripple--spread, #{$theme}-#{$type}-badge-ripple--opacity;
animation-duration: 1.5s, 1.5s;
animation-delay: .5s, .5s;
animation-timing-function: $fast-in-cubic-bezier, $default-cubic-bezier;
animation-iteration-count: infinite, infinite;
}
2019-10-09 00:43:02 +08:00
}
2019-10-08 19:06:23 +08:00
}
}
}
2019-10-09 17:38:08 +08:00
@mixin badge-ripple-mixin($type) {
@keyframes #{$theme}-#{$type}-badge-ripple--spread {
from {
box-shadow: 0 0 0 0px map-get($map: $--badge-background-color, $key: $type);
}
to {
box-shadow: 0 0 0 4px map-get($map: $--badge-background-color, $key: $type);
}
}
@keyframes #{$theme}-#{$type}-badge-ripple--opacity {
from {
opacity: .4;
}
to {
opacity: 0;
2019-10-08 14:36:04 +08:00
}
}
}
2019-10-09 17:38:08 +08:00
@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-block;
position: relative;
vertical-align: middle;
@include m(dot) {
@include b(badge-sup) {
height: 8px;
width: 8px;
padding: 0;
min-width: 8px;
left: calc(100% - 4px);
bottom: calc(100% - 4px);
&::after {
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 {
2019-10-08 14:36:04 +08:00
@include b(badge-sup) {
2019-10-09 17:38:08 +08:00
@include fade-in-scale-up-transition(badge, left bottom);
transition: background-color .3s $default-cubic-bezier, color .3s $default-cubic-bezier;
color: white;
user-select: none;
position: absolute;
height: 18px;
line-height: 18px;
border-radius: 9px;
padding: 0 6px;
text-align: center;
font-size: 12px;
left: calc(100% - 8px);
bottom: calc(100% - 8px);
font-weight: bold;
&::after {
border-radius: 9px;
content: "";
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
}
@include b(scroll-numbers) {
overflow: hidden;
white-space: nowrap;
display: inline-block;
height: 18px;
line-height: 18px;
@include b(scroll-number) {
@include fade-up-width-expand-transition($duration: .2s);
@include fade-in-width-expand-transition($duration: .2s, $delay: 0s);
display: inline-block;
position: relative;
height: 18px;
@include b(scroll-number-old-number) {
display: inline-block;
opacity: 0;
position: absolute;
left: 0;
@include m(top) {
transform: translateY(-100%);
}
@include m(bottom) {
transform: translateY(100%);
}
@include m(down-scroll) {
animation: n-badge-number-fade-down-out .2s $fast-in-cubic-bezier;
animation-iteration-count: 1
}
@include m(up-scroll) {
animation: n-badge-number-fade-up-out .2s $fast-in-cubic-bezier;
animation-iteration-count: 1
}
}
@include b(scroll-number-current-number) {
display: inline-block;
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
opacity: 1;
transform: translateY(0);
@include m(down-scroll) {
animation: n-badge-number-fade-down-in .2s $fast-in-cubic-bezier;
animation-iteration-count: 1
}
@include m(up-scroll) {
animation: n-badge-number-fade-up-in .2s $fast-in-cubic-bezier;
animation-iteration-count: 1
}
@include e(inner) {
display: inline-block;
position: absolute;
right: 0;
top: 0;
@include m(not-number) {
right: unset;
left: 0;
}
}
}
}
2019-08-07 11:40:23 +08:00
}
}
}