diff --git a/src/app/features/common-settings/appearance/Appearance.tsx b/src/app/features/common-settings/appearance/Appearance.tsx new file mode 100644 index 000000000..4954dc988 --- /dev/null +++ b/src/app/features/common-settings/appearance/Appearance.tsx @@ -0,0 +1,147 @@ +import { useState, type MouseEventHandler } from 'react'; +import { + Box, + Text, + IconButton, + Icon, + Icons, + Scroll, + Button, + config, + Menu, + MenuItem, + PopOut, + type RectCords, +} from 'folds'; +import { Page, PageContent, PageHeader } from '$components/page'; +import { SequenceCard } from '$components/sequence-card'; +import { SettingTile } from '$components/setting-tile'; +import { useRoom } from '$hooks/useRoom'; + +import { SequenceCardStyle } from '$features/common-settings/styles.css'; +import { useShowRoomIcon } from '$hooks/useShowRoomIcon'; +import { useSetting } from '$state/hooks/settings'; +import type { ShowRoomIcon } from '$state/settings'; +import { settingsAtom } from '$state/settings'; +import { stopPropagation } from '$utils/keyboard'; +import FocusTrap from 'focus-trap-react'; + +function SelectShowRoomIcon({roomId}: {roomId: string}) { + const [menuCords, setMenuCords] = useState(); + const showRoomIconItems = useShowRoomIcon(); + const [showRoomIconArray, setShowRoomIconArray] = useSetting(settingsAtom, 'perRoomShowRoomIcon'); + const showRoomIcon = showRoomIconArray.find(item => item.roomId === roomId )?.display; + + const handleMenu: MouseEventHandler = (evt) => { + setMenuCords(evt.currentTarget.getBoundingClientRect()); + }; + + const handleSelect = (position: ShowRoomIcon) => { + const CleanedShowRoomIconArray = showRoomIconArray.filter(item => item.roomId !== roomId ); + const newShowRoomIconArray = [...CleanedShowRoomIconArray, {roomId, display: position}] + setShowRoomIconArray(newShowRoomIconArray); + setMenuCords(undefined); + }; + + return ( + <> + + setMenuCords(undefined), + clickOutsideDeactivates: true, + isKeyForward: (evt: KeyboardEvent) => + evt.key === 'ArrowDown' || evt.key === 'ArrowRight', + isKeyBackward: (evt: KeyboardEvent) => + evt.key === 'ArrowUp' || evt.key === 'ArrowLeft', + escapeDeactivates: stopPropagation, + }} + > + + + {showRoomIconItems.map((item) => ( + handleSelect(item.layout)} + > + {item.name} + + ))} + + + + } + /> + + ); +} + +type AppearanceProps = { + requestClose: () => void; +}; +export function Appearance({ requestClose }: AppearanceProps) { + const room = useRoom(); + + return ( + + + + + + Appearance + + + + + + + + + + + + + + + Visual Tweaks + + } + /> + + + + + + + + ); +} diff --git a/src/app/features/settings/cosmetics/Themes.tsx b/src/app/features/settings/cosmetics/Themes.tsx index e00e5f425..6081accdc 100644 --- a/src/app/features/settings/cosmetics/Themes.tsx +++ b/src/app/features/settings/cosmetics/Themes.tsx @@ -868,7 +868,7 @@ export function Appearance({ } diff --git a/src/app/features/space-settings/SpaceSettings.tsx b/src/app/features/space-settings/SpaceSettings.tsx index d773e5ff8..6479d6de6 100644 --- a/src/app/features/space-settings/SpaceSettings.tsx +++ b/src/app/features/space-settings/SpaceSettings.tsx @@ -17,6 +17,7 @@ import { EmojisStickers } from '$features/common-settings/emojis-stickers'; import { Members } from '$features/common-settings/members'; import { DeveloperTools } from '$features/common-settings/developer-tools'; import { Cosmetics } from '$features/common-settings/cosmetics/Cosmetics'; +import { Appearance } from '$features/common-settings/appearance/Appearance'; import { RoomAbbreviations } from '$features/room-settings/abbreviations/RoomAbbreviations'; import { General } from './general'; import { Permissions } from './permissions'; @@ -67,6 +68,12 @@ const useSpaceSettingsMenuItems = (): SpaceSettingsMenuItem[] => name: 'Developer Tools', icon: Icons.Terminal, }, + { + page: SpaceSettingsPage.AppearancePage, + name: 'Appearance', + icon: Icons.Alphabet, + activeIcon: Icons.AlphabetUnderline, + }, ], [] ); @@ -197,6 +204,9 @@ export function SpaceSettings({ initialPage, requestClose }: SpaceSettingsProps) {activePage === SpaceSettingsPage.AbbreviationsPage && ( )} + {activePage === SpaceSettingsPage.AppearancePage && ( + + )} ); } diff --git a/src/app/pages/client/space/Space.tsx b/src/app/pages/client/space/Space.tsx index e4599c463..0c2e09c7f 100644 --- a/src/app/pages/client/space/Space.tsx +++ b/src/app/pages/client/space/Space.tsx @@ -372,7 +372,7 @@ function SpaceHeader({ hideText, mx }: { hideText?: boolean; mx: MatrixClient }) {hasBanner && ( <> -
+ -
+ )} {hasBanner && bannerViewerOpen && ( @@ -521,10 +521,15 @@ export function Space() { const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth'); const [curWidth, setCurWidth] = useState(roomSidebarWidth); - const [showRoomIcon] = useSetting(settingsAtom, 'showRoomIcon'); + const [showRoomIconGeneral] = useSetting(settingsAtom, 'showRoomIcon'); + + const [showRoomIconArray] = useSetting(settingsAtom, 'perRoomShowRoomIcon'); + // oxlint-disable-next-line no-console + console.log(showRoomIconArray, space.roomId); + const showIcons = () => { - if (showRoomIcon === ShowRoomIcon.Always) return true; - if (showRoomIcon === ShowRoomIcon.Never) return false; + if (showRoomIconGeneral === ShowRoomIcon.Always) return true; + if (showRoomIconGeneral === ShowRoomIcon.Never) return false; return curWidth < 144; }; useEffect(() => { diff --git a/src/app/state/settings.ts b/src/app/state/settings.ts index b1b744c1f..aab58f600 100644 --- a/src/app/state/settings.ts +++ b/src/app/state/settings.ts @@ -28,6 +28,11 @@ export enum ShowRoomIcon { Smart = 'smart', Never = 'never', } +export type PerRoomShowRoomIcon = { + roomId: string; + display: ShowRoomIcon; +}; + export type JumboEmojiSize = 'none' | 'extraSmall' | 'small' | 'normal' | 'large' | 'extraLarge'; export type ThemeRemoteFavorite = { @@ -160,6 +165,7 @@ export interface Settings { mentionInReplies: boolean; showPersonaSetting: boolean; closeFoldersByDefault: boolean; + perRoomShowRoomIcon: PerRoomShowRoomIcon[]; showRoomIcon: ShowRoomIcon; showRoomBanners: boolean; roomSidebarWidth: number; @@ -292,6 +298,7 @@ export const defaultSettings: Settings = { mentionInReplies: true, showPersonaSetting: false, closeFoldersByDefault: false, + perRoomShowRoomIcon: [], showRoomIcon: ShowRoomIcon.Smart, showRoomBanners: true, roomSidebarWidth: 256, diff --git a/src/app/state/spaceSettings.ts b/src/app/state/spaceSettings.ts index c33b5e957..de91d6f3a 100644 --- a/src/app/state/spaceSettings.ts +++ b/src/app/state/spaceSettings.ts @@ -9,6 +9,7 @@ export enum SpaceSettingsPage { // Sable pages CosmeticsPage, AbbreviationsPage, + AppearancePage, } export type SpaceSettingsState = {