feat: ALT button (#9265)

This commit is contained in:
freeplay 2023-06-25 20:26:15 -04:00
parent 403837051d
commit c867899440
3 changed files with 77 additions and 41 deletions

View file

@ -941,6 +941,7 @@ deleteAccountConfirm: "This will irreversibly delete your account. Proceed?"
incorrectPassword: "Incorrect password." incorrectPassword: "Incorrect password."
voteConfirm: "Confirm your vote for \"{choice}\"?" voteConfirm: "Confirm your vote for \"{choice}\"?"
hide: "Hide" hide: "Hide"
alt: "ALT"
leaveGroup: "Leave group" leaveGroup: "Leave group"
leaveGroupConfirm: "Are you sure you want to leave \"{name}\"?" leaveGroupConfirm: "Are you sure you want to leave \"{name}\"?"
useDrawerReactionPickerForMobile: "Display reaction picker as drawer on mobile" useDrawerReactionPickerForMobile: "Display reaction picker as drawer on mobile"

View file

@ -16,25 +16,34 @@
</div> </div>
</button> </button>
<div v-else class="gqnyydlz"> <div v-else class="gqnyydlz">
<a :href="image.url" :title="image.name"> <a :href="image.url">
<ImgWithBlurhash <ImgWithBlurhash
:hash="image.blurhash" :hash="image.blurhash"
:src="url" :src="url"
:alt="image.comment" :alt="image.comment"
:type="image.type" :type="image.type"
:title="image.comment"
:cover="false" :cover="false"
/> />
<div v-if="image.type === 'image/gif'" class="gif">GIF</div> <div v-if="image.type === 'image/gif'" class="gif">GIF</div>
</a> </a>
<div class="buttons">
<button
v-if="image.comment"
v-tooltip="i18n.ts.alt"
class="_button"
@click.stop="captionPopup"
>
<i class="ph-subtitles ph-bold ph-lg"></i>
</button>
<button <button
v-tooltip="i18n.ts.hide" v-tooltip="i18n.ts.hide"
class="_button hide" class="_button"
@click="hide = true" @click="hide = true"
> >
<i class="ph-eye-slash ph-bold ph-lg"></i> <i class="ph-eye-slash ph-bold ph-lg"></i>
</button> </button>
</div> </div>
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -44,6 +53,8 @@ import { getStaticImageUrl } from "@/scripts/get-static-image-url";
import ImgWithBlurhash from "@/components/MkImgWithBlurhash.vue"; import ImgWithBlurhash from "@/components/MkImgWithBlurhash.vue";
import { defaultStore } from "@/store"; import { defaultStore } from "@/store";
import { i18n } from "@/i18n"; import { i18n } from "@/i18n";
import * as os from "@/os";
const props = defineProps<{ const props = defineProps<{
image: misskey.entities.DriveFile; image: misskey.entities.DriveFile;
@ -59,6 +70,13 @@ const url =
? getStaticImageUrl(props.image.thumbnailUrl) ? getStaticImageUrl(props.image.thumbnailUrl)
: props.image.thumbnailUrl; : props.image.thumbnailUrl;
function captionPopup() {
os.alert({
type: "info",
text: props.image.comment
})
}
// Plugin:register_note_view_interruptor 使watch // Plugin:register_note_view_interruptor 使watch
watch( watch(
() => props.image, () => props.image,
@ -110,10 +128,15 @@ watch(
position: relative; position: relative;
background: var(--bg); background: var(--bg);
> .hide { > .buttons {
display: block; display: flex;
gap: 4px;
position: absolute; position: absolute;
border-radius: 6px; border-radius: 6px;
overflow: hidden;
top: 12px;
right: 12px;
> * {
background-color: var(--accentedBg); background-color: var(--accentedBg);
-webkit-backdrop-filter: var(--blur, blur(15px)); -webkit-backdrop-filter: var(--blur, blur(15px));
backdrop-filter: var(--blur, blur(15px)); backdrop-filter: var(--blur, blur(15px));
@ -121,11 +144,6 @@ watch(
font-size: 0.8em; font-size: 0.8em;
padding: 6px 8px; padding: 6px 8px;
text-align: center; text-align: center;
top: 12px;
right: 12px;
> i {
display: block;
} }
} }

View file

@ -32,7 +32,6 @@
> >
<video <video
:poster="video.thumbnailUrl" :poster="video.thumbnailUrl"
:title="video.comment"
:aria-label="video.comment" :aria-label="video.comment"
preload="none" preload="none"
controls controls
@ -41,14 +40,24 @@
<source :src="video.url" :type="video.type" /> <source :src="video.url" :type="video.type" />
</video> </video>
</VuePlyr> </VuePlyr>
<div class="buttons">
<button
v-if="video.comment"
v-tooltip="i18n.ts.alt"
class="_button"
@click.stop="captionPopup"
>
<i class="ph-subtitles ph-bold ph-lg"></i>
</button>
<button <button
v-tooltip="i18n.ts.hide" v-tooltip="i18n.ts.hide"
class="_button hide" class="_button"
@click="hide = true" @click="hide = true"
> >
<i class="ph-eye-slash ph-bold ph-lg"></i> <i class="ph-eye-slash ph-bold ph-lg"></i>
</button> </button>
</div> </div>
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -58,6 +67,7 @@ import type * as misskey from "calckey-js";
import { defaultStore } from "@/store"; import { defaultStore } from "@/store";
import "vue-plyr/dist/vue-plyr.css"; import "vue-plyr/dist/vue-plyr.css";
import { i18n } from "@/i18n"; import { i18n } from "@/i18n";
import * as os from "@/os";
const props = defineProps<{ const props = defineProps<{
video: misskey.entities.DriveFile; video: misskey.entities.DriveFile;
@ -72,6 +82,13 @@ const hide = ref(
: props.video.isSensitive && defaultStore.state.nsfw !== "ignore" : props.video.isSensitive && defaultStore.state.nsfw !== "ignore"
); );
function captionPopup() {
os.alert({
type: "info",
text: props.video.comment
})
}
onMounted(() => { onMounted(() => {
mini.value = plyr.value.player.media.scrollWidth < 300; mini.value = plyr.value.player.media.scrollWidth < 300;
if (mini.value) { if (mini.value) {
@ -87,10 +104,15 @@ onMounted(() => {
position: relative; position: relative;
--plyr-color-main: var(--accent); --plyr-color-main: var(--accent);
> .hide { > .buttons {
display: block; display: flex;
gap: 4px;
position: absolute; position: absolute;
border-radius: 6px; border-radius: 6px;
overflow: hidden;
top: 12px;
right: 12px;
> * {
background-color: var(--accentedBg); background-color: var(--accentedBg);
-webkit-backdrop-filter: var(--blur, blur(15px)); -webkit-backdrop-filter: var(--blur, blur(15px));
backdrop-filter: var(--blur, blur(15px)); backdrop-filter: var(--blur, blur(15px));
@ -98,11 +120,6 @@ onMounted(() => {
font-size: 0.8em; font-size: 0.8em;
padding: 6px 8px; padding: 6px 8px;
text-align: center; text-align: center;
top: 12px;
right: 12px;
> i {
display: block;
} }
} }