import * as React from 'react'; import { useState } from 'react'; import { useEmojiStyleConfig, useGetEmojiUrlConfig, usePreviewConfig } from '../../config/useConfig'; import { emojiByUnified, emojiName, emojiUnified } from '../../dataUtils/emojiSelectors'; import { useEmojiPreviewEvents } from '../../hooks/useEmojiPreviewEvents'; import { useIsSkinToneInPreview } from '../../hooks/useShouldShowSkinTonePicker'; import Flex from '../Layout/Flex'; import Space from '../Layout/Space'; import { useEmojiVariationPickerState } from '../context/PickerContext'; import { ViewOnlyEmoji } from '../emoji/Emoji'; import './Preview.css'; import { SkinTonePickerMenu } from '../header/SkinTonePicker'; export function Preview() { const previewConfig = usePreviewConfig(); const isSkinToneInPreview = useIsSkinToneInPreview(); if (!previewConfig.showPreview) { return null; } return ( {isSkinToneInPreview ? : null} ); } export function PreviewBody() { const previewConfig = usePreviewConfig(); const [previewEmoji, setPreviewEmoji] = useState(null); const emojiStyle = useEmojiStyleConfig(); const [variationPickerEmoji] = useEmojiVariationPickerState(); const getEmojiUrl = useGetEmojiUrlConfig(); useEmojiPreviewEvents(previewConfig.showPreview, setPreviewEmoji); const emoji = emojiByUnified(previewEmoji?.originalUnified); const show = emoji != null && previewEmoji != null; return ; function PreviewContent() { const defaultEmoji = variationPickerEmoji ?? emojiByUnified(previewConfig.defaultEmoji) if (!defaultEmoji) { return null } const defaultText = variationPickerEmoji ? emojiName(variationPickerEmoji) : previewConfig.defaultCaption; return ( <>
{show ? ( ) : defaultEmoji ? ( ) : null}
{show ? (
{emojiName(emoji)}
) : (
{defaultText}
)} ); } } export type PreviewEmoji = null | { unified: string; originalUnified: string; };