Emoji size account setting
This commit is contained in:
1 parent
ccf6df4f00
commit
9e6b742e62
5 files changed
+199
-6
No files matched your search
@@ -29,6 +29,8 @@ import { FALLBACK_MIMETYPE, getBlobSafeMimeType } from '../../utils/mimeTypes';
|
||||
import { parseGeoUri, scaleYDimension } from '../../utils/common';
|
||||
import { Attachment, AttachmentBox, AttachmentContent, AttachmentHeader } from './attachment';
|
||||
import { FileHeader, FileDownloadButton } from './FileHeader';
|
||||
import { useSetting } from '../../state/hooks/settings';
|
||||
import { settingsAtom } from '../../state/settings';
|
||||
|
||||
export function MBadEncrypted() {
|
||||
return (
|
||||
@@ -78,17 +80,19 @@ type MTextProps = {
|
||||
};
|
||||
export function MText({ edited, content, renderBody, renderUrlsPreview, style }: MTextProps) {
|
||||
const { body, formatted_body: customBody } = content;
|
||||
const [jumboEmojiSize] = useSetting(settingsAtom, 'jumboEmojiSize');
|
||||
|
||||
if (typeof body !== 'string') return <BrokenContent />;
|
||||
const trimmedBody = trimReplyFromBody(body);
|
||||
const urlsMatch = renderUrlsPreview && trimmedBody.match(URL_REG);
|
||||
const urls = urlsMatch ? [...new Set(urlsMatch)] : undefined;
|
||||
const isJumbo = JUMBO_EMOJI_REG.test(trimmedBody);
|
||||
|
||||
return (
|
||||
<>
|
||||
<MessageTextBody
|
||||
preWrap={typeof customBody !== 'string'}
|
||||
jumboEmoji={JUMBO_EMOJI_REG.test(trimmedBody)}
|
||||
jumboEmoji={isJumbo ? jumboEmojiSize : 'none'}
|
||||
style={style}
|
||||
>
|
||||
{renderBody({
|
||||
@@ -117,18 +121,20 @@ export function MEmote({
|
||||
renderUrlsPreview,
|
||||
}: MEmoteProps) {
|
||||
const { body, formatted_body: customBody } = content;
|
||||
const [jumboEmojiSize] = useSetting(settingsAtom, 'jumboEmojiSize');
|
||||
|
||||
if (typeof body !== 'string') return <BrokenContent />;
|
||||
const trimmedBody = trimReplyFromBody(body);
|
||||
const urlsMatch = renderUrlsPreview && trimmedBody.match(URL_REG);
|
||||
const urls = urlsMatch ? [...new Set(urlsMatch)] : undefined;
|
||||
const isJumbo = JUMBO_EMOJI_REG.test(trimmedBody);
|
||||
|
||||
return (
|
||||
<>
|
||||
<MessageTextBody
|
||||
emote
|
||||
preWrap={typeof customBody !== 'string'}
|
||||
jumboEmoji={JUMBO_EMOJI_REG.test(trimmedBody)}
|
||||
jumboEmoji={isJumbo ? jumboEmojiSize : 'none'}
|
||||
>
|
||||
<b>{`${displayName} `}</b>
|
||||
{renderBody({
|
||||
@@ -150,18 +156,20 @@ type MNoticeProps = {
|
||||
};
|
||||
export function MNotice({ edited, content, renderBody, renderUrlsPreview }: MNoticeProps) {
|
||||
const { body, formatted_body: customBody } = content;
|
||||
const [jumboEmojiSize] = useSetting(settingsAtom, 'jumboEmojiSize');
|
||||
|
||||
if (typeof body !== 'string') return <BrokenContent />;
|
||||
const trimmedBody = trimReplyFromBody(body);
|
||||
const urlsMatch = renderUrlsPreview && trimmedBody.match(URL_REG);
|
||||
const urls = urlsMatch ? [...new Set(urlsMatch)] : undefined;
|
||||
const isJumbo = JUMBO_EMOJI_REG.test(trimmedBody);
|
||||
|
||||
return (
|
||||
<>
|
||||
<MessageTextBody
|
||||
notice
|
||||
preWrap={typeof customBody !== 'string'}
|
||||
jumboEmoji={JUMBO_EMOJI_REG.test(trimmedBody)}
|
||||
jumboEmoji={isJumbo ? jumboEmojiSize : 'none'}
|
||||
>
|
||||
{renderBody({
|
||||
body: trimmedBody,
|
||||
|
||||
@@ -190,9 +190,29 @@ export const MessageTextBody = recipe({
|
||||
},
|
||||
},
|
||||
jumboEmoji: {
|
||||
true: {
|
||||
fontSize: '1.504em',
|
||||
lineHeight: '1.4962em',
|
||||
none: {
|
||||
fontSize: '1em',
|
||||
lineHeight: 'inherit'
|
||||
},
|
||||
extraSmall: {
|
||||
fontSize: '1.25em',
|
||||
lineHeight: '1.4em'
|
||||
},
|
||||
small: {
|
||||
fontSize: '1.5em',
|
||||
lineHeight: '1.5em'
|
||||
},
|
||||
normal: {
|
||||
fontSize: '1.805em',
|
||||
lineHeight: '1.625em'
|
||||
},
|
||||
large: {
|
||||
fontSize: '2.1em',
|
||||
lineHeight: '1.675em'
|
||||
},
|
||||
extraLarge: {
|
||||
fontSize: '2.4em',
|
||||
lineHeight: '1.7em'
|
||||
},
|
||||
},
|
||||
emote: {
|
||||
|
||||
@@ -33,6 +33,7 @@ import { About } from './about';
|
||||
import { UseStateProvider } from '../../components/UseStateProvider';
|
||||
import { stopPropagation } from '../../utils/keyboard';
|
||||
import { LogoutDialog } from '../../components/LogoutDialog';
|
||||
import { Cosmetics } from './cosmetics/Cosmetics';
|
||||
|
||||
export enum SettingsPages {
|
||||
GeneralPage,
|
||||
@@ -40,6 +41,7 @@ export enum SettingsPages {
|
||||
NotificationPage,
|
||||
DevicesPage,
|
||||
EmojisStickersPage,
|
||||
CosmeticsPage,
|
||||
DeveloperToolsPage,
|
||||
AboutPage,
|
||||
}
|
||||
@@ -78,6 +80,11 @@ const useSettingsMenuItems = (): SettingsMenuItem[] =>
|
||||
name: 'Emojis & Stickers',
|
||||
icon: Icons.Smile,
|
||||
},
|
||||
{
|
||||
page: SettingsPages.CosmeticsPage,
|
||||
name: 'Cosmetics',
|
||||
icon: Icons.Alphabet,
|
||||
},
|
||||
{
|
||||
page: SettingsPages.DeveloperToolsPage,
|
||||
name: 'Developer Tools',
|
||||
@@ -225,6 +232,9 @@ export function Settings({ initialPage, requestClose }: SettingsProps) {
|
||||
{activePage === SettingsPages.EmojisStickersPage && (
|
||||
<EmojisStickers requestClose={handlePageRequestClose} />
|
||||
)}
|
||||
{activePage === SettingsPages.CosmeticsPage && (
|
||||
<Cosmetics requestClose={handlePageRequestClose} />
|
||||
)}
|
||||
{activePage === SettingsPages.DeveloperToolsPage && (
|
||||
<DeveloperTools requestClose={handlePageRequestClose} />
|
||||
)}
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
import React, { MouseEventHandler, useState } from 'react';
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
config,
|
||||
Icon,
|
||||
IconButton,
|
||||
Icons,
|
||||
Menu,
|
||||
MenuItem,
|
||||
PopOut,
|
||||
RectCords,
|
||||
Scroll,
|
||||
Text,
|
||||
} from 'folds';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { Page, PageContent, PageHeader } from '../../../components/page';
|
||||
import { SequenceCard } from '../../../components/sequence-card';
|
||||
import { useSetting } from '../../../state/hooks/settings';
|
||||
import { JumboEmojiSize, settingsAtom } from '../../../state/settings';
|
||||
import { SettingTile } from '../../../components/setting-tile';
|
||||
import { stopPropagation } from '../../../utils/keyboard';
|
||||
import { SequenceCardStyle } from '../styles.css';
|
||||
|
||||
const emojiSizeItems = [
|
||||
{ id: 'none', name: 'None (Same size as text)' },
|
||||
{ id: 'extraSmall', name: 'Extra Small' },
|
||||
{ id: 'small', name: 'Small' },
|
||||
{ id: 'normal', name: 'Normal' },
|
||||
{ id: 'large', name: 'Large' },
|
||||
{ id: 'extraLarge', name: 'Extra Large' },
|
||||
];
|
||||
|
||||
function SelectJumboEmojiSize() {
|
||||
const [menuCords, setMenuCords] = useState<RectCords>();
|
||||
const [jumboEmojiSize, setJumboEmojiSize] = useSetting(settingsAtom, 'jumboEmojiSize');
|
||||
|
||||
const handleMenu: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
setMenuCords(evt.currentTarget.getBoundingClientRect());
|
||||
};
|
||||
|
||||
const handleSelect = (sizeId: string) => {
|
||||
setJumboEmojiSize(sizeId as JumboEmojiSize);
|
||||
setMenuCords(undefined);
|
||||
};
|
||||
|
||||
const currentSizeName = emojiSizeItems.find((i) => i.id === jumboEmojiSize)?.name ?? 'Normal';
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
size="300"
|
||||
variant="Secondary"
|
||||
outlined
|
||||
fill="Soft"
|
||||
radii="300"
|
||||
after={<Icon size="300" src={Icons.ChevronBottom} />}
|
||||
onClick={handleMenu}
|
||||
>
|
||||
<Text size="T300">{currentSizeName}</Text>
|
||||
</Button>
|
||||
<PopOut
|
||||
anchor={menuCords}
|
||||
offset={5}
|
||||
position="Bottom"
|
||||
align="End"
|
||||
content={
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
onDeactivate: () => setMenuCords(undefined),
|
||||
clickOutsideDeactivates: true,
|
||||
isKeyForward: (evt: KeyboardEvent) => evt.key === 'ArrowDown' || evt.key === 'ArrowRight',
|
||||
isKeyBackward: (evt: KeyboardEvent) => evt.key === 'ArrowUp' || evt.key === 'ArrowLeft',
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<Menu>
|
||||
<Box direction="Column" gap="100" style={{ padding: config.space.S100 }}>
|
||||
{emojiSizeItems.map((item) => (
|
||||
<MenuItem
|
||||
key={item.id}
|
||||
size="300"
|
||||
variant={jumboEmojiSize === item.id ? 'Primary' : 'Surface'}
|
||||
radii="300"
|
||||
onClick={() => handleSelect(item.id)}
|
||||
>
|
||||
<Text size="T300">{item.name}</Text>
|
||||
</MenuItem>
|
||||
))}
|
||||
</Box>
|
||||
</Menu>
|
||||
</FocusTrap>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function JumboEmoji() {
|
||||
return (
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Jumbo Emoji</Text>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Jumbo Emoji Size"
|
||||
description="Adjust the size of emojis sent without text."
|
||||
after={<SelectJumboEmojiSize />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
type CosmeticsProps = {
|
||||
requestClose: () => void;
|
||||
};
|
||||
|
||||
export function Cosmetics({ requestClose }: CosmeticsProps) {
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader outlined={false}>
|
||||
<Box grow="Yes" gap="200">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Text size="H3" truncate>
|
||||
Cosmetics
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton onClick={requestClose} variant="Surface">
|
||||
<Icon src={Icons.Cross} />
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageHeader>
|
||||
<Box grow="Yes">
|
||||
<Scroll hideTrack visibility="Hover">
|
||||
<PageContent>
|
||||
<Box direction="Column" gap="700">
|
||||
<JumboEmoji />
|
||||
</Box>
|
||||
</PageContent>
|
||||
</Scroll>
|
||||
</Box>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
@@ -9,6 +9,8 @@ export enum MessageLayout {
|
||||
Bubble = 2,
|
||||
}
|
||||
|
||||
export type JumboEmojiSize = 'none' | 'extraSmall' | 'small' | 'normal' | 'large' | 'extraLarge';
|
||||
|
||||
export interface Settings {
|
||||
themeId?: string;
|
||||
useSystemTheme: boolean;
|
||||
@@ -41,6 +43,9 @@ export interface Settings {
|
||||
dateFormatString: string;
|
||||
|
||||
developerTools: boolean;
|
||||
|
||||
// Cosmetics!
|
||||
jumboEmojiSize: JumboEmojiSize;
|
||||
}
|
||||
|
||||
const defaultSettings: Settings = {
|
||||
@@ -75,6 +80,9 @@ const defaultSettings: Settings = {
|
||||
dateFormatString: 'D MMM YYYY',
|
||||
|
||||
developerTools: false,
|
||||
|
||||
// Cosmetics!
|
||||
jumboEmojiSize: 'normal'
|
||||
};
|
||||
|
||||
export const getSettings = () => {
|
||||
|
||||
Reference in new issue
Block a user