import { imgur } from '@blitzkit/core'; import { CodeIcon, HeightIcon, ImageIcon, ResetIcon, TimerIcon, WidthIcon, } from '@radix-ui/react-icons'; import { Box, Button, Flex, Heading, ScrollArea, Text } from '@radix-ui/themes'; import { useEffect, useRef, useState, type ReactNode } from 'react'; import { CopyButton } from '../../../../../components/CopyButton'; import { Boolean } from '../../../../../components/Embeds/Boolean'; import { Color } from '../../../../../components/Embeds/Color'; import { Enum } from '../../../../../components/Embeds/Enum'; import { GenerateURL } from '../../../../../components/Embeds/GenerateURL'; import { Import } from '../../../../../components/Embeds/Import'; import { PreviewWrapper } from '../../../../../components/Embeds/PreviewWrapper'; import { Radius } from '../../../../../components/Embeds/Radius'; import { RichText } from '../../../../../components/Embeds/RichText'; import { Size } from '../../../../../components/Embeds/Size'; import { SizeWithout0 } from '../../../../../components/Embeds/SizeWithout0'; import { Slider } from '../../../../../components/Embeds/Slider'; import { TextController } from '../../../../../components/Embeds/TextController'; import { PageWrapper } from '../../../../../components/PageWrapper'; import { embedConfigurations, extractEmbedConfigDefaults, } from '../../../../../constants/embeds'; import { NAVBAR_HEIGHT } from '../../../../../constants/navbar'; import { LocaleProvider, useLocale, type LocaleAcceptorProps, } from '../../../../../hooks/useLocale'; import { App } from '../../../../../stores/app'; import { EmbedState, type EmbedConfig } from '../../../../../stores/embedState'; import { EmbedItemType } from '../../../../../stores/embedState/constants'; export interface EmbedPreviewControllerProps { configKey: string; } interface PageProps { embed: keyof typeof embedConfigurations; } export function Page({ embed, locale }: PageProps & LocaleAcceptorProps) { const config = embedConfigurations[embed]; return ( ); } function Content({ embed }: PageProps) { const embedStateStore = EmbedState.useStore(); const config = embedConfigurations[embed] as EmbedConfig; const [backgroundImage, setBackgroundImage] = useState( imgur('SO13zur', { format: 'jpeg' }), ); const fileInput = useRef(); const { strings } = useLocale(); useEffect(() => { fileInput.current = document.createElement('input'); fileInput.current.type = 'file'; fileInput.current.style.display = 'none'; fileInput.current.accept = 'image/*'; fileInput.current.onchange = (event) => { const file = (event.target as HTMLInputElement).files?.[0]; if (!file) return; setBackgroundImage(URL.createObjectURL(file)); }; }, []); return ( {strings.website.tools.embed.configuration.export.title} {strings.website.tools.embed.configuration.export.description} 'body { margin: 0; background-color: transparent; overflow: hidden; }' } > {strings.website.tools.embed.configuration.export.css} `${embedStateStore.getState().width}`} > {strings.website.tools.embed.configuration.export.width} `${embedStateStore.getState().height}`} > {strings.website.tools.embed.configuration.export.height} '1'}> {strings.website.tools.embed.configuration.export.framerate} {strings.website.tools.embed.configuration.customize.title} {strings.website.tools.embed.configuration.customize.description} {Object.keys(config).map((configKey) => { const item = config[configKey]; let control: ReactNode; let oneLiner = false; switch (item.type) { case EmbedItemType.Boolean: { control = ; oneLiner = true; break; } case EmbedItemType.Color: { control = ; break; } case EmbedItemType.Radius: { control = ; oneLiner = true; break; } case EmbedItemType.Size: { control = ; oneLiner = true; break; } case EmbedItemType.SizeWithout0: { control = ; oneLiner = true; break; } case EmbedItemType.Slider: { control = ; oneLiner = true; break; } case EmbedItemType.String: { control = ; break; } case EmbedItemType.RichText: { control = ; break; } case EmbedItemType.Enum: { control = ; oneLiner = true; break; } } return ( { ( strings.website.tools.embed.types[embed] .options as Record )[configKey] } {control} ); })} {strings.website.tools.embed.preview.title} ); }