forked from AkkomaGang/akkoma-fe
Modify label
This commit is contained in:
parent
e13c4b6b85
commit
42a13b0f1b
2 changed files with 28 additions and 19 deletions
|
@ -13,6 +13,7 @@ const StillImage = {
|
||||||
return {
|
return {
|
||||||
stopGifs: this.$store.getters.mergedConfig.stopGifs || window.matchMedia('(prefers-reduced-motion: reduce)').matches,
|
stopGifs: this.$store.getters.mergedConfig.stopGifs || window.matchMedia('(prefers-reduced-motion: reduce)').matches,
|
||||||
isAnimated: false,
|
isAnimated: false,
|
||||||
|
imageTypeLabel: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -62,14 +63,17 @@ const StillImage = {
|
||||||
// Ordered from least to most intensive
|
// Ordered from least to most intensive
|
||||||
if (this.isGIF(reader.value)) {
|
if (this.isGIF(reader.value)) {
|
||||||
this.isAnimated = true
|
this.isAnimated = true
|
||||||
|
this.setLabel('GIF')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (this.isAnimatedWEBP(reader.value)) {
|
if (this.isAnimatedWEBP(reader.value)) {
|
||||||
this.isAnimated = true
|
this.isAnimated = true
|
||||||
|
this.setLabel('WEBP')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (this.isAnimatedPNG(reader.value)) {
|
if (this.isAnimatedPNG(reader.value)) {
|
||||||
this.isAnimated = true
|
this.isAnimated = true
|
||||||
|
this.setLabel('APNG')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -77,6 +81,9 @@ const StillImage = {
|
||||||
// this.imageLoadError && this.imageLoadError()
|
// this.imageLoadError && this.imageLoadError()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
setLabel (name) {
|
||||||
|
this.imageTypeLabel = name;
|
||||||
|
},
|
||||||
isGIF (data) {
|
isGIF (data) {
|
||||||
// I am a perfectly sane individual
|
// I am a perfectly sane individual
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
|
ref="still-image"
|
||||||
class="still-image"
|
class="still-image"
|
||||||
:class="{ animated: animated }"
|
:class="{ animated: animated }"
|
||||||
:style="style"
|
:style="style"
|
||||||
>
|
>
|
||||||
|
<div
|
||||||
|
v-if="isAnimated && imageTypeLabel"
|
||||||
|
class="image-type-label">
|
||||||
|
{{ imageTypeLabel }}
|
||||||
|
</div>
|
||||||
<canvas
|
<canvas
|
||||||
v-if="animated"
|
v-if="animated"
|
||||||
ref="canvas"
|
ref="canvas"
|
||||||
|
@ -57,30 +63,26 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.animated {
|
.image-type-label {
|
||||||
&::before {
|
|
||||||
zoom: var(--_still_image-label-scale, 1);
|
|
||||||
content: var(--image-type-label, 'A?');
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
top: 0.25em;
|
||||||
|
left: 0.25em;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
font-size: 0.7em;
|
font-size: 0.6em;
|
||||||
top: 0.5em;
|
|
||||||
left: 0.5em;
|
|
||||||
background: rgba(127, 127, 127, 0.5);
|
background: rgba(127, 127, 127, 0.5);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
display: block;
|
|
||||||
padding: 2px 4px;
|
padding: 2px 4px;
|
||||||
border-radius: $fallback--tooltipRadius;
|
|
||||||
border-radius: var(--tooltipRadius, $fallback--tooltipRadius);
|
border-radius: var(--tooltipRadius, $fallback--tooltipRadius);
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
visibility: var(--_still-image-label-visibility, visible);
|
visibility: var(--_still-image-label-visibility, visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.animated {
|
||||||
&:hover canvas {
|
&:hover canvas {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover::before {
|
&:hover .image-type-label {
|
||||||
visibility: var(--_still-image-label-visibility, hidden);
|
visibility: var(--_still-image-label-visibility, hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue