2024-11-30 02:19:32 +01:00
|
|
|
<template>
|
2024-12-07 15:21:28 +01:00
|
|
|
<Alert variant="warning" v-if="(sensitive || contentWarning) && showCw.value"
|
2024-12-07 15:16:45 +01:00
|
|
|
class="mb-4 py-2 px-4 grid grid-cols-[auto,1fr,auto] gap-2 items-center [&>svg~*]:pl-0 [&>svg+div]:translate-y-0 [&>svg]:static">
|
2024-12-07 22:17:22 +01:00
|
|
|
<AlertTitle class="sr-only">{{ m.livid_tangy_lionfish_clasp() }}</AlertTitle>
|
2024-12-07 15:16:45 +01:00
|
|
|
<div>
|
|
|
|
|
<TriangleAlert class="size-4" />
|
2024-12-02 19:30:19 +01:00
|
|
|
</div>
|
2024-12-07 15:16:45 +01:00
|
|
|
<AlertDescription>
|
2024-12-07 22:17:22 +01:00
|
|
|
{{ contentWarning || m.sour_seemly_bird_hike() }}
|
2024-12-07 15:16:45 +01:00
|
|
|
</AlertDescription>
|
2024-12-07 22:17:22 +01:00
|
|
|
<Button @click="blurred = !blurred" variant="outline" size="sm">{{ blurred ? m.bald_direct_turtle_win() : m.known_flaky_cockroach_dash() }}</Button>
|
2024-12-07 15:16:45 +01:00
|
|
|
</Alert>
|
|
|
|
|
|
2024-12-07 15:21:28 +01:00
|
|
|
<div ref="container" :class="cn('overflow-y-hidden relative duration-200', (blurred && showCw.value) && 'blur-md')" :style="{
|
2024-12-07 15:16:45 +01:00
|
|
|
maxHeight: collapsed ? '18rem' : `${container?.scrollHeight}px`,
|
|
|
|
|
}">
|
|
|
|
|
<div :class="[
|
|
|
|
|
'prose prose-sm block relative dark:prose-invert duration-200 !max-w-full break-words prose-a:no-underline prose-a:hover:underline',
|
|
|
|
|
$style.content,
|
|
|
|
|
]" v-html="content" v-render-emojis="emojis"></div>
|
2024-12-02 19:30:19 +01:00
|
|
|
<div v-if="isOverflowing && collapsed"
|
2024-12-07 15:16:45 +01:00
|
|
|
class="absolute inset-x-0 bottom-0 h-36 bg-gradient-to-t from-black/5 to-transparent rounded-b"></div>
|
2024-12-02 19:30:19 +01:00
|
|
|
<Button v-if="isOverflowing" @click="collapsed = !collapsed"
|
|
|
|
|
class="absolute bottom-2 right-1/2 translate-x-1/2">{{
|
2024-12-07 15:16:45 +01:00
|
|
|
collapsed
|
2024-12-07 22:17:22 +01:00
|
|
|
? `${m.lazy_honest_mammoth_bump()}${plainContent ? ` • ${m.dark_spare_goldfish_charm({
|
|
|
|
|
count: formattedCharacterCount ?? '0',
|
|
|
|
|
})}` : "" }`
|
|
|
|
|
: m.that_misty_mule_arrive()
|
2024-12-02 19:30:19 +01:00
|
|
|
}}</Button>
|
2024-11-30 02:19:32 +01:00
|
|
|
</div>
|
2024-11-30 16:39:02 +01:00
|
|
|
|
2024-12-07 15:21:28 +01:00
|
|
|
<Attachments v-if="attachments.length > 0" :attachments="attachments" :class="(blurred && showCw.value) && 'blur-xl'" />
|
2024-12-01 17:56:31 +01:00
|
|
|
|
2024-11-30 19:15:23 +01:00
|
|
|
<div v-if="quote" class="mt-4 rounded border overflow-hidden">
|
2024-11-30 16:39:02 +01:00
|
|
|
<Note :note="quote" :hide-actions="true" :small-layout="true" />
|
|
|
|
|
</div>
|
2024-11-30 02:19:32 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2024-12-07 15:16:45 +01:00
|
|
|
import { cn } from "@/lib/utils";
|
2024-12-02 22:21:04 +01:00
|
|
|
import type { Attachment, Emoji, Status } from "@versia/client/types";
|
2024-12-07 15:16:45 +01:00
|
|
|
import { TriangleAlert } from "lucide-vue-next";
|
2024-12-07 15:21:28 +01:00
|
|
|
import { Button } from "~/components/ui/button";
|
2024-12-07 22:17:22 +01:00
|
|
|
import * as m from "~/paraglide/messages.js";
|
2024-12-07 20:24:09 +01:00
|
|
|
import { languageTag } from "~/paraglide/runtime";
|
2024-12-07 15:21:28 +01:00
|
|
|
import { type BooleanSetting, SettingIds } from "~/settings";
|
2024-12-07 15:16:45 +01:00
|
|
|
import { Alert, AlertDescription, AlertTitle } from "../ui/alert";
|
2024-12-01 17:56:31 +01:00
|
|
|
import Attachments from "./attachments.vue";
|
2024-11-30 16:39:02 +01:00
|
|
|
import Note from "./note.vue";
|
|
|
|
|
|
2024-12-07 15:16:45 +01:00
|
|
|
const { content, plainContent, sensitive, contentWarning } = defineProps<{
|
2024-12-02 19:30:19 +01:00
|
|
|
plainContent?: string;
|
2024-11-30 02:19:32 +01:00
|
|
|
content: string;
|
2024-11-30 16:39:02 +01:00
|
|
|
quote?: NonNullable<Status["quote"]>;
|
2024-12-02 22:21:04 +01:00
|
|
|
emojis: Emoji[];
|
2024-12-01 17:56:31 +01:00
|
|
|
attachments: Attachment[];
|
2024-12-07 15:16:45 +01:00
|
|
|
sensitive: boolean;
|
|
|
|
|
contentWarning?: string;
|
2024-11-30 02:19:32 +01:00
|
|
|
}>();
|
2024-12-02 19:30:19 +01:00
|
|
|
const container = ref<HTMLDivElement | null>(null);
|
|
|
|
|
const collapsed = ref(true);
|
2024-12-07 15:16:45 +01:00
|
|
|
const blurred = ref(sensitive || !!contentWarning);
|
2024-12-07 15:21:28 +01:00
|
|
|
const showCw = useSetting(SettingIds.ShowContentWarning) as Ref<BooleanSetting>;
|
2024-12-02 19:30:19 +01:00
|
|
|
|
|
|
|
|
// max-h-72 is 18rem
|
|
|
|
|
const remToPx = (rem: number) =>
|
|
|
|
|
rem *
|
|
|
|
|
Number.parseFloat(
|
|
|
|
|
getComputedStyle(document.documentElement).fontSize || "16px",
|
|
|
|
|
);
|
|
|
|
|
const isOverflowing = computed(() => {
|
|
|
|
|
if (!container.value) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return container.value.scrollHeight > remToPx(18);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const characterCount = plainContent?.length;
|
|
|
|
|
const formattedCharacterCount = characterCount
|
2024-12-07 20:24:09 +01:00
|
|
|
? new Intl.NumberFormat(languageTag()).format(characterCount)
|
2024-12-02 19:30:19 +01:00
|
|
|
: undefined;
|
2024-11-30 02:19:32 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style module>
|
|
|
|
|
.content pre:has(code) {
|
|
|
|
|
word-wrap: normal;
|
|
|
|
|
background: transparent;
|
|
|
|
|
background-color: #ffffff0d;
|
2024-12-07 15:16:45 +01:00
|
|
|
border-radius: 0.25rem;
|
2024-11-30 02:19:32 +01:00
|
|
|
hyphens: none;
|
|
|
|
|
margin-top: 1rem;
|
|
|
|
|
overflow-x: auto;
|
2024-12-07 15:16:45 +01:00
|
|
|
padding: 0.75rem 1rem;
|
2024-11-30 02:19:32 +01:00
|
|
|
tab-size: 4;
|
|
|
|
|
white-space: pre;
|
|
|
|
|
word-break: normal;
|
|
|
|
|
word-spacing: normal;
|
|
|
|
|
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
|
|
|
|
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);
|
|
|
|
|
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), 0 0 #0000;
|
2024-12-07 15:16:45 +01:00
|
|
|
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow),
|
|
|
|
|
var(--tw-shadow, 0 0 #0000);
|
|
|
|
|
--tw-ring-color: hsla(0, 0%, 100%, 0.1);
|
2024-11-30 02:19:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.content pre code {
|
|
|
|
|
display: block;
|
2024-12-07 15:16:45 +01:00
|
|
|
padding: 0;
|
2024-11-30 02:19:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.content code:not(pre code)::after,
|
|
|
|
|
.content code:not(pre code)::before {
|
2024-12-07 15:16:45 +01:00
|
|
|
content: "";
|
2024-11-30 02:19:32 +01:00
|
|
|
}
|
|
|
|
|
|
2024-12-07 15:16:45 +01:00
|
|
|
.content ol li input[type="checkbox"],
|
|
|
|
|
.content ul li input[type="checkbox"] {
|
|
|
|
|
border-radius: 0.25rem;
|
2024-12-02 19:30:19 +01:00
|
|
|
margin-bottom: 0.2rem;
|
2024-12-07 15:16:45 +01:00
|
|
|
margin-right: 0.5rem;
|
2024-12-02 19:30:19 +01:00
|
|
|
margin-top: 0;
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
--tw-text-opacity: 1;
|
|
|
|
|
color: var(--theme-primary-400);
|
2024-11-30 02:19:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.content code:not(pre code) {
|
2024-12-07 15:16:45 +01:00
|
|
|
border-radius: 0.25rem;
|
|
|
|
|
padding: 0.25rem 0.5rem;
|
2024-11-30 02:19:32 +01:00
|
|
|
word-wrap: break-word;
|
|
|
|
|
background: transparent;
|
|
|
|
|
background-color: #ffffff0d;
|
|
|
|
|
hyphens: none;
|
|
|
|
|
margin-top: 1rem;
|
|
|
|
|
tab-size: 4;
|
|
|
|
|
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
|
|
|
|
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);
|
|
|
|
|
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), 0 0 #0000;
|
2024-12-07 15:16:45 +01:00
|
|
|
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow),
|
|
|
|
|
var(--tw-shadow, 0 0 #0000);
|
|
|
|
|
--tw-ring-color: hsla(0, 0%, 100%, 0.1);
|
2024-11-30 02:19:32 +01:00
|
|
|
}
|
2024-12-07 15:16:45 +01:00
|
|
|
</style>
|