diff --git a/src/app/components/message/MsgTypeRenderers.tsx b/src/app/components/message/MsgTypeRenderers.tsx index a40ecae1..a1f55527 100644 --- a/src/app/components/message/MsgTypeRenderers.tsx +++ b/src/app/components/message/MsgTypeRenderers.tsx @@ -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 ; 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 ( <> {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 ; 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 ( <> {`${displayName} `} {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 ; 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 ( <> {renderBody({ body: trimmedBody, diff --git a/src/app/components/message/layout/layout.css.ts b/src/app/components/message/layout/layout.css.ts index cc2cd0c6..840cd7a8 100644 --- a/src/app/components/message/layout/layout.css.ts +++ b/src/app/components/message/layout/layout.css.ts @@ -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: { diff --git a/src/app/features/settings/Settings.tsx b/src/app/features/settings/Settings.tsx index 5e1a20f4..ad6516af 100644 --- a/src/app/features/settings/Settings.tsx +++ b/src/app/features/settings/Settings.tsx @@ -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 && ( )} + {activePage === SettingsPages.CosmeticsPage && ( + + )} {activePage === SettingsPages.DeveloperToolsPage && ( )} diff --git a/src/app/features/settings/cosmetics/Cosmetics.tsx b/src/app/features/settings/cosmetics/Cosmetics.tsx new file mode 100644 index 00000000..8dd15e06 --- /dev/null +++ b/src/app/features/settings/cosmetics/Cosmetics.tsx @@ -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(); + const [jumboEmojiSize, setJumboEmojiSize] = useSetting(settingsAtom, 'jumboEmojiSize'); + + const handleMenu: MouseEventHandler = (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 ( + <> + + setMenuCords(undefined), + clickOutsideDeactivates: true, + isKeyForward: (evt: KeyboardEvent) => evt.key === 'ArrowDown' || evt.key === 'ArrowRight', + isKeyBackward: (evt: KeyboardEvent) => evt.key === 'ArrowUp' || evt.key === 'ArrowLeft', + escapeDeactivates: stopPropagation, + }} + > + + + {emojiSizeItems.map((item) => ( + handleSelect(item.id)} + > + {item.name} + + ))} + + + + } + /> + + ); +} + +function JumboEmoji() { + return ( + + Jumbo Emoji + + } + /> + + + ); +} + +type CosmeticsProps = { + requestClose: () => void; +}; + +export function Cosmetics({ requestClose }: CosmeticsProps) { + return ( + + + + + + Cosmetics + + + + + + + + + + + + + + + + + + + + ); +} \ No newline at end of file diff --git a/src/app/state/settings.ts b/src/app/state/settings.ts index 31ee6ccb..6d0fc724 100644 --- a/src/app/state/settings.ts +++ b/src/app/state/settings.ts @@ -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 = () => {