Adds logo support with masking.
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
title: 'Hello World !!'
|
title: 'Hello World !!'
|
||||||
subtitle: 'actually, I am a new pilot.'
|
subtitle: 'actually, I am a new pilot.'
|
||||||
|
logo: 'icon-any.svg'
|
||||||
|
asmask: true
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- title: '/Cloud'
|
- title: '/Cloud'
|
||||||
|
|||||||
40
src/lib/components/Brand.svelte
Normal file
40
src/lib/components/Brand.svelte
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { BrandConfig } from '$lib/config';
|
||||||
|
|
||||||
|
export let brand: BrandConfig = {};
|
||||||
|
export let size = 48;
|
||||||
|
console.log(brand);
|
||||||
|
|
||||||
|
function masked() {
|
||||||
|
return brand.logo != undefined && brand.asmask == true;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="logo container"
|
||||||
|
style="--size: {size}px; --mask: url({brand.logo || ''})"
|
||||||
|
class:masked={masked()}
|
||||||
|
>
|
||||||
|
{#if brand.logo}
|
||||||
|
{#if brand.asmask != true}
|
||||||
|
<img src={brand.logo} alt="logo" />
|
||||||
|
{/if}
|
||||||
|
{:else if brand.icon}
|
||||||
|
<p>an icon</p>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.container {
|
||||||
|
width: var(--size);
|
||||||
|
height: var(--size);
|
||||||
|
}
|
||||||
|
|
||||||
|
.masked {
|
||||||
|
background: black;
|
||||||
|
mask: var(--mask) center no-repeat;
|
||||||
|
mask-size: var(--size);
|
||||||
|
-webkit-mask: var(--mask) center no-repeat;
|
||||||
|
-webkit-mask-size: var(--size);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
export interface BrandConfig {
|
export interface BrandConfig {
|
||||||
logo?: string;
|
logo?: string;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
usemask?: boolean;
|
asmask?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SectionConfig extends BrandConfig {
|
export interface SectionConfig extends BrandConfig {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const requiredService: Required<ServiceConfig> = {
|
|||||||
subtitle: '',
|
subtitle: '',
|
||||||
logo: '',
|
logo: '',
|
||||||
icon: '',
|
icon: '',
|
||||||
usemask: false,
|
asmask: false,
|
||||||
url: '',
|
url: '',
|
||||||
target: '',
|
target: '',
|
||||||
type: ''
|
type: ''
|
||||||
@@ -20,7 +20,7 @@ const requiredServiceGroup: Required<ServiceGroupConfig> = {
|
|||||||
subtitle: '',
|
subtitle: '',
|
||||||
logo: '',
|
logo: '',
|
||||||
icon: '',
|
icon: '',
|
||||||
usemask: false,
|
asmask: false,
|
||||||
items: [requiredService]
|
items: [requiredService]
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ export const requiredConfig: Required<Config> = {
|
|||||||
subtitle: '',
|
subtitle: '',
|
||||||
logo: '',
|
logo: '',
|
||||||
icon: '',
|
icon: '',
|
||||||
usemask: false,
|
asmask: false,
|
||||||
services: [requiredServiceGroup]
|
services: [requiredServiceGroup]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import Brand from '$lib/components/Brand.svelte';
|
||||||
import ServiceGroup from '$lib/components/ServiceGroup.svelte';
|
import ServiceGroup from '$lib/components/ServiceGroup.svelte';
|
||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h1>{data.config.title}</h1>
|
<header>
|
||||||
{#if data.config.subtitle}
|
<Brand brand={data.config} />
|
||||||
<h2>{data.config.subtitle}</h2>
|
<h1>{data.config.title}</h1>
|
||||||
{/if}
|
{#if data.config.subtitle}
|
||||||
|
<h2>{data.config.subtitle}</h2>
|
||||||
|
{/if}
|
||||||
|
</header>
|
||||||
{#each data.config.services as group, i}
|
{#each data.config.services as group, i}
|
||||||
<ServiceGroup {group} groupData={data.serviceData[i]} />
|
<ServiceGroup {group} groupData={data.serviceData[i]} />
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
Reference in New Issue
Block a user