amis/scss/components/_tooltip.scss

260 lines
6.0 KiB
SCSS
Raw Normal View History

2019-04-30 11:11:25 +08:00
.#{$ns}Tooltip {
2019-12-06 09:58:08 +08:00
position: absolute;
top: 0;
left: 0;
font-family: inherit;
border-radius: $borderRadius;
min-width: $Tooltip-minWidth;
max-width: $Tooltip-maxWidth;
text-align: left;
white-space: normal;
z-index: $zindex-tooltip;
word-wrap: break-word;
background: $Tooltip-bg;
border: $Tooltip-borderWidth solid $Tooltip-borderColor;
box-shadow: $Tooltip-boxShadow;
&-arrow {
2019-04-30 11:11:25 +08:00
position: absolute;
2019-12-06 09:58:08 +08:00
display: block;
width: $Tooltip-arrow-width;
height: $Tooltip-arrow-height;
margin-left: -$Tooltip-arrow-width/2;
left: 50%;
&::before,
&::after {
position: absolute;
display: block;
content: '';
border-color: transparent;
border-style: solid;
2019-04-30 11:11:25 +08:00
}
2019-12-06 09:58:08 +08:00
}
2019-04-30 11:11:25 +08:00
2019-12-06 09:58:08 +08:00
&--top {
margin-top: -$Tooltip-arrow-height - px2rem(2px);
2019-11-13 14:46:47 +08:00
2019-12-06 09:58:08 +08:00
.#{$ns}Tooltip-arrow {
bottom: ($Tooltip-arrow-height + $Tooltip-borderWidth) * -1;
2019-11-13 14:46:47 +08:00
}
2019-12-06 09:58:08 +08:00
.#{$ns}Tooltip-arrow::before,
.#{$ns}Tooltip-arrow::after {
border-width: $Tooltip-arrow-height ($Tooltip-arrow-width / 2) 0;
}
.#{$ns}Tooltip-arrow::before {
bottom: 0;
border-top-color: $Tooltip-arrow-outerColor;
}
.#{$ns}Tooltip-arrow::after {
bottom: $Tooltip-borderWidth;
border-top-color: $Tooltip-arrow-color;
}
}
&--right {
margin-left: $Tooltip-arrow-height + px2rem(2px);
.#{$ns}Tooltip-arrow {
left: ($Tooltip-borderWidth) * -1;
width: $Tooltip-arrow-height;
height: $Tooltip-arrow-width;
margin-top: -$Tooltip-arrow-width/2;
top: 50%;
}
2019-12-06 09:58:08 +08:00
.#{$ns}Tooltip-arrow::before,
.#{$ns}Tooltip-arrow::after {
border-width: ($Tooltip-arrow-width / 2) $Tooltip-arrow-height
($Tooltip-arrow-width / 2) 0;
2019-04-30 11:11:25 +08:00
}
2019-12-06 09:58:08 +08:00
.#{$ns}Tooltip-arrow::before {
left: 0;
border-right-color: $Tooltip-arrow-outerColor;
}
2019-11-13 14:46:47 +08:00
2019-12-06 09:58:08 +08:00
.#{$ns}Tooltip-arrow::after {
left: $Tooltip-borderWidth;
border-right-color: $Tooltip-arrow-color;
2019-04-30 11:11:25 +08:00
}
2019-12-06 09:58:08 +08:00
}
&--bottom {
margin-top: $Tooltip-arrow-height + px2rem(2px);
2019-04-30 11:11:25 +08:00
2019-12-06 09:58:08 +08:00
.#{$ns}Tooltip-arrow {
top: ($Tooltip-arrow-height + $Tooltip-borderWidth) * -1;
2019-04-30 11:11:25 +08:00
}
2019-12-06 09:58:08 +08:00
.#{$ns}Tooltip-arrow::before,
.#{$ns}Tooltip-arrow::after {
border-width: 0 ($Tooltip-arrow-width / 2) $Tooltip-arrow-height
($Tooltip-arrow-width / 2);
2019-04-30 11:11:25 +08:00
}
2019-12-06 09:58:08 +08:00
.#{$ns}Tooltip-arrow::before {
top: 0;
border-bottom-color: $Tooltip-arrow-outerColor;
2019-07-09 16:29:48 +08:00
}
2019-12-06 09:58:08 +08:00
.#{$ns}Tooltip-arrow::after {
top: $Tooltip-borderWidth;
border-bottom-color: $Tooltip-arrow-color;
2019-07-09 16:29:48 +08:00
}
2019-12-06 09:58:08 +08:00
// This will remove the popover-header's border just below the arrow
.#{$ns}Tooltip-title::before {
position: absolute;
top: 0;
left: 50%;
display: block;
width: $Tooltip-arrow-width;
margin-left: ($Tooltip-arrow-width / -2);
content: '';
border-bottom: $Tooltip-borderWidth solid $Tooltip-title-bg;
2019-07-09 16:29:48 +08:00
}
2019-12-06 09:58:08 +08:00
}
2019-07-09 16:29:48 +08:00
2019-12-06 09:58:08 +08:00
&--left {
margin-left: -$Tooltip-arrow-height - px2rem(2px);
.#{$ns}Tooltip-arrow {
left: auto;
right: ($Tooltip-arrow-height + $Tooltip-borderWidth) * -1;
width: $Tooltip-arrow-height;
height: $Tooltip-arrow-width;
margin-top: -$Tooltip-arrow-width/2;
top: 50%;
2019-07-09 16:29:48 +08:00
}
2019-12-06 09:58:08 +08:00
.#{$ns}Tooltip-arrow::before,
.#{$ns}Tooltip-arrow::after {
border-width: ($Tooltip-arrow-width / 2) 0 ($Tooltip-arrow-width / 2)
$Tooltip-arrow-height;
2019-04-30 11:11:25 +08:00
}
2019-12-06 09:58:08 +08:00
.#{$ns}Tooltip-arrow::before {
right: 0;
border-left-color: $Tooltip-arrow-outerColor;
}
.#{$ns}Tooltip-arrow::after {
right: $Tooltip-borderWidth;
border-left-color: $Tooltip-arrow-color;
}
}
&-title {
padding: $Tooltip-title-paddingY $Tooltip-title-paddingX;
margin-bottom: 0; // Reset the default from Reboot
font-size: $fontSizeBase;
color: $Tooltip-title-color;
background-color: $Tooltip-title-bg;
border-bottom: $Tooltip-borderWidth solid darken($Tooltip-title-bg, 5%);
border-top-left-radius: $Tooltip-borderRadius - $Tooltip-borderWidth;
border-top-right-radius: $Tooltip-borderRadius - $Tooltip-borderWidth;
&:empty {
display: none;
}
}
&-body {
color: $Tooltip-body-color;
padding: $Tooltip-body-paddingY $Tooltip-body-paddingX;
}
}
@keyframes tooltipIn {
from {
opacity: 0;
margin: 0;
}
}
[data-tooltip] {
position: relative;
&:after {
pointer-events: none;
left: 0;
top: 50%;
transform: translateY(-50%);
position: absolute;
content: attr(data-tooltip);
font-size: $Tooltip--attr-fontSize;
line-height: $Tooltip--attr-lineHeigt;
text-align: left;
2020-06-13 18:31:54 +08:00
white-space: normal;
width: max-content;
box-sizing: content-box;
2020-06-13 18:31:54 +08:00
max-width: 300px;
2019-12-06 09:58:08 +08:00
background: $Tooltip--attr-bg;
border: $Tooltip--attr-borderWidth solid $Tooltip--attr-borderColor;
border-radius: $Tooltip--attr-borderRadius;
box-shadow: $Tooltip--attr-boxShadow;
left: 100%;
color: $Tooltip--attr-color;
padding: $Tooltip--attr-paddingY $Tooltip--attr-paddingX;
display: none;
animation-duration: 0.2s;
animation-fill-mode: both;
2020-06-13 18:31:54 +08:00
@media screen and (min-width: 0\0) {
2020-06-13 18:31:54 +08:00
white-space: nowrap;
max-width: unset;
}
2019-12-06 09:58:08 +08:00
}
&:not(.is-disabled):hover:after {
display: inline-block;
animation-name: tooltipIn;
opacity: 1;
z-index: $zindex-tooltip;
margin: 0 0 0 $Tooltip--attr-gap;
opacity: 1;
}
&[data-position='bottom']:after {
left: 50%;
top: 100%;
transform: translateX(-50%);
}
&[data-position='bottom']:hover:after {
margin: $Tooltip--attr-gap 0 0 0;
}
&[data-position='left']:after {
top: 50%;
right: 100%;
left: auto;
transform: translateY(-50%);
}
&[data-position='left']:hover:after {
2020-01-07 19:42:50 +08:00
margin: 0 $Tooltip--attr-gap 0 0;
2019-12-06 09:58:08 +08:00
}
&[data-position='top']:after {
left: 50%;
top: auto;
bottom: 100%;
transform: translateX(-50%);
}
&[data-position='top']:hover:after {
margin: -$Tooltip--attr-gap 0 0 0;
}
&:hover:active:after {
content: '';
display: none !important;
}
}