neater way to do hover thing with still image

This commit is contained in:
Henry Jameson 2020-07-28 01:54:40 +03:00
parent 65b6e23c00
commit 7870b3f7ec
2 changed files with 41 additions and 47 deletions

View file

@ -10,16 +10,9 @@ $status-margin: 0.75em;
border-left: 4px $fallback--cRed; border-left: 4px $fallback--cRed;
border-left: 4px var(--cRed, $fallback--cRed); border-left: 4px var(--cRed, $fallback--cRed);
// TODO find a way to do this in a cleaner way without JS &:hover .avatar {
// stylelint-disable rscss/class-format --still-image-img: visible;
&:hover .avatar.animated { --still-image-canvas: hidden;
canvas {
display: none;
}
img {
visibility: visible;
}
} }
&.-focused { &.-focused {

View file

@ -35,43 +35,6 @@
display: flex; display: flex;
align-items: center; align-items: center;
&:hover canvas {
display: none;
}
img {
width: 100%;
min-height: 100%;
object-fit: contain;
}
&.animated {
&:hover::before,
img {
visibility: hidden;
}
&:hover img {
visibility: visible
}
&::before {
content: 'gif';
position: absolute;
line-height: 10px;
font-size: 10px;
top: 5px;
left: 5px;
background: rgba(127,127,127,.5);
color: #FFF;
display: block;
padding: 2px 4px;
border-radius: $fallback--tooltipRadius;
border-radius: var(--tooltipRadius, $fallback--tooltipRadius);
z-index: 2;
}
}
canvas { canvas {
position: absolute; position: absolute;
top: 0; top: 0;
@ -81,6 +44,44 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
object-fit: contain; object-fit: contain;
visibility: var(--still-image-canvas, visible);
}
img {
width: 100%;
min-height: 100%;
object-fit: contain;
}
&.animated {
&::before {
content: 'gif';
position: absolute;
line-height: 10px;
font-size: 10px;
top: 5px;
left: 5px;
background: rgba(127, 127, 127, 0.5);
color: #fff;
display: block;
padding: 2px 4px;
border-radius: $fallback--tooltipRadius;
border-radius: var(--tooltipRadius, $fallback--tooltipRadius);
z-index: 2;
}
&:hover canvas {
display: none;
}
&:hover::before,
img {
visibility: var(--still-image-img, hidden);
}
&:hover img {
visibility: visible;
}
} }
} }
</style> </style>