mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 09:01:17 -08:00
fix edit diff and icon scaling
This commit is contained in:
1 parent
baa3403eaa
commit
2d522361bf
19 files changed
+93
-36
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fixed edit diffs not properly scaling with zoom.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fixed icons not scaling with zoom.
|
||||
@@ -4,7 +4,7 @@ import type { ReactNode } from 'react';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { config } from 'folds';
|
||||
import { ArrowBendUpLeftIcon, getPhosphorSize } from '$components/icons/phosphor';
|
||||
import { ArrowBendUpLeftIcon, getPhosphorIconSize } from '$components/icons/phosphor';
|
||||
import { mobileOrTablet } from '$utils/user-agent';
|
||||
import { RightSwipeAction, settingsAtom } from '$state/settings';
|
||||
|
||||
@@ -51,7 +51,7 @@ function ActiveSwipeWrapper({ children, onReply }: { children: ReactNode; onRepl
|
||||
>
|
||||
<motion.div style={{ opacity: iconOpacity }}>
|
||||
<ArrowBendUpLeftIcon
|
||||
size={getPhosphorSize().toolbar}
|
||||
size={getPhosphorIconSize('toolbar')}
|
||||
style={{
|
||||
color: isReady
|
||||
? 'var(--sable-surface-on-container)'
|
||||
|
||||
@@ -135,6 +135,12 @@ export const DEFAULT_PHOSPHOR_SIZES = {
|
||||
empty: 32,
|
||||
} as const;
|
||||
|
||||
export const PHOSPHOR_PX_PER_REM = 16;
|
||||
|
||||
export function phosphorSizeRem(px: number): string {
|
||||
return `${px / PHOSPHOR_PX_PER_REM}rem`;
|
||||
}
|
||||
|
||||
export type PhosphorRoleSizes = {
|
||||
compact: number;
|
||||
inline: number;
|
||||
@@ -199,6 +205,17 @@ function resolveIconTokenPx(
|
||||
}
|
||||
}
|
||||
|
||||
function resolveIconTokenSize(
|
||||
token: Exclude<IconSizeToken, 'Inherit'>,
|
||||
sizes: PhosphorRoleSizes
|
||||
): string {
|
||||
return phosphorSizeRem(resolveIconTokenPx(token, sizes));
|
||||
}
|
||||
|
||||
export function getPhosphorIconSize(role: keyof PhosphorRoleSizes): string {
|
||||
return phosphorSizeRem(getPhosphorSize()[role]);
|
||||
}
|
||||
|
||||
const timelineMutedStyle = { opacity: 0.6 } as const;
|
||||
|
||||
export type PhosphorIcon = ComponentType<IconProps>;
|
||||
@@ -219,7 +236,7 @@ export function sizedIcon(
|
||||
}
|
||||
return (
|
||||
<Icon
|
||||
size={resolveIconTokenPx(size, getPhosphorSize())}
|
||||
size={resolveIconTokenSize(size, getPhosphorSize())}
|
||||
weight={resolvedWeight}
|
||||
style={style}
|
||||
{...rest}
|
||||
@@ -228,19 +245,19 @@ export function sizedIcon(
|
||||
}
|
||||
|
||||
export function timelineIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode {
|
||||
return <Icon size={getPhosphorSize().inline} style={timelineMutedStyle} {...props} />;
|
||||
return <Icon size={getPhosphorIconSize('inline')} style={timelineMutedStyle} {...props} />;
|
||||
}
|
||||
|
||||
export function menuIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode {
|
||||
return <Icon size={getPhosphorSize().inline} {...props} />;
|
||||
return <Icon size={getPhosphorIconSize('inline')} {...props} />;
|
||||
}
|
||||
|
||||
export function composerIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode {
|
||||
return <Icon size={getPhosphorSize().toolbar} {...props} />;
|
||||
return <Icon size={getPhosphorIconSize('toolbar')} {...props} />;
|
||||
}
|
||||
|
||||
export function chipIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode {
|
||||
return <Icon size={getPhosphorSize().inline} {...props} />;
|
||||
return <Icon size={getPhosphorIconSize('inline')} {...props} />;
|
||||
}
|
||||
|
||||
export function profileIcon(Icon: PhosphorIcon, props?: SizedIconProps): ReactNode {
|
||||
@@ -259,17 +276,19 @@ export function chipCaretIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode
|
||||
flexShrink: 0,
|
||||
}}
|
||||
>
|
||||
<Icon size={getPhosphorSize().inline} style={{ display: 'block', ...style }} {...rest} />
|
||||
<Icon size={getPhosphorIconSize('inline')} style={{ display: 'block', ...style }} {...rest} />
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export function dropzoneIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode {
|
||||
return <Icon size={getPhosphorSize().empty} {...props} />;
|
||||
return <Icon size={getPhosphorIconSize('empty')} {...props} />;
|
||||
}
|
||||
|
||||
export function settingsNavIcon(Icon: PhosphorIcon, active: boolean, props?: IconProps): ReactNode {
|
||||
return <Icon size={getPhosphorSize().inline} weight={active ? 'fill' : 'regular'} {...props} />;
|
||||
return (
|
||||
<Icon size={getPhosphorIconSize('inline')} weight={active ? 'fill' : 'regular'} {...props} />
|
||||
);
|
||||
}
|
||||
|
||||
export type UserFallbackSize = 'sm' | 'md' | 'lg' | 'xl' | 'hero';
|
||||
@@ -283,7 +302,7 @@ export function userFallbackIcon(size: UserFallbackSize = 'md', props?: IconProp
|
||||
xl: sizes.toolbar,
|
||||
hero: sizes.empty,
|
||||
}[size];
|
||||
return <UserIcon size={px} weight="regular" {...props} />;
|
||||
return <UserIcon size={phosphorSizeRem(px)} weight="regular" {...props} />;
|
||||
}
|
||||
|
||||
export {
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
Image,
|
||||
Minus,
|
||||
Plus,
|
||||
phosphorSizeRem,
|
||||
sizedIcon,
|
||||
} from '$components/icons/phosphor';
|
||||
import { useImageGestures } from '$hooks/useImageGestures';
|
||||
@@ -107,7 +108,10 @@ export const ImageViewer = as<'div', ImageViewerProps>(
|
||||
aria-label="Toggle Pixelation"
|
||||
title={`Turn ${isPixelated ? 'Anti-aliasing' : 'Pixelation'} on`}
|
||||
>
|
||||
<CheckerboardIcon size={20} weight={isPixelated ? 'duotone' : 'fill'} />
|
||||
<CheckerboardIcon
|
||||
size={phosphorSizeRem(20)}
|
||||
weight={isPixelated ? 'duotone' : 'fill'}
|
||||
/>
|
||||
</IconButton>
|
||||
<IconButton
|
||||
variant="Surface"
|
||||
|
||||
@@ -16,7 +16,7 @@ export const DiffCodeBlock = style([
|
||||
overflowWrap: 'anywhere',
|
||||
wordBreak: 'break-word',
|
||||
overflow: 'hidden',
|
||||
fontSize: 'inherit',
|
||||
fontSize: '1rem !important',
|
||||
lineHeight: 'inherit',
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
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';
|
||||
|
||||
@@ -114,9 +113,9 @@ function DiffSkipRows({ skipIndex, lines, placement, revealed, onReveal }: DiffS
|
||||
|
||||
function InlineDiffBlock({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<Text as="pre" size="T200" className={css.DiffCodeBlock}>
|
||||
<pre className={css.DiffCodeBlock}>
|
||||
<code className={css.DiffCodeBlockInner}>{children}</code>
|
||||
</Text>
|
||||
</pre>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ export const TextViewerPre = style([
|
||||
whiteSpace: 'pre-wrap',
|
||||
overflowWrap: 'anywhere',
|
||||
wordBreak: 'break-word',
|
||||
fontSize: '1rem !important',
|
||||
lineHeight: 'inherit',
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
X,
|
||||
sizedIcon,
|
||||
type PhosphorIcon,
|
||||
phosphorSizeRem,
|
||||
} from '$components/icons/phosphor';
|
||||
import type { HTMLReactParserOptions } from 'html-react-parser';
|
||||
import { Play, Pause } from '@phosphor-icons/react';
|
||||
@@ -284,7 +285,11 @@ function PreviewAudio({ fileItem }: PreviewAudioProps) {
|
||||
aria-label={isPlaying ? 'Pause' : 'Play voice message'}
|
||||
aria-pressed={isPlaying}
|
||||
>
|
||||
{isPlaying ? <Pause size={20} weight="fill" /> : <Play size={20} weight="fill" />}
|
||||
{isPlaying ? (
|
||||
<Pause size={phosphorSizeRem(20)} weight="fill" />
|
||||
) : (
|
||||
<Play size={phosphorSizeRem(20)} weight="fill" />
|
||||
)}
|
||||
</IconButton>
|
||||
|
||||
<Box
|
||||
|
||||
@@ -168,7 +168,7 @@ function StateEventEdit({ type, stateKey, content, requestClose }: StateEventEdi
|
||||
<TextAreaComponent
|
||||
ref={textAreaRef}
|
||||
name="contentTextArea"
|
||||
style={{ fontFamily: 'var(--font-monospace)' }}
|
||||
style={{ fontFamily: 'var(--font-monospace)', fontSize: '1rem', lineHeight: 'inherit' }}
|
||||
onKeyDown={handleKeyDown}
|
||||
defaultValue={defaultContentStr}
|
||||
resize="None"
|
||||
|
||||
@@ -141,7 +141,7 @@ import {
|
||||
menuIcon,
|
||||
Microphone,
|
||||
PaperPlaneTilt,
|
||||
getPhosphorSize,
|
||||
getPhosphorIconSize,
|
||||
PlusCircle,
|
||||
Smiley,
|
||||
Sticker,
|
||||
@@ -1659,7 +1659,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
>
|
||||
{showAudioRecorder ? (
|
||||
<Stop
|
||||
size={getPhosphorSize().toolbar}
|
||||
size={getPhosphorIconSize('toolbar')}
|
||||
weight="fill"
|
||||
style={{ color: color.Critical.Main }}
|
||||
/>
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
DotsThreeOutlineVerticalIcon,
|
||||
dropzoneIcon,
|
||||
menuIcon,
|
||||
getPhosphorSize,
|
||||
getPhosphorIconSize,
|
||||
Plus,
|
||||
User,
|
||||
} from '$components/icons/phosphor';
|
||||
@@ -115,7 +115,10 @@ function DirectHeader({ hideText }: { hideText?: boolean }) {
|
||||
{hideText ? (
|
||||
<Box alignItems="Center" grow="Yes" justifyContent="Center">
|
||||
<IconButton aria-pressed={!!menuAnchor} variant="Background" onClick={handleOpenMenu}>
|
||||
<User size={getPhosphorSize().toolbar} weight={menuAnchor ? 'fill' : 'regular'} />
|
||||
<User
|
||||
size={getPhosphorIconSize('toolbar')}
|
||||
weight={menuAnchor ? 'fill' : 'regular'}
|
||||
/>
|
||||
</IconButton>
|
||||
</Box>
|
||||
) : (
|
||||
|
||||
@@ -17,7 +17,13 @@ import {
|
||||
} from '$pages/pathUtils';
|
||||
import { useCreateSelected } from '$hooks/router/useCreateSelected';
|
||||
import { JoinAddressPrompt } from '$components/join-address-prompt';
|
||||
import { composerIcon, Link, getPhosphorSize, Plus, SquaresFour } from '$components/icons/phosphor';
|
||||
import {
|
||||
composerIcon,
|
||||
Link,
|
||||
getPhosphorIconSize,
|
||||
Plus,
|
||||
SquaresFour,
|
||||
} from '$components/icons/phosphor';
|
||||
|
||||
export function CreateTab() {
|
||||
const createSelected = useCreateSelected();
|
||||
@@ -110,7 +116,7 @@ export function CreateTab() {
|
||||
outlined
|
||||
onClick={handleMenu}
|
||||
>
|
||||
<Plus size={getPhosphorSize().toolbar} />
|
||||
<Plus size={getPhosphorIconSize('toolbar')} />
|
||||
</SidebarAvatar>
|
||||
{joinAddress && (
|
||||
<JoinAddressPrompt
|
||||
|
||||
@@ -23,7 +23,7 @@ import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { useNavToActivePathAtom } from '$state/hooks/navToActivePath';
|
||||
import { markAsRead } from '$utils/notifications';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import { Checks, menuIcon, getPhosphorSize, User } from '$components/icons/phosphor';
|
||||
import { Checks, menuIcon, getPhosphorIconSize, User } from '$components/icons/phosphor';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { useDirectRooms } from '$pages/client/direct/useDirectRooms';
|
||||
@@ -115,7 +115,10 @@ export function DirectTab() {
|
||||
onClick={handleDirectClick}
|
||||
onContextMenu={handleContextMenu}
|
||||
>
|
||||
<User size={getPhosphorSize().toolbar} weight={directSelected ? 'fill' : 'regular'} />
|
||||
<User
|
||||
size={getPhosphorIconSize('toolbar')}
|
||||
weight={directSelected ? 'fill' : 'regular'}
|
||||
/>
|
||||
</SidebarAvatar>
|
||||
)}
|
||||
</SidebarItemTooltip>
|
||||
|
||||
@@ -13,7 +13,7 @@ import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { useNavToActivePathAtom } from '$state/hooks/navToActivePath';
|
||||
import { getMxIdServer } from '$utils/mxIdHelper';
|
||||
import { Compass, getPhosphorSize } from '$components/icons/phosphor';
|
||||
import { Compass, getPhosphorIconSize } from '$components/icons/phosphor';
|
||||
|
||||
export function ExploreTab() {
|
||||
const mx = useMatrixClient();
|
||||
@@ -55,7 +55,7 @@ export function ExploreTab() {
|
||||
{(triggerRef) => (
|
||||
<SidebarAvatar as="button" ref={triggerRef} outlined onClick={handleExploreClick}>
|
||||
<Compass
|
||||
size={getPhosphorSize().toolbar}
|
||||
size={getPhosphorIconSize('toolbar')}
|
||||
weight={exploreSelected ? 'fill' : 'regular'}
|
||||
/>
|
||||
</SidebarAvatar>
|
||||
|
||||
@@ -27,7 +27,7 @@ import { stopPropagation } from '$utils/keyboard';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { useHomeRooms } from '$pages/client/home/useHomeRooms';
|
||||
import { Checks, House, menuIcon, getPhosphorSize } from '$components/icons/phosphor';
|
||||
import { Checks, House, menuIcon, getPhosphorIconSize } from '$components/icons/phosphor';
|
||||
|
||||
type HomeMenuProps = {
|
||||
requestClose: () => void;
|
||||
@@ -106,7 +106,10 @@ export function HomeTab() {
|
||||
onClick={handleHomeClick}
|
||||
onContextMenu={handleContextMenu}
|
||||
>
|
||||
<House size={getPhosphorSize().toolbar} weight={homeSelected ? 'fill' : 'regular'} />
|
||||
<House
|
||||
size={getPhosphorIconSize('toolbar')}
|
||||
weight={homeSelected ? 'fill' : 'regular'}
|
||||
/>
|
||||
</SidebarAvatar>
|
||||
)}
|
||||
</SidebarItemTooltip>
|
||||
|
||||
@@ -16,7 +16,7 @@ import { useInboxSelected } from '$hooks/router/useInbox';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { useNavToActivePathAtom } from '$state/hooks/navToActivePath';
|
||||
import { useInviteCount } from '$hooks/useInviteCount';
|
||||
import { getPhosphorSize, Tray } from '$components/icons/phosphor';
|
||||
import { getPhosphorIconSize, Tray } from '$components/icons/phosphor';
|
||||
|
||||
export function InboxTab() {
|
||||
const screenSize = useScreenSizeContext();
|
||||
@@ -45,7 +45,10 @@ export function InboxTab() {
|
||||
<SidebarItemTooltip tooltip="Inbox">
|
||||
{(triggerRef) => (
|
||||
<SidebarAvatar as="button" ref={triggerRef} outlined onClick={handleInboxClick}>
|
||||
<Tray size={getPhosphorSize().toolbar} weight={inboxSelected ? 'fill' : 'regular'} />
|
||||
<Tray
|
||||
size={getPhosphorIconSize('toolbar')}
|
||||
weight={inboxSelected ? 'fill' : 'regular'}
|
||||
/>
|
||||
</SidebarAvatar>
|
||||
)}
|
||||
</SidebarItemTooltip>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useAtom } from 'jotai';
|
||||
import { SidebarAvatar, SidebarItem, SidebarItemTooltip } from '$components/sidebar';
|
||||
import { searchModalAtom } from '$state/searchModal';
|
||||
import { MagnifyingGlass, getPhosphorSize } from '$components/icons/phosphor';
|
||||
import { MagnifyingGlass, getPhosphorIconSize } from '$components/icons/phosphor';
|
||||
|
||||
export function SearchTab() {
|
||||
const [opened, setOpen] = useAtom(searchModalAtom);
|
||||
@@ -14,7 +14,7 @@ export function SearchTab() {
|
||||
{(triggerRef) => (
|
||||
<SidebarAvatar as="button" ref={triggerRef} outlined onClick={open}>
|
||||
<MagnifyingGlass
|
||||
size={getPhosphorSize().toolbar}
|
||||
size={getPhosphorIconSize('toolbar')}
|
||||
weight={opened ? 'fill' : 'regular'}
|
||||
/>
|
||||
</SidebarAvatar>
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
} from '$hooks/useDeviceVerificationStatus';
|
||||
import { useCrossSigningActive } from '$hooks/useCrossSigning';
|
||||
import { useOpenSettings } from '$features/settings';
|
||||
import { getPhosphorSize, ShieldWarning } from '$components/icons/phosphor';
|
||||
import { getPhosphorIconSize, ShieldWarning } from '$components/icons/phosphor';
|
||||
import * as css from './UnverifiedTab.css';
|
||||
|
||||
function UnverifiedIndicator() {
|
||||
@@ -59,7 +59,7 @@ function UnverifiedIndicator() {
|
||||
style={{
|
||||
color: unverified ? color.Critical.Main : color.Warning.Main,
|
||||
}}
|
||||
size={getPhosphorSize().toolbar}
|
||||
size={getPhosphorIconSize('toolbar')}
|
||||
/>
|
||||
</SidebarAvatar>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user