/** * Renders the "settings" tab of the signed-in user's own profile, where they * change their password and this browser's preferences. * * @module */ import { useState } from "react"; import { Trans } from "@lingui/react/macro"; import type { ColorScheme, StyleName } from "../../../shared/theme.ts"; import type { FeedTab } from "../../config/feedTabs.ts"; import { useTheme } from "../../hooks/theme/useTheme.ts"; import { useDefaultFeedTab } from "../../hooks/feed/useDefaultFeedTab.ts"; import { useSoundsEnabled } from "../../hooks/shared/useSoundsEnabled.ts"; import { previewChime } from "../../utils/shared/sound.ts"; import { Segmented, type SegmentedOption } from "../shared/Segmented.tsx"; import { ChangePasswordModal } from "./ChangePasswordModal.tsx"; import { ProfileSection } from "./ProfileSection.tsx"; import { SettingRow } from "./SettingRow.tsx"; // The styles' names are their own, in every language. const STYLE_OPTIONS: SegmentedOption[] = [ { value: "smooth", label: "Smooth" }, { value: "brutalist", label: "Brutalist" }, { value: "geocities", label: "GeoCities" }, { value: "nyt", label: "Times" }, { value: "kanagawa", label: "Kanagawa" }, { value: "melange", label: "Melange" }, ]; const COLOR_SCHEME_OPTIONS: SegmentedOption[] = [ { value: "auto", label: Auto }, { value: "light", label: Light }, { value: "dark", label: Dark }, ]; const FEED_TAB_OPTIONS: SegmentedOption[] = [ { value: "hot", label: Hot }, { value: "new", label: New }, { value: "journal", label: Journal }, { value: "followed", label: Followed }, ]; const ON_OFF_OPTIONS: SegmentedOption[] = [ { value: true, label: On }, { value: false, label: Off }, ]; /** * Renders the password change, which opens {@link ChangePasswordModal}, and * the style, color scheme, default feed tab and sounds, each stored for this * browser as soon as it is clicked. `UserPublicProfile` renders it on one's * own profile only. */ export function ProfileSettingsTab(): React.JSX.Element { const { style, colorScheme, setStyle, setColorScheme } = useTheme(); const [defaultFeedTab, setDefaultFeedTab] = useDefaultFeedTab(); const [soundsEnabled, setSoundsEnabled] = useSoundsEnabled(); const [changePasswordOpen, setChangePasswordOpen] = useState(false); return ( <> Account}>
Password}>
Appearance}>
Style}> Color scheme}>
Feeds}>
Default tab}>
Notifications}>
Sounds}> { setSoundsEnabled(on); // Let the user hear what they just turned on. if (on) previewChime("notify"); }} />
{changePasswordOpen && ( setChangePasswordOpen(false)} /> )} ); }