RegularToot: support content warning

This commit is contained in:
thislight 2024-11-20 16:24:57 +08:00
parent cff0c2880a
commit 737d63f88a
No known key found for this signature in database
GPG key ID: FCFE5192241CCD4E
3 changed files with 64 additions and 11 deletions

View file

@ -5,6 +5,8 @@ import {
type JSX,
Show,
createRenderEffect,
createSignal,
type Setter,
} from "solid-js";
import tootStyle from "./toot.module.css";
import { formatRelative } from "date-fns";
@ -200,6 +202,11 @@ export function findElementActionable(
return current;
}
function onToggleReveal(setValue: Setter<boolean>, event: Event) {
event.stopPropagation();
setValue((x) => !x);
}
/**
* Component for a toot.
*
@ -239,6 +246,7 @@ const RegularToot: Component<TootCardProps> = (props) => {
const status = () => managed.status;
const toot = () => status().reblog ?? status();
const session = useDefaultSession();
const [reveal, setReveal] = createSignal(false);
css`
.reply-sep {
@ -326,6 +334,10 @@ const RegularToot: Component<TootCardProps> = (props) => {
emojis={toot().emojis}
mentions={toot().mentions}
class={cardStyle.cardNoPad}
sensitive={toot().sensitive}
spoilerText={toot().spoilerText}
reveal={reveal()}
onToggleReveal={[onToggleReveal, setReveal]}
/>
<Show when={toot().card}>
<PreviewCard src={toot().card!} />