// SPDX-License-Identifier: AGPL-3.0-or-later import styles from '@app/features/channel/components/ThemeEmbed.module.css'; import { EmbedCard, EmbedSkeletonButton, EmbedSkeletonCircle, EmbedSkeletonSubtitle, EmbedSkeletonTitle, } from '@app/features/messaging/components/embeds/embed_card/EmbedCard'; import cardStyles from '@app/features/messaging/components/embeds/embed_card/EmbedCard.module.css'; import {useEmbedSkeletonOverride} from '@app/features/messaging/components/embeds/embed_card/useEmbedSkeletonOverride'; import * as ThemeCommands from '@app/features/theme/commands/ThemeCommands'; import {useThemeExists} from '@app/features/theme/hooks/useThemeExists'; import {Button} from '@app/features/ui/button/Button'; import {msg} from '@lingui/core/macro'; import {Trans, useLingui} from '@lingui/react/macro'; import {PaletteIcon, QuestionIcon} from '@phosphor-icons/react'; import {observer} from 'mobx-react-lite'; const THIS_THEME_IS_NO_LONGER_AVAILABLE_DESCRIPTOR = msg({ message: 'This theme is no longer available.', comment: 'Description text in the channel and chat theme embed.', }); const SHARED_THEME_DESCRIPTOR = msg({ message: 'Shared theme', comment: 'Button or menu action label in the channel and chat theme embed. Keep it concise.', }); const IMPORT_THEME_DESCRIPTOR = msg({ message: 'Import theme', comment: 'Short label in the channel and chat theme embed. Keep it concise.', }); const THEME_UNAVAILABLE_DESCRIPTOR = msg({ message: 'Theme unavailable', comment: 'Short label in the channel and chat theme embed. Keep it concise.', }); const IMPORT_UNAVAILABLE_DESCRIPTOR = msg({ message: 'Import unavailable', comment: 'Short label in the channel and chat theme embed. Keep it concise.', }); interface ThemeEmbedProps { themeId: string; } export const ThemeEmbed = observer(function ThemeEmbed({themeId}: ThemeEmbedProps) { const {i18n} = useLingui(); const status = useThemeExists(themeId); const shouldForceSkeleton = useEmbedSkeletonOverride(); const handleImport = () => { ThemeCommands.openAcceptModal(themeId, i18n); }; if (shouldForceSkeleton || status === 'loading') { return ; } if (status === 'error') { return ( ); } return ( } title={

{i18n._(SHARED_THEME_DESCRIPTOR)}

} subtitle={ You've got CSS! } footer={ } data-flx="channel.theme-embed.embed-card" /> ); }); const ThemeLoadingState = observer(() => { return ( } title={} subtitle={} footer={} data-flx="channel.theme-embed.theme-loading-state.embed-card" /> ); }); const ThemeUnavailableError = observer(({message}: {message: string | null}) => { const {i18n} = useLingui(); return ( } title={

{i18n._(THEME_UNAVAILABLE_DESCRIPTOR)}

} subtitle={ {message ?? i18n._(THIS_THEME_IS_NO_LONGER_AVAILABLE_DESCRIPTOR)} } footer={ } data-flx="channel.theme-embed.theme-unavailable-error.embed-card" /> ); });