From c4881db86c48331f44c10f29ce0c05f090361c56 Mon Sep 17 00:00:00 2001 From: Marie Date: Sun, 31 Oct 2021 18:57:35 +0100 Subject: [PATCH] feat: handle nsfw flag & added monospace font (#258) --- package.json | 1 + src/context/Theme.tsx | 7 ++++++- src/pages/channels/Channel.tsx | 2 +- src/pages/settings/channel/Overview.tsx | 23 ++++++++++++++++++++++- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 21f3b6a7..2b634852 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,7 @@ "@fontsource/space-mono": "^4.4.5", "@fontsource/ubuntu": "^4.4.5", "@fontsource/ubuntu-mono": "^4.4.5", + "@fontsource/jetbrains-mono": "^4.4.5", "@hcaptcha/react-hcaptcha": "^0.3.6", "@preact/preset-vite": "^2.0.0", "@rollup/plugin-replace": "^2.4.2", diff --git a/src/context/Theme.tsx b/src/context/Theme.tsx index 8383b980..49b527f0 100644 --- a/src/context/Theme.tsx +++ b/src/context/Theme.tsx @@ -62,7 +62,8 @@ export type MonospaceFonts = | "Roboto Mono" | "Source Code Pro" | "Space Mono" - | "Ubuntu Mono"; + | "Ubuntu Mono" + | "JetBrains Mono"; export type Theme = { [variable in Variables]: string; @@ -211,6 +212,10 @@ export const MONOSPACE_FONTS: Record< name: "Ubuntu Mono", load: () => import("@fontsource/ubuntu-mono/400.css"), }, + "JetBrains Mono": { + name: "JetBrains Mono", + load: () => import("@fontsource/jetbrains-mono/400.css"), + }, }; export const FONT_KEYS = Object.keys(FONTS).sort(); diff --git a/src/pages/channels/Channel.tsx b/src/pages/channels/Channel.tsx index b9198929..bf1c5f76 100644 --- a/src/pages/channels/Channel.tsx +++ b/src/pages/channels/Channel.tsx @@ -103,7 +103,7 @@ const TextChannel = observer(({ channel }: { channel: ChannelI }) => { !!( (channel.channel_type === "TextChannel" || channel.channel_type === "Group") && - channel.name?.includes("nsfw") + channel.nsfw ) }> { const [name, setName] = useState(channel.name ?? undefined); const [description, setDescription] = useState(channel.description ?? ""); + const [nsfw, setNSFW] = useState(channel.nsfw ?? false); useEffect(() => setName(channel.name ?? undefined), [channel.name]); useEffect( () => setDescription(channel.description ?? ""), [channel.description], ); + useEffect( + () => setNSFW(channel.nsfw ?? false), + [channel.nsfw], + ); const [changed, setChanged] = useState(false); function save() { - const changes: Record = {}; + const changes: Record = {}; if (name !== channel.name) changes.name = name; if (description !== channel.description) changes.description = description; + if (nsfw !== channel.nsfw) + changes.nsfw = nsfw; channel.edit(changes); setChanged(false); @@ -110,6 +118,19 @@ export default observer(({ channel }: Props) => { if (!changed) setChanged(true); }} /> + {channel.channel_type === "VoiceChannel" ? '' : ( + { + setNSFW(nsfwchange); + if (!changed) setChanged(true); + } + } + description="Set this channel to NSFW."> + NSFW + + )}