From 9d812a6abc484d74f7cf54116a511432b67aee5d Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Thu, 26 Dec 2024 20:13:34 +0530 Subject: [PATCH] emojis and sticker user settings - WIP --- src/app/features/settings/Settings.tsx | 4 + .../emojis-stickers/EmojisStickers.tsx | 39 ++++++++ .../settings/emojis-stickers/GlobalPacks.tsx | 88 +++++++++++++++++++ .../settings/emojis-stickers/UserPack.tsx | 52 +++++++++++ .../settings/emojis-stickers/index.ts | 1 + 5 files changed, 184 insertions(+) create mode 100644 src/app/features/settings/emojis-stickers/EmojisStickers.tsx create mode 100644 src/app/features/settings/emojis-stickers/GlobalPacks.tsx create mode 100644 src/app/features/settings/emojis-stickers/UserPack.tsx create mode 100644 src/app/features/settings/emojis-stickers/index.ts diff --git a/src/app/features/settings/Settings.tsx b/src/app/features/settings/Settings.tsx index 4a55265b..022d6cba 100644 --- a/src/app/features/settings/Settings.tsx +++ b/src/app/features/settings/Settings.tsx @@ -11,6 +11,7 @@ import { useMediaAuthentication } from '../../hooks/useMediaAuthentication'; import { UserAvatar } from '../../components/user-avatar'; import { nameInitials } from '../../utils/common'; import { Notifications } from './notifications'; +import { EmojisStickers } from './emojis-stickers'; import { DeveloperTools } from './developer-tools'; import { About } from './about'; @@ -170,6 +171,9 @@ export function Settings({ initialPage, requestClose }: SettingsProps) { {activePage === SettingsPages.NotificationPage && ( )} + {activePage === SettingsPages.EmojisStickersPage && ( + + )} {activePage === SettingsPages.DeveloperToolsPage && ( )} diff --git a/src/app/features/settings/emojis-stickers/EmojisStickers.tsx b/src/app/features/settings/emojis-stickers/EmojisStickers.tsx new file mode 100644 index 00000000..50fa2766 --- /dev/null +++ b/src/app/features/settings/emojis-stickers/EmojisStickers.tsx @@ -0,0 +1,39 @@ +import React from 'react'; +import { Box, Text, IconButton, Icon, Icons, Scroll } from 'folds'; +import { Page, PageContent, PageHeader } from '../../../components/page'; +import { GlobalPacks } from './GlobalPacks'; +import { UserPack } from './UserPack'; + +type EmojisStickersProps = { + requestClose: () => void; +}; +export function EmojisStickers({ requestClose }: EmojisStickersProps) { + return ( + + + + + + Emojis & Stickers + + + + + + + + + + + + + + + + + + + + + ); +} diff --git a/src/app/features/settings/emojis-stickers/GlobalPacks.tsx b/src/app/features/settings/emojis-stickers/GlobalPacks.tsx new file mode 100644 index 00000000..3f3fefa6 --- /dev/null +++ b/src/app/features/settings/emojis-stickers/GlobalPacks.tsx @@ -0,0 +1,88 @@ +import React from 'react'; +import { + Box, + Text, + Button, + Icon, + Icons, + IconButton, + Avatar, + AvatarImage, + AvatarFallback, +} from 'folds'; +import { useGlobalImagePacks } from '../../../hooks/useImagePacks'; +import { SequenceCardStyle } from '../styles.css'; +import { SequenceCard } from '../../../components/sequence-card'; +import { SettingTile } from '../../../components/setting-tile'; +import { mxcUrlToHttp } from '../../../utils/matrix'; +import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication'; +import { useMatrixClient } from '../../../hooks/useMatrixClient'; +import { ImageUsage } from '../../../plugins/custom-emoji'; +import { LineClamp2 } from '../../../styles/Text.css'; + +export function GlobalPacks() { + const mx = useMatrixClient(); + const useAuthentication = useMediaAuthentication(); + const globalPacks = useGlobalImagePacks(); + + return ( + + Globally Accessible + + + Select + + } + /> + + {globalPacks.map((pack) => { + const avatarMxc = pack.getAvatarUrl(ImageUsage.Emoticon); + const avatarUrl = avatarMxc ? mxcUrlToHttp(mx, avatarMxc, useAuthentication) : undefined; + + return ( + + {pack.meta.attribution}} + before={ + + + + + + {avatarUrl ? ( + + ) : ( + + + + )} + + + } + after={ + + } + /> + + ); + })} + + ); +} diff --git a/src/app/features/settings/emojis-stickers/UserPack.tsx b/src/app/features/settings/emojis-stickers/UserPack.tsx new file mode 100644 index 00000000..cd23d86c --- /dev/null +++ b/src/app/features/settings/emojis-stickers/UserPack.tsx @@ -0,0 +1,52 @@ +import React from 'react'; +import { Avatar, AvatarFallback, AvatarImage, Box, Button, Icon, Icons, Text } from 'folds'; +import { useUserImagePack } from '../../../hooks/useImagePacks'; +import { SequenceCard } from '../../../components/sequence-card'; +import { SequenceCardStyle } from '../styles.css'; +import { SettingTile } from '../../../components/setting-tile'; +import { ImageUsage } from '../../../plugins/custom-emoji'; +import { useMatrixClient } from '../../../hooks/useMatrixClient'; +import { mxcUrlToHttp } from '../../../utils/matrix'; +import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication'; + +export function UserPack() { + const mx = useMatrixClient(); + const useAuthentication = useMediaAuthentication(); + + const userPack = useUserImagePack(); + const avatarMxc = userPack?.getAvatarUrl(ImageUsage.Emoticon); + const avatarUrl = avatarMxc ? mxcUrlToHttp(mx, avatarMxc, useAuthentication) : undefined; + + return ( + + Personal Pack + + + {avatarUrl ? ( + + ) : ( + + + + )} + + } + after={ + + } + /> + + + ); +} diff --git a/src/app/features/settings/emojis-stickers/index.ts b/src/app/features/settings/emojis-stickers/index.ts new file mode 100644 index 00000000..9c9e9f52 --- /dev/null +++ b/src/app/features/settings/emojis-stickers/index.ts @@ -0,0 +1 @@ +export * from './EmojisStickers';