add cover image upload

This commit is contained in:
SethBurkart123
2024-04-05 13:16:03 +11:00
parent c7e7b41ce9
commit f30eec8f9e
2 changed files with 28 additions and 1 deletions
+25 -1
View File
@@ -19,6 +19,8 @@ function ThemeCreator() {
allowBackgrounds: true, allowBackgrounds: true,
CustomCSS: '', CustomCSS: '',
CustomImages: [], CustomImages: [],
coverImage: null,
isEditable: true
}); });
useEffect(() => { useEffect(() => {
@@ -154,7 +156,7 @@ function ThemeCreator() {
</div> </div>
<div> <div>
<div className='pb-2 text-sm'>Description <span className='italic opacity-80'>(optional)</span></div> <div className='pb-2 text-sm'>Description <span className='italic font-light opacity-80'>(optional)</span></div>
<textarea <textarea
id='themeDescription' id='themeDescription'
placeholder="Don't worry, this one's optional!" placeholder="Don't worry, this one's optional!"
@@ -163,6 +165,28 @@ function ThemeCreator() {
className='w-full p-2 rounded-lg focus:outline-none ring-0 focus:ring-1 ring-zinc-100 dark:ring-zinc-700 dark:bg-zinc-900 dark:text-white' /> className='w-full p-2 rounded-lg focus:outline-none ring-0 focus:ring-1 ring-zinc-100 dark:ring-zinc-700 dark:bg-zinc-900 dark:text-white' />
</div> </div>
<Divider />
<p className='pr-2 text-sm font-semibold'>Cover Image <span className='italic font-light opacity-80'>(optional)</span></p>
<p className='pb-3 text-sm'>Upload an image to use as the cover image for your theme. <span className='italic font-light'>Recommended resolution: 348x64</span></p>
<div className="relative flex justify-center w-full h-32 gap-1 overflow-hidden transition rounded-lg place-items-center bg-zinc-100 dark:bg-zinc-900">
<PlusIcon height={18} />
<span className='dark:text-white'>Add cover image</span>
<input type="file" accept='image/*' onChange={(e) => {
const file = e.target.files?.[0];
e.target.value = '';
if (file) {
const reader = new FileReader();
reader.onload = async () => {
const imageBlob = await fetch(reader.result as string).then(res => res.blob());
setTheme({ ...theme, coverImage: imageBlob });
};
reader.readAsDataURL(file);
}
}} className="absolute inset-0 w-full h-full opacity-0 cursor-pointer" />
</div>
<div className='flex items-center justify-between pt-4'> <div className='flex items-center justify-between pt-4'>
<div> <div>
<div className='pr-2 text-sm font-semibold'>Custom Theme Colour</div> <div className='pr-2 text-sm font-semibold'>Custom Theme Colour</div>
+3
View File
@@ -7,6 +7,8 @@ export type CustomTheme = {
allowBackgrounds: boolean; allowBackgrounds: boolean;
CustomCSS: string; CustomCSS: string;
CustomImages: CustomImage[]; CustomImages: CustomImage[];
coverImage: Blob | null;
isEditable: boolean;
} }
export type CustomImage = { export type CustomImage = {
@@ -23,6 +25,7 @@ export type CustomImageBase64 = {
export type CustomThemeBase64 = Omit<CustomTheme, 'CustomImages'> & { export type CustomThemeBase64 = Omit<CustomTheme, 'CustomImages'> & {
CustomImages: CustomImageBase64[]; CustomImages: CustomImageBase64[];
coverImage: string | null;
} }
export type ThemeList = { export type ThemeList = {