diff --git a/.changeset/add-hidden-events-timeline.md b/.changeset/add-hidden-events-timeline.md new file mode 100644 index 000000000..8f40fa1b6 --- /dev/null +++ b/.changeset/add-hidden-events-timeline.md @@ -0,0 +1,22 @@ +--- +default: minor +--- + +Added more hidden timeline events with settings and rendering. + +#### Settings + +- Added a master Show Hidden Events toggle with per-type sub-toggles for message edits, redactions, reactions, and other unrecognized events +- Sub-toggles stay visible beneath the master toggle and are disabled while hidden events are off + +#### Timeline rendering + +- Show message edits as timeline events with reply navigation and an inline word/line diff between versions +- Show reactions, message redactions, and reaction redactions as timeline events +- Keep redacted reactions in the timeline as tombstones with redaction events linking back to them when possible +- Improve reply-chip previews for edits, redactions, reactions, and redacted targets + +#### Safeguards + +- Hide forward, delete, and other message actions on timeline meta events that cannot be forwarded or meaningfully deleted +- Disallow forwarding deleted messages and other non-message event types diff --git a/.changeset/add-reaction-list-shortcut.md b/.changeset/add-reaction-list-shortcut.md new file mode 100644 index 000000000..5583390b8 --- /dev/null +++ b/.changeset/add-reaction-list-shortcut.md @@ -0,0 +1,5 @@ +--- +default: minor +--- + +Added an inline add-reaction button at the end of message reaction lists. diff --git a/.changeset/add_polls.md b/.changeset/add_polls.md index 62873f7fd..f956f30ba 100644 --- a/.changeset/add_polls.md +++ b/.changeset/add_polls.md @@ -4,10 +4,10 @@ default: minor Add polls! -## Add Polls with a new Menu for adding items +#### Add Polls with a new Menu for adding items - - The polls have a simple style for showing and interfacing with poll events - - There is now a simple interface for creating polls which integrates the spec - - Now the Plus button on the bottom left can open a menu for selecting what to send, which will be useful for future options aswell - - For the people that prefer to only add files with that button they can disable the menu and still create polls with the /poll command - - You can see who voted for what in a clear menu +- The polls have a simple style for showing and interfacing with poll events +- There is now a simple interface for creating polls which integrates the spec +- Now the Plus button on the bottom left can open a menu for selecting what to send, which will be useful for future options as well +- For the people that prefer to only add files with that button they can disable the menu and still create polls with the /poll command +- You can see who voted for what in a clear menu diff --git a/.changeset/migrate-timeline-composer-phosphor-icons.md b/.changeset/migrate-timeline-composer-phosphor-icons.md new file mode 100644 index 000000000..bac94091c --- /dev/null +++ b/.changeset/migrate-timeline-composer-phosphor-icons.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Migrated all icons to Phosphor Icons and added a setting to display globe/lock icon instead of the hash tag for the room sidebar. diff --git a/src/app/components/AccountDataEditor.tsx b/src/app/components/AccountDataEditor.tsx index 131ae7fab..90ed7907c 100644 --- a/src/app/components/AccountDataEditor.tsx +++ b/src/app/components/AccountDataEditor.tsx @@ -3,8 +3,6 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { Box, Text, - Icon, - Icons, IconButton, Input, Button, @@ -15,6 +13,7 @@ import { Scroll, config, } from 'folds'; +import { ArrowLeft, composerIcon, sizedIcon, X } from '$components/icons/phosphor'; import type { MatrixError } from '$types/matrix-sdk'; import { Cursor } from '$plugins/text-area'; import { syntaxErrorPosition } from '$utils/dom'; @@ -289,14 +288,14 @@ export function AccountDataEditor({ size="500" radii="Pill" onClick={requestClose} - before={} + before={sizedIcon(ArrowLeft, '100')} > Developer Tools - + {composerIcon(X)} diff --git a/src/app/components/BackupRestore.tsx b/src/app/components/BackupRestore.tsx index 74f365eea..a16ed784d 100644 --- a/src/app/components/BackupRestore.tsx +++ b/src/app/components/BackupRestore.tsx @@ -9,9 +9,7 @@ import { Button, color, config, - Icon, IconButton, - Icons, Menu, percent, PopOut, @@ -30,6 +28,12 @@ import { } from '$hooks/useKeyBackup'; import { stopPropagation } from '$utils/keyboard'; import { useRestoreBackupOnVerification } from '$hooks/useRestoreBackupOnVerification'; +import { + Download, + DotsThreeOutlineVerticalIcon, + sizedIcon, + menuIcon, +} from '$components/icons/phosphor'; import { InfoCard } from './info-card'; type BackupStatusProps = { @@ -184,7 +188,7 @@ export function BackupRestoreTile({ crypto }: BackupRestoreTileProps) { radii="300" onClick={handleMenu} > - + {menuIcon(DotsThreeOutlineVerticalIcon, { weight: menuCords ? 'fill' : 'regular' })} } + before={sizedIcon(Download, '100')} > Restore Backup diff --git a/src/app/components/DefaultErrorPage.tsx b/src/app/components/DefaultErrorPage.tsx index 62042cef1..714565702 100644 --- a/src/app/components/DefaultErrorPage.tsx +++ b/src/app/components/DefaultErrorPage.tsx @@ -1,11 +1,12 @@ -import { Box, Button, Dialog, Icon, Icons, Text, color, config } from 'folds'; +import { Box, Button, Dialog, Text, color, config } from 'folds'; +import { Warning, sizedIcon } from '$components/icons/phosphor'; import * as Sentry from '@sentry/react'; import { SplashScreen } from '$components/splash-screen'; import { buildGitHubUrl } from '$features/bug-report/BugReportModal'; type ErrorPageProps = { error: Error; - /** Sentry event ID — present when Sentry.ErrorBoundary captured the crash */ + /** Sentry event ID  Epresent when Sentry.ErrorBoundary captured the crash */ eventId?: string; }; @@ -48,12 +49,7 @@ export function ErrorPage({ error, eventId }: ErrorPageProps) { - + {sizedIcon(Warning, '300', { filled: true, style: { color: color.Critical.Main } })} Oops! Something went wrong diff --git a/src/app/components/DeviceVerification.tsx b/src/app/components/DeviceVerification.tsx index aedfe8e1e..cbe8fbe5a 100644 --- a/src/app/components/DeviceVerification.tsx +++ b/src/app/components/DeviceVerification.tsx @@ -8,15 +8,14 @@ import { config, Dialog, Header, - Icon, IconButton, - Icons, Overlay, OverlayBackdrop, OverlayCenter, Spinner, Text, } from 'folds'; +import { composerIcon, X } from '$components/icons/phosphor'; import FocusTrap from 'focus-trap-react'; import * as Sentry from '@sentry/react'; import { @@ -273,7 +272,7 @@ export function DeviceVerification({ request, onExit }: DeviceVerificationProps) Device Verification - + {composerIcon(X)} diff --git a/src/app/components/DeviceVerificationSetup.tsx b/src/app/components/DeviceVerificationSetup.tsx index 34bfa8d90..9f4717dd2 100644 --- a/src/app/components/DeviceVerificationSetup.tsx +++ b/src/app/components/DeviceVerificationSetup.tsx @@ -1,19 +1,7 @@ import type { FormEventHandler } from 'react'; import { forwardRef, useCallback, useState } from 'react'; -import { - Dialog, - Header, - Box, - Text, - IconButton, - Icon, - Icons, - config, - Button, - Chip, - color, - Spinner, -} from 'folds'; +import { Dialog, Header, Box, Text, IconButton, config, Button, Chip, color, Spinner } from 'folds'; +import { composerIcon, X } from '$components/icons/phosphor'; import FileSaver from 'file-saver'; import to from 'await-to-js'; import type { AuthDict, IAuthData, UIAuthCallback } from '$types/matrix-sdk'; @@ -304,7 +292,7 @@ export const DeviceVerificationSetup = forwardRefSetup Device Verification - + {composerIcon(X)} @@ -339,7 +327,7 @@ export const DeviceVerificationReset = forwardRefReset Device Verification - + {composerIcon(X)} {reset ? ( diff --git a/src/app/components/IncomingCallModal.tsx b/src/app/components/IncomingCallModal.tsx index 9652adf5d..c61cbe023 100644 --- a/src/app/components/IncomingCallModal.tsx +++ b/src/app/components/IncomingCallModal.tsx @@ -3,8 +3,6 @@ import { Dialog, Header, IconButton, - Icon, - Icons, Text, Button, Avatar, @@ -29,6 +27,7 @@ import { } from '$state/callEmbed'; import { createDebugLogger } from '$utils/debugLogger'; import { RoomAvatar } from './room-avatar'; +import { composerIcon, menuIcon, Phone, userFallbackIcon, X } from '$components/icons/phosphor'; const debugLog = createDebugLogger('IncomingCall'); @@ -85,7 +84,7 @@ export function IncomingCallInternal({ room, onClose }: IncomingCallInternalProp Incoming Call - + {composerIcon(X)} @@ -95,7 +94,7 @@ export function IncomingCallInternal({ room, onClose }: IncomingCallInternalProp roomId={room.roomId} src={avatarUrl ?? undefined} alt={roomName} - renderFallback={() => } + renderFallback={() => userFallbackIcon('lg')} /> @@ -122,7 +121,7 @@ export function IncomingCallInternal({ room, onClose }: IncomingCallInternalProp variant="Primary" style={{ minWidth: '110px' }} onClick={handleAnswer} - before={} + before={menuIcon(Phone)} > Answer diff --git a/src/app/components/JoinRulesSwitcher.tsx b/src/app/components/JoinRulesSwitcher.tsx index 970e7bb80..c5e50e91d 100644 --- a/src/app/components/JoinRulesSwitcher.tsx +++ b/src/app/components/JoinRulesSwitcher.tsx @@ -1,26 +1,27 @@ import type { MouseEventHandler } from 'react'; import { useCallback, useMemo, useState } from 'react'; -import type { IconSrc, RectCords } from 'folds'; -import { config, Box, MenuItem, Text, Icon, Icons, PopOut, Menu, Button, Spinner } from 'folds'; +import type { RectCords } from 'folds'; +import { config, Box, MenuItem, Text, PopOut, Menu, Button, Spinner } from 'folds'; import { JoinRule } from '$types/matrix-sdk'; import FocusTrap from 'focus-trap-react'; import { stopPropagation } from '$utils/keyboard'; -import { getRoomIconSrc } from '$utils/room'; +import { CaretDown, sizedIcon } from '$components/icons/phosphor'; +import { getRoomIconComponent, type RoomPhosphorIcon } from '$components/icons/roomIcons'; export type ExtraJoinRules = 'knock_restricted'; export type ExtendedJoinRules = JoinRule | ExtraJoinRules; -type JoinRuleIcons = Record; +type JoinRuleIcons = Record; export const useJoinRuleIcons = (roomType?: string): JoinRuleIcons => useMemo( () => ({ - [JoinRule.Invite]: getRoomIconSrc(Icons, roomType, JoinRule.Invite), - [JoinRule.Knock]: getRoomIconSrc(Icons, roomType, JoinRule.Knock), - knock_restricted: getRoomIconSrc(Icons, roomType, JoinRule.Restricted), - [JoinRule.Restricted]: getRoomIconSrc(Icons, roomType, JoinRule.Restricted), - [JoinRule.Public]: getRoomIconSrc(Icons, roomType, JoinRule.Public), - [JoinRule.Private]: getRoomIconSrc(Icons, roomType, JoinRule.Private), + [JoinRule.Invite]: getRoomIconComponent(roomType, JoinRule.Invite), + [JoinRule.Knock]: getRoomIconComponent(roomType, JoinRule.Knock), + knock_restricted: getRoomIconComponent(roomType, JoinRule.Restricted), + [JoinRule.Restricted]: getRoomIconComponent(roomType, JoinRule.Restricted), + [JoinRule.Public]: getRoomIconComponent(roomType, JoinRule.Public), + [JoinRule.Private]: getRoomIconComponent(roomType, JoinRule.Private), }), [roomType] ); @@ -97,7 +98,7 @@ export function JoinRulesSwitcher({ radii="300" aria-pressed={value === rule} onClick={() => handleChange(rule)} - before={} + before={sizedIcon(icons[rule], '100')} disabled={disabled} > @@ -116,12 +117,12 @@ export function JoinRulesSwitcher({ fill="Soft" radii="300" outlined - before={} + before={sizedIcon(icons[value] ?? icons[JoinRule.Restricted], '100')} after={ changing ? ( ) : ( - + sizedIcon(CaretDown, '100') ) } onClick={handleOpenMenu} diff --git a/src/app/components/ManualVerification.tsx b/src/app/components/ManualVerification.tsx index b0874622f..dcd4075e9 100644 --- a/src/app/components/ManualVerification.tsx +++ b/src/app/components/ManualVerification.tsx @@ -1,7 +1,8 @@ import type { MouseEventHandler, ReactNode } from 'react'; import { useCallback, useState } from 'react'; import type { RectCords } from 'folds'; -import { Box, Text, Chip, Icon, Icons, PopOut, Menu, config, MenuItem, color } from 'folds'; +import { Box, Text, Chip, PopOut, Menu, config, MenuItem, color } from 'folds'; +import { CaretDown, sizedIcon } from '$components/icons/phosphor'; import FocusTrap from 'focus-trap-react'; import type { SecretStorageKeyContent } from '$types/matrix/accountData'; import { storePrivateKey } from '$client/secretStorageKeys'; @@ -41,7 +42,7 @@ export function ManualVerificationMethodSwitcher({ variant="Secondary" fill="Soft" radii="Pill" - before={} + before={sizedIcon(CaretDown, '100')} onClick={handleMenu} > diff --git a/src/app/components/Pdf-viewer/PdfViewer.tsx b/src/app/components/Pdf-viewer/PdfViewer.tsx index dbd95ef46..00cba56fc 100644 --- a/src/app/components/Pdf-viewer/PdfViewer.tsx +++ b/src/app/components/Pdf-viewer/PdfViewer.tsx @@ -7,9 +7,7 @@ import { Button, Chip, Header, - Icon, IconButton, - Icons, Input, Menu, PopOut, @@ -19,6 +17,16 @@ import { as, config, } from 'folds'; +import { + ArrowLeft, + CaretLeft, + CaretRight, + Download, + Minus, + Plus, + Warning, + sizedIcon, +} from '$components/icons/phosphor'; import FocusTrap from 'focus-trap-react'; import FileSaver from 'file-saver'; import { AsyncStatus } from '$hooks/useAsyncCallback'; @@ -120,7 +128,7 @@ export const PdfViewer = as<'div', PdfViewerProps>(
- + {sizedIcon(ArrowLeft, '50')} {name} @@ -135,7 +143,7 @@ export const PdfViewer = as<'div', PdfViewerProps>( onClick={zoomOut} aria-label="Zoom Out" > - + {sizedIcon(Minus, '50')} setZoom(zoom === 1 ? 2 : 1)}> {Math.round(zoom * 100)}% @@ -148,13 +156,13 @@ export const PdfViewer = as<'div', PdfViewerProps>( onClick={zoomIn} aria-label="Zoom In" > - + {sizedIcon(Plus, '50')} } + before={sizedIcon(Download, '50')} > Download @@ -170,7 +178,7 @@ export const PdfViewer = as<'div', PdfViewerProps>( fill="Soft" size="300" radii="300" - before={} + before={sizedIcon(Warning, '50')} onClick={loadPdfJS} > Retry @@ -201,7 +209,7 @@ export const PdfViewer = as<'div', PdfViewerProps>( } + before={sizedIcon(CaretLeft, '50')} onClick={handlePrevPage} aria-disabled={pageNo <= 1} > @@ -263,7 +271,7 @@ export const PdfViewer = as<'div', PdfViewerProps>( } + after={sizedIcon(CaretRight, '50')} onClick={handleNextPage} aria-disabled={pageNo >= docState.data.numPages} > diff --git a/src/app/components/RoomNotificationSwitcher.tsx b/src/app/components/RoomNotificationSwitcher.tsx index ca2a0cc04..a585f7cb4 100644 --- a/src/app/components/RoomNotificationSwitcher.tsx +++ b/src/app/components/RoomNotificationSwitcher.tsx @@ -1,9 +1,9 @@ -import { Box, Icon, Text } from 'folds'; +import { Box, Text } from 'folds'; import type { ReactNode } from 'react'; import { type MouseEventHandler } from 'react'; import { SettingMenuSelector, type SettingMenuOption } from '$components/setting-menu-selector'; import { - getRoomNotificationModeIcon, + roomNotificationModeIcon, RoomNotificationMode, useSetRoomNotificationPreference, } from '$hooks/useRoomsNotificationPreferences'; @@ -61,7 +61,7 @@ export function RoomNotificationModeSwitcher({ gap="200" style={option.value === RoomNotificationMode.Unset ? { minHeight: '48px' } : undefined} > - + {roomNotificationModeIcon(option.value, { weight: selected ? 'fill' : 'regular' })} {selected ? {option.label} : option.label} {option.description && ( diff --git a/src/app/components/SwipeableMessageWrapper.tsx b/src/app/components/SwipeableMessageWrapper.tsx index 58fc9293e..cc4bade93 100644 --- a/src/app/components/SwipeableMessageWrapper.tsx +++ b/src/app/components/SwipeableMessageWrapper.tsx @@ -3,7 +3,8 @@ import { useDrag } from '@use-gesture/react'; import type { ReactNode } from 'react'; import { useMemo, useState } from 'react'; import { useAtomValue } from 'jotai'; -import { config, Icon, Icons } from 'folds'; +import { config } from 'folds'; +import { ArrowBendUpRightIcon, PHOSPHOR_SIZE } from '$components/icons/phosphor'; import { mobileOrTablet } from '$utils/user-agent'; import { RightSwipeAction, settingsAtom } from '$state/settings'; @@ -49,9 +50,8 @@ function ActiveSwipeWrapper({ children, onReply }: { children: ReactNode; onRepl }} > - - + {sizedIcon(X, '50')} )} diff --git a/src/app/components/create-room/AdditionalCreatorInput.tsx b/src/app/components/create-room/AdditionalCreatorInput.tsx index 1ac523a4d..c7b7710d3 100644 --- a/src/app/components/create-room/AdditionalCreatorInput.tsx +++ b/src/app/components/create-room/AdditionalCreatorInput.tsx @@ -4,8 +4,6 @@ import { Button, Chip, config, - Icon, - Icons, Input, Line, Menu, @@ -15,6 +13,7 @@ import { Text, toRem, } from 'folds'; +import { Plus, X, sizedIcon } from '$components/icons/phosphor'; import { isKeyHotkey } from 'is-hotkey'; import FocusTrap from 'focus-trap-react'; import { getMxIdServer } from '$utils/mxIdHelper'; @@ -161,7 +160,7 @@ export function AdditionalCreatorInput({ key={creator} variant="Secondary" radii="Pill" - after={} + after={sizedIcon(X, '50')} onClick={() => onRemove(creator)} disabled={disabled} > @@ -284,7 +283,7 @@ export function AdditionalCreatorInput({ aria-pressed={!!menuCords} disabled={disabled} > - + {sizedIcon(Plus, '50')} diff --git a/src/app/components/create-room/CreateRoomAccessSelector.tsx b/src/app/components/create-room/CreateRoomAccessSelector.tsx index 3a2eeaf8e..ba115055a 100644 --- a/src/app/components/create-room/CreateRoomAccessSelector.tsx +++ b/src/app/components/create-room/CreateRoomAccessSelector.tsx @@ -1,5 +1,6 @@ -import type { IconSrc } from 'folds'; -import { Box, Text, Icon, Icons, config } from 'folds'; +import type { ReactNode } from 'react'; +import { Box, Text, config } from 'folds'; +import { Check, sizedIcon } from '$components/icons/phosphor'; import { SequenceCard } from '$components/sequence-card'; import { SettingTile } from '$components/setting-tile'; import { CreateRoomAccess } from './types'; @@ -9,7 +10,7 @@ type CreateRoomAccessSelectorProps = { onSelect: (value: CreateRoomAccess) => void; canRestrict?: boolean; disabled?: boolean; - getIcon: (access: CreateRoomAccess) => IconSrc; + getIcon: (access: CreateRoomAccess) => ReactNode; }; export function CreateRoomAccessSelector({ value, @@ -33,8 +34,8 @@ export function CreateRoomAccessSelector({ disabled={disabled} > } - after={value === CreateRoomAccess.Restricted && } + before={getIcon(CreateRoomAccess.Restricted)} + after={value === CreateRoomAccess.Restricted && sizedIcon(Check)} > Restricted @@ -55,8 +56,8 @@ export function CreateRoomAccessSelector({ disabled={disabled} > } - after={value === CreateRoomAccess.Private && } + before={getIcon(CreateRoomAccess.Private)} + after={value === CreateRoomAccess.Private && sizedIcon(Check)} > Private @@ -76,8 +77,8 @@ export function CreateRoomAccessSelector({ disabled={disabled} > } - after={value === CreateRoomAccess.Public && } + before={getIcon(CreateRoomAccess.Public)} + after={value === CreateRoomAccess.Public && sizedIcon(Check)} > Public diff --git a/src/app/components/create-room/CreateRoomAliasInput.tsx b/src/app/components/create-room/CreateRoomAliasInput.tsx index f1d798307..bc5d12e2f 100644 --- a/src/app/components/create-room/CreateRoomAliasInput.tsx +++ b/src/app/components/create-room/CreateRoomAliasInput.tsx @@ -1,7 +1,8 @@ import type { FormEventHandler, KeyboardEventHandler } from 'react'; import { useCallback, useEffect, useRef, useState } from 'react'; import { MatrixError } from '$types/matrix-sdk'; -import { Box, color, Icon, Icons, Input, Spinner, Text, toRem } from 'folds'; +import { Box, color, Input, Spinner, Text, toRem } from 'folds'; +import { Hash, Warning, sizedIcon } from '$components/icons/phosphor'; import { isKeyHotkey } from 'is-hotkey'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { replaceSpaceWithDash } from '$utils/common'; @@ -84,7 +85,7 @@ export function CreateRoomAliasInput({ disabled }: { disabled?: boolean }) { aliasAvail.status === AsyncStatus.Loading ? ( ) : ( - + sizedIcon(Hash, '100') ) } after={ @@ -102,7 +103,7 @@ export function CreateRoomAliasInput({ disabled }: { disabled?: boolean }) { /> {aliasAvailable === false && ( - + {sizedIcon(Warning, '50', { filled: true })} This address is already taken. Please select a different one. diff --git a/src/app/components/create-room/CreateRoomTypeSelector.tsx b/src/app/components/create-room/CreateRoomTypeSelector.tsx index 14fe06f7c..6ab26d7c1 100644 --- a/src/app/components/create-room/CreateRoomTypeSelector.tsx +++ b/src/app/components/create-room/CreateRoomTypeSelector.tsx @@ -1,5 +1,6 @@ -import type { IconSrc } from 'folds'; -import { Box, Text, Icon, Icons, config } from 'folds'; +import type { ReactNode } from 'react'; +import { Box, Text, config } from 'folds'; +import { Check, sizedIcon } from '$components/icons/phosphor'; import { SequenceCard } from '$components/sequence-card'; import { SettingTile } from '$components/setting-tile'; import { BetaNoticeBadge } from '$components/BetaNoticeBadge'; @@ -9,7 +10,7 @@ type CreateRoomTypeSelectorProps = { value?: CreateRoomType; onSelect: (value: CreateRoomType) => void; disabled?: boolean; - getIcon: (type: CreateRoomType) => IconSrc; + getIcon: (type: CreateRoomType) => ReactNode; }; export function CreateRoomTypeSelector({ value, @@ -31,8 +32,8 @@ export function CreateRoomTypeSelector({ disabled={disabled} > } - after={value === CreateRoomType.TextRoom && } + before={getIcon(CreateRoomType.TextRoom)} + after={value === CreateRoomType.TextRoom && sizedIcon(Check)} > @@ -56,8 +57,8 @@ export function CreateRoomTypeSelector({ disabled={disabled} > } - after={value === CreateRoomType.VoiceRoom && } + before={getIcon(CreateRoomType.VoiceRoom)} + after={value === CreateRoomType.VoiceRoom && sizedIcon(Check)} > diff --git a/src/app/components/create-room/RoomVersionSelector.tsx b/src/app/components/create-room/RoomVersionSelector.tsx index dae1f0965..1f7179d88 100644 --- a/src/app/components/create-room/RoomVersionSelector.tsx +++ b/src/app/components/create-room/RoomVersionSelector.tsx @@ -1,7 +1,8 @@ import type { MouseEventHandler } from 'react'; import { useState } from 'react'; import type { RectCords } from 'folds'; -import { Box, Button, Chip, config, Icon, Icons, Menu, PopOut, Text, toRem } from 'folds'; +import { Box, Button, Chip, config, Menu, PopOut, Text, toRem } from 'folds'; +import { CaretDown, CaretUp, sizedIcon } from '$components/icons/phosphor'; import FocusTrap from 'focus-trap-react'; import { stopPropagation } from '$utils/keyboard'; import { SettingTile } from '$components/setting-tile'; @@ -94,7 +95,7 @@ export function RoomVersionSelector({ fill="Soft" radii="300" aria-pressed={!!menuCords} - before={} + before={sizedIcon(menuCords ? CaretUp : CaretDown, '50')} disabled={disabled} > {value} diff --git a/src/app/components/direct-invite-prompt/DirectInvitePrompt.tsx b/src/app/components/direct-invite-prompt/DirectInvitePrompt.tsx index fbb83a864..f17c4d113 100644 --- a/src/app/components/direct-invite-prompt/DirectInvitePrompt.tsx +++ b/src/app/components/direct-invite-prompt/DirectInvitePrompt.tsx @@ -4,9 +4,7 @@ import { Button, Dialog, Header, - Icon, IconButton, - Icons, Overlay, OverlayBackdrop, OverlayCenter, @@ -15,6 +13,7 @@ import { color, config, } from 'folds'; +import { composerIcon, X } from '$components/icons/phosphor'; import { stopPropagation } from '$utils/keyboard'; type DirectInvitePromptProps = { @@ -56,7 +55,7 @@ export function DirectInvitePrompt({ Invite another Member - + {composerIcon(X)}
diff --git a/src/app/components/editor/MarkdownToolbar.tsx b/src/app/components/editor/MarkdownToolbar.tsx index 64ebd6e60..aea81d105 100644 --- a/src/app/components/editor/MarkdownToolbar.tsx +++ b/src/app/components/editor/MarkdownToolbar.tsx @@ -1,12 +1,10 @@ import FocusTrap from 'focus-trap-react'; -import type { IconSrc, RectCords } from 'folds'; +import type { RectCords } from 'folds'; import { Badge, Box, config, - Icon, IconButton, - Icons, Line, Menu, PopOut, @@ -32,6 +30,26 @@ import { INLINE_HOTKEYS, } from './keyboard'; import * as css from './Editor.css'; +import { + CaretDown, + Code, + CodeBlock, + composerIcon, + EyeSlash, + sizedIcon, + ListBullets, + ListNumbers, + Quotes, + TextAa, + TextB, + TextHOne, + TextHThree, + TextHTwo, + TextItalic, + TextStrikethrough, + TextUnderline, + type PhosphorIcon, +} from '$components/icons/phosphor'; function BtnTooltip({ text, shortCode }: { text: string; shortCode?: string }) { return ( @@ -52,7 +70,7 @@ function BtnTooltip({ text, shortCode }: { text: string; shortCode?: string }) { type MarkdownInlineButtonProps = { marker: string; - icon: IconSrc; + icon: PhosphorIcon; tooltip: ReactNode; }; @@ -74,7 +92,7 @@ function MarkdownInlineButton({ marker, icon, tooltip }: MarkdownInlineButtonPro size="400" radii="300" > - + {sizedIcon(icon, '200')} )} @@ -83,7 +101,7 @@ function MarkdownInlineButton({ marker, icon, tooltip }: MarkdownInlineButtonPro type MarkdownBlockButtonProps = { prefix: string; - icon: IconSrc; + icon: PhosphorIcon; tooltip: ReactNode; }; @@ -105,7 +123,7 @@ function MarkdownBlockButton({ prefix, icon, tooltip }: MarkdownBlockButtonProps size="400" radii="300" > - + {sizedIcon(icon, '200')} )} @@ -157,7 +175,7 @@ function MarkdownHeadingButton() { size="400" radii="300" > - + {sizedIcon(TextHOne, '200')} )} @@ -172,7 +190,7 @@ function MarkdownHeadingButton() { size="400" radii="300" > - + {sizedIcon(TextHTwo, '200')} )} @@ -187,7 +205,7 @@ function MarkdownHeadingButton() { size="400" radii="300" > - + {sizedIcon(TextHThree, '200')} )} @@ -205,8 +223,8 @@ function MarkdownHeadingButton() { aria-haspopup="menu" aria-expanded={!!anchor} > - - + {sizedIcon(TextHOne, '200')} + {sizedIcon(CaretDown, '200')}
); @@ -222,32 +240,32 @@ export function MarkdownToolbar() { } /> } /> } /> } /> } /> } /> @@ -255,22 +273,22 @@ export function MarkdownToolbar() { } /> } /> } /> } /> @@ -310,7 +328,7 @@ export function MarkdownFormattingToolbarToggle({ aria-label={composerToolbarOpen ? 'Hide formatting toolbar' : 'Show formatting toolbar'} onClick={() => setComposerToolbarOpen(!composerToolbarOpen)} > - + {composerToolbarOpen ? composerIcon(TextUnderline) : composerIcon(TextAa)} ); } diff --git a/src/app/components/editor/autocomplete/RoomMentionAutocomplete.tsx b/src/app/components/editor/autocomplete/RoomMentionAutocomplete.tsx index b7b935f6f..dae946965 100644 --- a/src/app/components/editor/autocomplete/RoomMentionAutocomplete.tsx +++ b/src/app/components/editor/autocomplete/RoomMentionAutocomplete.tsx @@ -2,7 +2,8 @@ import type { KeyboardEvent as ReactKeyboardEvent } from 'react'; import { useCallback, useEffect, useMemo } from 'react'; import type { Editor } from 'slate'; import { ReactEditor } from 'slate-react'; -import { Avatar, Icon, Icons, MenuItem, Text } from 'folds'; +import { Avatar, MenuItem, Text } from 'folds'; +import { Hash, sizedIcon } from '$components/icons/phosphor'; import type { MatrixClient } from '$types/matrix-sdk'; import { JoinRule } from '$types/matrix-sdk'; import { useAtomValue } from 'jotai'; @@ -49,11 +50,7 @@ function UnknownRoomMentionItem({ radii="300" onKeyDown={(evt: ReactKeyboardEvent) => onTabPress(evt, handleSelect)} onClick={handleSelect} - before={ - - - - } + before={{sizedIcon(Hash, '100')}} > {roomAlias} diff --git a/src/app/components/editor/autocomplete/UserMentionAutocomplete.tsx b/src/app/components/editor/autocomplete/UserMentionAutocomplete.tsx index 61a587e26..4afd29495 100644 --- a/src/app/components/editor/autocomplete/UserMentionAutocomplete.tsx +++ b/src/app/components/editor/autocomplete/UserMentionAutocomplete.tsx @@ -2,7 +2,8 @@ import type { KeyboardEvent as ReactKeyboardEvent } from 'react'; import { useEffect } from 'react'; import type { Editor } from 'slate'; import { ReactEditor } from 'slate-react'; -import { Avatar, Icon, Icons, MenuItem, Text } from 'folds'; +import { Avatar, MenuItem, Text } from 'folds'; +import { userFallbackIcon } from '$components/icons/phosphor'; import type { MatrixClient, Room, RoomMember } from '$types/matrix-sdk'; import { useRoomMembers } from '$hooks/useRoomMembers'; @@ -55,10 +56,7 @@ function UnknownMentionItem({ onClick={() => handleAutocomplete(userId, name)} before={ - } - /> + userFallbackIcon('sm')} /> } > @@ -198,7 +196,7 @@ export function UserMentionAutocomplete({ userId={roomMember.userId} src={avatarUrl ?? undefined} alt={getName(roomMember)} - renderFallback={() => } + renderFallback={() => userFallbackIcon('sm')} /> } diff --git a/src/app/components/emoji-board/EmojiBoard.tsx b/src/app/components/emoji-board/EmojiBoard.tsx index d209b2d0a..b9a625b04 100644 --- a/src/app/components/emoji-board/EmojiBoard.tsx +++ b/src/app/components/emoji-board/EmojiBoard.tsx @@ -6,7 +6,8 @@ import type { RefObject, } from 'react'; import { useCallback, useEffect, useMemo, useRef } from 'react'; -import { Box, config, Icons, Scroll } from 'folds'; +import { Box, config, Scroll } from 'folds'; +import { ClockCounterClockwise } from '$components/icons/phosphor'; import FocusTrap from 'focus-trap-react'; import { isKeyHotkey } from 'is-hotkey'; import type { Room } from '$types/matrix-sdk'; @@ -201,7 +202,7 @@ function EmojiSidebar({ active={activeGroupId === RECENT_GROUP_ID} id={RECENT_GROUP_ID} label="Recent" - icon={Icons.RecentClock} + icon={ClockCounterClockwise} onClick={handleScrollToGroup} /> diff --git a/src/app/components/emoji-board/components/NoStickerPacks.tsx b/src/app/components/emoji-board/components/NoStickerPacks.tsx index 9b46229a6..c8372b241 100644 --- a/src/app/components/emoji-board/components/NoStickerPacks.tsx +++ b/src/app/components/emoji-board/components/NoStickerPacks.tsx @@ -1,4 +1,5 @@ -import { Box, toRem, config, Icons, Icon, Text } from 'folds'; +import { Box, toRem, config, Text } from 'folds'; +import { dropzoneIcon, Sticker } from '$components/icons/phosphor'; export function NoStickerPacks() { return ( @@ -9,7 +10,7 @@ export function NoStickerPacks() { direction="Column" gap="300" > - + {dropzoneIcon(Sticker)} No Sticker Packs! diff --git a/src/app/components/emoji-board/components/SearchInput.tsx b/src/app/components/emoji-board/components/SearchInput.tsx index bdd0df885..725e776b5 100644 --- a/src/app/components/emoji-board/components/SearchInput.tsx +++ b/src/app/components/emoji-board/components/SearchInput.tsx @@ -1,7 +1,8 @@ import type { ChangeEventHandler } from 'react'; import { useRef } from 'react'; -import { Input, Chip, Icon, Icons, Text } from 'folds'; +import { Input, Chip, Text } from 'folds'; import { mobileOrTablet } from '$utils/user-agent'; +import { ArrowRight, sizedIcon, MagnifyingGlass } from '$components/icons/phosphor'; type SearchInputProps = { query?: string; @@ -35,14 +36,14 @@ export function SearchInput({ } + after={sizedIcon(ArrowRight, '50')} outlined onClick={handleReact} > React ) : ( - + sizedIcon(MagnifyingGlass, '50') ) } onChange={onChange} diff --git a/src/app/components/emoji-board/components/Sidebar.tsx b/src/app/components/emoji-board/components/Sidebar.tsx index 5b000b247..19fcd2bf4 100644 --- a/src/app/components/emoji-board/components/Sidebar.tsx +++ b/src/app/components/emoji-board/components/Sidebar.tsx @@ -1,18 +1,7 @@ import type { ReactNode } from 'react'; -import type { IconSrc } from 'folds'; -import { - Box, - Scroll, - Line, - as, - TooltipProvider, - Tooltip, - Text, - IconButton, - Icon, - Icons, -} from 'folds'; +import { Box, Scroll, Line, as, TooltipProvider, Tooltip, Text, IconButton } from 'folds'; import classNames from 'classnames'; +import { sizedIcon, Image, type PhosphorIcon } from '$components/icons/phosphor'; import * as css from './styles.css'; export function Sidebar({ children }: { children: ReactNode }) { @@ -87,7 +76,7 @@ type GroupIconProps = { active: boolean; id: T; label: string; - icon: IconSrc; + icon: PhosphorIcon; onClick: (id: T) => void; }; export function GroupIcon({ @@ -99,7 +88,7 @@ export function GroupIcon({ }: GroupIconProps) { return ( - + {sizedIcon(icon, '200', { filled: active })} ); } @@ -123,7 +112,7 @@ export function ImageGroupIcon({ {url ? ( {label} ) : ( - + sizedIcon(Image, '200', { filled: active }) )} ); diff --git a/src/app/components/emoji-board/useEmojiGroupIcons.ts b/src/app/components/emoji-board/useEmojiGroupIcons.ts index 6ca067f35..b3e2de652 100644 --- a/src/app/components/emoji-board/useEmojiGroupIcons.ts +++ b/src/app/components/emoji-board/useEmojiGroupIcons.ts @@ -1,22 +1,31 @@ import { useMemo } from 'react'; -import type { IconSrc } from 'folds'; -import { Icons } from 'folds'; import { EmojiGroupId } from '$plugins/emoji'; +import type { PhosphorIcon } from '$components/icons/phosphor'; +import { + Basketball, + Coffee, + Flag, + Image, + Leaf, + Lightbulb, + Peace, + Smiley, +} from '$components/icons/phosphor'; -export type IEmojiGroupIcons = Record; +export type IEmojiGroupIcons = Record; export const useEmojiGroupIcons = (): IEmojiGroupIcons => useMemo( () => ({ - [EmojiGroupId.People]: Icons.Smile, - [EmojiGroupId.Nature]: Icons.Leaf, - [EmojiGroupId.Food]: Icons.Cup, - [EmojiGroupId.Activity]: Icons.Ball, - [EmojiGroupId.Travel]: Icons.Photo, - [EmojiGroupId.Object]: Icons.Bulb, - [EmojiGroupId.Symbol]: Icons.Peace, - [EmojiGroupId.Flag]: Icons.Flag, + [EmojiGroupId.People]: Smiley, + [EmojiGroupId.Nature]: Leaf, + [EmojiGroupId.Food]: Coffee, + [EmojiGroupId.Activity]: Basketball, + [EmojiGroupId.Travel]: Image, + [EmojiGroupId.Object]: Lightbulb, + [EmojiGroupId.Symbol]: Peace, + [EmojiGroupId.Flag]: Flag, }), [] ); diff --git a/src/app/components/event-history/EventHistory.tsx b/src/app/components/event-history/EventHistory.tsx index 8850802f7..08c198c51 100644 --- a/src/app/components/event-history/EventHistory.tsx +++ b/src/app/components/event-history/EventHistory.tsx @@ -3,9 +3,7 @@ import { Avatar, Box, Header, - Icon, IconButton, - Icons, Menu, MenuItem, Scroll, @@ -25,6 +23,15 @@ import { getMouseEventCords } from '$utils/dom'; import { useAtomValue, useSetAtom } from 'jotai'; import { nicknamesAtom } from '$state/nicknames'; import { UserAvatar } from '$components/user-avatar'; +import { + userFallbackIcon, + ArrowBendUpRightIcon, + ChatTeardropDots, + composerIcon, + menuIcon, + Trash, + X, +} from '$components/icons/phosphor'; import { RenderBody, Time } from '$components/message'; import { useSetting } from '$state/hooks/settings'; import { settingsAtom } from '$state/settings'; @@ -131,7 +138,7 @@ export const EventHistory = as<'div', EventHistoryProps>( } + after={menuIcon(ArrowBendUpRightIcon)} radii="300" fill="None" variant="Secondary" @@ -146,7 +153,7 @@ export const EventHistory = as<'div', EventHistoryProps>( /> } + after={menuIcon(ChatTeardropDots)} radii="300" fill="None" variant="Secondary" @@ -162,7 +169,7 @@ export const EventHistory = as<'div', EventHistoryProps>( {canDelete && ( } + after={menuIcon(Trash)} radii="300" fill="None" variant="Critical" @@ -230,7 +237,7 @@ export const EventHistory = as<'div', EventHistoryProps>( Message version history - + {composerIcon(X)}
@@ -258,7 +265,7 @@ export const EventHistory = as<'div', EventHistoryProps>( userId={readerId ?? ''} src={avatarUrl ?? undefined} alt={name} - renderFallback={() => } + renderFallback={() => userFallbackIcon('sm')} /> } diff --git a/src/app/components/event-readers/EventReaders.tsx b/src/app/components/event-readers/EventReaders.tsx index 88f7eac57..7575fbb03 100644 --- a/src/app/components/event-readers/EventReaders.tsx +++ b/src/app/components/event-readers/EventReaders.tsx @@ -1,17 +1,5 @@ import classNames from 'classnames'; -import { - Avatar, - Box, - Header, - Icon, - IconButton, - Icons, - MenuItem, - Scroll, - Text, - as, - config, -} from 'folds'; +import { Avatar, Box, Header, IconButton, MenuItem, Scroll, Text, as, config } from 'folds'; import type { Room } from '$types/matrix-sdk'; import { useRoomEventReaders } from '$hooks/useRoomEventReaders'; import { getMemberDisplayName } from '$utils/room'; @@ -24,6 +12,7 @@ import { getMouseEventCords } from '$utils/dom'; import { useAtomValue } from 'jotai'; import { nicknamesAtom } from '$state/nicknames'; import { UserAvatar } from '$components/user-avatar'; +import { composerIcon, userFallbackIcon, X } from '$components/icons/phosphor'; import * as css from './EventReaders.css'; export type EventReadersProps = { @@ -55,7 +44,7 @@ export const EventReaders = as<'div', EventReadersProps>( Seen by - + {composerIcon(X)}
@@ -101,7 +90,7 @@ export const EventReaders = as<'div', EventReadersProps>( userId={readerId} src={avatarUrl ?? undefined} alt={name} - renderFallback={() => } + renderFallback={() => userFallbackIcon('sm')} /> } diff --git a/src/app/components/icons/phosphor.tsx b/src/app/components/icons/phosphor.tsx new file mode 100644 index 000000000..40d8ac196 --- /dev/null +++ b/src/app/components/icons/phosphor.tsx @@ -0,0 +1,352 @@ +import type { IconProps } from '@phosphor-icons/react'; +import { + ArrowsDownUpIcon, + ArrowBendUpRightIcon, + ArrowDownIcon, + ArrowLeftIcon, + ArrowRightIcon, + ArrowSquareOutIcon, + ArrowUpIcon, + ArrowsClockwiseIcon, + AtIcon, + BasketballIcon, + BellIcon, + BellRingingIcon, + BellSlashIcon, + CaretDownIcon, + CaretLeftIcon, + CaretRightIcon, + CaretUpIcon, + ChatCircleIcon, + ChatCircleDotsIcon, + ChatsIcon, + ChatTeardropDotsIcon, + CheckIcon, + ChecksIcon, + ClockIcon, + ClockCounterClockwiseIcon, + CodeIcon, + CodeBlockIcon, + CoffeeIcon, + CompassIcon, + DatabaseIcon, + DevicesIcon, + DotsThreeIcon, + DotsThreeOutlineVerticalIcon, + DownloadIcon, + EnvelopeSimpleIcon, + EyeIcon, + EyeSlashIcon, + FileIcon, + FlagIcon, + FlaskIcon, + FlowerIcon, + FunnelIcon, + GearSixIcon, + GlobeIcon, + GridFourIcon, + HardDrivesIcon, + HashIcon, + HashStraightIcon, + HeadphonesIcon, + HeartIcon, + HouseIcon, + ImageIcon, + InfoIcon, + KeyboardIcon, + LeafIcon, + LightbulbIcon, + LinkIcon, + ListBulletsIcon, + ListNumbersIcon, + LockIcon, + MagnifyingGlassIcon, + MapPinPlusIcon, + MicrophoneIcon, + MicrophoneSlashIcon, + MinusIcon, + MonitorIcon, + PaintBrushIcon, + PaletteIcon, + PaperPlaneTiltIcon, + PauseIcon, + PawPrintIcon, + PeaceIcon, + PencilSimpleIcon, + PhoneIcon, + PhoneDisconnectIcon, + PlayIcon, + PlusIcon, + PlusCircleIcon, + PresentationIcon, + ProhibitIcon, + PushPinIcon, + PushPinSlashIcon, + QuotesIcon, + ShareNetworkIcon, + ShieldIcon, + ShieldWarningIcon, + SignInIcon, + SignOutIcon, + SmileyIcon, + SmileyStickerIcon, + SortAscendingIcon, + SpeakerHighIcon, + SpeakerSlashIcon, + SquaresFourIcon, + StarIcon, + StickerIcon, + StopIcon, + SunIcon, + TerminalIcon, + TextAaIcon, + TextBIcon, + TextHOneIcon, + TextHThreeIcon, + TextHTwoIcon, + TextItalicIcon, + TextStrikethroughIcon, + TextUnderlineIcon, + TrashIcon, + TrayIcon, + TreeStructureIcon, + UserIcon, + UserCircleIcon, + UserMinusIcon, + UserPlusIcon, + UsersThreeIcon, + VideoCameraIcon, + VideoCameraSlashIcon, + WarningIcon, + XIcon, +} from '@phosphor-icons/react'; +import type { ComponentType, ReactNode } from 'react'; + +/** Inline (20px), toolbar (24px), and empty-state (40px) icon sizes. */ +export const PHOSPHOR_SIZE = { + inline: 20, + toolbar: 24, + empty: 40, +} as const; + +/** Icon size tokens for `sizedIcon()` mapped to pixel values. */ +export type IconSizeToken = '50' | '100' | '200' | '300' | '400' | '500' | '600' | 'Inherit'; + +const ICON_SIZE_PX: Record, number> = { + '50': 12, + '100': 16, + '200': 20, + '300': 24, + '400': 32, + '500': 40, + '600': 48, +}; + +const timelineMutedStyle = { opacity: 0.6 } as const; + +export type PhosphorIcon = ComponentType; + +type SizedIconProps = IconProps & { + /** Folds `Icon` `filled` prop — maps to Phosphor `fill` weight. */ + filled?: boolean; +}; + +export function sizedIcon( + Icon: PhosphorIcon, + size: IconSizeToken = '200', + props?: SizedIconProps +): ReactNode { + const { filled, weight, style, ...rest } = props ?? {}; + const resolvedWeight = weight ?? (filled ? 'fill' : 'regular'); + if (size === 'Inherit') { + return ; + } + return ; +} + +export function timelineIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode { + return ; +} + +export function menuIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode { + return ; +} + +export function composerIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode { + return ; +} + +export function chipIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode { + return ; +} + +export function profileIcon(Icon: PhosphorIcon, props?: SizedIconProps): ReactNode { + return sizedIcon(Icon, '100', props); +} + +/** Caret in chip `after` slots — flex-centered so Phosphor glyphs align with label text. */ +export function chipCaretIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode { + const { style, ...rest } = props ?? {}; + return ( + + + + ); +} + +/** @deprecated Prefer composerIcon — same toolbar size. */ +export function navIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode { + return composerIcon(Icon, props); +} + +export function dropzoneIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode { + return ; +} + +export function settingsNavIcon(Icon: PhosphorIcon, active: boolean, props?: IconProps): ReactNode { + return ; +} + +export type UserFallbackSize = 'sm' | 'md' | 'lg' | 'xl' | 'hero'; + +const USER_FALLBACK_SIZE = { + sm: PHOSPHOR_SIZE.inline, + md: PHOSPHOR_SIZE.inline, + lg: PHOSPHOR_SIZE.toolbar, + xl: PHOSPHOR_SIZE.toolbar, + hero: PHOSPHOR_SIZE.empty, +} as const; + +export function userFallbackIcon(size: UserFallbackSize = 'md', props?: IconProps): ReactNode { + return ; +} + +export { + ArrowsDownUpIcon as ArrowsDownUp, + ArrowBendUpRightIcon, + ArrowDownIcon as ArrowDown, + ArrowLeftIcon as ArrowLeft, + ArrowRightIcon as ArrowRight, + ArrowSquareOutIcon as ArrowSquareOut, + ArrowUpIcon as ArrowUp, + ArrowsClockwiseIcon as ArrowsClockwise, + AtIcon as At, + BasketballIcon as Basketball, + BellIcon as Bell, + BellRingingIcon as BellRinging, + BellSlashIcon as BellSlash, + CaretDownIcon as CaretDown, + CaretLeftIcon as CaretLeft, + CaretRightIcon as CaretRight, + CaretUpIcon as CaretUp, + ChatCircleIcon as ChatCircle, + ChatCircleDotsIcon as ChatCircleDots, + ChatsIcon as Chats, + ChatTeardropDotsIcon as ChatTeardropDots, + CheckIcon as Check, + ChecksIcon as Checks, + ClockIcon as Clock, + ClockCounterClockwiseIcon as ClockCounterClockwise, + CodeIcon as Code, + CodeBlockIcon as CodeBlock, + CoffeeIcon as Coffee, + CompassIcon as Compass, + DatabaseIcon as Database, + DevicesIcon as Devices, + DotsThreeIcon as DotsThree, + DotsThreeOutlineVerticalIcon, + DownloadIcon as Download, + EnvelopeSimpleIcon as EnvelopeSimple, + EyeIcon as Eye, + EyeSlashIcon as EyeSlash, + FileIcon as File, + FlagIcon as Flag, + FlaskIcon as Flask, + FlowerIcon as Flower, + FunnelIcon as Funnel, + GearSixIcon as GearSix, + GlobeIcon as Globe, + GridFourIcon as GridFour, + HardDrivesIcon as HardDrives, + HashIcon as Hash, + HashStraightIcon as HashStraight, + HeadphonesIcon as Headphones, + HeartIcon as Heart, + HouseIcon as House, + ImageIcon as Image, + InfoIcon as Info, + KeyboardIcon as Keyboard, + LeafIcon as Leaf, + LightbulbIcon as Lightbulb, + LinkIcon as Link, + ListBulletsIcon as ListBullets, + ListNumbersIcon as ListNumbers, + LockIcon as Lock, + MagnifyingGlassIcon as MagnifyingGlass, + MapPinPlusIcon, + MicrophoneIcon as Microphone, + MicrophoneSlashIcon as MicrophoneSlash, + MinusIcon as Minus, + MonitorIcon as Monitor, + PaintBrushIcon as PaintBrush, + PaletteIcon as Palette, + PaperPlaneTiltIcon as PaperPlaneTilt, + PauseIcon as Pause, + PawPrintIcon as PawPrint, + PeaceIcon as Peace, + PencilSimpleIcon as PencilSimple, + PhoneIcon as Phone, + PhoneDisconnectIcon as PhoneDisconnect, + PlayIcon as Play, + PlusIcon as Plus, + PlusCircleIcon as PlusCircle, + PresentationIcon as Presentation, + ProhibitIcon as Prohibit, + PushPinIcon as PushPin, + PushPinSlashIcon as PushPinSlash, + QuotesIcon as Quotes, + ShareNetworkIcon as ShareNetwork, + ShieldIcon as Shield, + ShieldWarningIcon as ShieldWarning, + SignInIcon as SignIn, + SignOutIcon as SignOut, + SmileyIcon as Smiley, + SmileyStickerIcon as SmileySticker, + SortAscendingIcon as SortAscending, + SpeakerHighIcon as SpeakerHigh, + SpeakerSlashIcon as SpeakerSlash, + SquaresFourIcon as SquaresFour, + StarIcon as Star, + StickerIcon as Sticker, + StopIcon as Stop, + SunIcon as Sun, + TerminalIcon as Terminal, + TextAaIcon as TextAa, + TextBIcon as TextB, + TextHOneIcon as TextHOne, + TextHThreeIcon as TextHThree, + TextHTwoIcon as TextHTwo, + TextItalicIcon as TextItalic, + TextStrikethroughIcon as TextStrikethrough, + TextUnderlineIcon as TextUnderline, + TrashIcon as Trash, + TrayIcon as Tray, + TreeStructureIcon as TreeStructure, + UserIcon as User, + UserCircleIcon as UserCircle, + UserMinusIcon as UserMinus, + UserPlusIcon as UserPlus, + UsersThreeIcon as UsersThree, + VideoCameraIcon as VideoCamera, + VideoCameraSlashIcon as VideoCameraSlash, + WarningIcon as Warning, + XIcon as X, +}; diff --git a/src/app/components/icons/roomIcons.tsx b/src/app/components/icons/roomIcons.tsx new file mode 100644 index 000000000..1709a7d66 --- /dev/null +++ b/src/app/components/icons/roomIcons.tsx @@ -0,0 +1,99 @@ +import { JoinRule, RoomType } from '$types/matrix-sdk'; +import type { ComponentType } from 'react'; +import type { IconProps } from '@phosphor-icons/react'; +import { Globe, HashStraight, Lock, SpeakerHigh, SquaresFour } from './phosphor'; + +export type RoomPhosphorIcon = ComponentType; + +export type RoomIconOverlay = 'globe' | 'lock'; + +const isRegularRoom = (roomType?: string): boolean => + roomType !== RoomType.Space && roomType !== RoomType.UnstableCall; + +export function getRoomIconOverlay( + roomType?: string, + joinRule?: JoinRule +): RoomIconOverlay | undefined { + if (!isRegularRoom(roomType)) return undefined; + + if (joinRule === JoinRule.Public) return 'globe'; + if ( + joinRule === JoinRule.Invite || + joinRule === JoinRule.Knock || + joinRule === JoinRule.Private + ) { + return 'lock'; + } + return undefined; +} + +export function getRoomIconOverlayComponent(overlay: RoomIconOverlay): RoomPhosphorIcon { + return overlay === 'globe' ? Globe : Lock; +} + +export function getRoomStandaloneIconComponent( + roomType?: string, + joinRule?: JoinRule +): RoomPhosphorIcon { + if (roomType === RoomType.Space) { + if (joinRule === JoinRule.Public) return Globe; + if ( + joinRule === JoinRule.Invite || + joinRule === JoinRule.Knock || + joinRule === JoinRule.Private + ) { + return Lock; + } + return SquaresFour; + } + + if (roomType === RoomType.UnstableCall) { + if (joinRule === JoinRule.Public) return Globe; + if ( + joinRule === JoinRule.Invite || + joinRule === JoinRule.Knock || + joinRule === JoinRule.Private + ) { + return Lock; + } + return SpeakerHigh; + } + + if (joinRule === JoinRule.Public) return Globe; + if ( + joinRule === JoinRule.Invite || + joinRule === JoinRule.Knock || + joinRule === JoinRule.Private + ) { + return Lock; + } + return HashStraight; +} + +export function getRoomIconComponent(roomType?: string, joinRule?: JoinRule): RoomPhosphorIcon { + if (roomType === RoomType.Space) { + if (joinRule === JoinRule.Public) return Globe; + if ( + joinRule === JoinRule.Invite || + joinRule === JoinRule.Knock || + joinRule === JoinRule.Private + ) { + return Lock; + } + return SquaresFour; + } + + if (roomType === RoomType.UnstableCall) { + if (joinRule === JoinRule.Public) return Globe; + if ( + joinRule === JoinRule.Invite || + joinRule === JoinRule.Knock || + joinRule === JoinRule.Private + ) { + return Lock; + } + return SpeakerHigh; + } + + return HashStraight; +} diff --git a/src/app/components/image-editor/ImageEditor.tsx b/src/app/components/image-editor/ImageEditor.tsx index 13adad954..8e2854648 100644 --- a/src/app/components/image-editor/ImageEditor.tsx +++ b/src/app/components/image-editor/ImageEditor.tsx @@ -1,5 +1,6 @@ import classNames from 'classnames'; -import { Box, Chip, Header, Icon, IconButton, Icons, Text, as } from 'folds'; +import { Box, Chip, Header, IconButton, Text, as } from 'folds'; +import { ArrowLeft, sizedIcon } from '$components/icons/phosphor'; import * as css from './ImageEditor.css'; export type ImageEditorProps = { @@ -24,7 +25,7 @@ export const ImageEditor = as<'div', ImageEditorProps>(
- + {sizedIcon(ArrowLeft, '50')} Image Editor diff --git a/src/app/components/image-pack-view/ImagePackView.tsx b/src/app/components/image-pack-view/ImagePackView.tsx index 4f4c51519..fdca089ae 100644 --- a/src/app/components/image-pack-view/ImagePackView.tsx +++ b/src/app/components/image-pack-view/ImagePackView.tsx @@ -1,4 +1,5 @@ -import { Box, IconButton, Text, Icon, Icons, Scroll, Chip } from 'folds'; +import { Box, IconButton, Text, Scroll, Chip } from 'folds'; +import { ArrowLeft, composerIcon, sizedIcon, X } from '$components/icons/phosphor'; import type { PackAddress } from '$plugins/custom-emoji'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { Page, PageHeader, PageContent } from '$components/page'; @@ -22,14 +23,14 @@ export function ImagePackView({ address, requestClose }: ImagePackViewProps) { size="500" radii="Pill" onClick={requestClose} - before={} + before={sizedIcon(ArrowLeft, '100')} > Emojis & Stickers - + {composerIcon(X)} diff --git a/src/app/components/image-pack-view/ImageTile.tsx b/src/app/components/image-pack-view/ImageTile.tsx index 5692c7364..0038ca734 100644 --- a/src/app/components/image-pack-view/ImageTile.tsx +++ b/src/app/components/image-pack-view/ImageTile.tsx @@ -1,6 +1,7 @@ import type { FormEventHandler, ReactNode } from 'react'; import { useMemo, useState } from 'react'; -import { Badge, Box, Button, Chip, Icon, Icons, Input, Text } from 'folds'; +import { Badge, Box, Button, Chip, Input, Text } from 'folds'; +import { sizedIcon, Trash } from '$components/icons/phosphor'; import { mxcUrlToHttp } from '$utils/matrix'; import type { ImageUsage } from '$plugins/custom-emoji'; import { imageUsageEqual, PackImageReader } from '$plugins/custom-emoji'; @@ -74,7 +75,7 @@ export function ImageTile({ radii="Pill" onClick={() => onDeleteToggle?.(defaultShortcode)} > - {deleted ? Undo : } + {deleted ? Undo : sizedIcon(Trash, '50')} {!deleted && ( } + before={sizedIcon(PencilSimple, '50')} onClick={onEdit} outlined > diff --git a/src/app/components/image-pack-view/UsageSwitcher.tsx b/src/app/components/image-pack-view/UsageSwitcher.tsx index d06f3c859..1dc055470 100644 --- a/src/app/components/image-pack-view/UsageSwitcher.tsx +++ b/src/app/components/image-pack-view/UsageSwitcher.tsx @@ -1,7 +1,8 @@ import type { MouseEventHandler } from 'react'; import { useMemo, useState } from 'react'; import type { RectCords } from 'folds'; -import { Box, Button, config, Icon, Icons, Menu, MenuItem, PopOut, Text } from 'folds'; +import { Box, Button, config, Menu, MenuItem, PopOut, Text } from 'folds'; +import { CaretDown, sizedIcon } from '$components/icons/phosphor'; import FocusTrap from 'focus-trap-react'; import { ImageUsage } from '$plugins/custom-emoji'; import { stopPropagation } from '$utils/keyboard'; @@ -78,7 +79,7 @@ export function UsageSwitcher({ usage, onChange, canEdit }: UsageSwitcherProps) type="button" outlined aria-disabled={!canEdit} - after={canEdit && } + after={canEdit && sizedIcon(CaretDown, '100')} onClick={canEdit ? handleSelectUsage : undefined} > {getUsageStr(usage)} diff --git a/src/app/components/image-viewer/ImageViewer.tsx b/src/app/components/image-viewer/ImageViewer.tsx index 573ef0cfa..90fded832 100644 --- a/src/app/components/image-viewer/ImageViewer.tsx +++ b/src/app/components/image-viewer/ImageViewer.tsx @@ -1,7 +1,16 @@ import { useEffect, useRef, useState } from 'react'; import FileSaver from 'file-saver'; import classNames from 'classnames'; -import { Box, Chip, Header, Icon, IconButton, Icons, Text, as } from 'folds'; +import { Box, Chip, Header, IconButton, Text, as } from 'folds'; +import { + ArrowLeft, + ArrowsClockwise, + Download, + Image, + Minus, + Plus, + sizedIcon, +} from '$components/icons/phosphor'; import { useImageGestures } from '$hooks/useImageGestures'; import { useSetting } from '$state/hooks/settings'; import { isPixelatedRendering, settingsAtom } from '$state/settings'; @@ -83,7 +92,7 @@ export const ImageViewer = as<'div', ImageViewerProps>(
- + {sizedIcon(ArrowLeft, '200')} {alt} @@ -116,7 +125,7 @@ export const ImageViewer = as<'div', ImageViewerProps>( aria-label="View Original Size" title="View Original Size" > - + {sizedIcon(Image, '200')} ( aria-label="Reset Zoom" title="Zoom to Fill Container" > - + {sizedIcon(ArrowsClockwise, '200')} ( aria-label="Zoom Out" title="Zoom Out" > - + {sizedIcon(Minus, '50')} ( aria-label="Zoom In" title="Zoom In" > - + {sizedIcon(Plus, '50')} } + before={sizedIcon(Download, '50')} outlined > Download diff --git a/src/app/components/invite-user-prompt/InviteUserPrompt.tsx b/src/app/components/invite-user-prompt/InviteUserPrompt.tsx index 0d81bc5d7..def031d64 100644 --- a/src/app/components/invite-user-prompt/InviteUserPrompt.tsx +++ b/src/app/components/invite-user-prompt/InviteUserPrompt.tsx @@ -9,8 +9,6 @@ import { config, Text, IconButton, - Icon, - Icons, Input, Button, Spinner, @@ -32,6 +30,7 @@ import type { UseAsyncSearchOptions } from '$hooks/useAsyncSearch'; import { useAsyncSearch } from '$hooks/useAsyncSearch'; import { highlightText, makeHighlightRegex } from '$plugins/react-custom-html-parser'; import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback'; +import { composerIcon, X } from '$components/icons/phosphor'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { BreakWord } from '$styles/Text.css'; import { useAlive } from '$hooks/useAlive'; @@ -170,7 +169,7 @@ export function InviteUserPrompt({ room, requestClose }: InviteUserProps) { - + {composerIcon(X)}
diff --git a/src/app/components/join-address-prompt/JoinAddressPrompt.tsx b/src/app/components/join-address-prompt/JoinAddressPrompt.tsx index fc33f55ca..98cf7883c 100644 --- a/src/app/components/join-address-prompt/JoinAddressPrompt.tsx +++ b/src/app/components/join-address-prompt/JoinAddressPrompt.tsx @@ -11,12 +11,11 @@ import { Box, Text, IconButton, - Icon, - Icons, Button, Input, color, } from 'folds'; +import { composerIcon, X } from '$components/icons/phosphor'; import { stopPropagation } from '$utils/keyboard'; import { isRoomAlias, isRoomId } from '$utils/matrix'; import { parseMatrixToRoom, parseMatrixToRoomEvent, testMatrixTo } from '$plugins/matrix-to'; @@ -84,7 +83,7 @@ export function JoinAddressPrompt({ onOpen, onCancel }: JoinAddressProps) { Join with Address - + {composerIcon(X)}
Knock On Room - + {composerIcon(X)} Leave Room - + {composerIcon(X)} diff --git a/src/app/components/leave-space-prompt/LeaveSpacePrompt.tsx b/src/app/components/leave-space-prompt/LeaveSpacePrompt.tsx index c6aef838d..37a146924 100644 --- a/src/app/components/leave-space-prompt/LeaveSpacePrompt.tsx +++ b/src/app/components/leave-space-prompt/LeaveSpacePrompt.tsx @@ -10,8 +10,6 @@ import { Box, Text, IconButton, - Icon, - Icons, color, Button, Spinner, @@ -19,6 +17,7 @@ import { import type { MatrixError } from '$types/matrix-sdk'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback'; +import { composerIcon, X } from '$components/icons/phosphor'; import { stopPropagation } from '$utils/keyboard'; type LeaveSpacePromptProps = { @@ -69,7 +68,7 @@ export function LeaveSpacePrompt({ roomId, onDone, onCancel }: LeaveSpacePromptP Leave Space - + {composerIcon(X)} diff --git a/src/app/components/member-tile/MemberTile.tsx b/src/app/components/member-tile/MemberTile.tsx index c74433eb7..064102c9b 100644 --- a/src/app/components/member-tile/MemberTile.tsx +++ b/src/app/components/member-tile/MemberTile.tsx @@ -1,5 +1,6 @@ import type { ReactNode } from 'react'; -import { as, Avatar, Box, Icon, Icons, Text } from 'folds'; +import { as, Avatar, Box, Text } from 'folds'; +import { userFallbackIcon } from '$components/icons/phosphor'; import type { MatrixClient, Room, RoomMember } from '$types/matrix-sdk'; import { getMemberDisplayName } from '$utils/room'; import { getMxIdLocalPart } from '$utils/matrix'; @@ -44,7 +45,7 @@ export const MemberTile = as<'button', MemberTileProps>( userId={member.userId} src={avatarUrl ?? undefined} alt={name} - renderFallback={() => } + renderFallback={() => userFallbackIcon('xl')} /> diff --git a/src/app/components/message/FileHeader.tsx b/src/app/components/message/FileHeader.tsx index 92c41d37e..03473b22c 100644 --- a/src/app/components/message/FileHeader.tsx +++ b/src/app/components/message/FileHeader.tsx @@ -1,4 +1,5 @@ -import { Badge, Box, Icon, IconButton, Icons, Spinner, Text, as, toRem } from 'folds'; +import { Badge, Box, IconButton, Spinner, Text, as, toRem } from 'folds'; +import { Download, sizedIcon } from '$components/icons/phosphor'; import type { ReactNode } from 'react'; import { useCallback } from 'react'; import type { EncryptedAttachmentInfo } from 'browser-encrypt-attachment'; @@ -48,7 +49,7 @@ export function FileDownloadButton({ filename, url, mimeType, encInfo }: FileDow {downloading ? ( ) : ( - + sizedIcon(Download, '100') )} ); diff --git a/src/app/components/message/InlineTextDiff.css.ts b/src/app/components/message/InlineTextDiff.css.ts new file mode 100644 index 000000000..438162fb5 --- /dev/null +++ b/src/app/components/message/InlineTextDiff.css.ts @@ -0,0 +1,105 @@ +import { style } from '@vanilla-extract/css'; +import { color, config } from 'folds'; + +const mono = { fontFamily: 'var(--font-monospace)' }; + +export const DiffCodeBlock = style([ + mono, + { + margin: 0, + color: color.SurfaceVariant.OnContainer, + background: color.SurfaceVariant.Container, + border: `${config.borderWidth.B300} solid ${color.SurfaceVariant.ContainerLine}`, + borderRadius: config.radii.R300, + padding: `${config.space.S100} ${config.space.S200}`, + whiteSpace: 'pre-wrap', + overflowWrap: 'anywhere', + wordBreak: 'break-word', + overflow: 'hidden', + fontSize: 'inherit', + lineHeight: 'inherit', + }, +]); + +export const DiffCodeBlockInner = style({ + display: 'block', + margin: 0, + padding: 0, +}); + +export const DiffLine = style([ + mono, + { + display: 'flex', + gap: config.space.S200, + whiteSpace: 'pre-wrap', + overflowWrap: 'anywhere', + wordBreak: 'break-word', + }, +]); + +export const DiffLinePrefix = style({ + flexShrink: 0, + width: '1ch', + opacity: config.opacity.P500, + userSelect: 'none', +}); + +export const DiffLineText = style({ + flexGrow: 1, + minWidth: 0, +}); + +export const DiffLineEqual = style({}); + +export const DiffLineDelete = style({ + backgroundColor: color.Critical.Container, + color: color.Critical.OnContainer, +}); + +export const DiffLineInsert = style({ + backgroundColor: color.Success.Container, + color: color.Success.OnContainer, +}); + +export const DiffExpand = style([ + mono, + { + display: 'flex', + gap: config.space.S200, + alignItems: 'center', + width: '100%', + margin: 0, + padding: 0, + textAlign: 'left', + cursor: 'pointer', + background: 'transparent', + border: 'none', + color: 'inherit', + opacity: config.opacity.P500, + fontSize: 'inherit', + lineHeight: 'inherit', + whiteSpace: 'pre-wrap', + overflowWrap: 'anywhere', + wordBreak: 'break-word', + selectors: { + '&:hover': { + opacity: 1, + backgroundColor: color.SurfaceVariant.ContainerActive, + }, + }, + }, +]); + +export const DiffInlineDelete = style({ + backgroundColor: color.Critical.Container, + color: color.Critical.OnContainer, + textDecoration: 'line-through', + borderRadius: config.radii.R300, +}); + +export const DiffInlineInsert = style({ + backgroundColor: color.Success.Container, + color: color.Success.OnContainer, + borderRadius: config.radii.R300, +}); diff --git a/src/app/components/message/InlineTextDiff.tsx b/src/app/components/message/InlineTextDiff.tsx new file mode 100644 index 000000000..980adfa04 --- /dev/null +++ b/src/app/components/message/InlineTextDiff.tsx @@ -0,0 +1,179 @@ +import classNames from 'classnames'; +import { useCallback, useMemo, useState, type ReactNode } from 'react'; +import { Text } from 'folds'; +import { scaleSystemEmoji } from '$plugins/react-custom-html-parser'; +import { buildMessageDiffDisplay, type MessageDiffRow, type TextDiffPart } from '$utils/textDiff'; + +import * as css from './InlineTextDiff.css'; + +const SKIP_EXPAND_CHUNK = 20; + +type InlineTextDiffProps = { + oldText: string; + newText: string; +}; + +type CodeDiffRow = Exclude; + +const renderInlineParts = (parts: TextDiffPart[]) => + parts.map((part, index) => { + const content = scaleSystemEmoji(part.value); + const key = `diff-${index}-${part.type}`; + if (part.type === 'delete') { + return ( + + {content} + + ); + } + if (part.type === 'insert') { + return ( + + {content} + + ); + } + return {content}; + }); + +const renderCodeLine = (row: CodeDiffRow, key: string) => { + const prefix = row.type === 'delete' ? '-' : row.type === 'insert' ? '+' : ' '; + const lineClass = + row.type === 'delete' + ? css.DiffLineDelete + : row.type === 'insert' + ? css.DiffLineInsert + : css.DiffLineEqual; + + return ( +
+ + {prefix} + + {scaleSystemEmoji(row.text)} +
+ ); +}; + +type DiffSkipRowsProps = { + skipIndex: number; + lines: string[]; + placement: 'before' | 'after' | 'between'; + revealed: number; + onReveal: (skipIndex: number, amount: number) => void; +}; + +function DiffSkipRows({ skipIndex, lines, placement, revealed, onReveal }: DiffSkipRowsProps) { + const remaining = lines.length - revealed; + const nextReveal = Math.min(SKIP_EXPAND_CHUNK, remaining); + const expandUp = placement === 'before'; + const arrow = expandUp ? '↑' : '↓'; + const revealedLines = + placement === 'before' + ? lines.slice(Math.max(0, lines.length - revealed)) + : lines.slice(0, revealed); + + const label = `Expand ${remaining <= SKIP_EXPAND_CHUNK ? `all ${remaining}` : nextReveal} unchanged ${remaining === 1 ? 'line' : 'lines'}`; + + const expandRow = + remaining > 0 ? ( + + ) : null; + + const revealedRows = revealedLines.map((line, lineIndex) => + renderCodeLine({ type: 'equal', text: line }, `skip-${skipIndex}-line-${lineIndex}`) + ); + + if (expandUp) { + return ( + <> + {expandRow} + {revealedRows} + + ); + } + + return ( + <> + {revealedRows} + {expandRow} + + ); +} + +function InlineDiffBlock({ children }: { children: ReactNode }) { + return ( + + {children} + + ); +} + +export function InlineTextDiff({ oldText, newText }: InlineTextDiffProps) { + const display = useMemo(() => buildMessageDiffDisplay(oldText, newText), [oldText, newText]); + const [revealedBySkip, setRevealedBySkip] = useState>({}); + + const revealSkip = useCallback((skipIndex: number, amount: number) => { + setRevealedBySkip((prev) => ({ + ...prev, + [skipIndex]: (prev[skipIndex] ?? 0) + amount, + })); + }, []); + + if (display.mode === 'inline') { + if (display.parts.length === 0) { + return (empty); + } + + return ( + +
+ + {' '} + + {renderInlineParts(display.parts)} +
+
+ ); + } + + if (display.rows.length === 0) { + return (empty); + } + + let skipIndex = 0; + + return ( + + {display.rows.map((row, index) => { + if (row.type === 'skip') { + const currentSkipIndex = skipIndex; + skipIndex += 1; + return ( + + ); + } + + return renderCodeLine(row, `${row.type}-${row.text}-${index}`); + })} + + ); +} diff --git a/src/app/components/message/MsgTypeRenderers.tsx b/src/app/components/message/MsgTypeRenderers.tsx index 3e0e68f4c..4dc3db8e5 100644 --- a/src/app/components/message/MsgTypeRenderers.tsx +++ b/src/app/components/message/MsgTypeRenderers.tsx @@ -1,7 +1,8 @@ import type { CSSProperties, ReactNode } from 'react'; import { useMemo } from 'react'; -import { Box, Chip, Icon, Icons, Text, toRem } from 'folds'; -import type { IContent, IPreviewUrlResponse } from '$types/matrix-sdk'; +import { Box, Chip, Text, toRem } from 'folds'; +import { ArrowSquareOut, sizedIcon, Link } from '$components/icons/phosphor'; +import type { IContent, IPreviewUrlResponse, MatrixClient } from '$types/matrix-sdk'; import { JUMBO_EMOJI_REG } from '$utils/regex'; import { trimReplyFromBody } from '$utils/room'; import type { @@ -30,6 +31,7 @@ import { MessageDeletedContent, MessageEditedContent, MessageUnsupportedContent, + ReactionDeletedContent, } from './content'; import { MessageTextBody } from './layout'; import { unwrapForwardedContent } from './modals/MessageForward'; @@ -64,6 +66,34 @@ export function RedactedContent({ reason }: RedactedContentProps) { ); } +type RedactedReactionContentProps = { + reactionKey?: string; + shortcode?: string; + mx?: MatrixClient; + useAuthentication?: boolean; + reason?: string; +}; +export function RedactedReactionContent({ + reactionKey, + shortcode, + mx, + useAuthentication, + reason, +}: RedactedReactionContentProps) { + return ( + + + + ); +} + type BrokenContentProps = { body?: string; }; @@ -668,7 +698,7 @@ export function MLocation({ content, showMaps }: MLocationProps) { size="400" variant="SurfaceVariant" onClick={() => copyToClipboard(`${location.latitude}, ${location.longitude}`)} - before={} + before={sizedIcon(Link, '50')} className={css.LocationCoordsChip} > {`${location.latitude}, ${location.longitude}`} @@ -683,7 +713,7 @@ export function MLocation({ content, showMaps }: MLocationProps) { variant="Primary" radii="Pill" className={css.LocationExternalChip} - before={} + before={sizedIcon(ArrowSquareOut, '50')} > Open Location diff --git a/src/app/components/message/Reaction.tsx b/src/app/components/message/Reaction.tsx index c6d212ec4..3b4c3cebb 100644 --- a/src/app/components/message/Reaction.tsx +++ b/src/app/components/message/Reaction.tsx @@ -1,5 +1,6 @@ import { useState } from 'react'; -import { Box, Icon, Icons, Text, as } from 'folds'; +import { Box, Text, as } from 'folds'; +import { sizedIcon, Warning } from '$components/icons/phosphor'; import classNames from 'classnames'; import type { MatrixClient, MatrixEvent, Room } from '$types/matrix-sdk'; import { getHexcodeForEmoji, getShortcodeFor } from '$plugins/emoji'; @@ -35,11 +36,11 @@ export const Reaction = as< (() => { if (imgError) return ( - // Image loaded but fetch failed — show a small warning icon so the + // Image loaded but fetch failed  Eshow a small warning icon so the // reaction button still renders correctly and the user can see // something went wrong rather than a browser broken-image icon. - + {sizedIcon(Warning, '100', { style: { opacity: 0.5 } })} ); return ( diff --git a/src/app/components/message/ReactionKeyInline.tsx b/src/app/components/message/ReactionKeyInline.tsx new file mode 100644 index 000000000..901992eee --- /dev/null +++ b/src/app/components/message/ReactionKeyInline.tsx @@ -0,0 +1,59 @@ +import { useState } from 'react'; +import { Text } from 'folds'; +import type { MatrixClient } from '$types/matrix-sdk'; +import { menuIcon, Warning } from '$components/icons/phosphor'; +import { scaleSystemEmoji } from '$plugins/react-custom-html-parser'; +import { mxcUrlToHttp } from '$utils/matrix'; +import * as css from './Reaction.css'; + +type ReactionKeyInlineProps = { + mx: MatrixClient; + reactionKey?: string; + shortcode?: string; + useAuthentication?: boolean; +}; + +export function ReactionKeyInline({ + mx, + reactionKey, + shortcode, + useAuthentication, +}: ReactionKeyInlineProps) { + const [imgError, setImgError] = useState(false); + + if (!reactionKey) { + if (shortcode) { + return ( + + :{shortcode}: + + ); + } + return null; + } + + if (reactionKey.startsWith('mxc://')) { + if (imgError) { + return ( + + {menuIcon(Warning, { style: { opacity: 0.5 } })} + + ); + } + + return ( + {shortcode setImgError(true)} + /> + ); + } + + return ( + + {scaleSystemEmoji(reactionKey)} + + ); +} diff --git a/src/app/components/message/Reply.tsx b/src/app/components/message/Reply.tsx index c32e1c6ab..b25d2130d 100644 --- a/src/app/components/message/Reply.tsx +++ b/src/app/components/message/Reply.tsx @@ -1,5 +1,4 @@ -import type { IconSrc } from 'folds'; -import { Box, Chip, Icon, Icons, Text, as, color, toRem } from 'folds'; +import { Box, Chip, Text, as, color, toRem } from 'folds'; import type { EventTimelineSet, IMentions, Room, SessionMembershipData } from '$types/matrix-sdk'; import { EventType, MsgType } from '$types/matrix-sdk'; import type { MouseEventHandler, ReactNode } from 'react'; @@ -8,7 +7,30 @@ import { useQueryClient } from '@tanstack/react-query'; import classNames from 'classnames'; import parse from 'html-react-parser'; import { useAtomValue } from 'jotai'; -import { getMemberDisplayName, trimReplyFromBody, trimReplyFromFormattedBody } from '$utils/room'; +import { + ArrowBendUpRightIcon, + ArrowsClockwise, + ChatCircle, + chipIcon, + Code, + Hash, + ListBullets, + menuIcon, + Phone, + PhoneDisconnect, + PushPin, + timelineIcon, + Trash, + Smiley, +} from '$components/icons/phosphor'; +import { + getMemberDisplayName, + getReactionKey, + getReactionShortcode, + getRedactionTargetId, + trimReplyFromBody, + trimReplyFromFormattedBody, +} from '$utils/room'; import { getMxIdLocalPart } from '$utils/matrix'; import { randomNumberBetween } from '$utils/common'; import { sanitizeCustomHtml } from '$utils/sanitize'; @@ -41,15 +63,19 @@ import { MessageEmptyContent, MessageFailedContent, MessageUnsupportedContent, + ReactionDeletedContent, } from './content'; import * as css from './Reply.css'; import { LinePlaceholder } from './placeholder'; +import { ReactionKeyInline } from './ReactionKeyInline'; import { M_POLL_START, M_TEXT } from 'matrix-js-sdk'; const ROOM_REPLY_TIMELINE_EVENT_TYPES = new Set([ EventType.RoomMessage as string, EventType.RoomMessageEncrypted as string, EventType.Sticker as string, + EventType.Reaction as string, + EventType.RoomRedaction as string, ]); const nonEmptyTrimmed = (v: unknown): string | undefined => { @@ -77,25 +103,44 @@ export const replyPreviewBodyForTimelineEvent = ( content: Record, isRedacted: boolean ): ReactNode | undefined => { - if (!eventType || !ROOM_REPLY_TIMELINE_EVENT_TYPES.has(eventType)) return undefined; + if (!eventType) return undefined; + + if (eventType === (EventType.RoomRedaction as string)) { + return 'redacted a message'; + } + + if (eventType === (EventType.Reaction as string)) { + if (isRedacted) { + return ; + } + return undefined; + } + + if (!ROOM_REPLY_TIMELINE_EVENT_TYPES.has(eventType)) return undefined; + + const effectiveContent = + content['m.new_content'] != null && typeof content['m.new_content'] === 'object' + ? (content['m.new_content'] as Record) + : content; + if (isRedacted) return ; if (eventType === (EventType.Sticker as string)) { - const stickerBody = nonEmptyTrimmed(content.body); + const stickerBody = nonEmptyTrimmed(effectiveContent.body); if (stickerBody) return scaleSystemEmoji(stickerBody); return 'Sticker'; } - const rawMsgtype = content.msgtype; + const rawMsgtype = effectiveContent.msgtype; if (typeof rawMsgtype !== 'string') { return ; } const msgtype = rawMsgtype as MsgType; const trimmedBody = nonEmptyTrimmed( - typeof content.body === 'string' ? trimReplyFromBody(content.body) : '' + typeof effectiveContent.body === 'string' ? trimReplyFromBody(effectiveContent.body) : '' ); - const filename = nonEmptyTrimmed(content.filename); + const filename = nonEmptyTrimmed(effectiveContent.filename); if (trimmedBody) return undefined; const attachmentLabel = filename; @@ -123,7 +168,7 @@ export const replyPreviewBodyForTimelineEvent = ( type ReplyLayoutProps = { userColor?: string; username?: ReactNode; - icon?: IconSrc; + icon?: ReactNode; mentioned: boolean; replyIcon?: JSX.Element; }; @@ -137,11 +182,11 @@ export const ReplyLayout = as<'div', ReplyLayoutProps>( ref={ref} > - {replyIcon || } + {replyIcon ?? menuIcon(ArrowBendUpRightIcon)} - {!!icon && } + {icon} - {mentioned && } + {mentioned && '@'} {username} @@ -160,7 +205,7 @@ export const ThreadIndicator = as<'div'>(({ ...props }, ref) => ( {...props} ref={ref} > - + {chipIcon(ChatCircle)} Thread )); @@ -173,6 +218,7 @@ type ReplyProps = { mentions?: IMentions; onClick?: MouseEventHandler; replyIcon?: JSX.Element; + previewBodyOverride?: string; }; export const sanitizeReplyFormattedPreview = (formattedBody: string): string => { @@ -190,7 +236,17 @@ export const sanitizeReplyFormattedPreview = (formattedBody: string): string => export const Reply = as<'div', ReplyProps>( ( - { room, timelineSet, replyEventId, threadRootId, mentions, onClick, replyIcon, ...props }, + { + room, + timelineSet, + replyEventId, + threadRootId, + mentions, + onClick, + replyIcon, + previewBodyOverride, + ...props + }, ref ) => { const placeholderWidth = useMemo(() => randomNumberBetween(40, 400), []); @@ -203,19 +259,25 @@ export const Reply = as<'div', ReplyProps>( const mx = useMatrixClient(); - const { body, formatted_body: formattedBody, format } = replyEvent?.getContent() ?? {}; - const extensibleContent = replyEvent?.getContent()[M_TEXT.name] as + const rawContent = replyEvent?.getContent() ?? {}; + const contentForPreview = + rawContent['m.new_content'] != null && typeof rawContent['m.new_content'] === 'object' + ? (rawContent['m.new_content'] as Record) + : rawContent; + + const { body, formatted_body: formattedBody, format } = contentForPreview; + const extensibleContent = contentForPreview[M_TEXT.name] as | string | { body: string } | undefined; const extensibleBody = (extensibleContent as { body: string })?.body ?? extensibleContent; const sender = replyEvent?.getSender(); const eventType = replyEvent?.getType(); + const isRedacted = replyEvent?.isRedacted() === true; const ignoredUsers = useIgnoredUsers(); const isBlockedSender = !!sender && ignoredUsers.includes(sender); const { t } = useTranslation(); - const isRedacted = replyEvent?.isRedacted() === true; const parseMemberEvent = useMemberEventParser(); @@ -232,7 +294,20 @@ export const Reply = as<'div', ReplyProps>( 'incomingInlineImagesMaxHeight' ); - const fallbackBody = isRedacted ? : ; + const fallbackBody = + isRedacted && eventType === (EventType.Reaction as string) ? ( + + ) : isRedacted ? ( + + ) : ( + + ); const badEncryption = replyEvent?.getContent().msgtype === 'm.bad.encrypted'; const mentionClickHandler = useMentionClickHandler(room.roomId); @@ -252,7 +327,7 @@ export const Reply = as<'div', ReplyProps>( !replyEvent.getClearContent(); let bodyJSX: ReactNode = fallbackBody; - let image: IconSrc | undefined; + let image: ReactNode | undefined; let mentioned = sender != null && (mentions?.user_ids?.includes(sender) ?? false); const replyLinkifyOpts = useMemo( @@ -279,7 +354,7 @@ export const Reply = as<'div', ReplyProps>( question: { [M_TEXT.name]?: string; body?: string }; } )?.question; - image = Icons.UnorderList; + image = timelineIcon(ListBullets); bodyJSX = `'s poll asking ${(question[M_TEXT.name] as string) ?? question.body ?? ''}`; } else if (isFormattedReply && formattedBody !== '') { const sanitizedHtml = sanitizeReplyFormattedPreview(formattedBody); @@ -318,18 +393,57 @@ export const Reply = as<'div', ReplyProps>(
); } else if (eventType === EventType.RoomName) { - image = Icons.Hash; + image = timelineIcon(Hash); bodyJSX = t('Organisms.RoomCommon.changed_room_name'); } else if (eventType === EventType.RoomTopic) { - image = Icons.Hash; + image = timelineIcon(Hash); bodyJSX = ' changed room topic'; } else if (eventType === EventType.RoomAvatar) { - image = Icons.Hash; + image = timelineIcon(Hash); bodyJSX = ' changed room avatar'; } else if (eventType === EventType.GroupCallMemberPrefix && !!replyEvent) { const callJoined = replyEvent.getContent().application; - image = callJoined ? Icons.Phone : Icons.PhoneDown; + image = callJoined ? timelineIcon(Phone) : timelineIcon(PhoneDisconnect); bodyJSX = callJoined ? ' joined the call' : ' ended the call'; + } else if (eventType === EventType.RoomRedaction && replyEvent) { + image = timelineIcon(Trash); + const redactionTargetId = getRedactionTargetId(replyEvent); + const redactionTarget = redactionTargetId + ? (timelineSet?.findEventById(redactionTargetId) ?? + room.findEventById(redactionTargetId) ?? + null) + : null; + bodyJSX = + redactionTarget?.getType() === (EventType.Reaction as string) + ? ' redacted a reaction' + : ' redacted a message'; + } else if (eventType === EventType.Reaction && !!replyEvent) { + image = isRedacted ? timelineIcon(Trash) : timelineIcon(Smiley); + if (isRedacted) { + bodyJSX = ( + + ); + } else { + const reactionKey = getReactionKey(replyEvent); + const reactionShortcode = getReactionShortcode(replyEvent); + bodyJSX = ( + <> + {' reacted with '} + + + ); + } } else if (eventType === EventType.RoomPinnedEvents && replyEvent) { const { pinned } = replyEvent.getContent(); const prevPinned = replyEvent.getPrevContent().pinned; @@ -337,7 +451,7 @@ export const Reply = as<'div', ReplyProps>( prevPinned && pinned && pinned.filter((x: string) => !prevPinned.includes(x)); const pinsRemoved = prevPinned && pinned && prevPinned.filter((x: string) => !pinned.includes(x)); - image = Icons.Pin; + image = timelineIcon(PushPin); bodyJSX = ( <> {(pinsAdded?.length > 0 && @@ -361,7 +475,7 @@ export const Reply = as<'div', ReplyProps>( if (timelinePreview !== undefined) { bodyJSX = timelinePreview; } else if (replyEvent.isState()) { - image = Icons.Code; + image = timelineIcon(Code); bodyJSX = ( <> {' sent '} @@ -373,6 +487,14 @@ export const Reply = as<'div', ReplyProps>( bodyJSX = ; } } + if (typeof previewBodyOverride === 'string' && previewBodyOverride.length > 0 && !isRedacted) { + const strippedOverride = trimReplyFromBody(previewBodyOverride).replaceAll( + /(?:\r\n|\r|\n)/g, + ' ' + ); + bodyJSX = scaleSystemEmoji(strippedOverride); + } + let replyContent = bodyJSX; if (isBlockedSender) { replyContent = ; @@ -407,22 +529,20 @@ export const Reply = as<'div', ReplyProps>( {replyContent} ) : ( - (isRedacted && ) || ( - - ) + )} {replyEvent === null && ( } + before={menuIcon(ArrowsClockwise)} onClick={(evt) => { evt.stopPropagation(); void queryClient.invalidateQueries({ diff --git a/src/app/components/message/content/AudioContent.tsx b/src/app/components/message/content/AudioContent.tsx index 89674edd9..1039031d5 100644 --- a/src/app/components/message/content/AudioContent.tsx +++ b/src/app/components/message/content/AudioContent.tsx @@ -1,7 +1,8 @@ /* oxlint-disable jsx-a11y/media-has-caption */ import type { ReactNode } from 'react'; import { useCallback, useEffect, useRef, useState } from 'react'; -import { Badge, Chip, Icon, IconButton, Icons, ProgressBar, Spinner, Text, toRem } from 'folds'; +import { Badge, Chip, IconButton, ProgressBar, Spinner, Text, toRem } from 'folds'; +import { sizedIcon, Pause, Play, SpeakerHigh, SpeakerSlash } from '$components/icons/phosphor'; import type { EncryptedAttachmentInfo } from 'browser-encrypt-attachment'; import { Range } from 'react-range'; import { useMatrixClient } from '$hooks/useMatrixClient'; @@ -173,7 +174,7 @@ export function AudioContent({ srcState.status === AsyncStatus.Loading || loading ? ( ) : ( - + sizedIcon(playing ? Pause : Play, '50', { filled: playing }) ) } > @@ -194,7 +195,7 @@ export function AudioContent({ onClick={() => setMute(!mute)} aria-pressed={mute} > - + {sizedIcon(mute ? SpeakerSlash : SpeakerHigh, '50')} {messageLayout === (MessageLayout.Compact as number) && time} @@ -19,7 +18,7 @@ export function EventContent({ messageLayout, time, iconSrc, content }: EventCon alignItems="Center" justifyContent="Center" > - + {icon}
); diff --git a/src/app/components/message/content/FallbackContent.tsx b/src/app/components/message/content/FallbackContent.tsx index 638e830c3..89c8365ab 100644 --- a/src/app/components/message/content/FallbackContent.tsx +++ b/src/app/components/message/content/FallbackContent.tsx @@ -1,5 +1,8 @@ -import { Box, Icon, Icons, Text, as, color, config } from 'folds'; +import { Box, Text, as, color, config } from 'folds'; +import type { MatrixClient } from '$types/matrix-sdk'; +import { Lock, timelineIcon, Trash, Warning, X } from '$components/icons/phosphor'; +import { ReactionKeyInline } from '../ReactionKeyInline'; import { BreakWord } from '$styles/Text.css'; const warningStyle = { color: color.Warning.Main, opacity: config.opacity.P300 }; @@ -8,7 +11,7 @@ const criticalStyle = { color: color.Critical.Main, opacity: config.opacity.P300 export const MessageDeletedContent = as<'div', { children?: never; reason?: string }>( ({ reason, ...props }, ref) => ( - + {timelineIcon(Trash, { style: warningStyle })} {reason ? ( This message has been deleted. {reason} ) : ( @@ -18,6 +21,43 @@ export const MessageDeletedContent = as<'div', { children?: never; reason?: stri ) ); +export const ReactionDeletedContent = as< + 'div', + { + children?: never; + reactionKey?: string; + shortcode?: string; + mx?: MatrixClient; + useAuthentication?: boolean; + reason?: string; + hideIcon?: boolean; + } +>(({ reactionKey, shortcode, mx, useAuthentication, reason, hideIcon, ...props }, ref) => ( + + {!hideIcon && timelineIcon(Trash, { style: warningStyle })} + {reactionKey || shortcode ? ( + + This reaction has been removed:{' '} + {mx ? ( + + ) : ( + (reactionKey ?? `:${shortcode}:`) + )} + {reason ? ` ${reason}` : ''} + + ) : reason ? ( + This reaction has been removed. {reason} + ) : ( + This reaction has been removed + )} + +)); + export const MessageUnsupportedContent = as<'div', { children?: never; body?: string }>( ({ body, ...props }, ref) => ( - + {timelineIcon(Warning, { style: criticalStyle })} Unsupported message {body && `: ${body}`} @@ -41,21 +81,21 @@ export const MessageUnsupportedContent = as<'div', { children?: never; body?: st export const MessageFailedContent = as<'div', { children?: never }>(({ ...props }, ref) => ( - + {timelineIcon(Warning, { style: criticalStyle })} Failed to load message )); export const MessageBadEncryptedContent = as<'div', { children?: never }>(({ ...props }, ref) => ( - + {timelineIcon(Lock, { style: warningStyle })} Unable to decrypt message )); export const MessageNotDecryptedContent = as<'div', { children?: never }>(({ ...props }, ref) => ( - + {timelineIcon(Lock, { style: warningStyle })} This message is not decrypted yet )); @@ -72,7 +112,7 @@ export const MessageBrokenContent = as<'div', { children?: never; body?: string {...props} ref={ref} > - + {timelineIcon(Warning, { style: criticalStyle })} Broken message {body && `: ${body}`} @@ -84,14 +124,14 @@ export const MessageBrokenContent = as<'div', { children?: never; body?: string export const MessageEmptyContent = as<'div', { children?: never }>(({ ...props }, ref) => ( - + {timelineIcon(Warning, { style: criticalStyle })} Empty message )); export const MessageBlockedContent = as<'div', { children?: never }>(({ ...props }, ref) => ( - + {timelineIcon(X, { style: warningStyle })} Message from a blocked user )); diff --git a/src/app/components/message/content/FileContent.tsx b/src/app/components/message/content/FileContent.tsx index 73b11613f..2e7e0daa8 100644 --- a/src/app/components/message/content/FileContent.tsx +++ b/src/app/components/message/content/FileContent.tsx @@ -3,8 +3,6 @@ import { useCallback, useState } from 'react'; import { Box, Button, - Icon, - Icons, Modal, Overlay, OverlayBackdrop, @@ -15,6 +13,7 @@ import { TooltipProvider, as, } from 'folds'; +import { ArrowRight, Download, sizedIcon, Warning } from '$components/icons/phosphor'; import FileSaver from 'file-saver'; import type { EncryptedAttachmentInfo } from 'browser-encrypt-attachment'; import FocusTrap from 'focus-trap-react'; @@ -52,7 +51,7 @@ const renderErrorButton = (retry: () => void, text: string) => ( outlined radii="300" onClick={retry} - before={} + before={sizedIcon(Warning, '100', { filled: true })} > {text} @@ -141,7 +140,7 @@ export function ReadTextFile({ body, mimeType, url, encInfo, renderViewer }: Rea textState.status === AsyncStatus.Loading ? ( ) : ( - + sizedIcon(ArrowRight, '100', { filled: true }) ) } > @@ -225,7 +224,7 @@ export function ReadPdfFile({ body, mimeType, url, encInfo, renderViewer }: Read pdfState.status === AsyncStatus.Loading ? ( ) : ( - + sizedIcon(ArrowRight, '100', { filled: true }) ) } > @@ -281,7 +280,7 @@ export function DownloadFile({ body, mimeType, url, info, encInfo }: DownloadFil downloadState.status === AsyncStatus.Loading ? ( ) : ( - + sizedIcon(Download, '100', { filled: true }) ) } > diff --git a/src/app/components/message/content/ImageContent.tsx b/src/app/components/message/content/ImageContent.tsx index 590736760..4aa3b33c1 100644 --- a/src/app/components/message/content/ImageContent.tsx +++ b/src/app/components/message/content/ImageContent.tsx @@ -5,8 +5,6 @@ import { Box, Button, Chip, - Icon, - Icons, Menu, MenuItem, Modal, @@ -21,6 +19,7 @@ import { config, toRem, } from 'folds'; +import { Eye, EyeSlash, menuIcon, sizedIcon, Image, Warning } from '$components/icons/phosphor'; import classNames from 'classnames'; import { BlurhashCanvas } from 'react-blurhash'; import FocusTrap from 'focus-trap-react'; @@ -272,7 +271,7 @@ export const ImageContent = as<'div', ImageContentProps>( radii="300" size="300" onClick={loadSrc} - before={} + before={sizedIcon(Image, 'Inherit', { filled: true })} > View @@ -364,7 +363,7 @@ export const ImageContent = as<'div', ImageContentProps>( outlined radii="300" onClick={handleRetry} - before={} + before={sizedIcon(Warning, 'Inherit', { filled: true })} > Retry @@ -377,7 +376,7 @@ export const ImageContent = as<'div', ImageContentProps>( } + after={menuIcon(blurred ? Eye : EyeSlash)} radii="300" fill="Soft" variant="Secondary" diff --git a/src/app/components/message/content/VideoContent.tsx b/src/app/components/message/content/VideoContent.tsx index 2b1166084..e514f4052 100644 --- a/src/app/components/message/content/VideoContent.tsx +++ b/src/app/components/message/content/VideoContent.tsx @@ -5,8 +5,6 @@ import { Box, Button, Chip, - Icon, - Icons, Menu, MenuItem, Spinner, @@ -16,6 +14,7 @@ import { as, config, } from 'folds'; +import { Eye, EyeSlash, menuIcon, sizedIcon, Play, Warning } from '$components/icons/phosphor'; import classNames from 'classnames'; import { BlurhashCanvas } from 'react-blurhash'; import type { EncryptedAttachmentInfo } from 'browser-encrypt-attachment'; @@ -147,7 +146,7 @@ export const VideoContent = as<'div', VideoContentProps>( radii="300" size="300" onClick={loadSrc} - before={} + before={sizedIcon(Play, 'Inherit', { filled: true })} > Watch @@ -229,7 +228,7 @@ export const VideoContent = as<'div', VideoContentProps>( outlined radii="300" onClick={handleRetry} - before={} + before={sizedIcon(Warning, 'Inherit', { filled: true })} > Retry @@ -242,7 +241,7 @@ export const VideoContent = as<'div', VideoContentProps>( } + after={menuIcon(blurred ? Eye : EyeSlash)} radii="300" fill="Soft" variant="Secondary" diff --git a/src/app/components/message/index.ts b/src/app/components/message/index.ts index 6f7415ad3..4d6326b55 100644 --- a/src/app/components/message/index.ts +++ b/src/app/components/message/index.ts @@ -1,6 +1,8 @@ export * from './layout'; export * from './placeholder'; export * from './Reaction'; +export * from './ReactionKeyInline'; +export * from './InlineTextDiff'; export * from './attachment'; export * from './Reply'; export * from './content'; diff --git a/src/app/components/message/modals/MessageDelete.tsx b/src/app/components/message/modals/MessageDelete.tsx index 7e4fba5be..98e2b0709 100644 --- a/src/app/components/message/modals/MessageDelete.tsx +++ b/src/app/components/message/modals/MessageDelete.tsx @@ -7,8 +7,6 @@ import { Dialog, Header, IconButton, - Icon, - Icons, Text, Input, Button, @@ -17,6 +15,7 @@ import { config, color, } from 'folds'; +import { menuIcon, Trash, X } from '$components/icons/phosphor'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback'; import { modalAtom, ModalType } from '$state/modal'; @@ -32,7 +31,7 @@ export function MessageDeleteItem({ room, mEvent }: { room: Room; mEvent: Matrix return ( } + after={menuIcon(Trash)} radii="300" fill="None" variant="Critical" @@ -115,7 +114,7 @@ export function MessageDeleteInternal({ room, mEvent, onClose }: MessageDeleteIn Delete Message - + {menuIcon(X)} } + after={menuIcon(Clock)} radii="300" onClick={(e: MouseEvent) => { e.preventDefault(); diff --git a/src/app/components/message/modals/MessageForward.tsx b/src/app/components/message/modals/MessageForward.tsx index 36de4b1f9..946f764a0 100644 --- a/src/app/components/message/modals/MessageForward.tsx +++ b/src/app/components/message/modals/MessageForward.tsx @@ -2,10 +2,11 @@ import { useMatrixClient } from '$hooks/useMatrixClient'; import { modalAtom, ModalType } from '$state/modal'; -import { Icon, Icons, MenuItem, Text, as } from 'folds'; +import { MenuItem, Text, as } from 'folds'; +import { ArrowRight, menuIcon } from '$components/icons/phosphor'; import { useAtomValue, useSetAtom } from 'jotai'; import type { MatrixEvent, Room } from '$types/matrix-sdk'; -import { useCallback, useMemo, useState } from 'react'; +import { useCallback, useEffect, useMemo, useState } from 'react'; import { allRoomsAtom } from '$state/room-list/roomList'; import { useAllJoinedRoomsSet, useGetRoom } from '$hooks/useGetRoom'; import { factoryRoomIdByActivity } from '$utils/sort'; @@ -14,6 +15,7 @@ import { sanitizeCustomHtml, sanitizeText } from '$utils/sanitize'; import { createDebugLogger } from '$utils/debugLogger'; import * as Sentry from '@sentry/react'; import { isRoomPrivate } from '$utils/roomVisibility'; +import { canForwardEvent } from '$utils/room'; import * as prefix from '$unstable/prefixes'; import { RoomSearchModal } from '$features/search'; const debugLog = createDebugLogger('MessageForward'); @@ -23,6 +25,8 @@ export const MessageForwardItem = as<'button', MessageForwardItemProps>( ({ room, mEvent, onClose, ...props }: MessageForwardItemProps) => { const setModal = useSetAtom(modalAtom); + if (!canForwardEvent(mEvent)) return null; + const handleClick = () => { setModal({ type: ModalType.Forward, @@ -35,7 +39,7 @@ export const MessageForwardItem = as<'button', MessageForwardItemProps>( return ( } + after={menuIcon(ArrowRight)} radii="300" {...props} onClick={handleClick} @@ -92,12 +96,17 @@ export function MessageForwardInternal({ onClose, }: Readonly) { const mx = useMatrixClient(); - + const forwardable = canForwardEvent(mEvent); const [isForwarding, setIsForwarding] = useState(false); const [forwardError, setForwardError] = useState(null); const allRooms = useAtomValue(allRoomsAtom); const allJoinedRooms = useAllJoinedRoomsSet(); const getRoom = useGetRoom(allJoinedRooms); + + useEffect(() => { + if (!forwardable) onClose(); + }, [forwardable, onClose]); + // possible targets to forward the message to const forwardTargets = useMemo( () => @@ -259,6 +268,8 @@ export function MessageForwardInternal({ [forwardError, forwardTargets, forwardToRoom, isForwarding] ); + if (!forwardable) return null; + return ; } diff --git a/src/app/components/message/modals/MessageReactions.tsx b/src/app/components/message/modals/MessageReactions.tsx index a2fbae286..d875acc42 100644 --- a/src/app/components/message/modals/MessageReactions.tsx +++ b/src/app/components/message/modals/MessageReactions.tsx @@ -1,7 +1,8 @@ import type { MouseEvent } from 'react'; import type { Room, Relations } from '$types/matrix-sdk'; import { useSetAtom } from 'jotai'; -import { Icon, Icons, Text, MenuItem } from 'folds'; +import { Text, MenuItem } from 'folds'; +import { menuIcon, Smiley } from '$components/icons/phosphor'; import { modalAtom, ModalType } from '$state/modal'; import * as css from '$features/room/message/styles.css'; import { ReactionViewer } from '$features/room/reaction-viewer'; @@ -12,7 +13,7 @@ export function MessageAllReactionItem({ room, relations }: { room: Room; relati return ( } + after={menuIcon(Smiley)} radii="300" onClick={(e: MouseEvent) => { e.preventDefault(); diff --git a/src/app/components/message/modals/MessageReadRecipts.tsx b/src/app/components/message/modals/MessageReadRecipts.tsx index 6dfec9849..a5bf89ec2 100644 --- a/src/app/components/message/modals/MessageReadRecipts.tsx +++ b/src/app/components/message/modals/MessageReadRecipts.tsx @@ -1,7 +1,8 @@ import type { MouseEvent } from 'react'; import type { Room } from '$types/matrix-sdk'; import { useSetAtom } from 'jotai'; -import { MenuItem, Icon, Icons, Text } from 'folds'; +import { MenuItem, Text } from 'folds'; +import { Checks, menuIcon } from '$components/icons/phosphor'; import { modalAtom, ModalType } from '$state/modal'; import { EventReaders } from '$components/event-readers'; import * as css from '$features/room/message/styles.css'; @@ -12,7 +13,7 @@ export function MessageReadReceiptItem({ room, eventId }: { room: Room; eventId: return ( } + after={menuIcon(Checks)} radii="300" onClick={(e: MouseEvent) => { e.preventDefault(); diff --git a/src/app/components/message/modals/MessageReport.tsx b/src/app/components/message/modals/MessageReport.tsx index 1d1357ddf..c71ff662e 100644 --- a/src/app/components/message/modals/MessageReport.tsx +++ b/src/app/components/message/modals/MessageReport.tsx @@ -7,8 +7,6 @@ import { Dialog, Header, IconButton, - Icon, - Icons, Text, Input, Button, @@ -17,6 +15,7 @@ import { config, color, } from 'folds'; +import { menuIcon, Warning, X } from '$components/icons/phosphor'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback'; import * as css from '$features/room/message/styles.css'; @@ -34,7 +33,7 @@ export function MessageReportItem({ room, mEvent }: { room: Room; mEvent: Matrix size="300" variant="Critical" fill="None" - after={} + after={menuIcon(Warning)} radii="300" onClick={(e: MouseEvent) => { e.preventDefault(); @@ -114,7 +113,7 @@ export function MessageReportInternal({ room, mEvent, onClose }: MessageReportIn Report Message - + {menuIcon(X)} } + after={menuIcon(CodeBlock)} radii="300" onClick={(e: MouseEvent) => { e.preventDefault(); diff --git a/src/app/components/notification-banner/NotificationBanner.tsx b/src/app/components/notification-banner/NotificationBanner.tsx index 4476e8389..4d70fd084 100644 --- a/src/app/components/notification-banner/NotificationBanner.tsx +++ b/src/app/components/notification-banner/NotificationBanner.tsx @@ -1,7 +1,8 @@ import { useAtom } from 'jotai'; import type { ReactNode } from 'react'; import { useCallback, useEffect, useRef, useState } from 'react'; -import { Box, Icon, IconButton, Icons, Text } from 'folds'; +import { Box, IconButton, Text } from 'folds'; +import { sizedIcon, X } from '$components/icons/phosphor'; import { createLogger } from '$utils/debug'; import type { InAppBannerNotification } from '$state/sessions'; import { inAppBannerAtom } from '$state/sessions'; @@ -70,7 +71,7 @@ function BannerItem({ notification, onDismiss }: BannerItemProps) { dismissAnimTimerRef.current = setTimeout(() => onDismiss(notification.id), 200); }, [notification.id, onDismiss]); - // Auto-dismiss timer — only runs when not paused. + // Auto-dismiss timer  Eonly runs when not paused. useEffect(() => { if (paused) return undefined; const remaining = BANNER_DURATION_MS - elapsedRef.current; @@ -132,7 +133,7 @@ function BannerItem({ notification, onDismiss }: BannerItemProps) { {notification.senderName ?? notification.title} {(notification.roomName || notification.serverName) && ( - {' (​'} + {' ('} {notification.roomName && `#${notification.roomName}`} {notification.roomName && notification.serverName && ', '} {notification.serverName}) @@ -157,7 +158,7 @@ function BannerItem({ notification, onDismiss }: BannerItemProps) { }} aria-label="Dismiss notification" > - + {sizedIcon(X, '100')}
3 ? next.slice(next.length - 3) : next; diff --git a/src/app/components/password-input/PasswordInput.tsx b/src/app/components/password-input/PasswordInput.tsx index d859af8d7..a8f2f1e55 100644 --- a/src/app/components/password-input/PasswordInput.tsx +++ b/src/app/components/password-input/PasswordInput.tsx @@ -1,6 +1,7 @@ import type { ComponentProps } from 'react'; import { forwardRef } from 'react'; -import { Icon, IconButton, Input, config, Icons } from 'folds'; +import { IconButton, Input, config } from 'folds'; +import { Eye, EyeSlash, sizedIcon } from '$components/icons/phosphor'; import { UseStateProvider } from '$components/UseStateProvider'; type PasswordInputProps = Omit, 'type' | 'size'> & { @@ -30,11 +31,9 @@ export const PasswordInput = forwardRef( size="300" radii="300" > - + {sizedIcon(visible ? Eye : EyeSlash, '100', { + style: { opacity: config.opacity.P300 }, + })} } diff --git a/src/app/components/room-avatar/RoomAvatar.css.ts b/src/app/components/room-avatar/RoomAvatar.css.ts index c9745a9aa..5acd6482e 100644 --- a/src/app/components/room-avatar/RoomAvatar.css.ts +++ b/src/app/components/room-avatar/RoomAvatar.css.ts @@ -1,5 +1,5 @@ -import { style } from '@vanilla-extract/css'; -import { color } from 'folds'; +import { style, styleVariants } from '@vanilla-extract/css'; +import { color, config } from 'folds'; export const RoomAvatar = style({ backgroundColor: color.Secondary.Container, @@ -12,3 +12,62 @@ export const RoomAvatar = style({ }, }, }); + +export const RoomIconRoot = style({ + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + width: '100%', + height: '100%', + lineHeight: 0, + overflow: 'visible', +}); + +export const RoomIconComposite = style({ + position: 'relative', + display: 'inline-flex', + alignItems: 'center', + justifyContent: 'center', + lineHeight: 0, + flexShrink: 0, + overflow: 'visible', +}); + +export const RoomIconBadge = style({ + position: 'absolute', + top: '-4%', + right: '-4%', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + aspectRatio: '1', + boxSizing: 'border-box', + backgroundColor: color.Background.Container, + lineHeight: 0, + zIndex: 1, + overflow: 'visible', + pointerEvents: 'none', +}); + +export const RoomIconBadgeShape = styleVariants({ + globe: { + width: '62%', + padding: 0, + borderRadius: '50%', + }, + lock: { + width: '64%', + padding: 0, + borderTopLeftRadius: config.radii.R300, + borderTopRightRadius: config.radii.R300, + borderBottomLeftRadius: '20%', + borderBottomRightRadius: '20%', + }, +}); + +export const RoomIconBadgeIcon = style({ + display: 'flex', + width: '100%', + height: '100%', + flexShrink: 0, +}); diff --git a/src/app/components/room-avatar/RoomAvatar.tsx b/src/app/components/room-avatar/RoomAvatar.tsx index fa8acd4e5..18cc39fa5 100644 --- a/src/app/components/room-avatar/RoomAvatar.tsx +++ b/src/app/components/room-avatar/RoomAvatar.tsx @@ -1,8 +1,16 @@ import type { JoinRule } from '$types/matrix-sdk'; -import { AvatarFallback, Icon, Icons, color } from 'folds'; -import type { ComponentProps, ReactNode } from 'react'; +import { AvatarFallback, color } from 'folds'; +import type { ReactNode } from 'react'; import { forwardRef, useEffect, useState } from 'react'; -import { getRoomIconSrc } from '$utils/room'; +import type { IconProps } from '@phosphor-icons/react'; +import classNames from 'classnames'; +import { sizedIcon, type IconSizeToken } from '$components/icons/phosphor'; +import { + getRoomIconComponent, + getRoomIconOverlay, + getRoomIconOverlayComponent, + getRoomStandaloneIconComponent, +} from '$components/icons/roomIcons'; import colorMXID from '$utils/colorMXID'; import * as css from './RoomAvatar.css'; import { AvatarImage } from './AvatarImage'; @@ -39,11 +47,47 @@ export function RoomAvatar({ roomId, src, alt, renderFallback, uniformIcons }: R } export const RoomIcon = forwardRef< - SVGSVGElement, - Omit, 'src'> & { + HTMLSpanElement, + Omit & { joinRule?: JoinRule; roomType?: string; + size?: IconSizeToken; + filled?: boolean; + withOverlay?: boolean; } ->(({ joinRule, roomType, ...props }, ref) => ( - -)); +>( + ( + { joinRule, roomType, size = '200', filled, withOverlay = true, className, style, ...props }, + ref + ) => { + const Icon = withOverlay + ? getRoomIconComponent(roomType, joinRule) + : getRoomStandaloneIconComponent(roomType, joinRule); + const overlay = withOverlay ? getRoomIconOverlay(roomType, joinRule) : undefined; + + if (overlay) { + const OverlayIcon = getRoomIconOverlayComponent(overlay); + return ( + + + {sizedIcon(Icon, size, { ...props, filled })} + + + + + + + + ); + } + + return ( + + {sizedIcon(Icon, size, { ...props, filled })} + + ); + } +); diff --git a/src/app/components/room-card/RoomCard.tsx b/src/app/components/room-card/RoomCard.tsx index 9c35f0186..74f698734 100644 --- a/src/app/components/room-card/RoomCard.tsx +++ b/src/app/components/room-card/RoomCard.tsx @@ -8,8 +8,6 @@ import { Box, Button, Dialog, - Icon, - Icons, Overlay, OverlayBackdrop, OverlayCenter, @@ -22,6 +20,7 @@ import { } from 'folds'; import classNames from 'classnames'; import FocusTrap from 'focus-trap-react'; +import { userFallbackIcon } from '$components/icons/phosphor'; import { getMxIdLocalPart, mxcUrlToHttp } from '$utils/matrix'; import { nameInitials } from '$utils/common'; import { useMatrixClient } from '$hooks/useMatrixClient'; @@ -284,7 +283,7 @@ export const RoomCard = as<'div', RoomCardProps>( {typeof joinedMemberCount === 'number' && ( - + {userFallbackIcon('sm')} {`${formatCompactNumber(joinedMemberCount)} Members`} )} diff --git a/src/app/components/room-intro/RoomIntro.tsx b/src/app/components/room-intro/RoomIntro.tsx index cd993fb38..fdd09c927 100644 --- a/src/app/components/room-intro/RoomIntro.tsx +++ b/src/app/components/room-intro/RoomIntro.tsx @@ -1,5 +1,5 @@ import { useCallback, useEffect, useState } from 'react'; -import { Avatar, Box, Button, Icon, Icons, Spinner, Text, as } from 'folds'; +import { Avatar, Box, Button, Spinner, Text, as } from 'folds'; import type { Room } from '$types/matrix-sdk'; import { useAtomValue } from 'jotai'; import type { IRoomCreateContent } from '$types/matrix/room'; @@ -20,6 +20,7 @@ import { settingsAtom } from '$state/settings'; import { RoomAvatar } from '$components/room-avatar'; import { InviteUserPrompt } from '$components/invite-user-prompt'; import { InfoCard } from '$components/info-card'; +import { userFallbackIcon } from '$components/icons/phosphor'; import { DirectInvitePrompt } from '$components/direct-invite-prompt'; import { EventType, KnownMembership } from '$types/matrix-sdk'; @@ -117,7 +118,7 @@ export const RoomIntro = as<'div', RoomIntroProps>(({ room, ...props }, ref) => {isDirectConversation && ( } + before={userFallbackIcon('md')} beforeAlign="Center" description="This is a direct message" after={ diff --git a/src/app/components/room-topic-viewer/RoomTopicViewer.tsx b/src/app/components/room-topic-viewer/RoomTopicViewer.tsx index 8838cea25..8a25da319 100644 --- a/src/app/components/room-topic-viewer/RoomTopicViewer.tsx +++ b/src/app/components/room-topic-viewer/RoomTopicViewer.tsx @@ -1,4 +1,5 @@ -import { as, Box, Header, Icon, IconButton, Icons, Modal, Scroll, Text } from 'folds'; +import { as, Box, Header, IconButton, Modal, Scroll, Text } from 'folds'; +import { composerIcon, X } from '$components/icons/phosphor'; import classNames from 'classnames'; import Linkify from 'linkify-react'; import { LINKIFY_OPTS, scaleSystemEmoji } from '$plugins/react-custom-html-parser'; @@ -26,7 +27,7 @@ export const RoomTopicViewer = as< - + {composerIcon(X)} diff --git a/src/app/components/setting-menu-selector/SettingMenuSelector.tsx b/src/app/components/setting-menu-selector/SettingMenuSelector.tsx index 6717313b2..ff0fdaebf 100644 --- a/src/app/components/setting-menu-selector/SettingMenuSelector.tsx +++ b/src/app/components/setting-menu-selector/SettingMenuSelector.tsx @@ -1,6 +1,7 @@ import FocusTrap from 'focus-trap-react'; import type { RectCords } from 'folds'; -import { Box, Button, config, Icon, Icons, Menu, MenuItem, PopOut, Spinner, Text } from 'folds'; +import { Box, Button, config, Menu, MenuItem, PopOut, Spinner, Text } from 'folds'; +import { CaretDown, sizedIcon } from '$components/icons/phosphor'; import { type ComponentPropsWithoutRef, type MouseEventHandler, @@ -96,13 +97,7 @@ export function SettingMenuSelector({ outlined fill="Soft" radii="300" - after={ - loading ? ( - - ) : ( - - ) - } + after={loading ? : sizedIcon(CaretDown, '300')} onClick={handleOpenMenu} disabled={isDisabled} > diff --git a/src/app/components/setting-tile/SettingTile.tsx b/src/app/components/setting-tile/SettingTile.tsx index 7c3982442..53b5a56bb 100644 --- a/src/app/components/setting-tile/SettingTile.tsx +++ b/src/app/components/setting-tile/SettingTile.tsx @@ -1,5 +1,6 @@ import type { ReactNode } from 'react'; -import { Box, Icon, IconButton, Icons, Text } from 'folds'; +import { Box, IconButton, Text } from 'folds'; +import { Check, Link, sizedIcon } from '$components/icons/phosphor'; import { BreakWord } from '$styles/Text.css'; import { buildSettingsLink } from '$features/settings/settingsLink'; import { copyToClipboard } from '$utils/dom'; @@ -58,7 +59,7 @@ function SettingTileSettingLinkAction({ fill="None" radii="Inherit" > - + {sizedIcon(copied ? Check : Link, '50')} ); } diff --git a/src/app/components/telemetry-consent/TelemetryConsentBanner.tsx b/src/app/components/telemetry-consent/TelemetryConsentBanner.tsx index 5c1e90a08..6bc92f028 100644 --- a/src/app/components/telemetry-consent/TelemetryConsentBanner.tsx +++ b/src/app/components/telemetry-consent/TelemetryConsentBanner.tsx @@ -1,5 +1,6 @@ import { useEffect, useRef, useState } from 'react'; -import { Box, Button, Icon, Icons, Text } from 'folds'; +import { Box, Button, Text } from 'folds'; +import { Shield, sizedIcon } from '$components/icons/phosphor'; import * as css from './TelemetryConsentBanner.css'; const SENTRY_KEY = 'sable_sentry_enabled'; @@ -41,7 +42,7 @@ export function TelemetryConsentBanner() { aria-label="Crash reporting prompt" >
- + {sizedIcon(Shield, '400')}
Help improve Sable diff --git a/src/app/components/text-viewer/TextViewer.tsx b/src/app/components/text-viewer/TextViewer.tsx index 74cd47188..7f9f1f1bc 100644 --- a/src/app/components/text-viewer/TextViewer.tsx +++ b/src/app/components/text-viewer/TextViewer.tsx @@ -1,7 +1,8 @@ import type { ComponentProps, HTMLAttributes } from 'react'; import { forwardRef } from 'react'; import classNames from 'classnames'; -import { Box, Chip, Header, Icon, IconButton, Icons, Scroll, Text, as } from 'folds'; +import { Box, Chip, Header, IconButton, Scroll, Text, as } from 'folds'; +import { ArrowLeft, sizedIcon } from '$components/icons/phosphor'; import { CodeHighlightRenderer } from '$components/code-highlight'; import { copyToClipboard } from '$utils/dom'; import * as css from './TextViewer.css'; @@ -48,7 +49,7 @@ export const TextViewer = as<'div', TextViewerProps>(
- + {sizedIcon(ArrowLeft, '50')} {name} diff --git a/src/app/components/theme/ThemeMigrationBanner.tsx b/src/app/components/theme/ThemeMigrationBanner.tsx index 793e84755..5d65b5eff 100644 --- a/src/app/components/theme/ThemeMigrationBanner.tsx +++ b/src/app/components/theme/ThemeMigrationBanner.tsx @@ -6,14 +6,13 @@ import { config, Dialog, Header, - Icon, IconButton, - Icons, Overlay, OverlayBackdrop, OverlayCenter, Text, } from 'folds'; +import { sizedIcon, X } from '$components/icons/phosphor'; import { useStore } from 'jotai/react'; import { useOptionalClientConfig } from '$hooks/useClientConfig'; @@ -116,7 +115,7 @@ export function ThemeMigrationBanner() { disabled={busy} aria-label="Close" > - + {sizedIcon(X, '100')}
diff --git a/src/app/components/theme/ThemePreviewCard.tsx b/src/app/components/theme/ThemePreviewCard.tsx index 2c6026ae2..049ef3393 100644 --- a/src/app/components/theme/ThemePreviewCard.tsx +++ b/src/app/components/theme/ThemePreviewCard.tsx @@ -1,16 +1,6 @@ import { type ReactNode, useCallback, useMemo } from 'react'; -import { - Box, - Button, - Icon, - IconButton, - Icons, - Text, - Tooltip, - TooltipProvider, - toRem, - config, -} from 'folds'; +import { Box, Button, IconButton, Text, Tooltip, TooltipProvider, toRem, config } from 'folds'; +import { Check, Download, Link, Star, Warning, sizedIcon } from '$components/icons/phosphor'; import { useTimeoutToggle } from '$hooks/useTimeoutToggle'; import { copyToClipboard } from '$utils/dom'; @@ -109,14 +99,17 @@ export function ThemePreviewCard({ } > {(triggerRef) => ( - + style={{ + color: 'var(--sable-warn-on-container)', + flexShrink: 0, + display: 'inline-flex', + }} + > + {sizedIcon(Warning, '100', { filled: true })} + )} )} @@ -141,7 +134,7 @@ export function ThemePreviewCard({ handleCopy().catch(() => undefined); }} > - + {sizedIcon(copied ? Check : Link, '200')} )} @@ -157,7 +150,7 @@ export function ThemePreviewCard({ onExport(); }} > - + {sizedIcon(Download, '200')} )} @@ -173,7 +166,7 @@ export function ThemePreviewCard({ Promise.resolve(onToggleFavorite()).catch(() => undefined); }} > - + {sizedIcon(Star, '200', { filled: isFavorited })} )} diff --git a/src/app/components/uia-stages/PasswordStage.tsx b/src/app/components/uia-stages/PasswordStage.tsx index 5c8f04b44..3eeeb8b99 100644 --- a/src/app/components/uia-stages/PasswordStage.tsx +++ b/src/app/components/uia-stages/PasswordStage.tsx @@ -1,4 +1,5 @@ -import { Box, Button, color, config, Dialog, Header, Icon, IconButton, Icons, Text } from 'folds'; +import { Box, Button, color, config, Dialog, Header, IconButton, Text } from 'folds'; +import { Warning, composerIcon, sizedIcon, X } from '$components/icons/phosphor'; import type { FormEventHandler } from 'react'; import { AuthType } from '$types/matrix-sdk'; import { PasswordInput } from '$components/password-input'; @@ -46,7 +47,7 @@ export function PasswordStage({ Account Password - + {composerIcon(X)} {errorCode && ( - + {sizedIcon(Warning, '50', { filled: true })} {errorCode === (ErrorCode.M_FORBIDDEN as string) diff --git a/src/app/components/uia-stages/SSOStage.tsx b/src/app/components/uia-stages/SSOStage.tsx index 6de4cbdfd..fdc56cf13 100644 --- a/src/app/components/uia-stages/SSOStage.tsx +++ b/src/app/components/uia-stages/SSOStage.tsx @@ -1,4 +1,5 @@ -import { Box, Button, color, config, Dialog, Header, Icon, IconButton, Icons, Text } from 'folds'; +import { Box, Button, color, config, Dialog, Header, IconButton, Text } from 'folds'; +import { Warning, composerIcon, sizedIcon, X } from '$components/icons/phosphor'; import { useCallback, useEffect, useState } from 'react'; import type { StageComponentProps } from './types'; @@ -57,7 +58,7 @@ export function SSOStage({ SSO Login - + {composerIcon(X)} {errorCode && ( - + {sizedIcon(Warning, '50', { filled: true })} {`${errorCode}: ${error}`} diff --git a/src/app/components/upload-board/UploadBoard.tsx b/src/app/components/upload-board/UploadBoard.tsx index ff808124f..232d65fec 100644 --- a/src/app/components/upload-board/UploadBoard.tsx +++ b/src/app/components/upload-board/UploadBoard.tsx @@ -1,6 +1,7 @@ import type { MutableRefObject, ReactNode } from 'react'; import { useImperativeHandle, useRef } from 'react'; -import { Badge, Box, Chip, Header, Icon, Icons, Spinner, Text, as, percent } from 'folds'; +import { Badge, Box, Chip, Header, Spinner, Text, as, percent } from 'folds'; +import { CaretRight, CaretUp, PaperPlaneTilt, X, sizedIcon } from '$components/icons/phosphor'; import classNames from 'classnames'; import { useAtomValue } from 'jotai'; @@ -87,7 +88,7 @@ export function UploadBoardHeader({ grow="Yes" gap="100" > - + {sizedIcon(open ? CaretUp : CaretRight, '50')} Files @@ -98,7 +99,7 @@ export function UploadBoardHeader({ variant="Primary" radii="Pill" outlined - after={} + after={sizedIcon(PaperPlaneTilt, '50', { filled: true })} > Send @@ -122,7 +123,7 @@ export function UploadBoardHeader({ onClick={handleCancel} variant="SurfaceVariant" radii="Pill" - after={} + after={sizedIcon(X, '50')} > {uploads.length === 1 ? 'Remove' : 'Remove All'} diff --git a/src/app/components/upload-card/CompactUploadCardRenderer.tsx b/src/app/components/upload-card/CompactUploadCardRenderer.tsx index 06378d450..ecb602ec4 100644 --- a/src/app/components/upload-card/CompactUploadCardRenderer.tsx +++ b/src/app/components/upload-card/CompactUploadCardRenderer.tsx @@ -1,13 +1,31 @@ import { useEffect } from 'react'; -import { Chip, Icon, IconButton, Icons, Text, color } from 'folds'; +import { Chip, IconButton, Text, color } from 'folds'; +import { + Check, + File, + Image, + Play, + VideoCamera, + X, + sizedIcon, + type PhosphorIcon, +} from '$components/icons/phosphor'; import type { TUploadAtom, UploadSuccess } from '$state/upload'; import { UploadStatus, useBindUploadAtom } from '$state/upload'; import { useMatrixClient } from '$hooks/useMatrixClient'; import type { TUploadContent } from '$utils/matrix'; -import { bytesToSize, getFileTypeIcon } from '$utils/common'; +import { bytesToSize } from '$utils/common'; import { useMediaConfig } from '$hooks/useMediaConfig'; import { UploadCard, UploadCardError, CompactUploadCardProgress } from './UploadCard'; +function getFileTypeIconComponent(fileType: string): PhosphorIcon { + const type = fileType.toLowerCase(); + if (type.startsWith('audio')) return Play; + if (type.startsWith('video')) return VideoCamera; + if (type.startsWith('image')) return Image; + return File; +} + type CompactUploadCardRendererProps = { isEncrypted?: boolean; uploadAtom: TUploadAtom; @@ -48,7 +66,7 @@ export function CompactUploadCardRenderer({ compact outlined radii="300" - before={} + before={sizedIcon(getFileTypeIconComponent(file.type))} after={ <> {upload.status === UploadStatus.Error && ( @@ -70,7 +88,7 @@ export function CompactUploadCardRenderer({ radii="Pill" size="300" > - + {sizedIcon(X, '200')} } @@ -80,7 +98,7 @@ export function CompactUploadCardRenderer({ {file.name} - + {sizedIcon(Check, '100', { style: { color: color.Success.Main } })} ) : ( <> diff --git a/src/app/components/upload-card/UploadCard.tsx b/src/app/components/upload-card/UploadCard.tsx index bbab67a25..cdd6ae3d7 100644 --- a/src/app/components/upload-card/UploadCard.tsx +++ b/src/app/components/upload-card/UploadCard.tsx @@ -1,4 +1,5 @@ -import { Badge, Box, Icon, Icons, ProgressBar, Text, percent } from 'folds'; +import { Badge, Box, ProgressBar, Text, percent } from 'folds'; +import { Warning, sizedIcon } from '$components/icons/phosphor'; import type { ReactNode } from 'react'; import { forwardRef } from 'react'; @@ -80,7 +81,7 @@ type UploadCardErrorProps = { export function UploadCardError({ children }: UploadCardErrorProps) { return ( - + {sizedIcon(Warning, '50')} {children} ); diff --git a/src/app/components/upload-card/UploadCardRenderer.tsx b/src/app/components/upload-card/UploadCardRenderer.tsx index 54fb22f53..6e9147387 100644 --- a/src/app/components/upload-card/UploadCardRenderer.tsx +++ b/src/app/components/upload-card/UploadCardRenderer.tsx @@ -3,9 +3,7 @@ import { useEffect, useMemo, useRef, useState } from 'react'; import { Box, Chip, - Icon, IconButton, - Icons, Scroll, Text, Tooltip, @@ -14,6 +12,18 @@ import { config, toRem, } from 'folds'; +import { + Check, + EyeSlash, + File, + Image, + Info, + PencilSimple, + VideoCamera, + X, + sizedIcon, + type PhosphorIcon, +} from '$components/icons/phosphor'; import type { HTMLReactParserOptions } from 'html-react-parser'; import { Play, Pause } from '@phosphor-icons/react'; import { useMediaAuthentication } from '$hooks/useMediaAuthentication'; @@ -25,7 +35,7 @@ import type { UploadSuccess } from '$state/upload'; import { UploadStatus, useBindUploadAtom } from '$state/upload'; import { useMatrixClient } from '$hooks/useMatrixClient'; import type { TUploadContent } from '$utils/matrix'; -import { bytesToSize, getFileTypeIcon } from '$utils/common'; +import { bytesToSize } from '$utils/common'; import type { TUploadItem, TUploadMetadata } from '$state/room/roomInputDrafts'; import { roomUploadAtomFamily } from '$state/room/roomInputDrafts'; import { useObjectURL } from '$hooks/useObjectURL'; @@ -37,6 +47,14 @@ import { UploadCard, UploadCardError, UploadCardProgress } from './UploadCard'; import * as css from './UploadCard.css'; import { DescriptionEditor } from './UploadDescriptionEditor'; +function getFileTypeIconComponent(fileType: string): PhosphorIcon { + const type = fileType.toLowerCase(); + if (type.startsWith('audio')) return Play; + if (type.startsWith('video')) return VideoCamera; + if (type.startsWith('image')) return Image; + return File; +} + type PreviewImageProps = { fileItem: TUploadItem; }; @@ -207,7 +225,7 @@ function PreviewAudio({ fileItem }: PreviewAudioProps) { setCurrentTime(targetTime); } else { // Metadata not yet loaded (Firefox, first scrub before load() resolves). - // Do NOT call load() again here — that resets currentTime to 0 and + // Do NOT call load() again here  Ethat resets currentTime to 0 and // restarts the fetch. load() was already called in the useEffect; // just wait for the in-flight loadedmetadata event. el.addEventListener( @@ -336,7 +354,7 @@ function MediaPreview({ fileItem, onSpoiler, children }: MediaPreviewProps) { fill="Soft" radii="Pill" aria-pressed={metadata.markedAsSpoiler} - before={} + before={sizedIcon(EyeSlash, '50')} onClick={() => onSpoiler(!metadata.markedAsSpoiler)} > Spoiler @@ -429,7 +447,7 @@ export function UploadCardRenderer({ return ( } + before={sizedIcon(getFileTypeIconComponent(file.type))} after={ <> {upload.status === UploadStatus.Error && ( @@ -454,7 +472,7 @@ export function UploadCardRenderer({ radii="Pill" size="300" > - + {sizedIcon(PencilSimple, '50')} )} {isDescribed && ( @@ -470,7 +488,7 @@ export function UploadCardRenderer({ } > - {(triggerRef) => } + {(triggerRef) => {sizedIcon(Info, '50')}} )} @@ -481,7 +499,7 @@ export function UploadCardRenderer({ radii="Pill" size="300" > - + {sizedIcon(X, '200')} } @@ -561,9 +579,8 @@ export function UploadCardRenderer({ {file.name} - {upload.status === UploadStatus.Success && ( - - )} + {upload.status === UploadStatus.Success && + sizedIcon(Check, '100', { style: { color: color.Success.Main } })} ); } diff --git a/src/app/components/upload-card/UploadDescriptionEditor.tsx b/src/app/components/upload-card/UploadDescriptionEditor.tsx index 2805668ca..9f6531f58 100644 --- a/src/app/components/upload-card/UploadDescriptionEditor.tsx +++ b/src/app/components/upload-card/UploadDescriptionEditor.tsx @@ -2,7 +2,8 @@ import type { KeyboardEventHandler } from 'react'; import { useCallback, useEffect, useState, useRef } from 'react'; import type { Room } from '$types/matrix-sdk'; import type { RectCords } from 'folds'; -import { Box, Chip, Icon, IconButton, Icons, PopOut, Spinner, Text, config } from 'folds'; +import { Box, Chip, IconButton, PopOut, Spinner, Text, config } from 'folds'; +import { Smiley, sizedIcon } from '$components/icons/phosphor'; import { Editor, Transforms } from 'slate'; import { ReactEditor } from 'slate-react'; import { isKeyHotkey } from 'is-hotkey'; @@ -229,7 +230,7 @@ export function DescriptionEditor({ radii="300" onClick={(evt) => setAnchor(evt.currentTarget.getBoundingClientRect())} > - + {sizedIcon(Smiley, '400', { filled: anchor !== undefined })} )} diff --git a/src/app/components/url-preview/ClientPreview.tsx b/src/app/components/url-preview/ClientPreview.tsx index 61809f187..ed9fb9edf 100644 --- a/src/app/components/url-preview/ClientPreview.tsx +++ b/src/app/components/url-preview/ClientPreview.tsx @@ -1,6 +1,7 @@ import type { ReactNode } from 'react'; import { useCallback, useEffect, useState } from 'react'; -import { Box, Badge, Icon, IconButton, Icons, Spinner, Text, as, toRem } from 'folds'; +import { Box, Badge, IconButton, Spinner, Text, as, toRem } from 'folds'; +import { Link, sizedIcon } from '$components/icons/phosphor'; import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback'; import { useSetting } from '$state/hooks/settings'; import { settingsAtom } from '$state/settings'; @@ -66,7 +67,7 @@ type EmbedOpenButtonProps = { export function EmbedOpenButton({ url }: EmbedOpenButtonProps) { return ( window.open(url, '_blank')}> - + {sizedIcon(Link, '100')} ); } diff --git a/src/app/components/url-preview/ThemeThirdPartyBanner.tsx b/src/app/components/url-preview/ThemeThirdPartyBanner.tsx index ca31d8008..0f8c6956e 100644 --- a/src/app/components/url-preview/ThemeThirdPartyBanner.tsx +++ b/src/app/components/url-preview/ThemeThirdPartyBanner.tsx @@ -1,4 +1,5 @@ -import { Box, Icon, Icons, Text, toRem, config } from 'folds'; +import { Box, Text, toRem, config } from 'folds'; +import { Warning, sizedIcon } from '$components/icons/phosphor'; type ThemeThirdPartyBannerProps = { hostLabel: string; @@ -26,7 +27,7 @@ export function ThemeThirdPartyBanner({ hostLabel, kind = 'theme' }: ThemeThirdP }} > - + {sizedIcon(Warning, '100', { filled: true })} {title} diff --git a/src/app/components/url-preview/TweakPreviewUrlCard.tsx b/src/app/components/url-preview/TweakPreviewUrlCard.tsx index c3c632745..43cd9a14a 100644 --- a/src/app/components/url-preview/TweakPreviewUrlCard.tsx +++ b/src/app/components/url-preview/TweakPreviewUrlCard.tsx @@ -2,9 +2,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { useQuery } from '@tanstack/react-query'; import { Box, - Icon, IconButton, - Icons, Spinner, Switch, Text, @@ -13,6 +11,7 @@ import { config, toRem, } from 'folds'; +import { Check, Link, Star, Warning, sizedIcon } from '$components/icons/phosphor'; import { useClientConfig } from '$hooks/useClientConfig'; import { useTimeoutToggle } from '$hooks/useTimeoutToggle'; @@ -285,14 +284,17 @@ export function TweakPreviewUrlCard({ url }: { url: string }) { } > {(triggerRef) => ( - + style={{ + color: 'var(--sable-warn-on-container)', + flexShrink: 0, + display: 'inline-flex', + }} + > + {sizedIcon(Warning, '100', { filled: true })} + )} )} @@ -319,7 +321,7 @@ export function TweakPreviewUrlCard({ url }: { url: string }) { handleCopy().catch(() => undefined); }} > - + {sizedIcon(copied ? Check : Link, '200')} undefined); }} > - + {sizedIcon(Star, '200', { filled: isFav })} >>(); @@ -461,7 +450,7 @@ export const UrlPreviewHolder = as<'div'>(({ children, ...props }, ref) => { outlined onClick={handleScrollBack} > - + {sizedIcon(ArrowLeft, '300')} )} @@ -486,7 +475,7 @@ export const UrlPreviewHolder = as<'div'>(({ children, ...props }, ref) => { outlined onClick={handleScrollFront} > - + {sizedIcon(ArrowRight, '300')} )} diff --git a/src/app/components/user-profile/CreatorChip.tsx b/src/app/components/user-profile/CreatorChip.tsx index 29ccbaafb..13968cec9 100644 --- a/src/app/components/user-profile/CreatorChip.tsx +++ b/src/app/components/user-profile/CreatorChip.tsx @@ -1,5 +1,6 @@ import type { RectCords } from 'folds'; -import { Chip, config, Icon, Icons, Menu, MenuItem, PopOut, Text } from 'folds'; +import { Chip, config, Menu, MenuItem, PopOut, Text } from 'folds'; +import { CaretDown, profileIcon } from '$components/icons/phosphor'; import type { CSSProperties } from 'react'; import type { MouseEventHandler } from 'react'; import { useState } from 'react'; @@ -106,13 +107,7 @@ export function CreatorChip({ variant={cardColor ? undefined : 'Success'} outlined={!cardColor} radii="Pill" - before={ - cords ? ( - - ) : ( - - ) - } + before={cords ? profileIcon(CaretDown) : } after={tagIconSrc ? : undefined} onClick={open} aria-pressed={!!cords} diff --git a/src/app/components/user-profile/PowerChip.tsx b/src/app/components/user-profile/PowerChip.tsx index dbb6ae579..2ee150453 100644 --- a/src/app/components/user-profile/PowerChip.tsx +++ b/src/app/components/user-profile/PowerChip.tsx @@ -6,9 +6,7 @@ import { config, Dialog, Header, - Icon, IconButton, - Icons, Line, Menu, MenuItem, @@ -20,6 +18,7 @@ import { Text, toRem, } from 'folds'; +import { CaretDown, menuIcon, profileIcon, X } from '$components/icons/phosphor'; import type { CSSProperties } from 'react'; import type { MouseEventHandler } from 'react'; import { useCallback, useState } from 'react'; @@ -76,7 +75,7 @@ function SelfDemoteAlert({ power, onCancel, onChange }: SelfDemoteAlertProps) { Self Demotion - + {menuIcon(X)} @@ -126,7 +125,7 @@ function SharedPowerAlert({ power, onCancel, onChange }: SharedPowerAlertProps) Shared Power - + {menuIcon(X)} @@ -368,7 +367,7 @@ export function PowerChip({ } before={ cords ? ( - + profileIcon(CaretDown) ) : ( <> {!changing && } diff --git a/src/app/components/user-profile/UserChips.tsx b/src/app/components/user-profile/UserChips.tsx index 2adeb5fbe..a3a40d411 100644 --- a/src/app/components/user-profile/UserChips.tsx +++ b/src/app/components/user-profile/UserChips.tsx @@ -14,14 +14,22 @@ import { Text, Line, Chip, - Icon, - Icons, Spinner, toRem, Box, Scroll, Avatar, } from 'folds'; +import { + CaretDown, + Check, + DotsThree, + HardDrives, + Link, + PencilSimple, + profileIcon, + Prohibit, +} from '$components/icons/phosphor'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { getMxIdServer } from '$utils/mxIdHelper'; import { useCloseUserRoomProfile } from '$state/hooks/userRoomProfile'; @@ -187,13 +195,7 @@ export function ServerChip({ - ) : ( - - ) - } + before={cords ? profileIcon(CaretDown) : profileIcon(copied ? Check : HardDrives)} onClick={open} aria-pressed={!!cords} className={cardColor ? css.UserHeroChipThemed : css.UserHeroBrightnessHover} @@ -307,13 +309,7 @@ export function ShareChip({ - ) : ( - - ) - } + before={cords ? profileIcon(CaretDown) : profileIcon(copied ? Check : Link)} onClick={open} aria-pressed={!!cords} className={!copied && cardColor ? css.UserHeroChipThemed : css.UserHeroBrightnessHover} @@ -730,7 +726,7 @@ export function OptionsChip({ fill="None" size="300" radii="300" - before={} + before={profileIcon(PencilSimple)} onClick={() => setEditingNick(true)} className={css.UserHeroMenuItem} style={heroMenuItemStyle( @@ -756,11 +752,7 @@ export function OptionsChip({ className={css.UserHeroMenuItem} style={heroMenuItemStyle({ backgroundColor: menuItemBg }, chipHoverBrightness)} before={ - ignoring ? ( - - ) : ( - - ) + ignoring ? : profileIcon(Prohibit) } disabled={ignoring} > @@ -785,11 +777,7 @@ export function OptionsChip({ chipHoverBrightness )} > - {ignoring ? ( - - ) : ( - - )} + {ignoring ? : profileIcon(DotsThree)} ); diff --git a/src/app/components/user-profile/UserHero.tsx b/src/app/components/user-profile/UserHero.tsx index 746a5d1e3..d98284e46 100644 --- a/src/app/components/user-profile/UserHero.tsx +++ b/src/app/components/user-profile/UserHero.tsx @@ -4,8 +4,6 @@ import { Avatar, Box, color as standardColors, - Icon, - Icons, Modal, Overlay, OverlayBackdrop, @@ -29,6 +27,7 @@ import { useBlobCache } from '$hooks/useBlobCache'; import { ImageViewer } from '$components/image-viewer'; import { AvatarPresence, PresenceBadge } from '$components/presence'; import { UserAvatar } from '$components/user-avatar'; +import { CaretDown, CaretUp, profileIcon, userFallbackIcon } from '$components/icons/phosphor'; import { ClientSideHoverFreeze } from '$components/ClientSideHoverFreeze'; import { useUserProfile } from '$hooks/useUserProfile'; import { shadeColor, areColorsTooSimilar } from '$utils/shadeColor'; @@ -125,7 +124,7 @@ export function UserHero({ userId, avatarUrl, bannerUrl, presence, autoplayGifs userId={userId} src={avatarUrl} alt={userId} - renderFallback={() => } + renderFallback={() => userFallbackIcon('hero')} /> @@ -214,7 +213,7 @@ export function UserHero({ userId, avatarUrl, bannerUrl, presence, autoplayGifs alignSelf: isFullStatus ? 'flex-start' : 'center', }} > - + {profileIcon(isFullStatus ? CaretUp : CaretDown)} )} diff --git a/src/app/components/user-profile/UserModeration.tsx b/src/app/components/user-profile/UserModeration.tsx index fb7b679da..bc796cc7f 100644 --- a/src/app/components/user-profile/UserModeration.tsx +++ b/src/app/components/user-profile/UserModeration.tsx @@ -1,4 +1,5 @@ -import { Box, Button, color, config, Icon, Icons, Spinner, Text, Input } from 'folds'; +import { Box, Button, color, config, Spinner, Text, Input } from 'folds'; +import { ArrowLeft, ArrowRight, profileIcon, Prohibit } from '$components/icons/phosphor'; import { useCallback, useRef } from 'react'; import { useRoom } from '$hooks/useRoom'; import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback'; @@ -295,7 +296,7 @@ export function UserModeration({ userId, canKick, canBan, canInvite }: UserModer inviteState.status === AsyncStatus.Loading ? ( ) : ( - + profileIcon(ArrowRight) ) } onClick={invite} @@ -315,7 +316,7 @@ export function UserModeration({ userId, canKick, canBan, canInvite }: UserModer kickState.status === AsyncStatus.Loading ? ( ) : ( - + profileIcon(ArrowLeft) ) } onClick={kick} @@ -335,7 +336,7 @@ export function UserModeration({ userId, canKick, canBan, canInvite }: UserModer banState.status === AsyncStatus.Loading ? ( ) : ( - + profileIcon(Prohibit) ) } onClick={ban} diff --git a/src/app/components/user-profile/UserRoomProfile.tsx b/src/app/components/user-profile/UserRoomProfile.tsx index 2732649c1..974e47266 100644 --- a/src/app/components/user-profile/UserRoomProfile.tsx +++ b/src/app/components/user-profile/UserRoomProfile.tsx @@ -1,22 +1,21 @@ -import { - Box, - Button, - color, - config, - Icon, - Icons, - Menu, - MenuItem, - Scroll, - Text, - toRem, -} from 'folds'; +import { Box, Button, color, config, Menu, MenuItem, Scroll, Text, toRem } from 'folds'; import type { CSSProperties, SyntheticEvent } from 'react'; import { useCallback, useMemo, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { useAtomValue } from 'jotai'; import type { Opts as LinkifyOpts } from 'linkifyjs'; import type { HTMLReactParserOptions } from 'html-react-parser'; +import { + ArrowLeft, + ArrowRight, + CaretDown, + CaretUp, + ChatCircle, + Clock, + Heart, + profileIcon, + User, +} from '$components/icons/phosphor'; import { mxcUrlToHttp } from '$utils/matrix'; import { getMemberAvatarMxc, getMemberDisplayName } from '$utils/room'; import { useMatrixClient } from '$hooks/useMatrixClient'; @@ -206,7 +205,7 @@ function UserExtendedSection({ }} onClick={() => handleMiscSelector(-1)} > - + {profileIcon(CaretUp)} Show less {unknownFields.map(([key], index) => ( @@ -232,9 +231,7 @@ function UserExtendedSection({ size="300" className={css.MiscDataToggleButton} onClick={() => setShowMisc(!showMisc)} - after={ - - } + after={profileIcon(miscDataIndex === -1 ? CaretDown : CaretUp)} style={{ padding: '1rem', justifyContent: 'flex-start', @@ -260,7 +257,7 @@ function UserExtendedSection({ {pronouns && ( - + {profileIcon(User, { style: { opacity: 0.5 } })} {pronouns} @@ -268,7 +265,7 @@ function UserExtendedSection({ )} {localTime && profile.timezone && ( - + {profileIcon(Clock, { style: { opacity: 0.5 } })} {localTime} ({profile.timezone.replaceAll(/^["']|["']$/g, '')}) @@ -276,7 +273,7 @@ function UserExtendedSection({ )} {catStatusText && ( - + {profileIcon(Heart, { style: { opacity: 0.5 } })} {catStatusText} @@ -345,7 +342,7 @@ function UserExtendedSection({ } style={{ color: textColor }} > - + {profileIcon(ArrowLeft)} )} {miscHeader} @@ -357,7 +354,7 @@ function UserExtendedSection({ onClick={() => setMiscDataIndex((miscDataIndex + 1) % unknownFields.length)} style={{ color: textColor }} > - + {profileIcon(ArrowRight)} )} @@ -591,7 +588,7 @@ export function UserRoomProfile({ userId, initialProfile }: Readonly} + before={profileIcon(ChatCircle, { filled: true })} onClick={handleMessage} className={showCustomHeroCard ? css.UserHeroChipThemed : css.UserHeroChip} style={{ diff --git a/src/app/features/add-existing/AddExisting.tsx b/src/app/features/add-existing/AddExisting.tsx index 1a589ced4..ca743979b 100644 --- a/src/app/features/add-existing/AddExisting.tsx +++ b/src/app/features/add-existing/AddExisting.tsx @@ -5,9 +5,7 @@ import { Button, config, Header, - Icon, IconButton, - Icons, Input, Menu, MenuItem, @@ -19,6 +17,14 @@ import { Spinner, Text, } from 'folds'; +import { + Check, + MagnifyingGlass, + X, + composerIcon, + sizedIcon, + menuIcon, +} from '$components/icons/phosphor'; import type { ChangeEventHandler, MouseEventHandler } from 'react'; import { useCallback, useMemo, useRef, useState } from 'react'; import { useAtomValue } from 'jotai'; @@ -220,7 +226,7 @@ export function AddExistingModal({ parentId, space, requestClose }: AddExistingM - + {composerIcon(X)} @@ -241,7 +247,7 @@ export function AddExistingModal({ parentId, space, requestClose }: AddExistingM > } + before={menuIcon(MagnifyingGlass)} placeholder="Search" size="400" variant="Background" @@ -322,7 +328,7 @@ export function AddExistingModal({ parentId, space, requestClose }: AddExistingM )} } - after={selectedItem && } + after={selectedItem && sizedIcon(Check, '200')} > diff --git a/src/app/features/bug-report/BugReportModal.tsx b/src/app/features/bug-report/BugReportModal.tsx index ee7d263bd..532a3bda0 100644 --- a/src/app/features/bug-report/BugReportModal.tsx +++ b/src/app/features/bug-report/BugReportModal.tsx @@ -6,9 +6,7 @@ import { Chip, config, Header, - Icon, IconButton, - Icons, Input, Modal, Overlay, @@ -20,6 +18,7 @@ import { TextArea, Checkbox, } from 'folds'; +import { ArrowRight, X, chipIcon, composerIcon } from '$components/icons/phosphor'; import * as Sentry from '@sentry/react'; import { useCloseBugReportModal, useBugReportModalOpen } from '$state/hooks/bugReportModal'; import { stopPropagation } from '$utils/keyboard'; @@ -246,7 +245,7 @@ function BugReportModal() { Report an Issue - + {composerIcon(X)} @@ -501,7 +500,7 @@ function BugReportModal() { radii="400" disabled={!canSubmit} onClick={handleSubmit} - after={} + after={chipIcon(ArrowRight)} > {sentryEnabled && type === 'bug' ? 'Submit Report' : 'Open on GitHub'} diff --git a/src/app/features/call-status/CallControl.tsx b/src/app/features/call-status/CallControl.tsx index 4fc81b642..4247c3baa 100644 --- a/src/app/features/call-status/CallControl.tsx +++ b/src/app/features/call-status/CallControl.tsx @@ -1,4 +1,15 @@ -import { Box, Chip, Icon, IconButton, Icons, Spinner, Text, Tooltip, TooltipProvider } from 'folds'; +import { Box, Chip, IconButton, Spinner, Text, Tooltip, TooltipProvider } from 'folds'; +import { + Headphones, + sizedIcon, + Microphone, + MicrophoneSlash, + PhoneDisconnect, + ShareNetwork, + SpeakerSlash, + VideoCamera, + VideoCameraSlash, +} from '$components/icons/phosphor'; import { useCallback } from 'react'; import { useSetAtom } from 'jotai'; import { StatusDivider } from './components'; @@ -33,7 +44,7 @@ function MicrophoneButton({ enabled, onToggle, disabled }: MicrophoneButtonProps outlined disabled={disabled} > - + {sizedIcon(enabled ? Microphone : MicrophoneSlash, '100', { filled: !enabled })} )} @@ -66,11 +77,7 @@ function SoundButton({ enabled, onToggle, disabled }: SoundButtonProps) { outlined disabled={disabled} > - + {sizedIcon(enabled ? Headphones : SpeakerSlash, '100', { filled: !enabled })} )} @@ -103,11 +110,7 @@ function VideoButton({ enabled, onToggle, disabled }: VideoButtonProps) { outlined disabled={disabled} > - + {sizedIcon(enabled ? VideoCamera : VideoCameraSlash, '100', { filled: enabled })} )} @@ -140,7 +143,7 @@ function ScreenShareButton({ enabled, onToggle, disabled }: ScreenShareButtonPro outlined disabled={disabled} > - + {sizedIcon(ShareNetwork, '100', { filled: enabled })} )} @@ -209,7 +212,7 @@ export function CallControl({ exiting ? ( ) : ( - + sizedIcon(PhoneDisconnect, '50', { filled: true }) ) } disabled={exiting} diff --git a/src/app/features/call-status/LiveChip.tsx b/src/app/features/call-status/LiveChip.tsx index 76e4dcd2b..9ac4dd904 100644 --- a/src/app/features/call-status/LiveChip.tsx +++ b/src/app/features/call-status/LiveChip.tsx @@ -7,8 +7,6 @@ import { Box, Chip, config, - Icon, - Icons, Menu, MenuItem, PopOut, @@ -16,6 +14,7 @@ import { Text, toRem, } from 'folds'; +import { CaretDown, CaretUp, sizedIcon, userFallbackIcon } from '$components/icons/phosphor'; import type { CallMembership } from '$types/matrix-sdk'; import FocusTrap from 'focus-trap-react'; import type { Room } from '$types/matrix-sdk'; @@ -103,7 +102,7 @@ export function LiveChip({ count, room, members }: LiveChipProps) { userId={userId} src={avatarUrl} alt={name} - renderFallback={() => } + renderFallback={() => userFallbackIcon('sm')} /> } @@ -125,7 +124,7 @@ export function LiveChip({ count, room, members }: LiveChipProps) { variant="Surface" fill="Soft" before={} - after={} + after={sizedIcon(cords ? CaretDown : CaretUp, '50')} radii="Pill" onClick={handleOpenMenu} > diff --git a/src/app/features/call-status/MemberGlance.tsx b/src/app/features/call-status/MemberGlance.tsx index c5da20c7e..1b68cecb7 100644 --- a/src/app/features/call-status/MemberGlance.tsx +++ b/src/app/features/call-status/MemberGlance.tsx @@ -1,7 +1,8 @@ -import { Box, config, Icon, Icons, Text } from 'folds'; +import { Box, config, Text } from 'folds'; import type { CallMembership } from '$types/matrix-sdk'; import type { Room } from '$types/matrix-sdk'; import { UserAvatar } from '../../components/user-avatar'; +import { userFallbackIcon } from '$components/icons/phosphor'; import { getMemberAvatarMxc, getMemberDisplayName } from '../../utils/room'; import { getMxIdLocalPart, mxcUrlToHttp } from '../../utils/matrix'; import { useMatrixClient } from '../../hooks/useMatrixClient'; @@ -59,7 +60,7 @@ export function MemberGlance({ room, members, speakers, max = 6 }: MemberGlanceP userId={userId} src={avatarUrl} alt={name} - renderFallback={() => } + renderFallback={() => userFallbackIcon('sm')} /> ); diff --git a/src/app/features/call-status/MemberSpeaking.tsx b/src/app/features/call-status/MemberSpeaking.tsx index f513a07f5..a69a4fdcc 100644 --- a/src/app/features/call-status/MemberSpeaking.tsx +++ b/src/app/features/call-status/MemberSpeaking.tsx @@ -1,5 +1,6 @@ import type { Room } from '$types/matrix-sdk'; -import { Box, Icon, Icons, Text } from 'folds'; +import { Box, Text } from 'folds'; +import { sizedIcon, Microphone } from '$components/icons/phosphor'; import { getMemberDisplayName } from '../../utils/room'; import { getMxIdLocalPart } from '../../utils/matrix'; @@ -13,7 +14,7 @@ export function MemberSpeaking({ room, speakers }: MemberSpeakingProps) { ); return ( - + {sizedIcon(Microphone, '100', { filled: true })} {speakingNames.length === 1 && ( <> diff --git a/src/app/features/call/CallControls.tsx b/src/app/features/call/CallControls.tsx index 2fc48de0c..55dfdd238 100644 --- a/src/app/features/call/CallControls.tsx +++ b/src/app/features/call/CallControls.tsx @@ -5,9 +5,7 @@ import { Box, Button, config, - Icon, IconButton, - Icons, Menu, MenuItem, PopOut, @@ -15,6 +13,12 @@ import { Text, toRem, } from 'folds'; +import { + composerIcon, + DotsThreeOutlineVerticalIcon, + sizedIcon, + PhoneDisconnect, +} from '$components/icons/phosphor'; import FocusTrap from 'focus-trap-react'; import { SequenceCard } from '$components/sequence-card'; import type { CallEmbed } from '$plugins/call'; @@ -202,7 +206,9 @@ export function CallControls({ callEmbed }: CallControlsProps) { outlined aria-pressed={!!cords} > - + {composerIcon(DotsThreeOutlineVerticalIcon, { + weight: cords ? 'fill' : 'regular', + })} @@ -218,7 +224,7 @@ export function CallControls({ callEmbed }: CallControlsProps) { exiting ? ( ) : ( - + sizedIcon(PhoneDisconnect, '200', { filled: true }) ) } disabled={exiting} diff --git a/src/app/features/call/CallMemberCard.tsx b/src/app/features/call/CallMemberCard.tsx index c6b451728..fd7a471c2 100644 --- a/src/app/features/call/CallMemberCard.tsx +++ b/src/app/features/call/CallMemberCard.tsx @@ -1,6 +1,13 @@ import type { CallMembership, SessionMembershipData } from '$types/matrix-sdk'; import { useState } from 'react'; -import { Avatar, Box, Icon, Icons, Text } from 'folds'; +import { Avatar, Box, Text } from 'folds'; +import { + CaretDown, + CaretUp, + sizedIcon, + userFallbackIcon, + VideoCameraSlash, +} from '$components/icons/phosphor'; import { useMatrixClient } from '../../hooks/useMatrixClient'; import { useMediaAuthentication } from '../../hooks/useMediaAuthentication'; import { useOpenUserRoomProfile } from '../../state/hooks/userRoomProfile'; @@ -63,7 +70,7 @@ export function CallMemberCard({ member }: CallMemberCardProps) { userId={userId} src={avatarUrl} alt={name} - renderFallback={() => } + renderFallback={() => userFallbackIcon('sm')} /> @@ -71,7 +78,7 @@ export function CallMemberCard({ member }: CallMemberCardProps) { {name} - {audioOnly && } + {audioOnly && sizedIcon(VideoCameraSlash, '100')} ); @@ -113,7 +120,7 @@ export function CallMemberRenderer({
)} - + {sizedIcon(viewMore ? CaretUp : CaretDown, '100')} )} diff --git a/src/app/features/call/Controls.tsx b/src/app/features/call/Controls.tsx index 3fe6d68fe..99a19cc03 100644 --- a/src/app/features/call/Controls.tsx +++ b/src/app/features/call/Controls.tsx @@ -1,4 +1,15 @@ -import { Icon, IconButton, Icons, Line, Text, Tooltip, TooltipProvider } from 'folds'; +import { IconButton, Line, Text, Tooltip, TooltipProvider } from 'folds'; +import { + ChatCircle, + Headphones, + sizedIcon, + Microphone, + MicrophoneSlash, + ShareNetwork, + SpeakerSlash, + VideoCamera, + VideoCameraSlash, +} from '$components/icons/phosphor'; import { useAtom } from 'jotai'; import * as css from './styles.css'; import { callChatAtom } from '../../state/callEmbed'; @@ -34,7 +45,7 @@ export function MicrophoneButton({ enabled, onToggle }: MicrophoneButtonProps) { onClick={() => onToggle()} outlined > - + {sizedIcon(enabled ? Microphone : MicrophoneSlash, '400', { filled: !enabled })} )} @@ -66,11 +77,7 @@ export function SoundButton({ enabled, onToggle }: SoundButtonProps) { onClick={() => onToggle()} outlined > - + {sizedIcon(enabled ? Headphones : SpeakerSlash, '400', { filled: !enabled })} )} @@ -102,11 +109,7 @@ export function VideoButton({ enabled, onToggle }: VideoButtonProps) { onClick={() => onToggle()} outlined > - + {sizedIcon(enabled ? VideoCamera : VideoCameraSlash, '400', { filled: enabled })} )} @@ -138,7 +141,7 @@ export function ScreenShareButton({ enabled, onToggle }: ScreenShareButtonProps) onClick={() => onToggle()} outlined > - + {sizedIcon(ShareNetwork, '400', { filled: enabled })} )} @@ -168,7 +171,7 @@ export function ChatButton() { onClick={() => setChat(!chat)} outlined > - + {sizedIcon(ChatCircle, '400', { filled: chat })} )} diff --git a/src/app/features/call/PrescreenControls.tsx b/src/app/features/call/PrescreenControls.tsx index 7ac8ac6ac..d877e87a4 100644 --- a/src/app/features/call/PrescreenControls.tsx +++ b/src/app/features/call/PrescreenControls.tsx @@ -1,4 +1,5 @@ -import { Box, Button, Icon, Icons, Spinner, Text, toRem } from 'folds'; +import { Box, Button, Spinner, Text, toRem } from 'folds'; +import { sizedIcon, Phone } from '$components/icons/phosphor'; import { SequenceCard } from '../../components/sequence-card'; import * as css from './styles.css'; import { ChatButton, ControlDivider, MicrophoneButton, SoundButton, VideoButton } from './Controls'; @@ -86,7 +87,7 @@ export function PrescreenControls({ canJoin }: PrescreenControlsProps) { joining ? ( ) : ( - + sizedIcon(Phone, '200', { filled: true }) ) } > diff --git a/src/app/features/common-settings/appearance/Appearance.tsx b/src/app/features/common-settings/appearance/Appearance.tsx index b7bc803e0..963bbe966 100644 --- a/src/app/features/common-settings/appearance/Appearance.tsx +++ b/src/app/features/common-settings/appearance/Appearance.tsx @@ -3,8 +3,6 @@ import { Box, Text, IconButton, - Icon, - Icons, Scroll, Button, config, @@ -13,6 +11,7 @@ import { PopOut, type RectCords, } from 'folds'; +import { CaretDown, composerIcon, X } from '$components/icons/phosphor'; import { Page, PageContent, PageHeader } from '$components/page'; import { SequenceCard } from '$components/sequence-card'; import { SettingTile } from '$components/setting-tile'; @@ -51,7 +50,7 @@ export function SelectShowPerRoomRoomIcon({ roomId }: { roomId: string }) { outlined fill="Soft" radii="300" - after={} + after={composerIcon(CaretDown)} onClick={handleMenu} > @@ -115,7 +114,7 @@ export function Appearance({ requestClose }: AppearanceProps) { - + {composerIcon(X)} diff --git a/src/app/features/common-settings/cosmetics/Cosmetics.tsx b/src/app/features/common-settings/cosmetics/Cosmetics.tsx index e7d505f88..b29d8f8a6 100644 --- a/src/app/features/common-settings/cosmetics/Cosmetics.tsx +++ b/src/app/features/common-settings/cosmetics/Cosmetics.tsx @@ -4,8 +4,6 @@ import { Box, Text, IconButton, - Icon, - Icons, Scroll, Switch, Avatar, @@ -20,6 +18,7 @@ import { Dialog, Header, } from 'folds'; +import { composerIcon, menuIcon, X } from '$components/icons/phosphor'; import { Page, PageContent, PageHeader } from '$components/page'; import { SequenceCard } from '$components/sequence-card'; import { SettingTile } from '$components/setting-tile'; @@ -212,7 +211,7 @@ export function CosmeticsAvatar({ profile, member, userId, room }: CosmeticsSett Remove Room Avatar setAlertRemove(false)} radii="300"> - + {composerIcon(X)} @@ -293,7 +292,7 @@ export function CosmeticsNickname({ profile, member, userId, room }: CosmeticsSe radii="300" variant="Secondary" > - + {menuIcon(X)} ) } @@ -428,7 +427,7 @@ export function Cosmetics({ requestClose }: CosmeticsProps) { - + {composerIcon(X)} diff --git a/src/app/features/common-settings/developer-tools/DevelopTools.tsx b/src/app/features/common-settings/developer-tools/DevelopTools.tsx index d35e20da7..4b9972f04 100644 --- a/src/app/features/common-settings/developer-tools/DevelopTools.tsx +++ b/src/app/features/common-settings/developer-tools/DevelopTools.tsx @@ -1,18 +1,16 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; import { useAtomValue } from 'jotai'; +import { Box, Text, IconButton, Scroll, Switch, Button, MenuItem, config, color } from 'folds'; import { - Box, - Text, - IconButton, - Icon, - Icons, - Scroll, - Switch, - Button, - MenuItem, - config, - color, -} from 'folds'; + CaretDown, + CaretRight, + CaretUp, + chipIcon, + composerIcon, + menuIcon, + Plus, + X, +} from '$components/icons/phosphor'; import { EventType, NotificationCountType } from '$types/matrix-sdk'; import { Page, PageContent, PageHeader } from '$components/page'; import { SequenceCard } from '$components/sequence-card'; @@ -180,7 +178,7 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) { - + {composerIcon(X)} @@ -279,13 +277,7 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) { size="300" radii="300" outlined - before={ - - } + before={menuIcon(expandState ? CaretUp : CaretDown, { weight: 'fill' })} > {expandState ? 'Collapse' : 'Expand'} @@ -311,17 +303,9 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) { size="300" radii="300" outlined - before={ - - } + before={menuIcon(expandUnreadDiagnostics ? CaretUp : CaretDown, { + weight: 'fill', + })} > {expandUnreadDiagnostics ? 'Collapse' : 'Expand'} @@ -396,17 +380,9 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) { size="300" radii="300" outlined - before={ - - } + before={menuIcon(expandSlidingDiagnostics ? CaretUp : CaretDown, { + weight: 'fill', + })} > {expandSlidingDiagnostics ? 'Collapse' : 'Expand'} @@ -469,7 +445,7 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) { fill="None" size="300" radii="0" - before={} + before={chipIcon(Plus)} > @@ -494,12 +470,7 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) { fill="None" size="300" radii="0" - before={ - - } + before={chipIcon(expanded ? CaretDown : CaretRight)} after={{stateKeyToEvents.size}} > @@ -526,7 +497,7 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) { fill="None" size="300" radii="0" - before={} + before={chipIcon(Plus)} > @@ -549,7 +520,7 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) { fill="None" size="300" radii="0" - after={} + after={chipIcon(CaretRight)} > @@ -584,13 +555,9 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) { size="300" radii="300" outlined - before={ - - } + before={menuIcon(expandAccountData ? CaretUp : CaretDown, { + weight: 'fill', + })} > {expandAccountData ? 'Collapse' : 'Expand'} @@ -608,7 +575,7 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) { fill="None" size="300" radii="0" - before={} + before={chipIcon(Plus)} onClick={() => setAccountDataType(null)} > @@ -626,7 +593,7 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) { fill="None" size="300" radii="0" - after={} + after={chipIcon(CaretRight)} onClick={() => setAccountDataType(type)} > diff --git a/src/app/features/common-settings/developer-tools/SendRoomEvent.tsx b/src/app/features/common-settings/developer-tools/SendRoomEvent.tsx index ad9f844e1..ea97427b8 100644 --- a/src/app/features/common-settings/developer-tools/SendRoomEvent.tsx +++ b/src/app/features/common-settings/developer-tools/SendRoomEvent.tsx @@ -4,8 +4,6 @@ import type { MatrixError, StateEvents, TimelineEvents } from '$types/matrix-sdk import { Box, Chip, - Icon, - Icons, IconButton, Text, config, @@ -15,6 +13,7 @@ import { TextArea as TextAreaComponent, Input, } from 'folds'; +import { ArrowLeft, composerIcon, menuIcon, X } from '$components/icons/phosphor'; import { Page, PageHeader } from '$components/page'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { useRoom } from '$hooks/useRoom'; @@ -118,18 +117,13 @@ export function SendRoomEvent({ type, stateKey, requestClose }: SendRoomEventPro - } - > + Developer Tools - + {composerIcon(X)} diff --git a/src/app/features/common-settings/developer-tools/StateEventEditor.tsx b/src/app/features/common-settings/developer-tools/StateEventEditor.tsx index 031d7d3da..1cf9710b8 100644 --- a/src/app/features/common-settings/developer-tools/StateEventEditor.tsx +++ b/src/app/features/common-settings/developer-tools/StateEventEditor.tsx @@ -3,8 +3,6 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { Box, Text, - Icon, - Icons, IconButton, Chip, Scroll, @@ -14,6 +12,7 @@ import { Spinner, Button, } from 'folds'; +import { ArrowLeft, composerIcon, menuIcon, X } from '$components/icons/phosphor'; import type { MatrixError, StateEvents } from '$types/matrix-sdk'; import { Page, PageHeader } from '$components/page'; import { SequenceCard } from '$components/sequence-card'; @@ -266,18 +265,13 @@ export function StateEventEditor({ type, stateKey, requestClose }: StateEventEdi - } - > + Developer Tools - + {composerIcon(X)} diff --git a/src/app/features/common-settings/emojis-stickers/EmojisStickers.tsx b/src/app/features/common-settings/emojis-stickers/EmojisStickers.tsx index cb26be3f2..1025cc232 100644 --- a/src/app/features/common-settings/emojis-stickers/EmojisStickers.tsx +++ b/src/app/features/common-settings/emojis-stickers/EmojisStickers.tsx @@ -1,5 +1,6 @@ import { useState } from 'react'; -import { Box, Icon, IconButton, Icons, Scroll, Text } from 'folds'; +import { Box, IconButton, Scroll, Text } from 'folds'; +import { composerIcon, X } from '$components/icons/phosphor'; import { Page, PageContent, PageHeader } from '$components/page'; import type { ImagePack } from '$plugins/custom-emoji'; import { ImagePackView } from '$components/image-pack-view'; @@ -30,7 +31,7 @@ export function EmojisStickers({ requestClose }: EmojisStickersProps) { - + {composerIcon(X)} diff --git a/src/app/features/common-settings/emojis-stickers/RoomPacks.tsx b/src/app/features/common-settings/emojis-stickers/RoomPacks.tsx index 7b0cdd49f..f9dd7a799 100644 --- a/src/app/features/common-settings/emojis-stickers/RoomPacks.tsx +++ b/src/app/features/common-settings/emojis-stickers/RoomPacks.tsx @@ -4,8 +4,6 @@ import { Box, Text, Button, - Icon, - Icons, Avatar, AvatarImage, AvatarFallback, @@ -17,6 +15,7 @@ import { IconButton, Menu, } from 'folds'; +import { composerIcon, menuIcon, Plus, Sticker, X } from '$components/icons/phosphor'; import type { MatrixError } from '$types/matrix-sdk'; import { SequenceCard } from '$components/sequence-card'; import type { ImagePack, PackAddress, PackContent } from '$plugins/custom-emoji'; @@ -219,7 +218,7 @@ export function RoomPacks({ onViewPack }: Readonly) { onClick={() => handleUndoRemove(address)} disabled={applyingChanges} > - + {menuIcon(Plus)} ) : ( ) { onClick={() => handleRemove(address)} disabled={applyingChanges} > - + {menuIcon(X)} ))} {avatarUrl ? ( ) : ( - - - + {composerIcon(Sticker, { weight: 'fill' })} )} diff --git a/src/app/features/common-settings/general/RoomAddress.tsx b/src/app/features/common-settings/general/RoomAddress.tsx index d7b6a400c..d73d1174c 100644 --- a/src/app/features/common-settings/general/RoomAddress.tsx +++ b/src/app/features/common-settings/general/RoomAddress.tsx @@ -8,13 +8,12 @@ import { Chip, color, config, - Icon, - Icons, Input, Spinner, Text, toRem, } from 'folds'; +import { CaretDown, CaretUp, menuIcon } from '$components/icons/phosphor'; import type { MatrixError } from '$types/matrix-sdk'; import { SettingTile } from '$components/setting-tile'; import { SequenceCard } from '$components/sequence-card'; @@ -388,9 +387,7 @@ export function RoomLocalAddresses({ permissions }: { permissions: RoomPermissio fill="Soft" outlined radii="300" - before={ - - } + before={menuIcon(expand ? CaretUp : CaretDown, { weight: 'fill' })} > {expand ? 'Collapse' : 'Expand'} diff --git a/src/app/features/common-settings/general/RoomEncryption.tsx b/src/app/features/common-settings/general/RoomEncryption.tsx index a54aacccb..9da75c666 100644 --- a/src/app/features/common-settings/general/RoomEncryption.tsx +++ b/src/app/features/common-settings/general/RoomEncryption.tsx @@ -6,15 +6,14 @@ import { config, Dialog, Header, - Icon, IconButton, - Icons, Overlay, OverlayBackdrop, OverlayCenter, Spinner, Text, } from 'folds'; +import { composerIcon, X } from '$components/icons/phosphor'; import { useCallback, useState } from 'react'; import type { MatrixError, StateEvents } from '$types/matrix-sdk'; import FocusTrap from 'focus-trap-react'; @@ -125,7 +124,7 @@ export function RoomEncryption({ permissions }: RoomEncryptionProps) { Enable Encryption setPrompt(false)} radii="300"> - + {composerIcon(X)} diff --git a/src/app/features/common-settings/general/RoomHistoryVisibility.tsx b/src/app/features/common-settings/general/RoomHistoryVisibility.tsx index 64ec50396..a29af1cd6 100644 --- a/src/app/features/common-settings/general/RoomHistoryVisibility.tsx +++ b/src/app/features/common-settings/general/RoomHistoryVisibility.tsx @@ -1,7 +1,8 @@ import type { MouseEventHandler } from 'react'; import { useCallback, useMemo, useState } from 'react'; import type { RectCords } from 'folds'; -import { Button, color, config, Icon, Icons, Menu, MenuItem, PopOut, Spinner, Text } from 'folds'; +import { Button, color, config, Menu, MenuItem, PopOut, Spinner, Text } from 'folds'; +import { CaretDown, menuIcon } from '$components/icons/phosphor'; import type { MatrixError, RoomHistoryVisibilityEventContent, @@ -139,13 +140,7 @@ export function RoomHistoryVisibility({ permissions }: RoomHistoryVisibilityProp outlined disabled={!canEdit || submitting} onClick={handleOpenMenu} - after={ - submitting ? ( - - ) : ( - - ) - } + after={submitting ? : menuIcon(CaretDown)} > {visibilityStr[historyVisibility]} diff --git a/src/app/features/common-settings/general/RoomProfile.tsx b/src/app/features/common-settings/general/RoomProfile.tsx index a65d7ef1a..6d2b764ef 100644 --- a/src/app/features/common-settings/general/RoomProfile.tsx +++ b/src/app/features/common-settings/general/RoomProfile.tsx @@ -7,9 +7,7 @@ import { config, Dialog, Header, - Icon, IconButton, - Icons, Input, Overlay, OverlayBackdrop, @@ -18,6 +16,14 @@ import { Text, TextArea, } from 'folds'; +import { + ArrowsClockwise, + chipIcon, + composerIcon, + menuIcon, + PencilSimple, + X, +} from '$components/icons/phosphor'; import type { FormEventHandler } from 'react'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { useAtomValue } from 'jotai'; @@ -263,7 +269,7 @@ export function RoomProfileEdit({ disabled={submitting} title="Reset DM Name" > - + {menuIcon(ArrowsClockwise)} )} @@ -468,7 +474,7 @@ function RoomBannerEdit({ bannerURI, permissions }: Readonly) { Remove Banner setAlertRemove(false)} radii="300"> - + {composerIcon(X)} @@ -557,7 +563,7 @@ export function RoomProfile({ permissions }: RoomProfileProps) { variant="Secondary" fill="Soft" radii="300" - before={} + before={chipIcon(PencilSimple)} onClick={() => setEdit(true)} outlined > diff --git a/src/app/features/common-settings/general/RoomUpgrade.tsx b/src/app/features/common-settings/general/RoomUpgrade.tsx index 70131e7f0..6c8b8eb73 100644 --- a/src/app/features/common-settings/general/RoomUpgrade.tsx +++ b/src/app/features/common-settings/general/RoomUpgrade.tsx @@ -12,9 +12,8 @@ import { config, Box, IconButton, - Icon, - Icons, } from 'folds'; +import { composerIcon, X } from '$components/icons/phosphor'; import FocusTrap from 'focus-trap-react'; import type { MatrixError, RoomTombstoneEventContent } from '$types/matrix-sdk'; import { Method, EventType } from '$types/matrix-sdk'; @@ -107,7 +106,7 @@ function RoomUpgradeDialog({ requestClose }: { requestClose: () => void }) { {room.isSpaceRoom() ? 'Space Upgrade' : 'Room Upgrade'} - + {composerIcon(X)} diff --git a/src/app/features/common-settings/members/Members.tsx b/src/app/features/common-settings/members/Members.tsx index cfdc7615e..a091bae09 100644 --- a/src/app/features/common-settings/members/Members.tsx +++ b/src/app/features/common-settings/members/Members.tsx @@ -1,20 +1,17 @@ import type { ChangeEventHandler, MouseEventHandler } from 'react'; import { useCallback, useMemo, useRef, useState } from 'react'; import type { RectCords } from 'folds'; +import { Box, Chip, config, IconButton, Input, PopOut, Scroll, Spinner, Text, toRem } from 'folds'; import { - Box, - Chip, - config, - Icon, - IconButton, - Icons, - Input, - PopOut, - Scroll, - Spinner, - Text, - toRem, -} from 'folds'; + ArrowsDownUp, + CaretUp, + chipIcon, + composerIcon, + Funnel, + MagnifyingGlass, + menuIcon, + X, +} from '$components/icons/phosphor'; import { useVirtualizer } from '@tanstack/react-virtual'; import type { RoomMember } from '$types/matrix-sdk'; import { Page, PageContent, PageHeader } from '$components/page'; @@ -151,7 +148,7 @@ export function Members({ requestClose }: MembersProps) { - + {composerIcon(X)} @@ -168,7 +165,7 @@ export function Members({ requestClose }: MembersProps) { } + before={menuIcon(MagnifyingGlass)} variant="SurfaceVariant" size="500" placeholder="Search" @@ -182,7 +179,7 @@ export function Members({ requestClose }: MembersProps) { radii="Pill" aria-pressed onClick={handleSearchReset} - after={} + after={chipIcon(X)} > {result.items.length === 0 @@ -220,7 +217,7 @@ export function Members({ requestClose }: MembersProps) { variant="SurfaceVariant" size="400" radii="300" - before={} + before={chipIcon(Funnel)} > {membershipFilter.name} @@ -252,7 +249,7 @@ export function Members({ requestClose }: MembersProps) { variant="SurfaceVariant" size="400" radii="300" - after={} + after={chipIcon(ArrowsDownUp)} > {memberSort.name} @@ -273,7 +270,7 @@ export function Members({ requestClose }: MembersProps) { size="300" aria-label="Scroll to Top" > - + {composerIcon(CaretUp)} {fetchingMembers && ( diff --git a/src/app/features/common-settings/permissions/PermissionGroups.tsx b/src/app/features/common-settings/permissions/PermissionGroups.tsx index 9508741cc..628f53bad 100644 --- a/src/app/features/common-settings/permissions/PermissionGroups.tsx +++ b/src/app/features/common-settings/permissions/PermissionGroups.tsx @@ -1,5 +1,6 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; -import { Badge, Box, Button, Chip, config, Icon, Icons, Menu, Spinner, Text } from 'folds'; +import { Badge, Box, Button, Chip, config, Menu, Spinner, Text } from 'folds'; +import { CaretDown, CaretUp, chipIcon } from '$components/icons/phosphor'; import { produce } from 'immer'; import { SequenceCard } from '$components/sequence-card'; import { SettingTile } from '$components/setting-tile'; @@ -147,11 +148,7 @@ export function PermissionGroups({ ) } - before={ - canEdit && ( - - ) - } + before={canEdit && chipIcon(opened ? CaretUp : CaretDown)} onClick={handleOpen} > @@ -211,14 +208,7 @@ export function PermissionGroups({ ) } - before={ - canEdit && ( - - ) - } + before={canEdit && chipIcon(opened ? CaretUp : CaretDown)} onClick={handleOpen} > diff --git a/src/app/features/common-settings/permissions/PowersEditor.tsx b/src/app/features/common-settings/permissions/PowersEditor.tsx index ba43bafa0..a056866fd 100644 --- a/src/app/features/common-settings/permissions/PowersEditor.tsx +++ b/src/app/features/common-settings/permissions/PowersEditor.tsx @@ -5,8 +5,6 @@ import { Box, Text, Chip, - Icon, - Icons, IconButton, Scroll, Button, @@ -19,6 +17,15 @@ import { TooltipProvider, Tooltip, } from 'folds'; +import { + ArrowLeft, + chipIcon, + composerIcon, + menuIcon, + SmileySticker, + Trash, + X, +} from '$components/icons/phosphor'; import { HexColorPicker } from 'react-colorful'; import { useAtomValue } from 'jotai'; import { Page, PageContent, PageHeader } from '$components/page'; @@ -254,7 +261,7 @@ function EditPower({ maxPower, power, tag, onSave, onClose }: Readonly} + before={chipIcon(SmileySticker)} > Pick @@ -377,18 +384,13 @@ export function PowersEditor({ powerLevels, requestClose }: Readonly - } - > + Permissions - + {composerIcon(X)} @@ -514,7 +516,7 @@ export function PowersEditor({ powerLevels, requestClose }: Readonly handleToggleDelete(power) } > - + {chipIcon(Trash)} )} diff --git a/src/app/features/create-chat/CreateChat.tsx b/src/app/features/create-chat/CreateChat.tsx index 492e9a1c4..a5c6693ba 100644 --- a/src/app/features/create-chat/CreateChat.tsx +++ b/src/app/features/create-chat/CreateChat.tsx @@ -1,4 +1,5 @@ -import { Box, Button, color, config, Icon, Icons, Input, Spinner, Switch, Text } from 'folds'; +import { Box, Button, color, config, Input, Spinner, Switch, Text } from 'folds'; +import { sizedIcon, Warning } from '$components/icons/phosphor'; import type { FormEventHandler } from 'react'; import { useCallback, useState } from 'react'; import type { ICreateRoomStateEvent } from '$types/matrix-sdk'; @@ -95,7 +96,7 @@ export function CreateChat({ defaultUserId }: CreateChatProps) { /> {invalidUserId && ( - + {sizedIcon(Warning, '50', { filled: true })} Please enter a valid User ID. @@ -126,7 +127,7 @@ export function CreateChat({ defaultUserId }: CreateChatProps) { {error && ( - + {sizedIcon(Warning, '100', { filled: true })} {error instanceof MatrixError && error.name === (ErrorCode.M_LIMIT_EXCEEDED as string) diff --git a/src/app/features/create-room/CreateRoom.tsx b/src/app/features/create-room/CreateRoom.tsx index 59b2ec571..c41378017 100644 --- a/src/app/features/create-room/CreateRoom.tsx +++ b/src/app/features/create-room/CreateRoom.tsx @@ -1,21 +1,8 @@ -import type { FormEventHandler } from 'react'; +import type { ReactNode, FormEventHandler } from 'react'; import { useCallback, useEffect, useState } from 'react'; import type { Room } from '$types/matrix-sdk'; import { MatrixError, JoinRule, RoomType } from '$types/matrix-sdk'; -import { - Box, - Button, - Chip, - color, - config, - Icon, - Icons, - Input, - Spinner, - Switch, - Text, - TextArea, -} from 'folds'; +import { Box, Button, Chip, color, config, Input, Spinner, Switch, Text, TextArea } from 'folds'; import { SettingTile } from '$components/setting-tile'; import { SequenceCard } from '$components/sequence-card'; import { useMatrixClient } from '$hooks/useMatrixClient'; @@ -36,7 +23,16 @@ import { } from '$components/create-room'; import { CreateRoomTypeSelector } from '$components/create-room/CreateRoomTypeSelector'; -import { getRoomIconSrc } from '$utils/room'; +import { getRoomStandaloneIconComponent } from '$components/icons/roomIcons'; +import { + CaretDown, + CaretUp, + Hash, + sizedIcon, + SpeakerHigh, + Warning, + type IconSizeToken, +} from '$components/icons/phosphor'; import { createDebugLogger } from '$utils/debugLogger'; import { restrictedSupported, @@ -48,19 +44,26 @@ import { ErrorCode } from '../../cs-errorcode'; const debugLog = createDebugLogger('CreateRoom'); -const getCreateRoomAccessToIcon = (access: CreateRoomAccess, type?: CreateRoomType) => { +const getCreateRoomAccessToIcon = ( + access: CreateRoomAccess, + type?: CreateRoomType, + size: IconSizeToken = '400' +): ReactNode => { const isVoiceRoom = type === CreateRoomType.VoiceRoom; let joinRule: JoinRule = JoinRule.Public; if (access === CreateRoomAccess.Restricted) joinRule = JoinRule.Restricted; if (access === CreateRoomAccess.Private) joinRule = JoinRule.Knock; - return getRoomIconSrc(Icons, isVoiceRoom ? RoomType.UnstableCall : undefined, joinRule); + return sizedIcon( + getRoomStandaloneIconComponent(isVoiceRoom ? RoomType.UnstableCall : undefined, joinRule), + size + ); }; -const getCreateRoomTypeToIcon = (type: CreateRoomType) => { - if (type === CreateRoomType.VoiceRoom) return Icons.VolumeHigh; - return Icons.Hash; +const getCreateRoomTypeToIcon = (type: CreateRoomType): ReactNode => { + if (type === CreateRoomType.VoiceRoom) return sizedIcon(SpeakerHigh, '400'); + return sizedIcon(Hash, '400'); }; type CreateRoomFormProps = { @@ -206,7 +209,7 @@ export function CreateRoomForm({ Name } + before={getCreateRoomAccessToIcon(access, type, '100')} name="nameInput" autoFocus size="500" @@ -235,7 +238,7 @@ export function CreateRoomForm({ } + before={sizedIcon(advance ? CaretUp : CaretDown, '50')} onClick={() => setAdvance(!advance)} type="button" > @@ -333,7 +336,7 @@ export function CreateRoomForm({ {error && ( - + {sizedIcon(Warning, '100', { filled: true })} {error instanceof MatrixError && error.name === (ErrorCode.M_LIMIT_EXCEEDED as string) diff --git a/src/app/features/create-room/CreateRoomModal.tsx b/src/app/features/create-room/CreateRoomModal.tsx index ba3f20a01..b5e7026d0 100644 --- a/src/app/features/create-room/CreateRoomModal.tsx +++ b/src/app/features/create-room/CreateRoomModal.tsx @@ -2,9 +2,7 @@ import { Box, config, Header, - Icon, IconButton, - Icons, Modal, Overlay, OverlayBackdrop, @@ -12,6 +10,7 @@ import { Scroll, Text, } from 'folds'; +import { X, composerIcon } from '$components/icons/phosphor'; import FocusTrap from 'focus-trap-react'; import { useAllJoinedRoomsSet, useGetRoom } from '$hooks/useGetRoom'; import { SpaceProvider } from '$hooks/useSpace'; @@ -60,7 +59,7 @@ function CreateRoomModal({ state }: CreateRoomModalProps) { - + {composerIcon(X)} diff --git a/src/app/features/create-space/CreateSpace.tsx b/src/app/features/create-space/CreateSpace.tsx index 8518110ad..ac8e75764 100644 --- a/src/app/features/create-space/CreateSpace.tsx +++ b/src/app/features/create-space/CreateSpace.tsx @@ -1,21 +1,8 @@ -import type { FormEventHandler } from 'react'; +import type { ReactNode, FormEventHandler } from 'react'; import { useCallback, useEffect, useState } from 'react'; import type { Room } from '$types/matrix-sdk'; import { MatrixError, RoomType } from '$types/matrix-sdk'; -import { - Box, - Button, - Chip, - color, - config, - Icon, - Icons, - Input, - Spinner, - Switch, - Text, - TextArea, -} from 'folds'; +import { Box, Button, Chip, color, config, Input, Spinner, Switch, Text, TextArea } from 'folds'; import { SettingTile } from '$components/setting-tile'; import { SequenceCard } from '$components/sequence-card'; import { useMatrixClient } from '$hooks/useMatrixClient'; @@ -39,13 +26,27 @@ import { knockSupported, knockRestrictedSupported, } from '$utils/roomSupport'; +import { JoinRule } from '$types/matrix-sdk'; +import { getRoomIconComponent } from '$components/icons/roomIcons'; +import { + CaretDown, + CaretUp, + sizedIcon, + Warning, + type IconSizeToken, +} from '$components/icons/phosphor'; import { ErrorCode } from '../../cs-errorcode'; -const getCreateSpaceAccessToIcon = (access: CreateRoomAccess) => { - if (access === CreateRoomAccess.Private) return Icons.SpaceLock; - if (access === CreateRoomAccess.Restricted) return Icons.Space; - return Icons.SpaceGlobe; +const getCreateSpaceAccessToIcon = ( + access: CreateRoomAccess, + size: IconSizeToken = '400' +): ReactNode => { + let joinRule: JoinRule = JoinRule.Public; + if (access === CreateRoomAccess.Restricted) joinRule = JoinRule.Restricted; + if (access === CreateRoomAccess.Private) joinRule = JoinRule.Knock; + + return sizedIcon(getRoomIconComponent(RoomType.Space, joinRule), size); }; type CreateSpaceFormProps = { @@ -153,7 +154,7 @@ export function CreateSpaceForm({ defaultAccess, space, onCreate }: CreateSpaceF Name } + before={getCreateSpaceAccessToIcon(access, '100')} name="nameInput" autoFocus size="500" @@ -182,7 +183,7 @@ export function CreateSpaceForm({ defaultAccess, space, onCreate }: CreateSpaceF } + before={sizedIcon(advance ? CaretUp : CaretDown, '50')} onClick={() => setAdvance(!advance)} type="button" > @@ -252,7 +253,7 @@ export function CreateSpaceForm({ defaultAccess, space, onCreate }: CreateSpaceF {error && ( - + {sizedIcon(Warning, '100', { filled: true })} {error instanceof MatrixError && error.name === (ErrorCode.M_LIMIT_EXCEEDED as string) diff --git a/src/app/features/create-space/CreateSpaceModal.tsx b/src/app/features/create-space/CreateSpaceModal.tsx index 44d8acbf2..d3d1ef54e 100644 --- a/src/app/features/create-space/CreateSpaceModal.tsx +++ b/src/app/features/create-space/CreateSpaceModal.tsx @@ -2,9 +2,7 @@ import { Box, config, Header, - Icon, IconButton, - Icons, Modal, Overlay, OverlayBackdrop, @@ -12,6 +10,7 @@ import { Scroll, Text, } from 'folds'; +import { composerIcon, X } from '$components/icons/phosphor'; import FocusTrap from 'focus-trap-react'; import { useAllJoinedRoomsSet, useGetRoom } from '$hooks/useGetRoom'; import { SpaceProvider } from '$hooks/useSpace'; @@ -58,7 +57,7 @@ function CreateSpaceModal({ state }: CreateSpaceModalProps) { - + {composerIcon(X)} diff --git a/src/app/features/join-before-navigate/JoinBeforeNavigate.tsx b/src/app/features/join-before-navigate/JoinBeforeNavigate.tsx index 17cf86ec3..3d6982ff8 100644 --- a/src/app/features/join-before-navigate/JoinBeforeNavigate.tsx +++ b/src/app/features/join-before-navigate/JoinBeforeNavigate.tsx @@ -1,4 +1,5 @@ -import { Box, Icon, IconButton, Icons, Scroll, Text, toRem } from 'folds'; +import { Box, IconButton, Scroll, Text, toRem } from 'folds'; +import { ArrowLeft, composerIcon } from '$components/icons/phosphor'; import { useAtomValue } from 'jotai'; import { RoomCard } from '$components/room-card'; import { RoomTopicViewer } from '$components/room-topic-viewer'; @@ -36,11 +37,7 @@ export function JoinBeforeNavigate({ {screenSize === ScreenSize.Mobile && ( - {(onBack) => ( - - - - )} + {(onBack) => {composerIcon(ArrowLeft)}} )} diff --git a/src/app/features/lobby/DnD.css.ts b/src/app/features/lobby/DnD.css.ts index 2b7e5e363..62798e33b 100644 --- a/src/app/features/lobby/DnD.css.ts +++ b/src/app/features/lobby/DnD.css.ts @@ -2,9 +2,17 @@ import { style } from '@vanilla-extract/css'; import { color, config, toRem } from 'folds'; import { ContainerColor } from '$styles/ContainerColor.css'; +export const DragHandleWidth = toRem(24); +const ReorderableContentInset = toRem(8); + +export const ReorderableContent = style({ + paddingLeft: ReorderableContentInset, +}); + export const ItemDraggableTarget = style([ ContainerColor({ variant: 'SurfaceVariant' }), { + width: DragHandleWidth, height: '100%', position: 'absolute', left: 0, diff --git a/src/app/features/lobby/DnD.tsx b/src/app/features/lobby/DnD.tsx index c39949a09..c533da197 100644 --- a/src/app/features/lobby/DnD.tsx +++ b/src/app/features/lobby/DnD.tsx @@ -8,8 +8,9 @@ import { import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element'; import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine'; import classNames from 'classnames'; -import { Box, Icon, Icons, as } from 'folds'; +import { Box, as } from 'folds'; import type { HierarchyItem } from '$hooks/useSpaceHierarchy'; +import { chipIcon, DotsThreeOutlineVerticalIcon } from '$components/icons/phosphor'; import * as css from './DnD.css'; export type DropContainerData = { @@ -58,7 +59,7 @@ export const ItemDraggableTarget = as<'div'>(({ className, ...props }, ref) => ( ref={ref} {...props} > - + {chipIcon(DotsThreeOutlineVerticalIcon)} )); diff --git a/src/app/features/lobby/HierarchyItemMenu.tsx b/src/app/features/lobby/HierarchyItemMenu.tsx index 165343c82..6c594ad4d 100644 --- a/src/app/features/lobby/HierarchyItemMenu.tsx +++ b/src/app/features/lobby/HierarchyItemMenu.tsx @@ -2,20 +2,7 @@ import type { MouseEventHandler } from 'react'; import { useCallback, useEffect, useState } from 'react'; import FocusTrap from 'focus-trap-react'; import type { RectCords } from 'folds'; -import { - Box, - IconButton, - Icon, - Icons, - PopOut, - Menu, - MenuItem, - Text, - config, - Line, - Spinner, - toRem, -} from 'folds'; +import { Box, IconButton, PopOut, Menu, MenuItem, Text, config, Line, Spinner, toRem } from 'folds'; import type { HierarchyItem } from '$hooks/useSpaceHierarchy'; import { useMatrixClient } from '$hooks/useMatrixClient'; import type { MSpaceChildContent } from '$types/matrix/room'; @@ -37,6 +24,12 @@ import { getCanonicalAliasOrRoomId } from '$utils/matrix'; import { useNavigate } from 'react-router-dom'; import { getSpaceLobbyPath } from '$pages/pathUtils'; import { EventType } from '$types/matrix-sdk'; +import { + chipIcon, + DotsThreeOutlineVerticalIcon, + menuIcon, + SignOut, +} from '$components/icons/phosphor'; type HierarchyItemWithParent = HierarchyItem & { parentId: string; @@ -255,7 +248,7 @@ export function HierarchyItemMenu({ radii="300" aria-pressed={!!menuAnchor} > - + {chipIcon(DotsThreeOutlineVerticalIcon, { weight: menuAnchor ? 'fill' : 'regular' })} {menuAnchor && ( } + after={menuIcon(SignOut)} radii="300" aria-pressed={promptLeave} > diff --git a/src/app/features/lobby/Lobby.tsx b/src/app/features/lobby/Lobby.tsx index 8d2b826ac..c8efb2843 100644 --- a/src/app/features/lobby/Lobby.tsx +++ b/src/app/features/lobby/Lobby.tsx @@ -1,18 +1,6 @@ import type { MouseEventHandler, ReactElement } from 'react'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; -import { - Box, - Chip, - Icon, - IconButton, - Icons, - Line, - Scroll, - Spinner, - Text, - color, - config, -} from 'folds'; +import { Box, Chip, IconButton, Line, Scroll, Spinner, Text, color, config } from 'folds'; import type { VirtualItem } from '@tanstack/react-virtual'; import { useVirtualizer } from '@tanstack/react-virtual'; import { useAtom, useAtomValue } from 'jotai'; @@ -66,6 +54,7 @@ import { useRoomMembers } from '$hooks/useRoomMembers'; import { useGetRoom } from '$hooks/useGetRoom'; import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback'; import { getRoomPermissionsAPI } from '$hooks/useRoomPermissions'; +import { CaretUp, composerIcon } from '$components/icons/phosphor'; import { getRoomCreatorsForRoomId } from '$hooks/useRoomCreators'; import { MembersDrawer } from '$features/room/MembersDrawer'; import { SpaceHierarchyItem } from './SpaceHierarchyItem'; @@ -652,7 +641,7 @@ export function Lobby() { size="300" aria-label="Scroll to Top" > - + {composerIcon(CaretUp)}
( variant="Primary" fill="None" size="300" - after={} + after={menuIcon(UserPlus)} radii="300" aria-pressed={invitePrompt} disabled={!canInvite} @@ -91,12 +100,7 @@ const LobbyMenu = forwardRef( Invite - } - radii="300" - > + Space Settings @@ -112,7 +116,7 @@ const LobbyMenu = forwardRef( variant="Critical" fill="None" size="300" - after={} + after={menuIcon(SignOut)} radii="300" aria-pressed={promptLeave} > @@ -145,6 +149,7 @@ export function LobbyHeader({ showProfile, powerLevels }: LobbyHeaderProps) { const useAuthentication = useMediaAuthentication(); const space = useSpace(); const setPeopleDrawer = useSetSetting(settingsAtom, 'isPeopleDrawer'); + const [peopleDrawer] = useSetting(settingsAtom, 'isPeopleDrawer'); const [menuAnchor, setMenuAnchor] = useState(); const screenSize = useScreenSizeContext(); @@ -167,7 +172,7 @@ export function LobbyHeader({ showProfile, powerLevels }: LobbyHeaderProps) { {(onBack) => ( - + {composerIcon(ArrowLeft)} )} @@ -214,7 +219,7 @@ export function LobbyHeader({ showProfile, powerLevels }: LobbyHeaderProps) { offset={4} tooltip={ - Members + {peopleDrawer ? 'Hide Members' : 'Show Members'} } > @@ -224,7 +229,7 @@ export function LobbyHeader({ showProfile, powerLevels }: LobbyHeaderProps) { ref={triggerRef} onClick={() => setPeopleDrawer((drawer) => !drawer)} > - + {composerIcon(UserCircle, { weight: peopleDrawer ? 'fill' : 'regular' })} )} @@ -246,7 +251,7 @@ export function LobbyHeader({ showProfile, powerLevels }: LobbyHeaderProps) { ref={triggerRef} aria-pressed={!!menuAnchor} > - + {navIcon(DotsThreeOutlineVerticalIcon, { weight: menuAnchor ? 'fill' : 'regular' })} )} diff --git a/src/app/features/lobby/RoomItem.tsx b/src/app/features/lobby/RoomItem.tsx index 6c23e125c..123bacce2 100644 --- a/src/app/features/lobby/RoomItem.tsx +++ b/src/app/features/lobby/RoomItem.tsx @@ -5,8 +5,6 @@ import { Badge, Box, Chip, - Icon, - Icons, Line, Overlay, OverlayBackdrop, @@ -38,6 +36,15 @@ import { mxcUrlToHttp } from '$utils/matrix'; import { useMediaAuthentication } from '$hooks/useMediaAuthentication'; import { formatCompactNumber } from '$utils/formatCompactNumber'; import { ItemDraggableTarget, useDraggableItem } from './DnD'; +import * as dndCss from './DnD.css'; +import { + ArrowRight, + chipIcon, + composerIcon, + EnvelopeSimple, + Plus, + Warning, +} from '$components/icons/phosphor'; import * as styleCss from './style.css'; import * as css from './RoomItem.css'; @@ -69,15 +76,14 @@ function RoomJoinButton({ roomId, via }: RoomJoinButtonProps) { } > {(triggerRef) => ( - + > + {composerIcon(Warning, { weight: 'fill' })} + )} )} @@ -86,9 +92,7 @@ function RoomJoinButton({ roomId, via }: RoomJoinButtonProps) { fill="Soft" size="400" radii="Pill" - before={ - canJoin ? : - } + before={canJoin ? chipIcon(Plus) : } onClick={join} disabled={!canJoin} > @@ -108,7 +112,7 @@ function RoomKnockButton({ roomId, via }: RoomJoinButtonProps) { fill="Soft" size="400" radii="Pill" - before={} + before={chipIcon(EnvelopeSimple)} onClick={() => setKnocking(true)} > Knock @@ -376,7 +380,11 @@ export const RoomItemCard = as<'div', RoomItemCardProps>( ref={ref} > {before} - + {canReorder && } {room ? ( @@ -406,7 +414,7 @@ export const RoomItemCard = as<'div', RoomItemCardProps>( radii="Pill" aria-label="Open Room" > - + {chipIcon(ArrowRight)} ) : ( diff --git a/src/app/features/lobby/SpaceItem.tsx b/src/app/features/lobby/SpaceItem.tsx index 9ca9298e5..60ec814f9 100644 --- a/src/app/features/lobby/SpaceItem.tsx +++ b/src/app/features/lobby/SpaceItem.tsx @@ -6,8 +6,6 @@ import { Avatar, Text, Chip, - Icon, - Icons, as, Badge, toRem, @@ -38,6 +36,7 @@ import FocusTrap from 'focus-trap-react'; import * as css from './SpaceItem.css'; import * as styleCss from './style.css'; import { useDraggableItem } from './DnD'; +import { CaretDown, CaretRight, chipCaretIcon, chipIcon, Plus } from '$components/icons/phosphor'; function SpaceProfileLoading() { return ( @@ -138,9 +137,7 @@ export function UnjoinedSpaceProfile({ /> } - after={ - canJoin ? : - } + after={canJoin ? chipIcon(Plus) : } > @@ -202,7 +199,7 @@ function SpaceProfile({ /> } - after={} + after={closed ? chipCaretIcon(CaretRight) : chipCaretIcon(CaretDown)} > @@ -231,7 +228,7 @@ function RootSpaceProfile({ closed, categoryId, handleClose }: RootSpaceProfileP className={css.HeaderChip} variant="Surface" size="500" - after={} + after={closed ? chipCaretIcon(CaretRight) : chipCaretIcon(CaretDown)} > @@ -308,7 +305,7 @@ function AddRoomButton({ item }: { item: HierarchyItem }) { } + before={chipIcon(Plus)} onClick={handleAddRoom} aria-pressed={!!cords} > @@ -377,7 +374,7 @@ function AddSpaceButton({ item }: { item: HierarchyItem }) { } + before={chipIcon(Plus)} onClick={handleAddSpace} aria-pressed={!!cords} > diff --git a/src/app/features/lobby/SpaceNavItem.tsx b/src/app/features/lobby/SpaceNavItem.tsx index 95eb56977..deca187dd 100644 --- a/src/app/features/lobby/SpaceNavItem.tsx +++ b/src/app/features/lobby/SpaceNavItem.tsx @@ -1,6 +1,6 @@ import type { ReactNode } from 'react'; import { useRef } from 'react'; -import { Avatar, Badge, Box, Chip, Icon, Icons, as, Text } from 'folds'; +import { Avatar, Badge, Box, Chip, as, Text } from 'folds'; import classNames from 'classnames'; import type { IHierarchyRoom, MatrixClient, Room } from '$types/matrix-sdk'; import { useMatrixClient } from '$hooks/useMatrixClient'; @@ -16,6 +16,7 @@ import { getSpaceLobbyPath } from '$pages/pathUtils'; import { InaccessibleSpaceProfile, UnjoinedSpaceProfile } from './SpaceItem'; import * as css from './SpaceNavItem.css'; import { useDraggableItem } from './DnD'; +import { chipIcon, SquaresFour } from '$components/icons/phosphor'; type SpaceProfileProps = { roomId: string; @@ -55,7 +56,7 @@ function SpaceNavProfile({ /> } - after={} + after={chipIcon(SquaresFour)} > diff --git a/src/app/features/message-search/MessageSearch.tsx b/src/app/features/message-search/MessageSearch.tsx index 893ff00eb..c18d1ba15 100644 --- a/src/app/features/message-search/MessageSearch.tsx +++ b/src/app/features/message-search/MessageSearch.tsx @@ -1,6 +1,7 @@ import type { RefObject } from 'react'; import { useEffect, useMemo, useRef } from 'react'; -import { Text, Box, Icon, Icons, config, Spinner, IconButton, Line, toRem } from 'folds'; +import { Text, Box, config, Spinner, IconButton, Line, toRem } from 'folds'; +import { CaretUp, ChatCircle, dropzoneIcon, sizedIcon, Info } from '$components/icons/phosphor'; import { useAtomValue } from 'jotai'; import { useVirtualizer } from '@tanstack/react-virtual'; import { useInfiniteQuery } from '@tanstack/react-query'; @@ -202,7 +203,7 @@ export function MessageSearch({ size="300" aria-label="Scroll to Top" > - + {sizedIcon(CaretUp, '300')} @@ -230,7 +231,7 @@ export function MessageSearch({ } + icon={dropzoneIcon(ChatCircle)} title="Search Messages" subTitle="Find helpful messages in your community by searching with related keywords." /> @@ -245,7 +246,7 @@ export function MessageSearch({ alignItems="Center" gap="200" > - + {sizedIcon(Info, '200')} No results found for {`"${msgSearchParams.term}"`} diff --git a/src/app/features/message-search/SearchFilters.tsx b/src/app/features/message-search/SearchFilters.tsx index 7a5706ab1..cc6487e08 100644 --- a/src/app/features/message-search/SearchFilters.tsx +++ b/src/app/features/message-search/SearchFilters.tsx @@ -5,8 +5,6 @@ import { Box, Chip, Text, - Icon, - Icons, Line, config, PopOut, @@ -19,11 +17,12 @@ import { Input, Badge, } from 'folds'; -import { SearchOrderBy } from '$types/matrix-sdk'; import FocusTrap from 'focus-trap-react'; +import { getRoomIconComponent } from '$components/icons/roomIcons'; +import { Check, sizedIcon, PlusCircle, SortAscending, X } from '$components/icons/phosphor'; +import { SearchOrderBy } from '$types/matrix-sdk'; import { useVirtualizer } from '@tanstack/react-virtual'; import { useMatrixClient } from '$hooks/useMatrixClient'; -import { getRoomIconSrc } from '$utils/room'; import { factoryRoomIdByAtoZ } from '$utils/sort'; import type { SearchItemStrGetter, UseAsyncSearchOptions } from '$hooks/useAsyncSearch'; import { useAsyncSearch } from '$hooks/useAsyncSearch'; @@ -94,7 +93,7 @@ function OrderButton({ order, onChange }: OrderButtonProps) { } + after={sizedIcon(SortAscending, '50')} onClick={handleOpenMenu} > {rankOrder ? Relevance : Recent} @@ -263,12 +262,10 @@ function SelectRoomButton({ roomList, selectedRooms, onChange }: SelectRoomButto size="300" radii="300" aria-pressed={selected} - before={ - - } + before={sizedIcon( + getRoomIconComponent(room.getType(), room.getJoinRule()), + '50' + )} > {room.name} @@ -309,7 +306,7 @@ function SelectRoomButton({ roomList, selectedRooms, onChange }: SelectRoomButto onClick={handleOpenMenu} variant="SurfaceVariant" radii="Pill" - before={} + before={sizedIcon(PlusCircle, '100')} > Select Rooms @@ -348,7 +345,7 @@ export function SearchFilters({ } + before={!global && sizedIcon(Check, '100')} outlined onClick={() => onGlobalChange()} > @@ -358,7 +355,7 @@ export function SearchFilters({ } + before={global && sizedIcon(Check, '100')} outlined onClick={() => onGlobalChange(true)} > @@ -381,10 +378,8 @@ export function SearchFilters({ variant="Success" onClick={() => onSelectedRoomsChange(selectedRooms.filter((rId) => rId !== roomId))} radii="Pill" - before={ - - } - after={} + before={sizedIcon(getRoomIconComponent(room.getType(), room.getJoinRule()), '50')} + after={sizedIcon(X, '50')} > {room.name} diff --git a/src/app/features/message-search/SearchInput.tsx b/src/app/features/message-search/SearchInput.tsx index dc5307603..db3a169bf 100644 --- a/src/app/features/message-search/SearchInput.tsx +++ b/src/app/features/message-search/SearchInput.tsx @@ -1,5 +1,6 @@ import type { FormEventHandler, RefObject } from 'react'; -import { Box, Text, Input, Icon, Icons, Spinner, Chip, config } from 'folds'; +import { Box, Text, Input, Spinner, Chip, config } from 'folds'; +import { sizedIcon, MagnifyingGlass, X } from '$components/icons/phosphor'; type SearchProps = { active?: boolean; @@ -38,7 +39,7 @@ export function SearchInput({ active, loading, searchInputRef, onSearch, onReset active && loading ? ( ) : ( - + sizedIcon(MagnifyingGlass, '200') ) } after={ @@ -50,7 +51,7 @@ export function SearchInput({ active, loading, searchInputRef, onSearch, onReset size="400" radii="Pill" outlined - after={} + after={sizedIcon(X, '50')} onClick={onReset} > Clear diff --git a/src/app/features/message-search/SearchResultGroup.tsx b/src/app/features/message-search/SearchResultGroup.tsx index ff1e72264..4ed5aa5d7 100644 --- a/src/app/features/message-search/SearchResultGroup.tsx +++ b/src/app/features/message-search/SearchResultGroup.tsx @@ -4,7 +4,7 @@ import type { IEventWithRoomId, Room } from '$types/matrix-sdk'; import { JoinRule, RelationType, EventType } from '$types/matrix-sdk'; import type { IImageContent } from '$types/matrix/common'; import type { HTMLReactParserOptions } from 'html-react-parser'; -import { Avatar, Box, Chip, Header, Icon, Icons, Text, config } from 'folds'; +import { Avatar, Box, Chip, Header, Text, config } from 'folds'; import type { Opts as LinkifyOpts } from 'linkifyjs'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { @@ -40,6 +40,7 @@ import { useAtomValue } from 'jotai'; import { nicknamesAtom } from '$state/nicknames'; import { SequenceCard } from '$components/sequence-card'; import { UserAvatar } from '$components/user-avatar'; +import { userFallbackIcon } from '$components/icons/phosphor'; import { useMentionClickHandler } from '$hooks/useMentionClickHandler'; import { useSpoilerClickHandler } from '$hooks/useSpoilerClickHandler'; import { useMediaAuthentication } from '$hooks/useMediaAuthentication'; @@ -308,7 +309,7 @@ export function SearchResultGroup({ : undefined } alt={displayName} - renderFallback={() => } + renderFallback={() => userFallbackIcon('lg')} /> diff --git a/src/app/features/room-nav/RoomNavCategoryButton.tsx b/src/app/features/room-nav/RoomNavCategoryButton.tsx index 97f78d543..e825fdd6e 100644 --- a/src/app/features/room-nav/RoomNavCategoryButton.tsx +++ b/src/app/features/room-nav/RoomNavCategoryButton.tsx @@ -1,5 +1,6 @@ -import { as, Chip, Icon, IconButton, Icons, Text } from 'folds'; +import { as, Chip, IconButton, Text } from 'folds'; import classNames from 'classnames'; +import { CaretDown, CaretRight, chipCaretIcon } from '$components/icons/phosphor'; import * as css from './styles.css'; export const RoomNavCategoryButton = as<'button', { closed?: boolean }>( @@ -11,11 +12,9 @@ export const RoomNavCategoryButton = as<'button', { closed?: boolean }>( variant="Background" radii="400" after={ - + + {chipCaretIcon(closed ? CaretRight : CaretDown)} + } {...props} ref={ref} @@ -36,12 +35,9 @@ export const RoomNavCategoryButton = as<'button', { closed?: boolean }>( style={{ padding: '0' }} ref={ref} > - + + {chipCaretIcon(closed ? CaretRight : CaretDown)} + ); } diff --git a/src/app/features/room-nav/RoomNavItem.tsx b/src/app/features/room-nav/RoomNavItem.tsx index 7262e8fbe..5f0d23070 100644 --- a/src/app/features/room-nav/RoomNavItem.tsx +++ b/src/app/features/room-nav/RoomNavItem.tsx @@ -6,9 +6,7 @@ import type { RectCords } from 'folds'; import { Avatar, Box, - Icon, IconButton, - Icons, Text, Menu, MenuItem, @@ -50,8 +48,21 @@ import { settingsAtom } from '$state/settings'; import { useOpenRoomSettings } from '$state/hooks/roomSettings'; import { useSpaceOptionally } from '$hooks/useSpace'; import { - getRoomNotificationModeIcon, + ChatCircleDots, + Checks, + chipIcon, + DotsThreeOutlineVerticalIcon, + GearSix, + Link, + menuIcon, + Phone, + SignOut, + UserPlus, +} from '$components/icons/phosphor'; +import { RoomNotificationMode, + roomNotificationModeChipIcon, + roomNotificationModeIcon, } from '$hooks/useRoomsNotificationPreferences'; import { RoomNotificationModeSwitcher } from '$components/RoomNotificationSwitcher'; import { useRoomCreators } from '$hooks/useRoomCreators'; @@ -152,7 +163,7 @@ const RoomNavItemMenu = forwardRef( } + after={menuIcon(Checks)} radii="300" disabled={!unread} > @@ -168,7 +179,7 @@ const RoomNavItemMenu = forwardRef( changing ? ( ) : ( - + roomNotificationModeIcon(notificationMode) ) } radii="300" @@ -189,7 +200,7 @@ const RoomNavItemMenu = forwardRef( variant="Primary" fill="None" size="300" - after={} + after={menuIcon(UserPlus)} radii="300" aria-pressed={invitePrompt} disabled={!canInvite} @@ -198,22 +209,12 @@ const RoomNavItemMenu = forwardRef( Invite - } - radii="300" - > + Copy Link - } - radii="300" - > + Room Settings @@ -229,7 +230,7 @@ const RoomNavItemMenu = forwardRef( variant="Critical" fill="None" size="300" - after={} + after={menuIcon(SignOut)} radii="300" aria-pressed={promptLeave} > @@ -292,6 +293,7 @@ export function RoomNavItem({ (receipt) => receipt.userId !== mx.getUserId() ); + const [roomIconOverlay] = useSetting(settingsAtom, 'roomIconOverlay'); const nicknames = useAtomValue(nicknamesAtom); const dmUserId = direct ? room.getAvatarFallbackMember()?.userId : undefined; const matrixRoomName = useRoomName(room); @@ -469,9 +471,10 @@ export function RoomNavItem({ : config.opacity.P300, }} filled={selected || isActiveCall} - size="100" + size="200" joinRule={room.getJoinRule()} roomType={room.getType()} + withOverlay={roomIconOverlay} /> )} @@ -523,18 +526,16 @@ export function RoomNavItem({ )} {!optionsVisible && notificationMode !== RoomNotificationMode.Unset && ( - + + {roomNotificationModeChipIcon(notificationMode)} + )} {(room.isCallRoom() || direct) && callMembers.length > 0 && !optionsVisible && ( - + {chipIcon(Phone)} {direct ? 'Calling' : `${callMembers.length} Live`} @@ -572,7 +573,7 @@ export function RoomNavItem({ size="300" radii="300" > - + {chipIcon(ChatCircleDots, { weight: isChatOpen ? 'fill' : 'regular' })} )} @@ -616,7 +617,9 @@ export function RoomNavItem({ size="300" radii="300" > - + {chipIcon(DotsThreeOutlineVerticalIcon, { + weight: menuAnchor ? 'fill' : 'regular', + })} )} diff --git a/src/app/features/room-nav/RoomNavUser.tsx b/src/app/features/room-nav/RoomNavUser.tsx index 488545b32..3c9e1323b 100644 --- a/src/app/features/room-nav/RoomNavUser.tsx +++ b/src/app/features/room-nav/RoomNavUser.tsx @@ -1,4 +1,5 @@ -import { Avatar, Box, Icon, Icons, Text } from 'folds'; +import { Avatar, Box, Text } from 'folds'; +import { userFallbackIcon } from '$components/icons/phosphor'; import type { MouseEventHandler } from 'react'; import { useAtomValue } from 'jotai'; import type { Room, CallMembership } from '$types/matrix-sdk'; @@ -54,7 +55,7 @@ export function RoomNavUser({ room, callMembership, hideText }: RoomNavUserProps userId={userId} src={avatarUrl ?? undefined} alt={name} - renderFallback={() => } + renderFallback={() => userFallbackIcon('sm')} /> {!hideText && ( diff --git a/src/app/features/room-nav/styles.css.ts b/src/app/features/room-nav/styles.css.ts index b5701a6f6..06227918f 100644 --- a/src/app/features/room-nav/styles.css.ts +++ b/src/app/features/room-nav/styles.css.ts @@ -5,5 +5,9 @@ export const CategoryButton = style({ flexGrow: 1, }); export const CategoryButtonIcon = style({ + display: 'inline-flex', + alignItems: 'center', + justifyContent: 'center', + lineHeight: 0, opacity: config.opacity.P400, }); diff --git a/src/app/features/room-settings/RoomSettings.tsx b/src/app/features/room-settings/RoomSettings.tsx index f960460fd..28e289e52 100644 --- a/src/app/features/room-settings/RoomSettings.tsx +++ b/src/app/features/room-settings/RoomSettings.tsx @@ -1,7 +1,8 @@ import { useMemo, useState } from 'react'; +import type { ComponentType } from 'react'; +import type { IconProps } from '@phosphor-icons/react'; import { useAtomValue } from 'jotai'; -import type { IconSrc } from 'folds'; -import { Avatar, Box, config, Icon, IconButton, Icons, MenuItem, Text } from 'folds'; +import { Avatar, Box, config, IconButton, MenuItem, Text } from 'folds'; import { JoinRule } from '$types/matrix-sdk'; import { PageNav, PageNavContent, PageNavHeader, PageRoot } from '$components/page'; import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize'; @@ -20,15 +21,29 @@ import { DeveloperTools } from '$features/common-settings/developer-tools'; import { Cosmetics } from '$features/common-settings/cosmetics/Cosmetics'; import { settingsAtom } from '$state/settings'; import { useSetting } from '$state/hooks/settings'; +import { + composerIcon, + GearSix, + Info, + Lock, + PaintBrush, + settingsNavIcon, + Smiley, + Terminal, + User, + X, +} from '$components/icons/phosphor'; import { Permissions } from './permissions'; import { General } from './general'; import { RoomAbbreviations } from './abbreviations/RoomAbbreviations'; +type PhosphorIcon = ComponentType; + type RoomSettingsMenuItem = { page: RoomSettingsPage; name: string; - icon: IconSrc; - activeIcon?: IconSrc; + icon: PhosphorIcon; + activeIcon?: PhosphorIcon; }; const useRoomSettingsMenuItems = (): RoomSettingsMenuItem[] => @@ -37,38 +52,37 @@ const useRoomSettingsMenuItems = (): RoomSettingsMenuItem[] => { page: RoomSettingsPage.GeneralPage, name: 'General', - icon: Icons.Setting, + icon: GearSix, }, { page: RoomSettingsPage.MembersPage, name: 'Members', - icon: Icons.User, + icon: User, }, { page: RoomSettingsPage.PermissionsPage, name: 'Permissions', - icon: Icons.Lock, + icon: Lock, }, { page: RoomSettingsPage.CosmeticsPage, name: 'Cosmetics', - icon: Icons.Alphabet, - activeIcon: Icons.AlphabetUnderline, + icon: PaintBrush, }, { page: RoomSettingsPage.AbbreviationsPage, name: 'Abbreviations', - icon: Icons.Info, + icon: Info, }, { page: RoomSettingsPage.EmojisStickersPage, name: 'Emojis & Stickers', - icon: Icons.Smile, + icon: Smiley, }, { page: RoomSettingsPage.DeveloperToolsPage, name: 'Developer Tools', - icon: Icons.Terminal, + icon: Terminal, }, ], [] @@ -145,7 +159,7 @@ export function RoomSettings({ initialPage, requestClose }: RoomSettingsProps) { {screenSize === ScreenSize.Mobile && ( - + {composerIcon(X)} )} @@ -154,24 +168,21 @@ export function RoomSettings({ initialPage, requestClose }: RoomSettingsProps) {
{menuItems.map((item) => { - const currentIcon = - activePage === item.page && item.activeIcon ? item.activeIcon : item.icon; + const active = activePage === item.page; + const IconComponent = active && item.activeIcon ? item.activeIcon : item.icon; return ( - } + aria-pressed={active} + before={settingsNavIcon(IconComponent, active)} onClick={() => setActivePage(item.page)} > - + {composerIcon(X)} @@ -287,7 +276,7 @@ export function RoomAbbreviations({ requestClose, isSpace }: AbbreviationsProps) disabled={saving} aria-label={`Remove abbreviation ${entry.term}`} > - + {menuIcon(Trash)} )} diff --git a/src/app/features/room-settings/general/General.tsx b/src/app/features/room-settings/general/General.tsx index c4546b601..3f87b3b7b 100644 --- a/src/app/features/room-settings/general/General.tsx +++ b/src/app/features/room-settings/general/General.tsx @@ -1,4 +1,5 @@ -import { Box, Icon, IconButton, Icons, Scroll, Text } from 'folds'; +import { Box, IconButton, Scroll, Text } from 'folds'; +import { composerIcon, X } from '$components/icons/phosphor'; import { Page, PageContent, PageHeader } from '$components/page'; import { usePowerLevels } from '$hooks/usePowerLevels'; import { useRoom } from '$hooks/useRoom'; @@ -35,7 +36,7 @@ export function General({ requestClose }: GeneralProps) { - + {composerIcon(X)} diff --git a/src/app/features/room-settings/permissions/Permissions.tsx b/src/app/features/room-settings/permissions/Permissions.tsx index 7966b6eda..ddf89de41 100644 --- a/src/app/features/room-settings/permissions/Permissions.tsx +++ b/src/app/features/room-settings/permissions/Permissions.tsx @@ -1,5 +1,6 @@ import { useState } from 'react'; -import { Box, Icon, IconButton, Icons, Scroll, Text } from 'folds'; +import { Box, IconButton, Scroll, Text } from 'folds'; +import { composerIcon, X } from '$components/icons/phosphor'; import { Page, PageContent, PageHeader } from '$components/page'; import { useRoom } from '$hooks/useRoom'; import { usePowerLevels } from '$hooks/usePowerLevels'; @@ -48,7 +49,7 @@ export function Permissions({ requestClose }: PermissionsProps) { - + {composerIcon(X)} diff --git a/src/app/features/room/CallChatView.tsx b/src/app/features/room/CallChatView.tsx index e73842f94..bdd23c3fe 100644 --- a/src/app/features/room/CallChatView.tsx +++ b/src/app/features/room/CallChatView.tsx @@ -1,6 +1,7 @@ import { useSetAtom } from 'jotai'; import { useParams } from 'react-router-dom'; -import { Box, Text, TooltipProvider, Tooltip, Icon, Icons, IconButton, toRem } from 'folds'; +import { Box, Text, TooltipProvider, Tooltip, IconButton, toRem } from 'folds'; +import { composerIcon, X } from '$components/icons/phosphor'; import { Page, PageHeader } from '../../components/page'; import { callChatAtom } from '../../state/callEmbed'; import { RoomView } from './RoomView'; @@ -70,7 +71,7 @@ export function CallChatView() { > {(triggerRef) => ( - + {composerIcon(X)} )} diff --git a/src/app/features/room/MembersDrawer.tsx b/src/app/features/room/MembersDrawer.tsx index 779003437..7e595ffbc 100644 --- a/src/app/features/room/MembersDrawer.tsx +++ b/src/app/features/room/MembersDrawer.tsx @@ -7,9 +7,7 @@ import { Box, Chip, Header, - Icon, IconButton, - Icons, Input, MenuItem, PopOut, @@ -41,6 +39,17 @@ import { useAtomValue } from 'jotai'; import { nicknamesAtom } from '$state/nicknames'; import { ScrollTopContainer } from '$components/scroll-top-container'; import { UserAvatar } from '$components/user-avatar'; +import { + ArrowsDownUp, + CaretUp, + chipIcon, + composerIcon, + Funnel, + MagnifyingGlass, + navIcon, + userFallbackIcon, + X, +} from '$components/icons/phosphor'; import { useRoomTypingMember } from '$hooks/useRoomTypingMembers'; import { useMediaAuthentication } from '$hooks/useMediaAuthentication'; import { useMembershipFilter, useMembershipFilterMenu } from '$hooks/useMemberFilter'; @@ -93,7 +102,7 @@ function MemberDrawerHeader({ room, hideText }: MemberDrawerHeaderProps) { variant="Background" onClick={() => setPeopleDrawer(false)} > - + {composerIcon(X)} )} @@ -159,7 +168,7 @@ function MemberItem({ userId={member.userId} src={avatarUrl ?? undefined} alt={name} - renderFallback={() => } + renderFallback={() => userFallbackIcon('md')} /> @@ -378,7 +387,7 @@ export function MembersDrawer({ room, members }: MembersDrawerProps) { variant="Background" size="400" radii="300" - before={} + before={chipIcon(Funnel)} > {membershipFilter.name} @@ -410,7 +419,7 @@ export function MembersDrawer({ room, members }: MembersDrawerProps) { variant="Background" size="400" radii="300" - after={} + after={chipIcon(ArrowsDownUp)} > {memberSort.name} @@ -427,7 +436,7 @@ export function MembersDrawer({ room, members }: MembersDrawerProps) { variant="Surface" size="400" radii="400" - before={} + before={chipIcon(MagnifyingGlass)} after={ result && ( } + after={chipIcon(X)} > {`${result.items.length || 'No'} ${ result.items.length === 1 ? 'Result' : 'Results' @@ -463,7 +472,7 @@ export function MembersDrawer({ room, members }: MembersDrawerProps) { size="300" aria-label="Scroll to Top" > - + {navIcon(CaretUp)} diff --git a/src/app/features/room/RoomCallButton.tsx b/src/app/features/room/RoomCallButton.tsx index 3c60e5935..08e179f05 100644 --- a/src/app/features/room/RoomCallButton.tsx +++ b/src/app/features/room/RoomCallButton.tsx @@ -1,4 +1,5 @@ -import { IconButton, Icon, Icons, TooltipProvider, Tooltip, Text } from 'folds'; +import { IconButton, TooltipProvider, Tooltip, Text } from 'folds'; +import { navIcon, Phone } from '$components/icons/phosphor'; import { useAtomValue } from 'jotai'; import type { Room, TimelineEvents } from '$types/matrix-sdk'; import { useCallStart, useCallJoined } from '$hooks/useCallEmbed'; @@ -67,7 +68,7 @@ export function RoomCallButton({ room }: RoomCallButtonProps) { onClick={handleStartCall} aria-label="Start Voice Call" > - + {navIcon(Phone)} )} diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx index 87ec6e68f..7214b430c 100644 --- a/src/app/features/room/RoomInput.tsx +++ b/src/app/features/room/RoomInput.tsx @@ -21,9 +21,7 @@ import { color, config, Dialog, - Icon, IconButton, - Icons, Menu, MenuItem, Overlay, @@ -129,7 +127,27 @@ import { convertPerMessageProfileToBeeperFormat, getCurrentlyUsedPerMessageProfileForRoom, } from '$hooks/usePerMessageProfile'; -import { Microphone, Stop, MapPinPlusIcon } from '@phosphor-icons/react'; +import { + Bell, + BellSlash, + CaretDown, + chipIcon, + Clock, + composerIcon, + dropzoneIcon, + File as FileIcon, + ListBullets, + MapPinPlusIcon, + menuIcon, + Microphone, + PaperPlaneTilt, + PHOSPHOR_SIZE, + PlusCircle, + Smiley, + Sticker, + Stop, + X, +} from '$components/icons/phosphor'; import { getSupportedAudioExtension } from '$plugins/voice-recorder-kit/supportedCodec'; import { ErrorCode } from '../../cs-errorcode'; import { sanitizeText } from '$utils/sanitize'; @@ -1337,7 +1355,7 @@ export const RoomInput = forwardRef( gap="500" style={{ padding: toRem(60) }} > - + {dropzoneIcon(FileIcon)} {`Drop Files in "${room?.name || 'Room'}"`} @@ -1434,10 +1452,10 @@ export const RoomInput = forwardRef( radii="300" title="schedule message send" > - + {chipIcon(X)} - + {menuIcon(Clock)} Scheduled for {timeDayMonthYear(scheduledTime.getTime())} at{' '} {timeHourMinute(scheduledTime.getTime(), hour24Clock)} @@ -1490,7 +1508,7 @@ export const RoomInput = forwardRef( aria-label="Cancel reply" title="Cancel reply" > - + {chipIcon(X)} ( } onClick={() => setSilentReply(!silentReply)} > - {!silentReply && } - {silentReply && } + {!silentReply && composerIcon(Bell)} + {silentReply && composerIcon(BellSlash)} @@ -1558,7 +1576,7 @@ export const RoomInput = forwardRef( setAddMenuAnchor(undefined); setShowPollPicker(true); }} - before={} + before={menuIcon(ListBullets)} > Create Poll @@ -1569,7 +1587,7 @@ export const RoomInput = forwardRef( setAddMenuAnchor(undefined); setShowLocationPicker(true); }} - before={} + before={menuIcon(MapPinPlusIcon)} > Add Location @@ -1580,7 +1598,7 @@ export const RoomInput = forwardRef( pickFile('*'); setAddMenuAnchor(undefined); }} - before={} + before={menuIcon(PlusCircle)} > Add File @@ -1601,7 +1619,7 @@ export const RoomInput = forwardRef( title={editorOldAddFile ? 'Upload File' : 'Add'} aria-label={editorOldAddFile ? 'Upload and attach a File' : 'Add new Item'} > - + {composerIcon(PlusCircle)} } @@ -1652,9 +1670,13 @@ export const RoomInput = forwardRef( }} > {showAudioRecorder ? ( - + ) : ( - + composerIcon(Microphone) )} @@ -1703,10 +1725,9 @@ export const RoomInput = forwardRef( title="open sticker picker" aria-label="Open sticker picker" > - + {composerIcon(Sticker, { + weight: emojiBoardTab === EmojiBoardTab.Sticker ? 'fill' : 'regular', + })} )} ( title="open emoji picker" aria-label="Open emoji picker" > - + {composerIcon(Smiley, { + weight: hideStickerBtn + ? emojiBoardTab + ? 'fill' + : 'regular' + : emojiBoardTab === EmojiBoardTab.Emoji + ? 'fill' + : 'regular', + })} )} @@ -1754,7 +1778,7 @@ export const RoomInput = forwardRef( setScheduleMenuAnchor(undefined); submit(); }} - before={} + before={menuIcon(PaperPlaneTilt)} > Send Now @@ -1765,7 +1789,7 @@ export const RoomInput = forwardRef( setScheduleMenuAnchor(undefined); setShowSchedulePicker(true); }} - before={} + before={menuIcon(Clock)} > Schedule Send @@ -1812,7 +1836,7 @@ export const RoomInput = forwardRef( radii="0" className={delayedEventsSupported ? css.SplitSendButton : undefined} > - + {scheduledTime ? composerIcon(Clock) : composerIcon(PaperPlaneTilt)} {delayedEventsSupported && !mobileOrTablet() && ( ( radii="0" className={css.SplitChevronButton} > - + {chipIcon(CaretDown)} )} diff --git a/src/app/features/room/RoomTimeline.tsx b/src/app/features/room/RoomTimeline.tsx index 08bd19c53..18698fcdc 100644 --- a/src/app/features/room/RoomTimeline.tsx +++ b/src/app/features/room/RoomTimeline.tsx @@ -16,20 +16,8 @@ import classNames from 'classnames'; import type { VListHandle } from 'virtua'; import { VList } from 'virtua'; import type { ContainerColor } from 'folds'; -import { - as, - Box, - Chip, - Icon, - Icons, - Line, - Text, - Badge, - color, - config, - toRem, - Spinner, -} from 'folds'; +import { as, Box, Chip, Line, Text, Badge, color, config, toRem, Spinner } from 'folds'; +import { ArrowDown, ChatTeardropDots, Checks, chipIcon } from '$components/icons/phosphor'; import { MessageBase, CompactPlaceholder, DefaultPlaceholder } from '$components/message'; import { RoomIntro } from '$components/room-intro'; import { useMatrixClient } from '$hooks/useMatrixClient'; @@ -61,7 +49,7 @@ import { useMediaAuthentication } from '$hooks/useMediaAuthentication'; import { useIgnoredUsers } from '$hooks/useIgnoredUsers'; import { useImagePackRooms } from '$hooks/useImagePackRooms'; import { settingsAtom, MessageLayout } from '$state/settings'; -import { useSetting } from '$state/hooks/settings'; +import { useHiddenEventSettings, useSetting } from '$state/hooks/settings'; import { nicknamesAtom } from '$state/nicknames'; import { useRoomAbbreviationsContext } from '$hooks/useRoomAbbreviations'; import { buildAbbrReplaceTextNode } from '$components/message/RenderBody'; @@ -147,8 +135,7 @@ export function RoomTimeline({ const [encUrlPreview] = useSetting(settingsAtom, 'encUrlPreview'); const [clientUrlPreview] = useSetting(settingsAtom, 'clientUrlPreview'); const [encClientUrlPreview] = useSetting(settingsAtom, 'encClientUrlPreview'); - const [showHiddenEvents] = useSetting(settingsAtom, 'showHiddenEvents'); - const [showTombstoneEvents] = useSetting(settingsAtom, 'showTombstoneEvents'); + const hiddenEvents = useHiddenEventSettings(settingsAtom); const [showDeveloperTools] = useSetting(settingsAtom, 'developerTools'); const [reducedMotion] = useSetting(settingsAtom, 'reducedMotion'); const [hour24Clock] = useSetting(settingsAtom, 'hour24Clock'); @@ -619,7 +606,7 @@ export function RoomTimeline({ isReadOnly, hideMembershipEvents, hideNickAvatarEvents, - showHiddenEvents, + hiddenEvents, }, state: { focusItem: timelineSync.focusItem, editId, activeReplyId, openThreadId }, permissions: { @@ -780,8 +767,7 @@ export function RoomTimeline({ items: vListIndices, linkedTimelines: timelineSync.timeline.linkedTimelines, ignoredUsersSet, - showHiddenEvents, - showTombstoneEvents, + hiddenEvents, mxUserId: mx.getUserId(), readUptoEventId: readUptoEventIdRef.current, hideMembershipEvents, @@ -875,7 +861,7 @@ export function RoomTimeline({ variant="Primary" radii="Pill" outlined - before={} + before={chipIcon(ChatTeardropDots)} onClick={() => timelineSync.loadEventTimeline(unreadInfo.readUptoEventId)} > Jump to Unread @@ -884,7 +870,7 @@ export function RoomTimeline({ variant="SurfaceVariant" radii="Pill" outlined - before={} + before={chipIcon(Checks)} onClick={() => markAsRead(mx, room.roomId, hideReads)} > Mark as Read @@ -1037,7 +1023,7 @@ export function RoomTimeline({ variant="SurfaceVariant" radii="Pill" outlined - before={} + before={chipIcon(ArrowDown)} onClick={() => { if (eventId) navigateRoom(room.roomId, undefined, { replace: true }); timelineSync.setTimeline(getInitialTimeline(room)); diff --git a/src/app/features/room/RoomViewFollowing.tsx b/src/app/features/room/RoomViewFollowing.tsx index 979ee6507..5dfc01f71 100644 --- a/src/app/features/room/RoomViewFollowing.tsx +++ b/src/app/features/room/RoomViewFollowing.tsx @@ -1,5 +1,6 @@ import { useAtomValue } from 'jotai'; -import { Box, Icon, Icons, Text, as, config } from 'folds'; +import { Box, Text, as, config } from 'folds'; +import { Checks, menuIcon } from '$components/icons/phosphor'; import type { Room } from '$types/matrix-sdk'; import classNames from 'classnames'; import { useAtom } from 'jotai'; @@ -61,7 +62,7 @@ export const RoomViewFollowing = as<'div', RoomViewFollowingProps>( > {names.length > 0 && ( <> - + {menuIcon(Checks, { style: { opacity: config.opacity.P300 } })} {names.length === 1 && ( <> diff --git a/src/app/features/room/RoomViewHeader.tsx b/src/app/features/room/RoomViewHeader.tsx index f45e6172f..632331b17 100644 --- a/src/app/features/room/RoomViewHeader.tsx +++ b/src/app/features/room/RoomViewHeader.tsx @@ -11,8 +11,6 @@ import { OverlayCenter, OverlayBackdrop, IconButton, - Icon, - Icons, Tooltip, TooltipProvider, Menu, @@ -37,6 +35,24 @@ import { import { useStateEvent } from '$hooks/useStateEvent'; import { PageHeader } from '$components/page'; +import { + ArrowLeft, + ChatCircleDots, + Checks, + Chats, + ClockCounterClockwise, + composerIcon, + DotsThreeOutlineVerticalIcon, + GearSix, + GridFour, + Link, + MagnifyingGlass, + menuIcon, + PushPin, + SignOut, + UserCircle, + UserPlus, +} from '$components/icons/phosphor'; import { RoomAvatar, RoomIcon } from '$components/room-avatar'; import { UseStateProvider } from '$components/UseStateProvider'; import { RoomTopicViewer } from '$components/room-topic-viewer'; @@ -73,7 +89,7 @@ import { useOpenRoomSettings } from '$state/hooks/roomSettings'; import { RoomNotificationModeSwitcher } from '$components/RoomNotificationSwitcher'; import { getRoomNotificationMode, - getRoomNotificationModeIcon, + roomNotificationModeIcon, useRoomsNotificationPreferencesContext, } from '$hooks/useRoomsNotificationPreferences'; import { useRoomNavigate } from '$hooks/useRoomNavigate'; @@ -216,7 +232,7 @@ const RoomMenu = forwardRef(({ room, requestClose } + after={menuIcon(Checks)} radii="300" disabled={!unread} > @@ -232,7 +248,7 @@ const RoomMenu = forwardRef(({ room, requestClose changing ? ( ) : ( - + roomNotificationModeIcon(notificationMode) ) } radii="300" @@ -253,7 +269,7 @@ const RoomMenu = forwardRef(({ room, requestClose variant="Primary" fill="None" size="300" - after={} + after={menuIcon(UserPlus)} radii="300" aria-pressed={invitePrompt} disabled={!canInvite} @@ -262,22 +278,12 @@ const RoomMenu = forwardRef(({ room, requestClose Invite - } - radii="300" - > + Copy Link - } - radii="300" - > + Room Settings @@ -288,7 +294,7 @@ const RoomMenu = forwardRef(({ room, requestClose setPromptJump(true)} size="300" - after={} + after={menuIcon(ClockCounterClockwise)} radii="300" aria-pressed={promptJump} > @@ -320,7 +326,7 @@ const RoomMenu = forwardRef(({ room, requestClose variant="Critical" fill="None" size="300" - after={} + after={menuIcon(SignOut)} radii="300" aria-pressed={promptLeave} > @@ -604,7 +610,7 @@ export function RoomViewHeader({ callView }: Readonly<{ callView?: boolean }>) { {(onBack) => ( - + {composerIcon(ArrowLeft)} )} @@ -618,7 +624,12 @@ export function RoomViewHeader({ callView }: Readonly<{ callView?: boolean }>) { src={avatarUrl} alt={name} renderFallback={() => ( - + )} /> @@ -682,7 +693,7 @@ export function RoomViewHeader({ callView }: Readonly<{ callView?: boolean }>) { > {(triggerRef) => ( - + {composerIcon(MagnifyingGlass)} )} @@ -721,7 +732,7 @@ export function RoomViewHeader({ callView }: Readonly<{ callView?: boolean }>) { )} - + {composerIcon(PushPin, { weight: pinMenuAnchor ? 'fill' : 'regular' })} )} @@ -792,7 +803,7 @@ export function RoomViewHeader({ callView }: Readonly<{ callView?: boolean }>) { )} - + {composerIcon(Chats, { weight: threadBrowserOpen ? 'fill' : 'regular' })} )} @@ -833,7 +844,7 @@ export function RoomViewHeader({ callView }: Readonly<{ callView?: boolean }>) { )} - + {composerIcon(GridFour, { weight: widgetDrawer ? 'fill' : 'regular' })} )} @@ -854,7 +865,7 @@ export function RoomViewHeader({ callView }: Readonly<{ callView?: boolean }>) { > {(triggerRef) => ( - + {composerIcon(UserCircle, { weight: peopleDrawer ? 'fill' : 'regular' })} )} @@ -878,7 +889,7 @@ export function RoomViewHeader({ callView }: Readonly<{ callView?: boolean }>) { setChat(!chat); }} > - + {composerIcon(ChatCircleDots, { weight: chat ? 'fill' : 'regular' })} )} @@ -901,7 +912,9 @@ export function RoomViewHeader({ callView }: Readonly<{ callView?: boolean }>) { ref={triggerRef} aria-pressed={!!menuAnchor} > - + {composerIcon(DotsThreeOutlineVerticalIcon, { + weight: menuAnchor ? 'fill' : 'regular', + })} )} diff --git a/src/app/features/room/RoomViewTyping.tsx b/src/app/features/room/RoomViewTyping.tsx index 3d1120d52..98267fdd8 100644 --- a/src/app/features/room/RoomViewTyping.tsx +++ b/src/app/features/room/RoomViewTyping.tsx @@ -1,4 +1,5 @@ -import { Box, Icon, IconButton, Icons, Text, as } from 'folds'; +import { Box, IconButton, Text, as } from 'folds'; +import { chipIcon, X } from '$components/icons/phosphor'; import type { Room } from '$types/matrix-sdk'; import classNames from 'classnames'; import { useSetAtom, useAtomValue } from 'jotai'; @@ -115,7 +116,7 @@ export const RoomViewTyping = as<'div', RoomViewTypingProps>( )} - + {chipIcon(X)}
diff --git a/src/app/features/room/ThreadBrowser.tsx b/src/app/features/room/ThreadBrowser.tsx index a5dd56382..72d967db8 100644 --- a/src/app/features/room/ThreadBrowser.tsx +++ b/src/app/features/room/ThreadBrowser.tsx @@ -3,9 +3,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { Box, Header, - Icon, IconButton, - Icons, Input, Scroll, Spinner, @@ -28,6 +26,14 @@ import { nicknamesAtom } from '$state/nicknames'; import { getMemberAvatarMxc, getMemberDisplayName, reactionOrEditEvent } from '$utils/room'; import { getMxIdLocalPart, mxcUrlToHttp } from '$utils/matrix'; import { UserAvatar } from '$components/user-avatar'; +import { + Chats, + chipIcon, + composerIcon, + MagnifyingGlass, + userFallbackIcon, + X, +} from '$components/icons/phosphor'; import { AvatarBase, ModernLayout, @@ -189,7 +195,7 @@ function ThreadPreview({ room, thread, onClick, onJump }: ThreadPreviewProps) { : undefined } alt={displayName} - renderFallback={() => } + renderFallback={() => userFallbackIcon('lg')} /> @@ -472,7 +478,7 @@ export function ThreadBrowser({ room, onOpenThread, onClose, overlay }: ThreadBr )}
- + {composerIcon(Chats)} Threads @@ -485,7 +491,7 @@ export function ThreadBrowser({ room, onOpenThread, onClose, overlay }: ThreadBr radii="300" aria-label="Close threads" > - + {composerIcon(X)}
@@ -504,7 +510,7 @@ export function ThreadBrowser({ room, onOpenThread, onClose, overlay }: ThreadBr variant="Surface" size="400" radii="400" - before={} + before={chipIcon(MagnifyingGlass)} after={ query ? ( - + {chipIcon(X)} ) : undefined } @@ -553,7 +559,7 @@ export function ThreadBrowser({ room, onOpenThread, onClose, overlay }: ThreadBr justifyContent="Center" style={{ padding: config.space.S400, gap: config.space.S200 }} > - + {composerIcon(Chats, { style: { opacity: 0.6 } })} {lowerQuery ? 'No threads match your search.' : 'No threads yet.'} diff --git a/src/app/features/room/ThreadDrawer.tsx b/src/app/features/room/ThreadDrawer.tsx index 7c3cb231a..8a3b206bc 100644 --- a/src/app/features/room/ThreadDrawer.tsx +++ b/src/app/features/room/ThreadDrawer.tsx @@ -1,6 +1,7 @@ import type { MouseEventHandler } from 'react'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; -import { Box, Header, Icon, IconButton, Icons, Scroll, Spinner, Text, config, toRem } from 'folds'; +import { Box, Header, IconButton, Scroll, Spinner, Text, config, toRem } from 'folds'; +import { Chats, composerIcon, X } from '$components/icons/phosphor'; import type { IEvent, Room } from '$types/matrix-sdk'; import { Direction, @@ -36,7 +37,7 @@ import { useMediaAuthentication } from '$hooks/useMediaAuthentication'; import { useSettingsLinkBaseUrl } from '$features/settings/useSettingsLinkBaseUrl'; import { nicknamesAtom } from '$state/nicknames'; import { settingsAtom } from '$state/settings'; -import { useSetting } from '$state/hooks/settings'; +import { useHiddenEventSettings, useSetting } from '$state/hooks/settings'; import { useRoomAbbreviationsContext } from '$hooks/useRoomAbbreviations'; import { buildAbbrReplaceTextNode } from '$components/message/RenderBody'; import { createMentionElement, moveCursor, useEditor } from '$components/editor'; @@ -146,8 +147,7 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra const [encClientUrlPreview] = useSetting(settingsAtom, 'encClientUrlPreview'); const [autoplayStickers] = useSetting(settingsAtom, 'autoplayStickers'); const [autoplayEmojis] = useSetting(settingsAtom, 'autoplayEmojis'); - const [showHiddenEvents] = useSetting(settingsAtom, 'showHiddenEvents'); - const [showTombstoneEvents] = useSetting(settingsAtom, 'showTombstoneEvents'); + const hiddenEvents = useHiddenEventSettings(settingsAtom); const [hideMemberInReadOnly] = useSetting(settingsAtom, 'hideMembershipInReadOnly'); const [showBundledPreview] = useSetting(settingsAtom, 'bundledPreview'); const showUrlPreview = room.hasEncryptionStateEvent() ? encUrlPreview : urlPreview; @@ -259,8 +259,7 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra linkedTimelines, skipThreadFilter: true, ignoredUsersSet, - showHiddenEvents, - showTombstoneEvents, + hiddenEvents, mxUserId: mx.getUserId(), readUptoEventId: undefined, hideMembershipEvents: true, @@ -719,7 +718,7 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra isReadOnly, hideMembershipEvents: true, hideNickAvatarEvents: true, - showHiddenEvents, + hiddenEvents, hideThreadChip: true, }, state: { focusItem, editId, activeReplyId, openThreadId: threadRootId, suppressMark }, @@ -786,7 +785,7 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra {/* Header */}
- + {composerIcon(Chats)} Thread @@ -799,7 +798,7 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra radii="300" aria-label="Close thread" > - + {composerIcon(X)}
@@ -879,7 +878,7 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra justifyContent="Center" style={{ padding: config.space.S400, gap: config.space.S200 }} > - + {composerIcon(Chats, { style: { opacity: 0.6 } })} No replies yet. Start the thread below! diff --git a/src/app/features/room/jump-to-time/JumpToTime.tsx b/src/app/features/room/jump-to-time/JumpToTime.tsx index 2f1318ed0..0cf34fa1e 100644 --- a/src/app/features/room/jump-to-time/JumpToTime.tsx +++ b/src/app/features/room/jump-to-time/JumpToTime.tsx @@ -1,6 +1,7 @@ import type { MouseEventHandler } from 'react'; import { useCallback, useMemo, useState } from 'react'; import FocusTrap from 'focus-trap-react'; +import { CaretDown, chipIcon, composerIcon, X } from '$components/icons/phosphor'; import type { RectCords } from 'folds'; import { Dialog, @@ -12,8 +13,6 @@ import { Box, Text, IconButton, - Icon, - Icons, color, Button, Spinner, @@ -111,7 +110,7 @@ export function JumpToTime({ onCancel, onSubmit }: JumpToTimeProps) { Jump to Time
- + {composerIcon(X)} @@ -128,7 +127,7 @@ export function JumpToTime({ onCancel, onSubmit }: JumpToTimeProps) { outlined radii="300" aria-pressed={!!timePickerCords} - after={} + after={chipIcon(CaretDown)} onClick={handleTimePicker} > {timeHourMinute(ts, hour24Clock)} @@ -169,7 +168,7 @@ export function JumpToTime({ onCancel, onSubmit }: JumpToTimeProps) { outlined radii="300" aria-pressed={!!datePickerCords} - after={} + after={chipIcon(CaretDown)} onClick={handleDatePicker} > {timeDayMonthYear(ts)} diff --git a/src/app/features/room/location-modal/LocationDialog.tsx b/src/app/features/room/location-modal/LocationDialog.tsx index d411a5237..c989ebeb2 100644 --- a/src/app/features/room/location-modal/LocationDialog.tsx +++ b/src/app/features/room/location-modal/LocationDialog.tsx @@ -9,13 +9,12 @@ import { Box, Text, IconButton, - Icon, - Icons, Button, Input, Chip, } from 'folds'; import { ClipboardIcon, MapPinAreaIcon, MapPinLineIcon } from '@phosphor-icons/react'; +import { chipIcon, composerIcon, Warning, X } from '$components/icons/phosphor'; import { stopPropagation } from '$utils/keyboard'; import type { IContent, MatrixClient, Room } from 'matrix-js-sdk'; import * as css from './LocationDialog.css'; @@ -276,7 +275,7 @@ export function LocationDialog({ title="Cancel Sharing Location" aria-label="Cancel Sharing Location" > - + {composerIcon(X)} @@ -311,7 +310,7 @@ export function LocationDialog({ {locationError !== LocationErrors.none && ( - + {chipIcon(Warning)} {locationError} )} diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index b9e920f40..b34b26cba 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -3,9 +3,7 @@ import { Avatar, Box, Chip, - Icon, IconButton, - Icons, Line, Menu, MenuItem, @@ -61,6 +59,20 @@ import type { MemberPowerTag } from '$types/matrix/room'; import type { StateEvents } from '$types/matrix-sdk'; import { PowerIcon } from '$components/power'; +import { + ArrowBendUpRightIcon, + ChatCircleDots, + DotsThreeOutlineVerticalIcon, + Info, + Link, + menuIcon, + PencilSimple, + PushPin, + PushPinSlash, + Smiley, + Star, + userFallbackIcon, +} from '$components/icons/phosphor'; import { getPowerTagIconSrc } from '$hooks/useMemberPowerTag'; import { useSableCosmetics } from '$hooks/useSableCosmetics'; import { SwipeableMessageWrapper } from '$components/SwipeableMessageWrapper'; @@ -148,7 +160,7 @@ export const MessageCopyLinkItem = as< return ( } + after={menuIcon(Link)} radii="300" onClick={handleCopy} {...props} @@ -189,7 +201,7 @@ export const MessagePinItem = as< return ( } + after={menuIcon(isPinned ? PushPinSlash : PushPin)} radii="300" onClick={handlePin} {...props} @@ -694,7 +706,7 @@ function MessageInternal( userId={senderId} src={cachedAvatar} alt={cleanedDisplayName} - renderFallback={() => } + renderFallback={() => userFallbackIcon('md')} /> @@ -849,7 +861,7 @@ function MessageInternal( )} {isSableFeedback && ( - + {menuIcon(Info)} Only you can see this. @@ -945,7 +957,7 @@ function MessageInternal( const edits = evtTimeline && getEventEdits(evtTimeline.getTimelineSet(), evtId, mEvent.getType())?.getRelations(); - const isEdited = edits !== undefined; + const isEdited = !!edits?.length; return ( - + {menuIcon(Smiley)} )} @@ -1016,7 +1028,7 @@ function MessageInternal( size="300" radii="300" > - + {menuIcon(ArrowBendUpRightIcon)} {!isThreadedMessage && ( - + {menuIcon(ChatCircleDots)} )} {canEditEvent(mx, mEvent) && onEditId && ( @@ -1045,7 +1057,7 @@ function MessageInternal( size="300" radii="300" > - + {menuIcon(PencilSimple)} )} } + after={menuIcon(Smiley)} radii="300" onClick={handleAddReactions} > @@ -1097,7 +1109,7 @@ function MessageInternal( !doesStickerExistInDefaultPack(mx, mEvent.getContent().url) && ( } + after={menuIcon(Star)} radii="300" onClick={() => { addStickerToDefaultPack( @@ -1123,7 +1135,7 @@ function MessageInternal( {relations && } } + after={menuIcon(ArrowBendUpRightIcon)} radii="300" data-event-id={mEvent.getId()} onClick={(evt: React.MouseEvent) => { @@ -1140,7 +1152,7 @@ function MessageInternal( {!isThreadedMessage && ( } + after={menuIcon(ChatCircleDots)} radii="300" data-event-id={mEvent.getId()} onClick={(evt: React.MouseEvent) => { @@ -1166,7 +1178,7 @@ function MessageInternal( {canEditEvent(mx, mEvent) && onEditId && ( } + after={menuIcon(PencilSimple)} radii="300" data-event-id={mEvent.getId()} onClick={() => { @@ -1267,7 +1279,7 @@ function MessageInternal( ) : ( } + after={menuIcon(PencilSimple)} radii="300" onClick={() => { setNickDraft(nicknames[senderId] ?? ''); @@ -1310,7 +1322,9 @@ function MessageInternal( onClick={handleOpenMenu} aria-pressed={!!menuAnchor} > - + {menuIcon(DotsThreeOutlineVerticalIcon, { + weight: menuAnchor ? 'fill' : 'regular', + })} @@ -1462,7 +1476,7 @@ export const Event = as<'div', EventProps>( const edits = evtTimeline && getEventEdits(evtTimeline.getTimelineSet(), evtId, mEvent.getType())?.getRelations(); - const isEdited = edits !== undefined; + const isEdited = !!edits?.length; return ( ( } + after={menuIcon(ArrowBendUpRightIcon)} radii="300" data-event-id={mEvent.getId()} onClick={(evt: React.MouseEvent) => { @@ -1566,7 +1580,7 @@ export const Event = as<'div', EventProps>( size="300" radii="300" > - + {menuIcon(ArrowBendUpRightIcon)} ( onClick={handleOpenMenu} aria-pressed={!!menuAnchor} > - + {menuIcon(DotsThreeOutlineVerticalIcon, { + weight: menuAnchor ? 'fill' : 'regular', + })} )} diff --git a/src/app/features/room/message/MessageEditor.tsx b/src/app/features/room/message/MessageEditor.tsx index bc0566ad5..320af869c 100644 --- a/src/app/features/room/message/MessageEditor.tsx +++ b/src/app/features/room/message/MessageEditor.tsx @@ -2,7 +2,8 @@ import type { KeyboardEventHandler, MouseEventHandler } from 'react'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { useAtomValue } from 'jotai'; import type { RectCords } from 'folds'; -import { Box, Chip, Icon, IconButton, Icons, PopOut, Spinner, Text, as, config } from 'folds'; +import { Box, Chip, IconButton, PopOut, Spinner, Text, as, config } from 'folds'; +import { composerIcon, Smiley } from '$components/icons/phosphor'; import { Editor, Transforms } from 'slate'; import { ReactEditor } from 'slate-react'; import type { @@ -590,7 +591,9 @@ export const MessageEditor = as<'div', MessageEditorProps>( size="300" radii="300" > - + {composerIcon(Smiley, { + weight: anchor !== undefined ? 'fill' : 'regular', + })} )} diff --git a/src/app/features/room/message/Reactions.tsx b/src/app/features/room/message/Reactions.tsx index e2fc88478..e0ef83fb7 100644 --- a/src/app/features/room/message/Reactions.tsx +++ b/src/app/features/room/message/Reactions.tsx @@ -6,11 +6,13 @@ import { Overlay, OverlayBackdrop, OverlayCenter, + PopOut, Text, Tooltip, TooltipProvider, as, toRem, + type RectCords, } from 'folds'; import classNames from 'classnames'; import type { Room } from '$types/matrix-sdk'; @@ -19,6 +21,8 @@ import FocusTrap from 'focus-trap-react'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { factoryEventSentBy } from '$utils/matrix'; import { Reaction, ReactionTooltipMsg } from '$components/message'; +import { EmojiBoard } from '$components/emoji-board'; +import { sizedIcon, Smiley } from '$components/icons/phosphor'; import { useRelations } from '$hooks/useRelations'; import { stopPropagation } from '$utils/keyboard'; import { useMediaAuthentication } from '$hooks/useMediaAuthentication'; @@ -31,6 +35,7 @@ export type ReactionsProps = { canSendReaction: boolean; canDeleteOwn: boolean; relations: Relations; + imagePackRooms?: Room[]; onReactionToggle: (targetEventId: string, key: string, shortcode?: string) => void; }; export const Reactions = as<'div', ReactionsProps>( @@ -43,6 +48,7 @@ export const Reactions = as<'div', ReactionsProps>( canSendReaction, canDeleteOwn, onReactionToggle, + imagePackRooms, ...props }, ref @@ -50,6 +56,7 @@ export const Reactions = as<'div', ReactionsProps>( const mx = useMatrixClient(); const useAuthentication = useMediaAuthentication(); const [viewer, setViewer] = useState(false); + const [emojiBoardAnchor, setEmojiBoardAnchor] = useState(); const myUserId = mx.getUserId(); const reactions = useRelations( relations, @@ -64,6 +71,12 @@ export const Reactions = as<'div', ReactionsProps>( else setViewer(key); }; + const handleOpenEmojiBoard: MouseEventHandler = (evt) => { + evt.stopPropagation(); + evt.preventDefault(); + setEmojiBoardAnchor(evt.currentTarget.getBoundingClientRect()); + }; + return ( ( ); })} + {canSendReaction && reactions.length > 0 && ( + { + onReactionToggle(mEventId, key); + setEmojiBoardAnchor(undefined); + }} + onCustomEmojiSelect={(mxc, shortcode) => { + onReactionToggle(mEventId, mxc, shortcode); + setEmojiBoardAnchor(undefined); + }} + requestClose={() => setEmojiBoardAnchor(undefined)} + /> + } + > + + Add Reaction + + } + > + {(targetRef) => ( + + {sizedIcon(Smiley, '100', { filled: !!emojiBoardAnchor })} + + )} + + + )} {reactions.length > 0 && ( { diff --git a/src/app/features/room/message/styles.css.ts b/src/app/features/room/message/styles.css.ts index 031adf300..e26ff8e7b 100644 --- a/src/app/features/room/message/styles.css.ts +++ b/src/app/features/room/message/styles.css.ts @@ -1,5 +1,5 @@ import { style } from '@vanilla-extract/css'; -import { DefaultReset, config, toRem } from 'folds'; +import { DefaultReset, FocusOutline, color, config, toRem } from 'folds'; export const MessageBase = style({ position: 'relative', @@ -57,6 +57,38 @@ export const ReactionsTooltipText = style({ wordBreak: 'break-word', }); +export const ReactionAdd = style([ + FocusOutline, + { + display: 'inline-flex', + alignItems: 'center', + justifyContent: 'center', + flexShrink: 0, + padding: `${toRem(2)} ${config.space.S200}`, + minHeight: toRem(24), + backgroundColor: color.SurfaceVariant.Container, + border: `${config.borderWidth.B300} solid ${color.SurfaceVariant.ContainerLine}`, + borderRadius: config.radii.R300, + color: color.SurfaceVariant.OnContainer, + opacity: config.opacity.P500, + cursor: 'pointer', + + selectors: { + '&:hover, &:focus-visible': { + backgroundColor: color.SurfaceVariant.ContainerHover, + opacity: 1, + }, + '&:active': { + backgroundColor: color.SurfaceVariant.ContainerActive, + }, + '&[aria-pressed=true]': { + opacity: 1, + backgroundColor: color.SurfaceVariant.ContainerHover, + }, + }, + }, +]); + export const MessagePending = style({ opacity: config.opacity.Placeholder, }); diff --git a/src/app/features/room/poll-modals/PollDialog.tsx b/src/app/features/room/poll-modals/PollDialog.tsx index 7e6aeb5d4..bdaa90128 100644 --- a/src/app/features/room/poll-modals/PollDialog.tsx +++ b/src/app/features/room/poll-modals/PollDialog.tsx @@ -8,8 +8,6 @@ import { Box, Text, IconButton, - Icon, - Icons, Button, Input, Chip, @@ -17,6 +15,7 @@ import { color, Scroll, } from 'folds'; +import { chipIcon, composerIcon, ListBullets, Minus, X } from '$components/icons/phosphor'; import { stopPropagation } from '$utils/keyboard'; import type { ChangeEventHandler, KeyboardEventHandler } from 'react'; import { useCallback, useRef, useState } from 'react'; @@ -168,7 +167,7 @@ export function PollDialog({ onCancel, mx, room, replyDraft, clearReplyDraft }:
- + {composerIcon(ListBullets)} {`New Poll ${replyDraft ? '(reply / thread)' : ''}`} - + {composerIcon(X)}
@@ -247,7 +246,7 @@ export function PollDialog({ onCancel, mx, room, replyDraft, clearReplyDraft }: aria-label="Remove Option" onClick={() => delOption(item.id)} > - + {chipIcon(Minus)} } /> diff --git a/src/app/features/room/poll-modals/PollResponses.tsx b/src/app/features/room/poll-modals/PollResponses.tsx index 7c5afe232..24391438e 100644 --- a/src/app/features/room/poll-modals/PollResponses.tsx +++ b/src/app/features/room/poll-modals/PollResponses.tsx @@ -4,9 +4,7 @@ import { Box, Button, Header, - Icon, IconButton, - Icons, Line, MenuItem, Scroll, @@ -21,6 +19,7 @@ import { useMatrixClient } from '$hooks/useMatrixClient'; import { useAtomValue } from 'jotai'; import { nicknamesAtom } from '$state/nicknames'; import { UserAvatar } from '$components/user-avatar'; +import { composerIcon, userFallbackIcon, X } from '$components/icons/phosphor'; import { useMediaAuthentication } from '$hooks/useMediaAuthentication'; import { useOpenUserRoomProfile } from '$state/hooks/userRoomProfile'; import { useSpaceOptionally } from '$hooks/useSpace'; @@ -106,7 +105,7 @@ export const PollResponsesViewer = as<'div', PollResponsesViewerProps>( - + {composerIcon(X)} @@ -152,7 +151,7 @@ export const PollResponsesViewer = as<'div', PollResponsesViewerProps>( userId={senderId} src={avatarUrl ?? undefined} alt={name} - renderFallback={() => } + renderFallback={() => userFallbackIcon('sm')} /> } diff --git a/src/app/features/room/reaction-viewer/ReactionViewer.tsx b/src/app/features/room/reaction-viewer/ReactionViewer.tsx index 2f27fe5de..f2c59aae3 100644 --- a/src/app/features/room/reaction-viewer/ReactionViewer.tsx +++ b/src/app/features/room/reaction-viewer/ReactionViewer.tsx @@ -1,19 +1,6 @@ import { useCallback, useState } from 'react'; import classNames from 'classnames'; -import { - Avatar, - Box, - Header, - Icon, - IconButton, - Icons, - Line, - MenuItem, - Scroll, - Text, - as, - config, -} from 'folds'; +import { Avatar, Box, Header, IconButton, Line, MenuItem, Scroll, Text, as, config } from 'folds'; import type { MatrixEvent, Room, RoomMember, Relations } from '$types/matrix-sdk'; import { getMemberDisplayName } from '$utils/room'; import { eventWithShortcode, getMxIdLocalPart } from '$utils/matrix'; @@ -24,6 +11,7 @@ import { getHexcodeForEmoji, getShortcodeFor } from '$plugins/emoji'; import { useAtomValue } from 'jotai'; import { nicknamesAtom } from '$state/nicknames'; import { UserAvatar } from '$components/user-avatar'; +import { composerIcon, userFallbackIcon, X } from '$components/icons/phosphor'; import { useMediaAuthentication } from '$hooks/useMediaAuthentication'; import { useOpenUserRoomProfile } from '$state/hooks/userRoomProfile'; import { useSpaceOptionally } from '$hooks/useSpace'; @@ -102,7 +90,7 @@ export const ReactionViewer = as<'div', ReactionViewerProps>( {`Reacted with :${selectedShortcode}:`}
- + {composerIcon(X)} @@ -148,7 +136,7 @@ export const ReactionViewer = as<'div', ReactionViewerProps>( userId={senderId} src={avatarUrl ?? undefined} alt={name} - renderFallback={() => } + renderFallback={() => userFallbackIcon('sm')} /> } diff --git a/src/app/features/room/room-pin-menu/RoomPinMenu.tsx b/src/app/features/room/room-pin-menu/RoomPinMenu.tsx index 25bc658df..fa6153d2f 100644 --- a/src/app/features/room/room-pin-menu/RoomPinMenu.tsx +++ b/src/app/features/room/room-pin-menu/RoomPinMenu.tsx @@ -9,9 +9,7 @@ import { color, config, Header, - Icon, IconButton, - Icons, Menu, Scroll, Spinner, @@ -42,6 +40,14 @@ import { UsernameBold, } from '$components/message'; import { UserAvatar } from '$components/user-avatar'; +import { + dropzoneIcon, + menuIcon, + navIcon, + PushPin, + userFallbackIcon, + X, +} from '$components/icons/phosphor'; import { getMxIdLocalPart, mxcUrlToHttp } from '$utils/matrix'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { @@ -163,7 +169,7 @@ function PinnedMessageActiveContent( : undefined } alt={displayName} - renderFallback={() => } + renderFallback={() => userFallbackIcon('lg')} /> @@ -196,7 +202,7 @@ function PinnedMessageActiveContent( onClick={handleOpenClick} /> )} - + {renderContent(pinnedEvent.getType(), false, pinnedEvent, displayName, getContent)} @@ -255,11 +261,7 @@ function PinnedMessage(props: PinnedMessageProps) { onClick={unpinState.status === AsyncStatus.Loading ? undefined : handleUnpinClick} aria-disabled={unpinState.status === AsyncStatus.Loading} > - {unpinState.status === AsyncStatus.Loading ? ( - - ) : ( - - )} + {unpinState.status === AsyncStatus.Loading ? : menuIcon(X)} )} @@ -586,7 +588,7 @@ export const RoomPinMenu = forwardRef(
- + {navIcon(X)} @@ -664,7 +666,7 @@ export const RoomPinMenu = forwardRef( justifyContent="Center" alignItems="Center" > - + {dropzoneIcon(PushPin)} - + {composerIcon(X)} @@ -127,7 +126,7 @@ export function SchedulePickerDialog({ outlined radii="300" aria-pressed={!!timePickerCords} - after={} + after={chipIcon(CaretDown)} onClick={handleTimePicker} > {timeHourMinute(ts, hour24Clock)} @@ -168,7 +167,7 @@ export function SchedulePickerDialog({ outlined radii="300" aria-pressed={!!datePickerCords} - after={} + after={chipIcon(CaretDown)} onClick={handleDatePicker} > {timeDayMonthYear(ts)} diff --git a/src/app/features/room/schedule-send/ScheduledMessagesList.tsx b/src/app/features/room/schedule-send/ScheduledMessagesList.tsx index 13f241d49..d38081f3b 100644 --- a/src/app/features/room/schedule-send/ScheduledMessagesList.tsx +++ b/src/app/features/room/schedule-send/ScheduledMessagesList.tsx @@ -1,6 +1,15 @@ import { useCallback, useState } from 'react'; import { useQuery, useQueryClient } from '@tanstack/react-query'; -import { Box, Text, Chip, Icon, Icons, IconButton } from 'folds'; +import { Box, Text, Chip, IconButton } from 'folds'; +import { + CaretDown, + CaretUp, + chipIcon, + Clock, + Lock, + PencilSimple, + X, +} from '$components/icons/phosphor'; import type { Room } from '$types/matrix-sdk'; import { useAtom, useAtomValue, useSetAtom } from 'jotai'; import { useMatrixClient } from '$hooks/useMatrixClient'; @@ -90,8 +99,8 @@ export function ScheduledMessagesList({ room, onEditMessage }: ScheduledMessages } - after={} + before={chipIcon(Clock)} + after={chipIcon(expanded ? CaretUp : CaretDown)} onClick={() => setExpanded(!expanded)} > @@ -123,7 +132,7 @@ export function ScheduledMessagesList({ room, onEditMessage }: ScheduledMessages {isEncryptedEvt ? ( - + {chipIcon(Lock)} Encrypted — cancel and resend to edit @@ -146,7 +155,7 @@ export function ScheduledMessagesList({ room, onEditMessage }: ScheduledMessages onClick={() => handleEdit(evt.delay_id, body, formattedBody, deliveryTs)} aria-label="Edit scheduled message" > - + {chipIcon(PencilSimple)} )} handleCancel(evt.delay_id)} aria-label="Cancel scheduled message" > - + {chipIcon(X)} diff --git a/src/app/features/search/Search.tsx b/src/app/features/search/Search.tsx index 0c928aa38..171d3140c 100644 --- a/src/app/features/search/Search.tsx +++ b/src/app/features/search/Search.tsx @@ -3,9 +3,7 @@ import { Avatar, Box, config, - Icon, IconButton, - Icons, Input, Line, MenuItem, @@ -16,6 +14,7 @@ import { Text, toRem, } from 'folds'; +import { MagnifyingGlass, X, composerIcon, menuIcon } from '$components/icons/phosphor'; import type { ChangeEventHandler, KeyboardEventHandler, MouseEventHandler } from 'react'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { isKeyHotkey } from 'is-hotkey'; @@ -310,7 +309,7 @@ export function RoomSearchModal({ requestClose, pickRoom }: RoomSearchModalProps aria-label="Close" disabled={pickRoom.busy} > - + {composerIcon(X)} )} @@ -333,7 +332,7 @@ export function RoomSearchModal({ requestClose, pickRoom }: RoomSearchModalProps radii="400" outlined placeholder={pickRoom ? 'Search rooms' : 'Search'} - before={} + before={menuIcon(MagnifyingGlass)} onChange={handleInputChange} onKeyDown={handleInputKeyDown} disabled={pickRoom?.busy} diff --git a/src/app/features/settings/Persona/PerMessageProfileEditor.tsx b/src/app/features/settings/Persona/PerMessageProfileEditor.tsx index f05129eae..ea3dece4d 100644 --- a/src/app/features/settings/Persona/PerMessageProfileEditor.tsx +++ b/src/app/features/settings/Persona/PerMessageProfileEditor.tsx @@ -1,5 +1,6 @@ import { SequenceCard } from '$components/sequence-card'; -import { Box, Button, Text, Avatar, config, Icon, IconButton, Icons, Input } from 'folds'; +import { Box, Button, Text, Avatar, config, IconButton, Input } from 'folds'; +import { menuIcon, X } from '$components/icons/phosphor'; import type { MatrixClient } from '$types/matrix-sdk'; import { useCallback, useMemo, useState } from 'react'; import { mxcUrlToHttp } from '$utils/matrix'; @@ -376,7 +377,7 @@ export function PerMessageProfileEditor({ aria-label="Reset display name" title="Reset display name" > - + {menuIcon(X)} ) } @@ -423,7 +424,7 @@ export function PerMessageProfileEditor({ aria-label="Reset pronouns" title="Reset pronouns" > - + {menuIcon(X)} ) } diff --git a/src/app/features/settings/Settings.tsx b/src/app/features/settings/Settings.tsx index 65be2eaf5..bf22676a0 100644 --- a/src/app/features/settings/Settings.tsx +++ b/src/app/features/settings/Settings.tsx @@ -1,13 +1,12 @@ import { useMemo, useState } from 'react'; -import type { IconSrc } from 'folds'; +import type { ComponentType } from 'react'; +import type { IconProps } from '@phosphor-icons/react'; import { Avatar, Box, Button, config, - Icon, IconButton, - Icons, MenuItem, Overlay, OverlayBackdrop, @@ -28,6 +27,24 @@ import { stopPropagation } from '$utils/keyboard'; import { LogoutDialog } from '$components/LogoutDialog'; import { useSetting } from '$state/hooks/settings'; import { settingsAtom } from '$state/settings'; +import { + Bell, + composerIcon, + Devices as DevicesIcon, + Flask, + GearSix, + Info, + Keyboard, + menuIcon, + settingsNavIcon, + SignOut, + Palette, + Smiley, + Terminal, + User, + UsersThree, + X, +} from '$components/icons/phosphor'; import { About } from './about'; import { Account } from './account'; import { Cosmetics } from './cosmetics/Cosmetics'; @@ -59,28 +76,30 @@ export enum SettingsPages { KeyboardShortcutsPage, } +type PhosphorIcon = ComponentType; + type SettingsMenuItem = { id: SettingsSectionId; name: string; - icon: IconSrc; - activeIcon?: IconSrc; + icon: PhosphorIcon; + activeIcon?: PhosphorIcon; }; const settingsMenuIcons: Record< SettingsSectionId, Pick > = { - general: { icon: Icons.Setting }, - account: { icon: Icons.User }, - persona: { icon: Icons.User }, - appearance: { icon: Icons.Alphabet, activeIcon: Icons.AlphabetUnderline }, - notifications: { icon: Icons.Bell }, - devices: { icon: Icons.Monitor }, - emojis: { icon: Icons.Smile }, - 'developer-tools': { icon: Icons.Terminal }, - experimental: { icon: Icons.Funnel }, - about: { icon: Icons.Info }, - 'keyboard-shortcuts': { icon: Icons.BlockCode }, + general: { icon: GearSix }, + account: { icon: User }, + persona: { icon: UsersThree }, + appearance: { icon: Palette }, + notifications: { icon: Bell }, + devices: { icon: DevicesIcon }, + emojis: { icon: Smiley }, + 'developer-tools': { icon: Terminal }, + experimental: { icon: Flask }, + about: { icon: Info }, + 'keyboard-shortcuts': { icon: Keyboard }, }; const settingsPageToSectionId: Record = { @@ -270,7 +289,7 @@ export function Settings({ onClick={handleRequestClose} variant="Background" > - + {composerIcon(X)} )} @@ -280,28 +299,21 @@ export function Settings({
{menuItems.map((item) => { - const currentIcon = - visibleSection === item.id && item.activeIcon ? item.activeIcon : item.icon; + const active = visibleSection === item.id; + const IconComponent = active && item.activeIcon ? item.activeIcon : item.icon; return ( - } + aria-pressed={active} + before={settingsNavIcon(IconComponent, active)} onClick={() => handleSelectSection(item.id)} > } + before={menuIcon(SignOut)} onClick={() => setLogout(true)} > Logout diff --git a/src/app/features/settings/SettingsSectionPage.tsx b/src/app/features/settings/SettingsSectionPage.tsx index 152b2e52f..a19d102d4 100644 --- a/src/app/features/settings/SettingsSectionPage.tsx +++ b/src/app/features/settings/SettingsSectionPage.tsx @@ -1,7 +1,8 @@ import type { ReactNode } from 'react'; -import { Box, Icon, IconButton, Icons, Text } from 'folds'; +import { Box, IconButton, Text } from 'folds'; import { Page, PageHeader } from '$components/page'; import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize'; +import { ArrowLeft, composerIcon, X } from '$components/icons/phosphor'; import { settingsHeader } from './styles.css'; type SettingsSectionPageProps = { @@ -34,7 +35,7 @@ export function SettingsSectionPage({ {showBack && ( - + {composerIcon(ArrowLeft)} )} @@ -43,7 +44,7 @@ export function SettingsSectionPage({ - + {composerIcon(X)} diff --git a/src/app/features/settings/about/About.tsx b/src/app/features/settings/about/About.tsx index a9b2b63f0..d0061d5b8 100644 --- a/src/app/features/settings/about/About.tsx +++ b/src/app/features/settings/about/About.tsx @@ -1,5 +1,6 @@ import { useState } from 'react'; -import { Box, Text, Icon, Icons, Scroll, Button, config, toRem, Spinner } from 'folds'; +import { Box, Text, Scroll, Button, config, toRem, Spinner } from 'folds'; +import { Code, Heart, menuIcon } from '$components/icons/phosphor'; import { PageContent } from '$components/page'; import { SequenceCard } from '$components/sequence-card'; import { SettingTile } from '$components/setting-tile'; @@ -213,7 +214,7 @@ export function About({ requestBack, requestClose }: Readonly) { fill="Soft" size="300" radii="300" - before={} + before={menuIcon(Code, { weight: 'fill' })} > Source Code @@ -226,7 +227,7 @@ export function About({ requestBack, requestClose }: Readonly) { fill="Soft" size="300" radii="300" - before={} + before={menuIcon(Heart, { weight: 'fill' })} > Support diff --git a/src/app/features/settings/account/BioEditor.tsx b/src/app/features/settings/account/BioEditor.tsx index 100d12a27..432cf5333 100644 --- a/src/app/features/settings/account/BioEditor.tsx +++ b/src/app/features/settings/account/BioEditor.tsx @@ -2,7 +2,8 @@ import type { KeyboardEventHandler } from 'react'; import { useCallback, useEffect, useState, useRef } from 'react'; import type { Room } from '$types/matrix-sdk'; import type { RectCords } from 'folds'; -import { Box, Chip, Icon, IconButton, Icons, PopOut, Spinner, Text, config } from 'folds'; +import { Box, Chip, IconButton, PopOut, Spinner, Text, config } from 'folds'; +import { composerIcon, Smiley } from '$components/icons/phosphor'; import { Editor, Transforms } from 'slate'; import { ReactEditor } from 'slate-react'; import { isKeyHotkey } from 'is-hotkey'; @@ -215,7 +216,9 @@ export function BioEditor({ value, isSaving, imagePackRooms, onSave }: BioEditor radii="300" onClick={(evt) => setAnchor(evt.currentTarget.getBoundingClientRect())} > - + {composerIcon(Smiley, { + weight: anchor !== undefined ? 'fill' : 'regular', + })} )} diff --git a/src/app/features/settings/account/IgnoredUserList.tsx b/src/app/features/settings/account/IgnoredUserList.tsx index 53d114650..78fa4e68e 100644 --- a/src/app/features/settings/account/IgnoredUserList.tsx +++ b/src/app/features/settings/account/IgnoredUserList.tsx @@ -1,6 +1,7 @@ import type { ChangeEventHandler, FormEventHandler } from 'react'; import { useCallback, useState } from 'react'; -import { Box, Button, Chip, Icon, IconButton, Icons, Input, Spinner, Text, config } from 'folds'; +import { Box, Button, Chip, IconButton, Input, Spinner, Text, config } from 'folds'; +import { menuIcon, X } from '$components/icons/phosphor'; import { SequenceCard } from '$components/sequence-card'; import { SettingTile } from '$components/setting-tile'; import { useMatrixClient } from '$hooks/useMatrixClient'; @@ -74,7 +75,7 @@ function IgnoreUserInput({ userList }: { userList: string[] }) { radii="300" variant="Secondary" > - + {menuIcon(X)} ) } @@ -112,13 +113,7 @@ function IgnoredUserChip({ userId, userList }: { userId: string; userList: strin - ) : ( - - ) - } + after={unIgnoring ? : menuIcon(X)} onClick={handleUnignore} disabled={unIgnoring} > diff --git a/src/app/features/settings/account/NameColorEditor.tsx b/src/app/features/settings/account/NameColorEditor.tsx index cfd13c3ab..71d524e42 100644 --- a/src/app/features/settings/account/NameColorEditor.tsx +++ b/src/app/features/settings/account/NameColorEditor.tsx @@ -1,5 +1,6 @@ import { useState, useEffect } from 'react'; -import { Box, Button, config, Text, Input, IconButton, Icon, Icons } from 'folds'; +import { Box, Button, config, Text, Input, IconButton } from 'folds'; +import { menuIcon, X } from '$components/icons/phosphor'; import { HexColorPicker } from 'react-colorful'; import { SettingTile } from '$components/setting-tile'; import { HexColorPickerPopOut } from '$components/HexColorPickerPopOut'; @@ -138,7 +139,7 @@ export function NameColorEditor({ onClick={handleReset} title="Reset to default" > - + {menuIcon(X)} )} diff --git a/src/app/features/settings/account/Profile.tsx b/src/app/features/settings/account/Profile.tsx index 19dc11609..ef7db0f9c 100644 --- a/src/app/features/settings/account/Profile.tsx +++ b/src/app/features/settings/account/Profile.tsx @@ -4,8 +4,6 @@ import { Box, Text, IconButton, - Icon, - Icons, Input, Avatar, Button, @@ -18,6 +16,7 @@ import { config, Spinner, } from 'folds'; +import { composerIcon, menuIcon, Star, Sun, X } from '$components/icons/phosphor'; import FocusTrap from 'focus-trap-react'; import { useSetAtom } from 'jotai'; import { SequenceCard } from '$components/sequence-card'; @@ -196,7 +195,7 @@ function ProfileAvatar({ profile, userId }: Readonly) { Remove Avatar setAlertRemove(false)} radii="300"> - + {composerIcon(X)} @@ -370,7 +369,7 @@ function ProfileBanner({ profile }: Readonly>) { Remove Banner setAlertRemove(false)} radii="300"> - + {composerIcon(X)} @@ -455,7 +454,7 @@ function ProfileDisplayName({ profile, userId }: Readonly) { radii="300" variant="Secondary" > - + {menuIcon(X)} ) } @@ -685,10 +684,9 @@ function ProfileExtended({ profile, userId }: Readonly) { {profile?.heroColorScheme?.brightness === 'dark' ? 'Dark Mode' : 'Light Mode'} - + {profile?.heroColorScheme?.brightness === 'dark' + ? menuIcon(Star, { weight: 'fill' }) + : menuIcon(Sun)} diff --git a/src/app/features/settings/account/StatusEditor.tsx b/src/app/features/settings/account/StatusEditor.tsx index 60eadf3f1..813be142f 100644 --- a/src/app/features/settings/account/StatusEditor.tsx +++ b/src/app/features/settings/account/StatusEditor.tsx @@ -1,6 +1,7 @@ import type { ChangeEventHandler, FormEventHandler } from 'react'; import { useEffect, useState } from 'react'; -import { Box, Text, Button, Input, IconButton, Icon, Icons, Spinner, config } from 'folds'; +import { Box, Text, Button, Input, IconButton, Spinner, config } from 'folds'; +import { menuIcon, X } from '$components/icons/phosphor'; import { SettingTile } from '$components/setting-tile'; type StatusEditorProps = { @@ -63,7 +64,7 @@ export function StatusEditor({ current = '', onSave }: StatusEditorProps) { radii="300" variant="Secondary" > - + {menuIcon(X)} ) } diff --git a/src/app/features/settings/account/TimezoneEditor.tsx b/src/app/features/settings/account/TimezoneEditor.tsx index 800dc72a2..dbae954da 100644 --- a/src/app/features/settings/account/TimezoneEditor.tsx +++ b/src/app/features/settings/account/TimezoneEditor.tsx @@ -1,6 +1,7 @@ import type { ChangeEvent } from 'react'; import { useMemo, useState, useEffect } from 'react'; -import { Box, IconButton, Button, Icon, Icons, Input, Text } from 'folds'; +import { Box, IconButton, Button, Input, Text } from 'folds'; +import { menuIcon, X } from '$components/icons/phosphor'; import { SettingTile } from '$components/setting-tile'; interface IntlWithSupportedValues { @@ -89,7 +90,7 @@ export function TimezoneEditor({ current, onSave }: TimezoneEditorProps) { radii="300" title="Reset" > - + {menuIcon(X)} } diff --git a/src/app/features/settings/cosmetics/Cosmetics.tsx b/src/app/features/settings/cosmetics/Cosmetics.tsx index bb938a855..f7f20f4a8 100644 --- a/src/app/features/settings/cosmetics/Cosmetics.tsx +++ b/src/app/features/settings/cosmetics/Cosmetics.tsx @@ -5,8 +5,6 @@ import { Box, Button, config, - Icon, - Icons, Input, Menu, MenuItem, @@ -16,6 +14,7 @@ import { Text, toRem, } from 'folds'; +import { CaretDown, composerIcon } from '$components/icons/phosphor'; import { isKeyHotkey } from 'is-hotkey'; import FocusTrap from 'focus-trap-react'; import { PageContent } from '$components/page'; @@ -150,7 +149,7 @@ function SelectJumboEmojiSize() { outlined fill="Soft" radii="300" - after={} + after={composerIcon(CaretDown)} onClick={handleMenu} > {currentSizeName} @@ -226,7 +225,7 @@ function SelectRenderCustomProfileCards() { outlined fill="Soft" radii="300" - after={} + after={composerIcon(CaretDown)} onClick={handleMenu} > {currentLabel} diff --git a/src/app/features/settings/cosmetics/ThemeCatalogOnboarding.tsx b/src/app/features/settings/cosmetics/ThemeCatalogOnboarding.tsx index e5fccee75..133a9c64f 100644 --- a/src/app/features/settings/cosmetics/ThemeCatalogOnboarding.tsx +++ b/src/app/features/settings/cosmetics/ThemeCatalogOnboarding.tsx @@ -6,14 +6,13 @@ import { config, Dialog, Header, - Icon, IconButton, - Icons, Overlay, OverlayBackdrop, OverlayCenter, Text, } from 'folds'; +import { menuIcon, X } from '$components/icons/phosphor'; import { stopPropagation } from '$utils/keyboard'; @@ -76,7 +75,7 @@ export function ThemeCatalogOnboarding({ open, onEnable, onDecline }: ThemeCatal onClick={handleDeclineClick} aria-label="Close" > - + {menuIcon(X)} diff --git a/src/app/features/settings/cosmetics/ThemeCatalogSettings.tsx b/src/app/features/settings/cosmetics/ThemeCatalogSettings.tsx index e602c7dfc..5694129f4 100644 --- a/src/app/features/settings/cosmetics/ThemeCatalogSettings.tsx +++ b/src/app/features/settings/cosmetics/ThemeCatalogSettings.tsx @@ -6,9 +6,7 @@ import { Box, Button, Chip, - Icon, IconButton, - Icons, Input, Scroll, Spinner, @@ -17,6 +15,7 @@ import { config, toRem, } from 'folds'; +import { Check, Download, Link, menuIcon, Star } from '$components/icons/phosphor'; import { useClientConfig } from '$hooks/useClientConfig'; import { ThemeKind } from '$hooks/useTheme'; import { useSetting } from '$state/hooks/settings'; @@ -160,7 +159,7 @@ function CatalogTweakCard({ handleCopy().catch(() => undefined); }} > - + {menuIcon(copied ? Check : Link)} )} {onExport && ( @@ -175,7 +174,7 @@ function CatalogTweakCard({ onExport(); }} > - + {menuIcon(Download)} )} undefined); }} > - + {menuIcon(Star, { weight: isFavorited ? 'fill' : 'regular' })} diff --git a/src/app/features/settings/cosmetics/ThemeImportModal.tsx b/src/app/features/settings/cosmetics/ThemeImportModal.tsx index 10c50e951..39f45ba0b 100644 --- a/src/app/features/settings/cosmetics/ThemeImportModal.tsx +++ b/src/app/features/settings/cosmetics/ThemeImportModal.tsx @@ -6,9 +6,7 @@ import { config, Dialog, Header, - Icon, IconButton, - Icons, Input, Overlay, OverlayBackdrop, @@ -16,6 +14,7 @@ import { Text, toRem, } from 'folds'; +import { menuIcon, X } from '$components/icons/phosphor'; import { useSetting } from '$state/hooks/settings'; import { @@ -250,7 +249,7 @@ export function ThemeImportModal({ open, onClose }: ThemeImportModalProps) { disabled={importBusy} aria-label="Close" > - + {menuIcon(X)} diff --git a/src/app/features/settings/cosmetics/Themes.tsx b/src/app/features/settings/cosmetics/Themes.tsx index dbcc9dcc1..8b5f94439 100644 --- a/src/app/features/settings/cosmetics/Themes.tsx +++ b/src/app/features/settings/cosmetics/Themes.tsx @@ -5,8 +5,6 @@ import { Button, Chip, config, - Icon, - Icons, Input, Menu, MenuItem, @@ -16,6 +14,7 @@ import { toRem, type RectCords, } from 'folds'; +import { CaretDown, composerIcon, menuIcon } from '$components/icons/phosphor'; import { isKeyHotkey } from 'is-hotkey'; import { SettingMenuSelector, type SettingMenuOption } from '$components/setting-menu-selector'; @@ -70,7 +69,7 @@ function ThemeTrigger({ variant={active ? 'Primary' : 'Secondary'} outlined={active} radii="Pill" - after={} + after={menuIcon(CaretDown)} onClick={onClick} disabled={disabled} > @@ -589,7 +588,7 @@ function PanelSelector({ outlined fill="Soft" radii="300" - after={} + after={composerIcon(CaretDown)} onClick={handleMenu} > @@ -755,7 +754,7 @@ function SelectShowRoomIcon() { outlined fill="Soft" radii="300" - after={} + after={composerIcon(CaretDown)} onClick={handleMenu} > @@ -815,6 +814,7 @@ export function Appearance({ settingsAtom, 'closeFoldersByDefault' ); + const [roomIconOverlay, setRoomIconOverlay] = useSetting(settingsAtom, 'roomIconOverlay'); return ( @@ -899,6 +899,16 @@ export function Appearance({ after={} /> + + + } + /> + {/*THIS SHOULD BE MOVED TO A NEW SETTINGS MENU INSIDE OF THE HOME SETTINGS AS SOON AS THERE IS A REASON TO CREATE A HOME MENU SETTINGS PANEL it is currently here because it would be eerie to have an entire home settings menu for just one single setting*/} diff --git a/src/app/features/settings/developer-tools/AccountData.tsx b/src/app/features/settings/developer-tools/AccountData.tsx index da2169189..f93b0f054 100644 --- a/src/app/features/settings/developer-tools/AccountData.tsx +++ b/src/app/features/settings/developer-tools/AccountData.tsx @@ -1,5 +1,13 @@ import { useCallback, useState } from 'react'; -import { Box, Text, Icon, Icons, Button, MenuItem } from 'folds'; +import { Box, Text, Button, MenuItem } from 'folds'; +import { + CaretDown, + CaretRight, + CaretUp, + chipIcon, + menuIcon, + Plus, +} from '$components/icons/phosphor'; import { SequenceCard } from '$components/sequence-card'; import { SettingTile } from '$components/setting-tile'; import { useMatrixClient } from '$hooks/useMatrixClient'; @@ -48,9 +56,7 @@ export function AccountData({ expand, onExpandToggle, onSelect }: AccountDataPro size="300" radii="300" outlined - before={ - - } + before={menuIcon(expand ? CaretUp : CaretDown, { weight: 'fill' })} > {expand ? 'Collapse' : 'Expand'} @@ -68,7 +74,7 @@ export function AccountData({ expand, onExpandToggle, onSelect }: AccountDataPro fill="None" size="300" radii="0" - before={} + before={chipIcon(Plus)} onClick={() => onSelect(null)} > @@ -84,7 +90,7 @@ export function AccountData({ expand, onExpandToggle, onSelect }: AccountDataPro fill="None" size="300" radii="0" - after={} + after={chipIcon(CaretRight)} onClick={() => onSelect(type)} > diff --git a/src/app/features/settings/developer-tools/SyncDiagnostics.tsx b/src/app/features/settings/developer-tools/SyncDiagnostics.tsx index 7feff143c..9c9a612e2 100644 --- a/src/app/features/settings/developer-tools/SyncDiagnostics.tsx +++ b/src/app/features/settings/developer-tools/SyncDiagnostics.tsx @@ -1,5 +1,6 @@ import { useEffect, useState } from 'react'; -import { Box, Button, Icon, Icons, Text } from 'folds'; +import { Box, Button, Text } from 'folds'; +import { CaretDown, CaretUp, menuIcon } from '$components/icons/phosphor'; import { SequenceCard } from '$components/sequence-card'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { getClientSyncDiagnostics } from '$client/initMatrix'; @@ -192,7 +193,7 @@ export function SyncDiagnostics() { fill="Soft" outlined radii="300" - before={} + before={menuIcon(expandSliding ? CaretUp : CaretDown)} onClick={() => setExpandSliding((v) => !v)} > {expandSliding ? 'Collapse' : 'Expand'} diff --git a/src/app/features/settings/devices/DeviceTile.tsx b/src/app/features/settings/devices/DeviceTile.tsx index 1ae4e5afa..90473005f 100644 --- a/src/app/features/settings/devices/DeviceTile.tsx +++ b/src/app/features/settings/devices/DeviceTile.tsx @@ -4,8 +4,6 @@ import { Box, Text, IconButton, - Icon, - Icons, Chip, Input, Button, @@ -16,6 +14,7 @@ import { OverlayBackdrop, OverlayCenter, } from 'folds'; +import { CaretDown, CaretRight, chipIcon, Trash } from '$components/icons/phosphor'; import type { CryptoApi, IMyDevice, MatrixError } from '$types/matrix-sdk'; import FocusTrap from 'focus-trap-react'; import { SettingTile } from '$components/setting-tile'; @@ -255,7 +254,7 @@ export function DeviceDeleteBtn({ onClick={() => onDeleteToggle(deviceId)} disabled={disabled} > - + {chipIcon(Trash)} ); } @@ -296,7 +295,7 @@ export function DeviceTile({ radii="300" onClick={() => setDetails(!details)} > - + {chipIcon(details ? CaretDown : CaretRight)} } after={ diff --git a/src/app/features/settings/devices/LocalBackup.tsx b/src/app/features/settings/devices/LocalBackup.tsx index eea175899..104cfb25c 100644 --- a/src/app/features/settings/devices/LocalBackup.tsx +++ b/src/app/features/settings/devices/LocalBackup.tsx @@ -1,6 +1,7 @@ import type { FormEventHandler } from 'react'; import { useCallback, useEffect, useState } from 'react'; -import { Box, Button, color, Icon, Icons, Spinner, Text, toRem } from 'folds'; +import { Box, Button, color, Spinner, Text, toRem } from 'folds'; +import { ArrowRight, CaretDown, CaretUp, File, menuIcon, X } from '$components/icons/phosphor'; import FileSaver from 'file-saver'; import { SequenceCard } from '$components/sequence-card'; import { SettingTile } from '$components/setting-tile'; @@ -155,9 +156,7 @@ function ExportKeysTile() { fill="Soft" outlined radii="300" - before={ - - } + before={menuIcon(expand ? CaretUp : CaretDown, { weight: 'fill' })} > {expand ? 'Collapse' : 'Expand'} @@ -286,8 +285,8 @@ function ImportKeysTile() { variant="Warning" fill="Solid" radii="300" - before={} - after={} + before={menuIcon(File, { weight: 'fill' })} + after={menuIcon(X)} > {file.name} @@ -302,7 +301,7 @@ function ImportKeysTile() { fill="Soft" outlined radii="300" - before={} + before={menuIcon(ArrowRight)} > Import diff --git a/src/app/features/settings/devices/Verification.tsx b/src/app/features/settings/devices/Verification.tsx index ab5c1914f..f9d410451 100644 --- a/src/app/features/settings/devices/Verification.tsx +++ b/src/app/features/settings/devices/Verification.tsx @@ -7,8 +7,6 @@ import { Button, Chip, config, - Icon, - Icons, Spinner, Text, Overlay, @@ -19,6 +17,7 @@ import { Menu, MenuItem, } from 'folds'; +import { DotsThreeOutlineVerticalIcon, menuIcon, X } from '$components/icons/phosphor'; import FocusTrap from 'focus-trap-react'; import type { CryptoApi, VerificationRequest } from '$types/matrix-sdk'; import { VerificationStatus } from '$hooks/useDeviceVerificationStatus'; @@ -155,7 +154,7 @@ export function VerifyCurrentDeviceTile({ radii="Pill" onClick={handleCancelVerification} > - + {menuIcon(X)} } /> @@ -296,7 +295,7 @@ export function DeviceVerificationOptions() { radii="300" onClick={handleMenu} > - + {menuIcon(DotsThreeOutlineVerticalIcon, { weight: menuCords ? 'fill' : 'regular' })} ) : ( - + {composerIcon(Sticker, { weight: 'fill' })} )} @@ -383,7 +382,7 @@ export function GlobalPacks({ onViewPack }: GlobalPacksProps) { onClick={() => handleUndoRemove(address)} disabled={applyingChanges} > - + {menuIcon(Plus)} ) : ( handleRemove(address)} disabled={applyingChanges} > - + {menuIcon(X)} )} {avatarUrl ? ( ) : ( - - - + {composerIcon(Sticker, { weight: 'fill' })} )} diff --git a/src/app/features/settings/emojis-stickers/UserPack.tsx b/src/app/features/settings/emojis-stickers/UserPack.tsx index 5d0c0c779..a98d7dac7 100644 --- a/src/app/features/settings/emojis-stickers/UserPack.tsx +++ b/src/app/features/settings/emojis-stickers/UserPack.tsx @@ -1,4 +1,5 @@ -import { Avatar, AvatarFallback, AvatarImage, Box, Button, Icon, Icons, Text } from 'folds'; +import { Avatar, AvatarFallback, AvatarImage, Box, Button, Text } from 'folds'; +import { composerIcon, Sticker } from '$components/icons/phosphor'; import { useUserImagePack } from '$hooks/useImagePacks'; import { SequenceCard } from '$components/sequence-card'; import { SettingTile } from '$components/setting-tile'; @@ -46,9 +47,7 @@ export function UserPack({ onViewPack }: UserPackProps) { {avatarUrl ? ( ) : ( - - - + {composerIcon(Sticker, { weight: 'fill' })} )} } diff --git a/src/app/features/settings/experimental/Experimental.tsx b/src/app/features/settings/experimental/Experimental.tsx index 330412185..fe4b039c7 100644 --- a/src/app/features/settings/experimental/Experimental.tsx +++ b/src/app/features/settings/experimental/Experimental.tsx @@ -1,4 +1,5 @@ -import { Box, Text, Icon, Icons, Scroll, Switch } from 'folds'; +import { Box, Text, Scroll, Switch } from 'folds'; +import { menuIcon, Warning } from '$components/icons/phosphor'; import { PageContent } from '$components/page'; import { InfoCard } from '$components/info-card'; import { settingsAtom } from '$state/settings'; @@ -45,7 +46,7 @@ export function Experimental({ requestBack, requestClose }: Readonly + before={menuIcon(Warning, { weight: 'fill' })} variant="Warning" description={ <> diff --git a/src/app/features/settings/general/General.tsx b/src/app/features/settings/general/General.tsx index 836cf3384..4ff9596f5 100644 --- a/src/app/features/settings/general/General.tsx +++ b/src/app/features/settings/general/General.tsx @@ -13,9 +13,7 @@ import { Button, config, Header, - Icon, IconButton, - Icons, Input, Menu, MenuItem, @@ -25,6 +23,16 @@ import { Text, toRem, } from 'folds'; +import { + ArrowUp, + CaretDown, + composerIcon, + Download, + Info, + menuIcon, + Shield, + X, +} from '$components/icons/phosphor'; import FocusTrap from 'focus-trap-react'; import { PageContent } from '$components/page'; import { SequenceCard } from '$components/sequence-card'; @@ -196,7 +204,7 @@ function DateHint({ hasChanges, handleReset }: Readonly) { size="300" radii="300" > - + {menuIcon(X)} ) : ( ) { radii="300" aria-pressed={!!anchor} > - + {menuIcon(Info, { style: { opacity: config.opacity.P300 } })} )} @@ -308,7 +316,7 @@ function PresetDateFormat({ value, onChange }: Readonly) outlined fill="Soft" radii="300" - after={} + after={composerIcon(CaretDown)} onClick={handleMenu} > @@ -382,10 +390,7 @@ function SelectDateFormat() { ); } -function getTombstoneSettingToggleTitle(showHidden: boolean, showTombstone: boolean): string { - if (showHidden) { - return 'Tombstone events are always shown when "Show Hidden Events" is enabled.'; - } +function getTombstoneSettingToggleTitle(showTombstone: boolean): string { if (showTombstone) { return 'Disable to hide redacted messages entirely instead of showing a tombstone.'; } @@ -523,7 +528,7 @@ function SelectMessageLayout() { outlined fill="Soft" radii="300" - after={} + after={composerIcon(CaretDown)} onClick={handleMenu} > @@ -591,7 +596,7 @@ function SelectCaptionPosition() { outlined fill="Soft" radii="300" - after={} + after={composerIcon(CaretDown)} onClick={handleMenu} > @@ -660,7 +665,7 @@ function SelectMessageSpacing() { outlined fill="Soft" radii="300" - after={} + after={composerIcon(CaretDown)} onClick={handleMenu} > @@ -734,7 +739,7 @@ function SelectRightSwipeAction({ disabled }: Readonly<{ disabled?: boolean }>) fill="Soft" radii="300" disabled={disabled} - after={} + after={composerIcon(CaretDown)} onClick={handleMenu} > {options.find((o) => o.id === action)?.name ?? action} @@ -909,6 +914,22 @@ function Messages() { settingsAtom, 'showTombstoneEvents' ); + const [hiddenEventEdits, setHiddenEventEdits] = useSetting(settingsAtom, 'hiddenEventEdits'); + const [hiddenEventRedactionTimeline, setHiddenEventRedactionTimeline] = useSetting( + settingsAtom, + 'hiddenEventRedactionTimeline' + ); + const [hiddenEventReactions, setHiddenEventReactions] = useSetting( + settingsAtom, + 'hiddenEventReactions' + ); + const [hiddenEventReactionTombstone, setHiddenEventReactionTombstone] = useSetting( + settingsAtom, + 'hiddenEventReactionTombstone' + ); + const [hiddenEventReactionRedactionTimeline, setHiddenEventReactionRedactionTimeline] = + useSetting(settingsAtom, 'hiddenEventReactionRedactionTimeline'); + const [hiddenEventOther, setHiddenEventOther] = useSetting(settingsAtom, 'hiddenEventOther'); const [hideMembershipInReadOnly, setHideMembershipInReadOnly] = useSetting( settingsAtom, 'hideMembershipInReadOnly' @@ -1013,6 +1034,7 @@ function Messages() { - + + } + /> + + + + } + /> + + + + } + /> + + + + } + /> + + + + } + /> + + + + } + /> + + + } /> @@ -1341,7 +1489,7 @@ function SettingsSyncSection() { fill="Soft" size="300" radii="300" - before={} + before={menuIcon(Download)} onClick={() => exportSettingsAsJson(fullSettings)} > Export Settings @@ -1351,7 +1499,7 @@ function SettingsSyncSection() { fill="Soft" size="300" radii="300" - before={} + before={menuIcon(ArrowUp)} onClick={handleImport} > Import Settings @@ -1461,7 +1609,7 @@ function DiagnosticsAndPrivacy() { fill="Soft" size="300" radii="300" - before={} + before={menuIcon(Shield, { weight: 'fill' })} > Privacy Policy diff --git a/src/app/features/settings/notifications/DeregisterPushNotifications.tsx b/src/app/features/settings/notifications/DeregisterPushNotifications.tsx index 7655d2bae..bc90d746a 100644 --- a/src/app/features/settings/notifications/DeregisterPushNotifications.tsx +++ b/src/app/features/settings/notifications/DeregisterPushNotifications.tsx @@ -7,15 +7,14 @@ import { config, Dialog, Header, - Icon, IconButton, - Icons, Overlay, OverlayBackdrop, OverlayCenter, Spinner, Text, } from 'folds'; +import { menuIcon, X } from '$components/icons/phosphor'; import { useAtom } from 'jotai'; import { useMatrixClient } from '../../../hooks/useMatrixClient'; import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback'; @@ -47,7 +46,7 @@ function ConfirmDeregisterDialog({ onClose, onConfirm, isLoading }: ConfirmDereg Reset All Push Notifications - + {menuIcon(X)} diff --git a/src/app/features/settings/notifications/KeywordMessages.tsx b/src/app/features/settings/notifications/KeywordMessages.tsx index 80128d94e..b5a348d4f 100644 --- a/src/app/features/settings/notifications/KeywordMessages.tsx +++ b/src/app/features/settings/notifications/KeywordMessages.tsx @@ -2,7 +2,8 @@ import type { ChangeEventHandler, FormEventHandler } from 'react'; import { useCallback, useMemo, useState } from 'react'; import type { IPushRule, IPushRules } from '$types/matrix-sdk'; import { PushRuleKind, EventType } from '$types/matrix-sdk'; -import { Box, Text, Badge, Button, Input, config, IconButton, Icons, Icon, Spinner } from 'folds'; +import { Box, Text, Badge, Button, Input, config, IconButton, Spinner } from 'folds'; +import { menuIcon, X } from '$components/icons/phosphor'; import { useAccountData } from '$hooks/useAccountData'; import { SequenceCard } from '$components/sequence-card'; @@ -87,7 +88,7 @@ function KeywordInput() { radii="300" variant="Secondary" > - + {menuIcon(X)} ) } @@ -125,7 +126,7 @@ function KeywordCross({ pushRule }: PushRulesProps) { const removing = removeState.status === AsyncStatus.Loading; return ( - {removing ? : } + {removing ? : menuIcon(X)} ); } diff --git a/src/app/features/settings/notifications/NotificationLevelsHint.tsx b/src/app/features/settings/notifications/NotificationLevelsHint.tsx index 6c00f6b6e..c874d8cc7 100644 --- a/src/app/features/settings/notifications/NotificationLevelsHint.tsx +++ b/src/app/features/settings/notifications/NotificationLevelsHint.tsx @@ -1,7 +1,8 @@ import type { MouseEventHandler } from 'react'; import { useState } from 'react'; import type { RectCords } from 'folds'; -import { Box, config, Header, Icon, IconButton, Icons, Menu, PopOut, Text } from 'folds'; +import { Box, config, Header, IconButton, Menu, PopOut, Text } from 'folds'; +import { Info, menuIcon } from '$components/icons/phosphor'; import FocusTrap from 'focus-trap-react'; import { stopPropagation } from '$utils/keyboard'; @@ -65,7 +66,7 @@ export function NotificationLevelsHint() { radii="300" aria-pressed={!!anchor} > - + {menuIcon(Info, { style: { opacity: config.opacity.P300 } })} ); diff --git a/src/app/features/settings/settingsLink.ts b/src/app/features/settings/settingsLink.ts index 787b6310b..2dca07d86 100644 --- a/src/app/features/settings/settingsLink.ts +++ b/src/app/features/settings/settingsLink.ts @@ -50,7 +50,13 @@ const settingsLinkFocusIdsBySection: Record - + {menuIcon(SquaresFour, { + style: { opacity: config.opacity.P300 }, + weight: selected ? 'fill' : 'regular', + })} {!hideText && ( diff --git a/src/app/features/space-settings/SpaceSettings.tsx b/src/app/features/space-settings/SpaceSettings.tsx index 6479d6de6..c9a4cb5cd 100644 --- a/src/app/features/space-settings/SpaceSettings.tsx +++ b/src/app/features/space-settings/SpaceSettings.tsx @@ -1,7 +1,8 @@ import { useMemo, useState } from 'react'; +import type { ComponentType } from 'react'; +import type { IconProps } from '@phosphor-icons/react'; import { useAtomValue } from 'jotai'; -import type { IconSrc } from 'folds'; -import { Avatar, Box, config, Icon, IconButton, Icons, MenuItem, Text } from 'folds'; +import { Avatar, Box, config, IconButton, MenuItem, Text } from 'folds'; import { JoinRule } from '$types/matrix-sdk'; import { PageNav, PageNavContent, PageNavHeader, PageRoot } from '$components/page'; import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize'; @@ -19,14 +20,29 @@ 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 { + composerIcon, + GearSix, + Info, + Lock, + PaintBrush, + Palette, + settingsNavIcon, + Smiley, + Terminal, + User, + X, +} from '$components/icons/phosphor'; import { General } from './general'; import { Permissions } from './permissions'; +type PhosphorIcon = ComponentType; + type SpaceSettingsMenuItem = { page: SpaceSettingsPage; name: string; - icon: IconSrc; - activeIcon?: IconSrc; + icon: PhosphorIcon; + activeIcon?: PhosphorIcon; }; const useSpaceSettingsMenuItems = (): SpaceSettingsMenuItem[] => @@ -35,44 +51,42 @@ const useSpaceSettingsMenuItems = (): SpaceSettingsMenuItem[] => { page: SpaceSettingsPage.GeneralPage, name: 'General', - icon: Icons.Setting, + icon: GearSix, }, { page: SpaceSettingsPage.MembersPage, name: 'Members', - icon: Icons.User, + icon: User, }, { page: SpaceSettingsPage.PermissionsPage, name: 'Permissions', - icon: Icons.Lock, + icon: Lock, }, { page: SpaceSettingsPage.CosmeticsPage, name: 'Cosmetics', - icon: Icons.Alphabet, - activeIcon: Icons.AlphabetUnderline, + icon: PaintBrush, }, { page: SpaceSettingsPage.AbbreviationsPage, name: 'Abbreviations', - icon: Icons.Info, + icon: Info, }, { page: SpaceSettingsPage.EmojisStickersPage, name: 'Emojis & Stickers', - icon: Icons.Smile, + icon: Smiley, }, { page: SpaceSettingsPage.DeveloperToolsPage, name: 'Developer Tools', - icon: Icons.Terminal, + icon: Terminal, }, { page: SpaceSettingsPage.AppearancePage, name: 'Appearance', - icon: Icons.Alphabet, - activeIcon: Icons.AlphabetUnderline, + icon: Palette, }, ], [] @@ -140,7 +154,7 @@ export function SpaceSettings({ initialPage, requestClose }: SpaceSettingsProps) {screenSize === ScreenSize.Mobile && ( - + {composerIcon(X)} )} @@ -149,24 +163,21 @@ export function SpaceSettings({ initialPage, requestClose }: SpaceSettingsProps)
{menuItems.map((item) => { - const currentIcon = - activePage === item.page && item.activeIcon ? item.activeIcon : item.icon; + const active = activePage === item.page; + const IconComponent = active && item.activeIcon ? item.activeIcon : item.icon; return ( - } + aria-pressed={active} + before={settingsNavIcon(IconComponent, active)} onClick={() => setActivePage(item.page)} > - + {composerIcon(X)} diff --git a/src/app/features/space-settings/permissions/Permissions.tsx b/src/app/features/space-settings/permissions/Permissions.tsx index 46bf0a9d0..68925c71d 100644 --- a/src/app/features/space-settings/permissions/Permissions.tsx +++ b/src/app/features/space-settings/permissions/Permissions.tsx @@ -1,9 +1,10 @@ import { useState } from 'react'; -import { Box, Icon, IconButton, Icons, Scroll, Text } from 'folds'; +import { Box, IconButton, Scroll, Text } from 'folds'; import { Page, PageContent, PageHeader } from '$components/page'; import { useRoom } from '$hooks/useRoom'; import { usePowerLevels } from '$hooks/usePowerLevels'; import { useMatrixClient } from '$hooks/useMatrixClient'; +import { composerIcon, X } from '$components/icons/phosphor'; import { PermissionGroups, Powers, PowersEditor } from '$features/common-settings/permissions'; import { useRoomCreators } from '$hooks/useRoomCreators'; @@ -48,7 +49,7 @@ export function Permissions({ requestClose }: PermissionsProps) { - + {composerIcon(X)} diff --git a/src/app/features/widgets/IntegrationManager.tsx b/src/app/features/widgets/IntegrationManager.tsx index cd90c0463..a098ba516 100644 --- a/src/app/features/widgets/IntegrationManager.tsx +++ b/src/app/features/widgets/IntegrationManager.tsx @@ -2,15 +2,14 @@ import { useEffect, useRef, useState } from 'react'; import { Box, Header, - Icon, IconButton, - Icons, Overlay, OverlayBackdrop, OverlayCenter, Spinner, Text, } from 'folds'; +import { composerIcon, X } from '$components/icons/phosphor'; import FocusTrap from 'focus-trap-react'; import type { Room } from '$types/matrix-sdk'; @@ -80,7 +79,7 @@ export function IntegrationManager({ room, open, onClose }: IntegrationManagerPr - + {composerIcon(X)} diff --git a/src/app/features/widgets/WidgetsDrawer.tsx b/src/app/features/widgets/WidgetsDrawer.tsx index d28ea7d51..321db4052 100644 --- a/src/app/features/widgets/WidgetsDrawer.tsx +++ b/src/app/features/widgets/WidgetsDrawer.tsx @@ -3,9 +3,7 @@ import { useEffect, useState } from 'react'; import { Box, Header, - Icon, IconButton, - Icons, Input, MenuItem, Scroll, @@ -17,6 +15,15 @@ import { Line, toRem, } from 'folds'; +import { + ArrowLeft, + composerIcon, + GridFour, + sizedIcon, + Plus, + Trash, + X, +} from '$components/icons/phosphor'; import type { Room } from '$types/matrix-sdk'; import { useMatrixClient } from '$hooks/useMatrixClient'; @@ -52,7 +59,7 @@ function WidgetDrawerHeader({ activeWidget, onBack }: WidgetsDrawerHeaderProps) {activeWidget && ( - + {composerIcon(ArrowLeft)} )} @@ -78,7 +85,7 @@ function WidgetDrawerHeader({ activeWidget, onBack }: WidgetsDrawerHeaderProps) variant="Background" onClick={() => setWidgetDrawer(false)} > - + {composerIcon(X)} )} @@ -197,7 +204,7 @@ function WidgetListItemView({ widget, onSelect, onRemove, canRemove }: WidgetLis fill="None" onClick={handleRemove} > - + {sizedIcon(Trash, '100')} )} @@ -316,7 +323,7 @@ export function WidgetsDrawer({ room }: WidgetsDrawerProps) { variant="Primary" fill="Soft" onClick={() => setShowIntegrationManager(true)} - before={} + before={sizedIcon(GridFour, '100')} > Integration Manager @@ -325,7 +332,7 @@ export function WidgetsDrawer({ room }: WidgetsDrawerProps) { variant="Secondary" fill="Soft" onClick={() => setShowAddForm(true)} - before={} + before={sizedIcon(Plus, '100')} > Add Custom Widget diff --git a/src/app/hooks/timeline/useProcessedTimeline.ts b/src/app/hooks/timeline/useProcessedTimeline.ts index 9609dafc0..0a803591a 100644 --- a/src/app/hooks/timeline/useProcessedTimeline.ts +++ b/src/app/hooks/timeline/useProcessedTimeline.ts @@ -5,15 +5,24 @@ import { getTimelineRelativeIndex, getTimelineEvent, } from '$utils/timeline'; -import { isMembershipChanged, isThreadRelationEvent, reactionOrEditEvent } from '$utils/room'; +import { + isMembershipChanged, + isThreadRelationEvent, + isEditEvent, + isReactionEvent, + isRedactableMessageType, + shouldShowRedactionTimelineEvent, + collectRelationReactionEvents, + collectRelationEditEvents, +} from '$utils/room'; import { inSameDay, minuteDifference } from '$utils/time'; +import type { ResolvedHiddenEventSettings } from '$state/hooks/settings'; export interface UseProcessedTimelineOptions { items: number[]; linkedTimelines: EventTimeline[]; ignoredUsersSet: Set; - showHiddenEvents: boolean; - showTombstoneEvents: boolean; + hiddenEvents: ResolvedHiddenEventSettings; mxUserId: string | null; readUptoEventId: string | undefined; hideMembershipEvents: boolean; @@ -65,12 +74,154 @@ const normalizeMessageType = (t: string): string => const getPmpId = (ev: MatrixEvent): string | null => ev.getContent()?.['com.beeper.per_message_profile']?.id ?? null; +type ProcessedEventDraft = Omit< + ProcessedEvent, + 'collapsed' | 'willRenderNewDivider' | 'willRenderDayDivider' +>; + +const computeCollapseAndDividers = ( + drafts: ProcessedEventDraft[], + mxUserId: string | null, + readUptoEventId: string | undefined +): ProcessedEvent[] => { + let prevEvent: MatrixEvent | undefined; + let isPrevRendered = false; + let newDivider = false; + let dayDivider = false; + + return drafts.map((draft) => { + const { mEvent, eventSender } = draft; + const type = mEvent.getType(); + + if (!newDivider && readUptoEventId) { + const prevId = prevEvent ? prevEvent.getId() : undefined; + newDivider = prevId === readUptoEventId; + } + + if (!dayDivider) { + dayDivider = prevEvent ? !inSameDay(prevEvent.getTs(), mEvent.getTs()) : false; + } + + const isMessageEvent = MESSAGE_EVENT_TYPES.has(type); + + let collapsed = false; + if (isPrevRendered && !dayDivider && prevEvent !== undefined) { + if (isMessageEvent) { + const withinTimeThreshold = minuteDifference(prevEvent.getTs(), mEvent.getTs()) < 2; + const senderMatch = prevEvent.getSender() === eventSender; + const typeMatch = normalizeMessageType(prevEvent.getType()) === normalizeMessageType(type); + const dividerOk = !newDivider || eventSender === mxUserId; + + collapsed = + dividerOk && + senderMatch && + typeMatch && + withinTimeThreshold && + getPmpId(prevEvent) === getPmpId(mEvent); + } else { + const prevIsMessageEvent = MESSAGE_EVENT_TYPES.has(prevEvent.getType()); + collapsed = !prevIsMessageEvent; + } + } + + const willRenderNewDivider = newDivider && eventSender !== mxUserId; + const willRenderDayDivider = dayDivider; + + prevEvent = mEvent; + isPrevRendered = true; + if (willRenderNewDivider) newDivider = false; + if (willRenderDayDivider) dayDivider = false; + + return { + ...draft, + collapsed, + willRenderNewDivider, + willRenderDayDivider, + }; + }); +}; + +const mergeRelationReactions = ( + result: ProcessedEvent[], + linkedTimelines: EventTimeline[], + ignoredUsersSet: Set, + hiddenEventReactions: boolean, + hiddenEventReactionTombstone: boolean, + mxUserId: string | null, + readUptoEventId: string | undefined +): ProcessedEvent[] => { + const existingIds = new Set(result.map((event) => event.id)); + const extras = collectRelationReactionEvents( + linkedTimelines, + existingIds, + ignoredUsersSet, + hiddenEventReactions, + hiddenEventReactionTombstone + ); + + if (extras.length === 0) return result; + + const mergedDrafts: ProcessedEventDraft[] = [ + ...result.map( + ({ collapsed: _c, willRenderNewDivider: _n, willRenderDayDivider: _d, ...draft }) => draft + ), + ...extras.map(({ mEvent, timelineSet }) => { + const mEventId = mEvent.getId()!; + return { + id: mEventId, + itemIndex: -1, + mEvent, + timelineSet, + eventSender: mEvent.getSender() ?? null, + }; + }), + ].toSorted((a, b) => a.mEvent.getTs() - b.mEvent.getTs()); + + return computeCollapseAndDividers(mergedDrafts, mxUserId, readUptoEventId); +}; + +const mergeRelationEdits = ( + result: ProcessedEvent[], + linkedTimelines: EventTimeline[], + ignoredUsersSet: Set, + hiddenEventEdits: boolean, + mxUserId: string | null, + readUptoEventId: string | undefined +): ProcessedEvent[] => { + const existingIds = new Set(result.map((event) => event.id)); + const extras = collectRelationEditEvents( + linkedTimelines, + existingIds, + ignoredUsersSet, + hiddenEventEdits + ); + + if (extras.length === 0) return result; + + const mergedDrafts: ProcessedEventDraft[] = [ + ...result.map( + ({ collapsed: _c, willRenderNewDivider: _n, willRenderDayDivider: _d, ...draft }) => draft + ), + ...extras.map(({ mEvent, timelineSet }) => { + const mEventId = mEvent.getId()!; + return { + id: mEventId, + itemIndex: -1, + mEvent, + timelineSet, + eventSender: mEvent.getSender() ?? null, + }; + }), + ].toSorted((a, b) => a.mEvent.getTs() - b.mEvent.getTs()); + + return computeCollapseAndDividers(mergedDrafts, mxUserId, readUptoEventId); +}; + export function useProcessedTimeline({ items, linkedTimelines, ignoredUsersSet, - showHiddenEvents, - showTombstoneEvents, + hiddenEvents, mxUserId, readUptoEventId, hideMembershipEvents, @@ -79,6 +230,17 @@ export function useProcessedTimeline({ hideMemberInReadOnly, skipThreadFilter, }: UseProcessedTimelineOptions): ProcessedEvent[] { + const { + showHiddenEvents, + showTombstoneEvents, + hiddenEventEdits, + hiddenEventRedactionTimeline, + hiddenEventReactions, + hiddenEventReactionTombstone, + hiddenEventReactionRedactionTimeline, + hiddenEventOther, + } = hiddenEvents; + return useMemo(() => { let prevEvent: MatrixEvent | undefined; let isPrevRendered = false; @@ -102,9 +264,17 @@ export function useProcessedTimeline({ const eventSender = mEvent.getSender() ?? null; if (eventSender && ignoredUsersSet.has(eventSender)) return acc; - if (mEvent.isRedacted() && !(showHiddenEvents || showTombstoneEvents)) return acc; const type = mEvent.getType(); + const isEdit = isEditEvent(mEvent); + const isReaction = isReactionEvent(mEvent); + const isRedactionEvt = mEvent.isRedaction(); + + if (mEvent.isRedacted()) { + const showMessageTombstone = showTombstoneEvents && isRedactableMessageType(type); + const showReactionTombstone = hiddenEventReactionTombstone && isReaction; + if (!showMessageTombstone && !showReactionTombstone) return acc; + } if (type === 'm.room.member') { const membershipChanged = isMembershipChanged(mEvent); @@ -113,7 +283,19 @@ export function useProcessedTimeline({ if (!membershipChanged && hideNickAvatarEvents) return acc; } - if (!showHiddenEvents) { + const allowSpecificHiddenEvent = + (isEdit && hiddenEventEdits) || + (isReaction && !mEvent.isRedacted() && hiddenEventReactions) || + (isReaction && mEvent.isRedacted() && hiddenEventReactionTombstone) || + (isRedactionEvt && + shouldShowRedactionTimelineEvent( + mEvent, + timelineSet, + hiddenEventRedactionTimeline, + hiddenEventReactionRedactionTimeline + )); + + if (!(showHiddenEvents && hiddenEventOther)) { const isStandardRendered = [ 'm.room.message', 'm.room.message.encrypted', @@ -126,9 +308,12 @@ export function useProcessedTimeline({ ].includes(type); if (!isStandardRendered) { - if (Object.keys(mEvent.getContent()).length === 0) return acc; - if (mEvent.getRelation()) return acc; - if (mEvent.isRedaction()) return acc; + if (Object.keys(mEvent.getContent()).length === 0 && !allowSpecificHiddenEvent) + return acc; + if (!allowSpecificHiddenEvent) { + if (mEvent.getRelation()) return acc; + if (mEvent.isRedaction()) return acc; + } } } @@ -140,8 +325,24 @@ export function useProcessedTimeline({ ) return acc; - const isReactionOrEdit = reactionOrEditEvent(mEvent); - if (isReactionOrEdit) return acc; + if (isEdit && !hiddenEventEdits) return acc; + if (isReaction) { + if (mEvent.isRedacted()) { + if (!hiddenEventReactionTombstone) return acc; + } else if (!hiddenEventReactions) { + return acc; + } + } + if ( + isRedactionEvt && + !shouldShowRedactionTimelineEvent( + mEvent, + timelineSet, + hiddenEventRedactionTimeline, + hiddenEventReactionRedactionTimeline + ) + ) + return acc; if (!newDivider && readUptoEventId) { const prevId = prevEvent ? prevEvent.getId() : undefined; @@ -197,13 +398,35 @@ export function useProcessedTimeline({ acc.push(processed); return acc; }, []); - return result; + + return mergeRelationEdits( + mergeRelationReactions( + result, + linkedTimelines, + ignoredUsersSet, + hiddenEventReactions, + hiddenEventReactionTombstone, + mxUserId, + readUptoEventId + ), + linkedTimelines, + ignoredUsersSet, + hiddenEventEdits, + mxUserId, + readUptoEventId + ); }, [ items, linkedTimelines, ignoredUsersSet, showHiddenEvents, showTombstoneEvents, + hiddenEventEdits, + hiddenEventRedactionTimeline, + hiddenEventReactions, + hiddenEventReactionTombstone, + hiddenEventReactionRedactionTimeline, + hiddenEventOther, mxUserId, readUptoEventId, hideMembershipEvents, diff --git a/src/app/hooks/timeline/useTimelineEventRenderer.tsx b/src/app/hooks/timeline/useTimelineEventRenderer.tsx index 9213e16f7..7b952a323 100644 --- a/src/app/hooks/timeline/useTimelineEventRenderer.tsx +++ b/src/app/hooks/timeline/useTimelineEventRenderer.tsx @@ -15,9 +15,22 @@ import { NotificationCountType, RoomEvent, ThreadEvent, EventType } from '$types import type { SessionMembershipData } from '$types/matrix-sdk'; import type { HTMLReactParserOptions } from 'html-react-parser'; import type { Opts as LinkifyOpts } from 'linkifyjs'; -import { Box, Chip, Avatar, Text, Icons, config, toRem, Icon } from 'folds'; -import type { MessageSpacing } from '$state/settings'; -import { MessageLayout } from '$state/settings'; +import { Box, Chip, Avatar, Text, config, toRem } from 'folds'; +import { + Code, + Hash, + menuIcon, + PencilSimple, + Phone, + PhoneDisconnect, + PushPin, + PushPinSlash, + Smiley, + timelineIcon, + Trash, +} from '$components/icons/phosphor'; +import type { ResolvedHiddenEventSettings } from '$state/hooks/settings'; +import { MessageLayout, type MessageSpacing } from '$state/settings'; import { nicknamesAtom } from '$state/nicknames'; import type { useGetMemberPowerTag } from '$hooks/useMemberPowerTag'; import type { useMemberEventParser } from '$hooks/useMemberEventParser'; @@ -28,10 +41,13 @@ import { useOpenUserRoomProfile } from '$state/hooks/userRoomProfile'; import { EventContent, ImageContent, + InlineTextDiff, MessageNotDecryptedContent, MSticker, RedactedContent, + RedactedReactionContent, Reply, + ReactionKeyInline, Time, } from '$components/message'; import { Image } from '$components/media'; @@ -44,8 +60,19 @@ import type { GetContentCallback } from '$types/matrix/room'; import { getMxIdLocalPart, mxcUrlToHttp } from '$utils/matrix'; import { getEditedEvent, + getEditChain, + getEditDiffBodies, + getEditTargetId, getEventReactions, getMemberDisplayName, + getPreviousEditId, + getRedactionTargetEvent, + getRedactionTargetId, + getReactionKey, + getReactionShortcode, + getReactionAnnotationTargetId, + getRedactionReason, + isEditEvent, isMembershipChanged, isThreadRelationEvent, reactionOrEditEvent, @@ -279,7 +306,7 @@ export interface TimelineEventRendererOptions { isReadOnly: boolean; hideMembershipEvents: boolean; hideNickAvatarEvents: boolean; - showHiddenEvents: boolean; + hiddenEvents: ResolvedHiddenEventSettings; hideThreadChip?: boolean; }; state: { @@ -337,7 +364,7 @@ export function useTimelineEventRenderer({ isReadOnly, hideMembershipEvents, hideNickAvatarEvents, - showHiddenEvents, + hiddenEvents, hideThreadChip, }, state: { focusItem, editId, activeReplyId, openThreadId, suppressMark }, @@ -356,10 +383,101 @@ export function useTimelineEventRenderer({ utils: { htmlReactParserOptions, linkifyOpts, getMemberPowerTag, parseMemberEvent }, }: TimelineEventRendererOptions) { const { t } = useTranslation(); + const { + hiddenEventEdits, + hiddenEventRedactionTimeline, + hiddenEventReactions, + hiddenEventReactionTombstone, + hiddenEventReactionRedactionTimeline, + hiddenEventOther, + } = hiddenEvents; + const useAuthentication = useMediaAuthentication(); + + const renderEditTimelineEvent = ( + mEventId: string, + mEvent: MatrixEvent, + item: number, + timelineSet: EventTimelineSet, + collapse: boolean + ) => { + if (!hiddenEventEdits) return null; + + const highlighted = focusItem?.index === item && focusItem.highlight; + const marked = activeReplyId === mEventId && suppressMark !== true; + const senderId = mEvent.getSender() ?? ''; + const senderName = + getMemberDisplayName(room, senderId, nicknames) || getMxIdLocalPart(senderId); + const editTargetId = getEditTargetId(mEvent); + const chain = editTargetId && getEditChain(timelineSet, editTargetId, mEvent.getType(), room); + const previousEditId = chain ? getPreviousEditId(mEvent, chain) : undefined; + const replyEventId = previousEditId ?? editTargetId; + const { oldBody, newBody } = getEditDiffBodies(mEvent, timelineSet, room); + const canShowDiff = + typeof oldBody === 'string' && typeof newBody === 'string' && oldBody !== newBody; + + const timeJSX = ( +