feat: set org landing page background (#471)

* landing page background settings

* translations

* worrked on the reviews

---------

Co-authored-by: Rotimi Best <[email protected]>
This commit is contained in:
Em_Dev
2024-10-05 23:33:09 +01:00
committed by GitHub
co-authored by Rotimi Best
parent 8298a621ea
commit 1ee02cdf3a
11 changed files with 110 additions and 11 deletions
@@ -147,6 +147,21 @@
} }
} }
function getBgImage(settings) {
const { show, image } = settings.header.background || {
show: true,
image: '/images/org-landingpage-banner.jpeg'
};
if (!show) {
return undefined;
}
if (image) {
return `url('${image}')`;
}
}
$: initPlyr(player, $landingPageSettings.header?.banner?.video); $: initPlyr(player, $landingPageSettings.header?.banner?.video);
$: setDefault(org?.landingpage); $: setDefault(org?.landingpage);
</script> </script>
@@ -165,7 +180,15 @@
<main> <main>
<!-- Header Section --> <!-- Header Section -->
{#if $landingPageSettings.header.show} {#if $landingPageSettings.header.show}
<header id="header" class="banner w-full h-[100vh] md:h-[90vh] mb-10 relative"> <header
id="header"
class={`w-full h-[100vh] md:h-[90vh] mb-10 relative ${
$landingPageSettings.header.background.show
? 'bg-cover bg-center'
: 'border-b border-gray-300'
}`}
style="background-image: {getBgImage($landingPageSettings)}"
>
<Navigation <Navigation
logo={org.avatar_url} logo={org.avatar_url}
orgName={org.name} orgName={org.name}
@@ -585,13 +608,3 @@
{/if} {/if}
</main> </main>
{/if} {/if}
<style>
.banner {
background: url('/images/org-landingpage-banner.jpeg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
</style>
@@ -109,6 +109,10 @@
landingpage.header.banner = $landingPageSettings.header.banner; landingpage.header.banner = $landingPageSettings.header.banner;
} }
if (!landingpage?.header?.background) {
landingpage.header.background = $landingPageSettings.header.background;
}
$landingPageSettings = { $landingPageSettings = {
...landingpage ...landingpage
}; };
@@ -218,6 +222,39 @@
{#if $handleOpenWidget.open && widgetKey === 'banner'} {#if $handleOpenWidget.open && widgetKey === 'banner'}
<UploadWidget bind:imageURL={$landingPageSettings.header.banner.image} /> <UploadWidget bind:imageURL={$landingPageSettings.header.banner.image} />
{/if} {/if}
<!-- background -->
<div class="mt-4">
<p class="font-bold mb-4">{$t('settings.landing_page.background.title')}</p>
<PrimaryButton
variant={VARIANTS.OUTLINED}
label={$t('settings.landing_page.about.select_image')}
className="mt-3"
onClick={() => widgetControl('background')}
/>
{#if $landingPageSettings.header.background?.image}
<img
alt="backgroundImage"
src={$landingPageSettings.header.background.image}
class="mt-2 rounded-md w-full"
/>
{/if}
<Toggle bind:toggled={$landingPageSettings.header.background.show} size="sm">
<span slot="labelA" style="color: gray"
>{$t('settings.landing_page.background.hide_background')}</span
>
<span slot="labelB" style="color: gray"
>{$t('settings.landing_page.background.show_background')}</span
>
</Toggle>
{#if $handleOpenWidget.open && widgetKey === 'background'}
<UploadWidget bind:imageURL={$landingPageSettings.header.background.image} />
{/if}
</div>
</Column> </Column>
</Row> </Row>
@@ -17,6 +17,10 @@ export interface OrgLandingPageJson {
type: string; type: string;
show: boolean; show: boolean;
}; };
background?: {
image: string;
show: boolean;
};
show: boolean; show: boolean;
}; };
aboutUs: { aboutUs: {
@@ -81,6 +85,10 @@ export const landingPageSettings: Writable<OrgLandingPageJson> = writable({
type: 'video', type: 'video',
show: true show: true
}, },
background: {
image: '',
show: true
},
show: true show: true
}, },
aboutUs: { aboutUs: {
@@ -1218,6 +1218,11 @@
"video": "Video", "video": "Video",
"image": "Bild" "image": "Bild"
} }
},
"background": {
"title": "Hintergrundbild",
"show_background": "Hintergrund anzeigen",
"hide_background": "Hintergrund ausblenden"
} }
}, },
"organization": { "organization": {
@@ -128,6 +128,11 @@
"title": "Title", "title": "Title",
"title_highlight": "Title-Highlight", "title_highlight": "Title-Highlight",
"subtitle": "Subtitle", "subtitle": "Subtitle",
"background": {
"title": "Background Image",
"show_background": "Show background",
"hide_background": "Hide background"
},
"actions": { "actions": {
"heading": "Actions", "heading": "Actions",
"label": "Label", "label": "Label",
@@ -139,6 +144,7 @@
"video": "Video", "video": "Video",
"image": "Image" "image": "Image"
}, },
"show_banner": "Show banner", "show_banner": "Show banner",
"hide_banner": "Hide banner" "hide_banner": "Hide banner"
}, },
@@ -1218,6 +1218,11 @@
"video": "Video", "video": "Video",
"image": "Imagen" "image": "Imagen"
} }
},
"background": {
"title": "Imagen de fondo",
"show_background": "Mostrar fondo",
"hide_background": "Ocultar fondo"
} }
}, },
"organization": { "organization": {
@@ -1218,6 +1218,11 @@
"video": "Vidéo", "video": "Vidéo",
"image": "Image" "image": "Image"
} }
},
"background": {
"title": "Image d'arrière-plan",
"show_background": "Afficher l'arrière-plan",
"hide_background": "Masquer l'arrière-plan"
} }
}, },
"organization": { "organization": {
@@ -1218,6 +1218,11 @@
"video": "वीडियो", "video": "वीडियो",
"image": "छवि" "image": "छवि"
} }
},
"background": {
"title": "पृष्ठभूमि छवि",
"show_background": "पृष्ठभूमि दिखाएँ",
"hide_background": "पृष्ठभूमि छिपाएँ"
} }
}, },
"organization": { "organization": {
@@ -1218,6 +1218,11 @@
"video": "Vídeo", "video": "Vídeo",
"image": "Imagem" "image": "Imagem"
} }
},
"background": {
"title": "Imagem de fundo",
"show_background": "Mostrar plano de fundo",
"hide_background": "Ocultar plano de fundo"
} }
}, },
"organization": { "organization": {
@@ -1218,6 +1218,11 @@
"video": "видео", "video": "видео",
"image": "Изображение" "image": "Изображение"
} }
},
"background": {
"title": "Фоновое изображение",
"show_background": "Показать фон",
"hide_background": "Скрыть фон"
} }
}, },
"organization": { "organization": {
@@ -1218,6 +1218,11 @@
"video": "Băng hình", "video": "Băng hình",
"image": "Hình ảnh" "image": "Hình ảnh"
} }
},
"background": {
"title": "Hình nền",
"show_background": "Hiển thị nền",
"hide_background": "Ẩn nền"
} }
}, },
"organization": { "organization": {