diff --git a/src/components/modal/Config.tsx b/src/components/modal/Config.tsx index 4849ec2..b7c39bf 100644 --- a/src/components/modal/Config.tsx +++ b/src/components/modal/Config.tsx @@ -1,6 +1,8 @@ import { createSignal, Show, For, type JSX, batch } from 'solid-js'; import ArrowLeft from 'heroicons/24/outline/arrow-left.svg'; +import ChevronDown from 'heroicons/24/outline/chevron-down.svg'; +import ChevronUp from 'heroicons/24/outline/chevron-up.svg'; import EyeSlash from 'heroicons/24/outline/eye-slash.svg'; import FaceSmile from 'heroicons/24/outline/face-smile.svg'; import PaintBrush from 'heroicons/24/outline/paint-brush.svg'; @@ -10,6 +12,8 @@ import XMark from 'heroicons/24/outline/x-mark.svg'; import BasicModal from '@/components/modal/BasicModal'; import UserNameDisplay from '@/components/UserDisplayName'; +import LazyLoad from '@/components/utils/LazyLoad'; +import usePopup from '@/components/utils/usePopup'; import { colorThemes } from '@/core/colorThemes'; import useConfig, { type Config } from '@/core/useConfig'; import useModalState from '@/hooks/useModalState'; @@ -27,17 +31,62 @@ const BaseUrlRegex = (schemaRegex: string) => const HttpUrlRegex = BaseUrlRegex('https?'); const RelayUrlRegex = BaseUrlRegex('wss?'); +const Section = (props: { title: string; initialOpened?: boolean; children: JSX.Element }) => { + const [opened, setOpened] = createSignal(props.initialOpened ?? true); + const toggleOpened = () => setOpened((current) => !current); + + return ( +
+

+ +

+ +
{props.children}
+
+
+ ); +}; + +const ToggleButton = (props: { + value: boolean; + onClick: JSX.EventHandler; +}) => ( + +); + const ProfileSection = () => { const i18n = useTranslation(); const pubkey = usePubkey(); const { showProfile, showProfileEdit } = useModalState(); return ( -
-

{i18n()('config.profile.profile')}

-
+
+
-
+ ); }; @@ -98,23 +147,10 @@ const RelayConfig = () => { return ( <> -
-

{i18n()('config.relays.relays')}

+

{i18n()('config.relays.numOfRelays', { count: config().relayUrls.length })}

-
    - - {(relayUrl: string) => ( -
  • -
    {relayUrl}
    - -
  • - )} -
    -
{ {i18n()('config.relays.addRelay')}
-
-
-

{i18n()('config.relays.importRelays')}

+
    + + {(relayUrl: string) => ( +
  • +
    {relayUrl}
    + +
  • + )} +
    +
+ +
-
+ ); }; @@ -166,14 +213,13 @@ const ColorThemeConfig = () => { }; return ( -
-

{i18n()('config.display.colorTheme')}

+
{(colorTheme) => (
-
+ ); }; @@ -221,8 +267,7 @@ const DateFormatConfig = () => { }; return ( -
-

{i18n()('config.display.timeNotation')}

+
{({ id, name, example }) => ( @@ -245,29 +290,10 @@ const DateFormatConfig = () => { )}
-
+ ); }; -const ToggleButton = (props: { - value: boolean; - onClick: JSX.EventHandler; -}) => ( - -); - const ReactionConfig = () => { const i18n = useTranslation(); const { config, setConfig } = useConfig(); @@ -287,8 +313,7 @@ const ReactionConfig = () => { }; return ( -
-

{i18n()('config.display.reaction')}

+
{i18n()('config.display.enableEmojiReaction')}
@@ -305,7 +330,7 @@ const ReactionConfig = () => { />
-
+ ); }; @@ -325,21 +350,7 @@ const EmojiConfig = () => { }; return ( -
-

{i18n()('config.customEmoji.customEmoji')}

-
    - - {({ shortcode, url }) => ( -
  • - {shortcode} -
    {shortcode}
    - -
  • - )} -
    -
+
+
    + + {({ shortcode, url }) => { + const [ref, setRef] = createSignal(); + const popup = usePopup(() => ({ + target: ref(), + popup: ( +
    +
    + {shortcode} +
    +
    {shortcode}
    +
    + +
    +
    + ), + })); + + return ( +
  • + + {popup.popup()} +
  • + ); + }} +
    +
+ ); }; @@ -400,8 +454,7 @@ const EmojiImport = () => { }; return ( -
-

{i18n()('config.customEmoji.emojiImport')}

+

{i18n()('config.customEmoji.emojiImportDescription')}