From 7ae2b4282f0f2e957bffcf0d9899fa71eedfefe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sun, 28 Apr 2024 22:47:49 +0200 Subject: [PATCH] Fix some settings, move them back to Settings page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- src/actions/settings.ts | 8 +-- src/components/sidebar-navigation-link.tsx | 6 +- src/components/status-action-button.tsx | 5 +- src/components/thumb-navigation-link.tsx | 4 +- src/components/ui/divider/divider.tsx | 2 +- src/features/account/components/header.tsx | 2 +- .../chat-widget/chat-pane-header.tsx | 5 +- src/features/developers/settings-store.tsx | 27 --------- src/features/preferences/index.tsx | 27 +++++++++ src/features/ui/components/profile-stats.tsx | 18 ++++-- src/features/ui/components/user-panel.tsx | 57 ++++++++++--------- src/init/soapbox-head.tsx | 3 +- src/styles/basics.scss | 8 +++ 13 files changed, 101 insertions(+), 71 deletions(-) diff --git a/src/actions/settings.ts b/src/actions/settings.ts index 102cbca19..4be0af0a7 100644 --- a/src/actions/settings.ts +++ b/src/actions/settings.ts @@ -31,10 +31,10 @@ const defaultSettings = ImmutableMap({ underlineLinks: false, autoPlayGif: true, displayMedia: 'default', - unfollowModal: false, + unfollowModal: true, boostModal: false, deleteModal: true, - missingDescriptionModal: false, + missingDescriptionModal: true, defaultPrivacy: 'public', defaultContentType: 'text/plain', themeMode: 'system', @@ -42,8 +42,8 @@ const defaultSettings = ImmutableMap({ showExplanationBox: true, explanationBox: true, autoloadTimelines: true, - autoloadMore: true, - preserveSpoilers: false, + autoloadMore: false, + preserveSpoilers: true, systemFont: false, demetricator: false, diff --git a/src/components/sidebar-navigation-link.tsx b/src/components/sidebar-navigation-link.tsx index 7f3b0306f..201bdd43b 100644 --- a/src/components/sidebar-navigation-link.tsx +++ b/src/components/sidebar-navigation-link.tsx @@ -2,6 +2,8 @@ import clsx from 'clsx'; import React from 'react'; import { NavLink } from 'react-router-dom'; +import { useSettings } from 'soapbox/hooks'; + import { Icon, Text } from './ui'; interface ISidebarNavigationLink { @@ -26,6 +28,8 @@ const SidebarNavigationLink = React.forwardRef((props: ISidebarNavigationLink, r const { icon, activeIcon, text, to = '', count, countMax, onClick } = props; const isActive = location.pathname === to; + const { demetricator } = useSettings(); + const handleClick: React.EventHandler = (e) => { if (onClick) { onClick(e); @@ -55,7 +59,7 @@ const SidebarNavigationLink = React.forwardRef((props: ISidebarNavigationLink, r > = ({ count = 0 }): JSX.Element => { + const { demetricator } = useSettings(); + return ( - {shortNumberFormat(count)} + {demetricator && count > 1 ? '1+' : shortNumberFormat(count)} ); }; diff --git a/src/components/thumb-navigation-link.tsx b/src/components/thumb-navigation-link.tsx index f824392e5..881bb6381 100644 --- a/src/components/thumb-navigation-link.tsx +++ b/src/components/thumb-navigation-link.tsx @@ -4,6 +4,7 @@ import { NavLink, useLocation } from 'react-router-dom'; import IconWithCounter from 'soapbox/components/icon-with-counter'; import { Icon, Text } from 'soapbox/components/ui'; +import { useSettings } from 'soapbox/hooks'; interface IThumbNavigationLink { count?: number; @@ -18,6 +19,7 @@ interface IThumbNavigationLink { const ThumbNavigationLink: React.FC = ({ count, countMax, src, activeSrc, text, to, exact, paths }): JSX.Element => { const { pathname } = useLocation(); + const { demetricator } = useSettings(); const isActive = (): boolean => { if (paths) { @@ -33,7 +35,7 @@ const ThumbNavigationLink: React.FC = ({ count, countMax, return ( - {count !== undefined ? ( + {!demetricator && count !== undefined ? ( ( {text && (
- + {text}
diff --git a/src/features/account/components/header.tsx b/src/features/account/components/header.tsx index 4489c133c..11fb8efde 100644 --- a/src/features/account/components/header.tsx +++ b/src/features/account/components/header.tsx @@ -618,7 +618,7 @@ const Header: React.FC = ({ account }) => { {account.verified && ( diff --git a/src/features/chats/components/chat-widget/chat-pane-header.tsx b/src/features/chats/components/chat-widget/chat-pane-header.tsx index c338c481a..0864434ad 100644 --- a/src/features/chats/components/chat-widget/chat-pane-header.tsx +++ b/src/features/chats/components/chat-widget/chat-pane-header.tsx @@ -1,6 +1,7 @@ import React, { HTMLAttributes } from 'react'; import { HStack, IconButton, Text } from 'soapbox/components/ui'; +import { useSettings } from 'soapbox/hooks'; interface IChatPaneHeader { isOpen: boolean; @@ -24,6 +25,8 @@ const ChatPaneHeader = (props: IChatPaneHeader) => { ...rest } = props; + const { demetricator } = useSettings(); + const ButtonComp = isToggleable ? 'button' : 'div'; const buttonProps: HTMLAttributes = {}; if (isToggleable) { @@ -41,7 +44,7 @@ const ChatPaneHeader = (props: IChatPaneHeader) => { {title} - {(typeof unreadCount !== 'undefined' && unreadCount > 0) && ( + {(!demetricator && typeof unreadCount !== 'undefined' && unreadCount > 0) && ( ({unreadCount}) diff --git a/src/features/developers/settings-store.tsx b/src/features/developers/settings-store.tsx index 4631ca0a7..7115f8303 100644 --- a/src/features/developers/settings-store.tsx +++ b/src/features/developers/settings-store.tsx @@ -109,33 +109,6 @@ const SettingsStore: React.FC = () => { > - - }> - - - - }> - - - - }> - - - - }> - - - - }> - - - - } - hint={} - > - - ); diff --git a/src/features/preferences/index.tsx b/src/features/preferences/index.tsx index 3e2cddcc7..9b432be66 100644 --- a/src/features/preferences/index.tsx +++ b/src/features/preferences/index.tsx @@ -180,6 +180,17 @@ const Preferences = () => { )} + + }> + + + + } + hint={} + > + + @@ -194,6 +205,10 @@ const Preferences = () => { }> + + }> + + @@ -201,6 +216,18 @@ const Preferences = () => { + }> + + + + }> + + + + }> + + + }> diff --git a/src/features/ui/components/profile-stats.tsx b/src/features/ui/components/profile-stats.tsx index 6863f9bd9..2594be0e2 100644 --- a/src/features/ui/components/profile-stats.tsx +++ b/src/features/ui/components/profile-stats.tsx @@ -3,6 +3,7 @@ import { useIntl, defineMessages } from 'react-intl'; import { NavLink } from 'react-router-dom'; import { HStack, Text } from 'soapbox/components/ui'; +import { useSettings } from 'soapbox/hooks'; import { shortNumberFormat } from 'soapbox/utils/numbers'; import type { Account } from 'soapbox/schemas'; @@ -20,6 +21,7 @@ interface IProfileStats { /** Display follower and following counts for an account. */ const ProfileStats: React.FC = ({ account, onClickHandler }) => { const intl = useIntl(); + const { demetricator } = useSettings(); if (!account) { return null; @@ -29,9 +31,11 @@ const ProfileStats: React.FC = ({ account, onClickHandler }) => { - - {shortNumberFormat(account.followers_count)} - + {!demetricator && ( + + {shortNumberFormat(account.followers_count)} + + )} {intl.formatMessage(messages.followers)} @@ -40,9 +44,11 @@ const ProfileStats: React.FC = ({ account, onClickHandler }) => { - - {shortNumberFormat(account.following_count)} - + {!demetricator && ( + + {shortNumberFormat(account.following_count)} + + )} {intl.formatMessage(messages.follows)} diff --git a/src/features/ui/components/user-panel.tsx b/src/features/ui/components/user-panel.tsx index 4d9036966..e21dc482d 100644 --- a/src/features/ui/components/user-panel.tsx +++ b/src/features/ui/components/user-panel.tsx @@ -6,7 +6,7 @@ import { useAccount } from 'soapbox/api/hooks'; import StillImage from 'soapbox/components/still-image'; import { Avatar, HStack, Stack, Text } from 'soapbox/components/ui'; import VerificationBadge from 'soapbox/components/verification-badge'; -import { useAppSelector } from 'soapbox/hooks'; +import { useAppSelector, useSettings } from 'soapbox/hooks'; import { getAcct } from 'soapbox/utils/accounts'; import { shortNumberFormat } from 'soapbox/utils/numbers'; import { displayFqn } from 'soapbox/utils/state'; @@ -20,6 +20,7 @@ interface IUserPanel { const UserPanel: React.FC = ({ accountId, action, badges, domain }) => { const intl = useIntl(); + const { demetricator } = useSettings(); const { account } = useAccount(accountId); const fqn = useAppSelector((state) => displayFqn(state)); @@ -76,33 +77,35 @@ const UserPanel: React.FC = ({ accountId, action, badges, domain }) - - {account.followers_count >= 0 && ( - - - - {shortNumberFormat(account.followers_count)} - - - - - - - )} + {!demetricator && ( + + {account.followers_count >= 0 && ( + + + + {shortNumberFormat(account.followers_count)} + + + + + + + )} - {account.following_count >= 0 && ( - - - - {shortNumberFormat(account.following_count)} - - - - - - - )} - + {account.following_count >= 0 && ( + + + + {shortNumberFormat(account.following_count)} + + + + + + + )} + + )} ); diff --git a/src/init/soapbox-head.tsx b/src/init/soapbox-head.tsx index c4bdd9f9c..9f1c3978e 100644 --- a/src/init/soapbox-head.tsx +++ b/src/init/soapbox-head.tsx @@ -20,7 +20,7 @@ interface ISoapboxHead { /** Injects metadata into site head with Helmet. */ const SoapboxHead: React.FC = ({ children }) => { const { locale, direction } = useLocale(); - const { demo, reduceMotion, underlineLinks, demetricator } = useSettings(); + const { demo, reduceMotion, underlineLinks, demetricator, systemFont } = useSettings(); const soapboxConfig = useSoapboxConfig(); const theme = useTheme(); @@ -31,6 +31,7 @@ const SoapboxHead: React.FC = ({ children }) => { 'no-reduce-motion': !reduceMotion, 'underline-links': underlineLinks, 'demetricator': demetricator, + 'system-font': systemFont, }); useEffect(() => { diff --git a/src/styles/basics.scss b/src/styles/basics.scss index fec5daa0e..de4b56881 100644 --- a/src/styles/basics.scss +++ b/src/styles/basics.scss @@ -31,3 +31,11 @@ noscript { div[data-viewport-type='window'] { position: static !important; } + +body.system-font, body.system-font .font-sans { + font-family: ui-sans-serif, system-ui, -apple-system, sans-serif; +} + +body.system-font .font-mono { + font-family: ui-monospace, mono; +}