naive-ui/styles/Tag.scss

156 lines
4.8 KiB
SCSS
Raw Normal View History

2019-08-07 14:21:15 +08:00
@import './mixins/mixins.scss';
@import './themes/vars.scss';
2019-08-07 14:21:15 +08:00
2019-09-27 16:02:20 +08:00
@mixin tag-size-mixin($size) {
$height: map-get($--n-height, $size) - 6px;
$font-size: (
"small": 12px,
"medium": 14px,
"large": 14px
);
@include m($size + "-size") {
line-height: $height;
height: $height;
font-size: map-get($font-size, $size);
2019-11-29 16:28:59 +08:00
@include m(round) {
padding-left: $height / 2;
padding-right: $height / 2;
border-radius: $height / 2;
@include m(closable) {
padding-right: 8px + $height / 2;
@include e(close-mark) {
right: $height / 2 - 8px;
}
}
}
2019-08-07 14:21:15 +08:00
}
2019-09-27 16:02:20 +08:00
}
@mixin tag-type-mixin($type) {
@include m($type + '-type') {
2019-11-29 16:28:59 +08:00
@include not-m(checkable) {
@include not-m(disabled) {
box-shadow: inset 0 0 0 1px map-get($map: $--tag-border-color, $key: $type);
color: map-get($map: $--tag-color, $key: $type);
background-color: map-get($map: $--tag-background-color, $key: $type);
@include e(close-mark) {
2019-09-27 16:02:20 +08:00
path {
2019-11-29 16:28:59 +08:00
fill: map-get($map: $--tag-close-mark-color, $key: $type);
}
&:hover {
path {
fill: map-get($map: $--tag-close-mark-color, $key: $type + '-hover');
}
}
&:active {
path {
fill: map-get($map: $--tag-close-mark-color, $key: $type + '-active');
}
2019-09-27 16:02:20 +08:00
}
}
2019-11-29 16:28:59 +08:00
&:hover {
background-color: map-get($map: $--tag-background-color, $key: $type + '-hover');
}
2019-09-27 16:02:20 +08:00
&:active {
2019-11-29 16:28:59 +08:00
background-color: map-get($map: $--tag-background-color, $key: $type + '-active');
2019-09-27 16:02:20 +08:00
}
2019-08-12 14:30:08 +08:00
}
2019-11-29 16:28:59 +08:00
@include m(disabled) {
box-shadow: inset 0 0 0 1px map-get($map: $--tag-border-color, $key: $type + '-disabled');
color: map-get($map: $--tag-color, $key: $type + '-disabled');
background-color: map-get($map: $--tag-background-color, $key: $type + '-disabled');
@include e(close-mark) {
path {
fill: map-get($map: $--tag-close-mark-color, $key: $type + '-disabled');
}
2019-09-27 16:02:20 +08:00
}
2019-08-12 14:30:08 +08:00
}
}
2019-11-29 16:28:59 +08:00
2019-08-07 14:21:15 +08:00
}
2019-09-27 16:02:20 +08:00
}
@include themes-mixin {
@include b(tag) {
@include once {
@include tag-size-mixin("small");
@include tag-size-mixin("medium");
@include tag-size-mixin("large");
white-space: nowrap;
position: relative;
padding: 0 7px;
border-radius: 4px;
box-sizing: border-box;
cursor: default;
display: inline-block;
2019-11-29 16:28:59 +08:00
transition: background-color .2s $default-cubic-bezier, color .3s $default-cubic-bezier, box-shadow .3s $default-cubic-bezier, opacity .3s $default-cubic-bezier;
2019-09-27 16:02:20 +08:00
@include e(close-mark) {
cursor: pointer;
path {
transition: fill .2s $default-cubic-bezier;
}
}
2019-11-29 16:28:59 +08:00
@include m(checkable) {
cursor: pointer;
}
2019-09-27 16:02:20 +08:00
@include m(disabled) {
cursor: not-allowed !important;
@include e(close-mark) {
cursor: not-allowed !important;
}
2019-11-29 16:28:59 +08:00
@include m(checkable) {
opacity: .4;
}
2019-09-27 16:02:20 +08:00
}
@include m(closable) {
padding-right: 18px;
@include e(close-mark) {
transition: color .3s $default-cubic-bezier;
right: 3px;
top: 50%;
transform: translateY(-50%);
height: 14px;
width: 14px;
line-height: 14px;
position: absolute;
}
2019-08-12 14:30:08 +08:00
}
}
2019-09-27 16:02:20 +08:00
@include tag-type-mixin('default');
@include tag-type-mixin('info');
@include tag-type-mixin('success');
@include tag-type-mixin('warning');
@include tag-type-mixin('error');
2019-11-29 16:28:59 +08:00
@include m(checkable) {
box-shadow: none;
color: map-get($--tag-color, 'checkable-default');
background-color: map-get($map: $--tag-background-color, $key: 'checkable-default');
@include not-m(disabled) {
&:hover {
@include not-m(checked) {
color: map-get($--tag-color, 'checkable-hover');
}
background-color: map-get($map: $--tag-background-color, $key: 'checkable-hover');
}
&:active {
@include not-m(checked) {
color: map-get($--tag-color, 'checkable-active');
}
background-color: map-get($map: $--tag-background-color, $key: 'checkable-active');
}
}
@include m(checked) {
color: map-get($--tag-color, 'checkable-active');
background-color: map-get($map: $--tag-background-color, $key: 'checkable-active');
@include not-m(disabled) {
&:hover {
background-color: map-get($map: $--tag-background-color, $key: 'checkable-checked-hover');
}
&:active {
background-color: map-get($map: $--tag-background-color, $key: 'checkable-checked-active');
}
}
}
}
2019-08-07 14:21:15 +08:00
}
}