mirror of
https://github.com/nikdoof/pocket-id.git
synced 2025-12-14 15:22:18 +00:00
feat!: add ability to set light and dark mode logo
This commit is contained in:
@@ -28,17 +28,19 @@
|
||||
}
|
||||
|
||||
async function updateImages(
|
||||
logo: File | null,
|
||||
logoLight: File | null,
|
||||
logoDark: File | null,
|
||||
backgroundImage: File | null,
|
||||
favicon: File | null
|
||||
) {
|
||||
const faviconPromise = favicon ? appConfigService.updateFavicon(favicon) : Promise.resolve();
|
||||
const logoPromise = logo ? appConfigService.updateLogo(logo) : Promise.resolve();
|
||||
const lightLogoPromise = logoLight ? appConfigService.updateLogo(logoLight, true) : Promise.resolve();
|
||||
const darkLogoPromise = logoDark ? appConfigService.updateLogo(logoDark, false) : Promise.resolve();
|
||||
const backgroundImagePromise = backgroundImage
|
||||
? appConfigService.updateBackgroundImage(backgroundImage)
|
||||
: Promise.resolve();
|
||||
|
||||
await Promise.all([logoPromise, backgroundImagePromise, faviconPromise])
|
||||
await Promise.all([lightLogoPromise, darkLogoPromise, backgroundImagePromise, faviconPromise])
|
||||
.then(() => toast.success('Images updated successfully'))
|
||||
.catch(axiosErrorToast);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
image = $bindable(),
|
||||
imageURL,
|
||||
accept = 'image/png, image/jpeg, image/svg+xml',
|
||||
forceColorScheme,
|
||||
...restProps
|
||||
}: HTMLAttributes<HTMLDivElement> & {
|
||||
id: string;
|
||||
@@ -18,6 +19,7 @@
|
||||
label: string;
|
||||
image: File | null;
|
||||
imageURL: string;
|
||||
forceColorScheme?: 'light' | 'dark';
|
||||
accept?: string;
|
||||
} = $props();
|
||||
|
||||
@@ -37,10 +39,16 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<div {...restProps}>
|
||||
<Label for={id}>{label}</Label>
|
||||
<div class="flex flex-col items-start md:flex-row md:items-center" {...restProps}>
|
||||
<Label class="w-52" for={id}>{label}</Label>
|
||||
<FileInput {id} variant="secondary" {accept} onchange={onImageChange}>
|
||||
<div class="bg-muted group relative flex items-center rounded">
|
||||
<div
|
||||
class="{forceColorScheme === 'light'
|
||||
? 'bg-[#F1F1F5]'
|
||||
: forceColorScheme === 'dark'
|
||||
? 'bg-[#27272A]'
|
||||
: 'bg-muted'} group relative flex items-center rounded"
|
||||
>
|
||||
<img
|
||||
class={cn(
|
||||
'h-full w-full rounded object-cover p-3 transition-opacity duration-200 group-hover:opacity-10',
|
||||
|
||||
@@ -5,15 +5,21 @@
|
||||
let {
|
||||
callback
|
||||
}: {
|
||||
callback: (logo: File | null, backgroundImage: File | null, favicon: File | null) => void;
|
||||
callback: (
|
||||
logoLight: File | null,
|
||||
logoDark: File | null,
|
||||
backgroundImage: File | null,
|
||||
favicon: File | null
|
||||
) => void;
|
||||
} = $props();
|
||||
|
||||
let logo = $state<File | null>(null);
|
||||
let logoLight = $state<File | null>(null);
|
||||
let logoDark = $state<File | null>(null);
|
||||
let backgroundImage = $state<File | null>(null);
|
||||
let favicon = $state<File | null>(null);
|
||||
</script>
|
||||
|
||||
<div class="application-images-grid">
|
||||
<div class="flex flex-col gap-8">
|
||||
<ApplicationImage
|
||||
id="favicon"
|
||||
imageClass="h-14 w-14 p-2"
|
||||
@@ -23,15 +29,23 @@
|
||||
accept="image/x-icon"
|
||||
/>
|
||||
<ApplicationImage
|
||||
id="logo"
|
||||
id="logo-light"
|
||||
imageClass="h-32 w-32"
|
||||
label="Logo"
|
||||
bind:image={logo}
|
||||
imageURL="/api/application-configuration/logo"
|
||||
label="Light Mode Logo"
|
||||
bind:image={logoLight}
|
||||
imageURL="/api/application-configuration/logo?light=true"
|
||||
forceColorScheme="light"
|
||||
/>
|
||||
<ApplicationImage
|
||||
id="logo-dark"
|
||||
imageClass="h-32 w-32"
|
||||
label="Dark Mode Logo"
|
||||
bind:image={logoDark}
|
||||
imageURL="/api/application-configuration/logo?light=false"
|
||||
forceColorScheme="dark"
|
||||
/>
|
||||
<ApplicationImage
|
||||
id="background-image"
|
||||
class="basis-full lg:basis-auto"
|
||||
imageClass="h-[350px] max-w-[500px]"
|
||||
label="Background Image"
|
||||
bind:image={backgroundImage}
|
||||
@@ -39,5 +53,7 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<Button class="mt-5" onclick={() => callback(logo, backgroundImage, favicon)}>Save</Button>
|
||||
<Button class="mt-5" onclick={() => callback(logoLight, logoDark, backgroundImage, favicon)}
|
||||
>Save</Button
|
||||
>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user