frontend/app/components/notes/content-warning.vue

52 lines
1.3 KiB
Vue
Raw Normal View History

2025-04-10 14:48:03 +02:00
<template>
<div class="flex flex-col gap-1">
<p class="text-sm leading-6 wrap-anywhere">
{{ note.spoiler_text || m.sour_seemly_bird_hike() }}
</p>
2025-12-09 22:32:22 +01:00
<Button
@click="hidden = !hidden"
variant="outline"
size="sm"
class="col-span-2"
>
{{ hidden ? m.bald_direct_turtle_win() :
2025-12-09 22:32:22 +01:00
m.known_flaky_cockroach_dash() }}
{{ constructText() }}
</Button>
</div>
2025-04-10 14:48:03 +02:00
</template>
<script lang="ts" setup>
2025-07-16 07:48:39 +02:00
import * as m from "~~/paraglide/messages.js";
2025-04-10 14:48:03 +02:00
import { Button } from "../ui/button";
import { key } from "./provider";
2025-04-10 14:48:03 +02:00
// biome-ignore lint/style/noNonNullAssertion: We want an error if not provided
const { note } = inject(key)!;
const attachmentCount = note.media_attachments.length;
const characterCount = note.text?.length || 0;
2025-04-10 14:48:03 +02:00
const hidden = defineModel<boolean>({
2025-04-10 14:48:03 +02:00
default: true,
});
const constructText = () => {
const parts: string[] = [];
if (characterCount > 0) {
parts.push(
`${characterCount} character${characterCount === 1 ? "" : "s"}`,
);
}
if (attachmentCount > 0) {
parts.push(
`${attachmentCount} file${attachmentCount === 1 ? "" : "s"}`,
);
}
return parts.length > 0 ? ` (${parts.join(" · ")})` : "";
};
2025-04-10 14:48:03 +02:00
</script>