From 28e118c5ecfc4419a6dba17b3192721df128ffed Mon Sep 17 00:00:00 2001 From: Alexandre Tuleu Date: Mon, 14 Aug 2023 21:38:34 +0200 Subject: [PATCH] Makes the navbar and layout clicks --- src/app.scss | 137 ++++++++++++------- src/config.yml | 31 ++++- src/lib/components/Brand.svelte | 29 ++-- src/lib/components/Header.svelte | 54 ++++++++ src/lib/components/LayoutButton.svelte | 19 +++ src/lib/components/ServiceCard.svelte | 10 +- src/lib/components/ServiceGroup.svelte | 9 +- src/lib/components/ThemeVariantButton.svelte | 20 ++- src/lib/config.ts | 7 + src/lib/server/config.ts | 20 ++- src/lib/stores/layout.ts | 6 + src/lib/{ => stores}/themeVariant.ts | 2 +- src/routes/+layout.svelte | 2 +- src/routes/+page.svelte | 54 +++----- 14 files changed, 270 insertions(+), 130 deletions(-) create mode 100644 src/lib/components/Header.svelte create mode 100644 src/lib/components/LayoutButton.svelte create mode 100644 src/lib/stores/layout.ts rename src/lib/{ => stores}/themeVariant.ts (71%) diff --git a/src/app.scss b/src/app.scss index fab11ac..471b1e2 100644 --- a/src/app.scss +++ b/src/app.scss @@ -12,21 +12,21 @@ body { background-position: center; color: var(--text); transition: background-color cubic-bezier(0.165, 0.84, 0.44, 1) 300ms; +} - a { - color: var(--link); - &:hover { - color: var(--link-hover); - } +a { + color: var(--link); + &:hover { + color: var(--link-hover); } +} - .title { - color: var(--text-title); - } +.title { + color: var(--text-title); +} - .subtitle { - color: var(--text-subtitle); - } +.subtitle { + color: var(--text-subtitle); } h1 { @@ -37,69 +37,50 @@ h2 { font-size: 1.7rem; margin-top: 2rem; margin-bottom: 1rem; - - .fas, - .fab, - .far { - margin-right: 10px; - } - - span { - font-weight: bold; - color: var(--highlight-secondary); - } } header { color: var(--text-header); - - .dashboard-title { - padding-left: 16px; - } - .first-line { + background-color: var(--highlight-primary); + .container { + padding-top: 24px; display: flex; flex-flow: row wrap; align-items: center; + gap: 16px; } - min-height: 100px; - background-color: var(--highlight-primary); + min-height: 104px; - h1 { - margin-top: -12px; - font-size: 2rem; - } - .headline { - font-size: 0.9rem; - height: min-content; - } - - .container { - min-height: 80px; - padding: 10px 0; - } .logo { - i { - vertical-align: top; - padding: 8px 15px; - font-size: 48px; + width: 48px; + height: 48px; + } + + .dashboard-title { + display: flex; + flex-flow: column wrap; + justify-content: space-between; + height: 48px; + h2 { + font-size: 0.9em; + line-height: 1em; } - img { - max-height: 70px; - max-width: 70px; + h1 { + font-size: 2em; + line-height: 1em; } } } - .navbar { + nav.navbar { background-color: var(--highlight-secondary); a { color: var(--text-header); - padding: 8px 12px; &:hover, &:focus { @@ -108,12 +89,62 @@ header { } } + .navbar-item { + .link-label { + margin-left: 8px; + } + padding: 8px 16px; + } + + .navbar-item:first-child { + margin-left: -16px; + } + + .navbar-item input { + width: 160px; + transition: width cubic-bezier(0.165, 0.84, 0.44, 1) 300ms; + } + + .navbar-item input:focus { + width: 240px; + } + .navbar-menu { background-color: inherit; } } +} - .navbar-end { - text-align: right; +main { + .layout-column { + display: grid; + grid-template-columns: var(--layout-template); + gap: 32px; + } + + .layout-row { + display: flex; + flex-flow: column nowrap; + gap: 32px; + } + + .service-group { + background: lime; + } + + .service-group.layout-column { + display: flex; + flex-flow: column nowrap; + gap: 16px; + } + + .service-group.layout-row { + display: grid; + grid-template-columns: var(--layout-template); + gap: 16px; + } + + .service-card { + background: orange; } } diff --git a/src/config.yml b/src/config.yml index 989cad9..37eeb78 100644 --- a/src/config.yml +++ b/src/config.yml @@ -4,9 +4,13 @@ logo: 'icon-any.svg' icon: 'fa fa-cloud' asmask: true -colors: - dark: - test: red +links: + - title: 'Cloud' + icon: 'fa fa-cloud' + url: 'https://example.com' + - title: 'Hard drive' + icon: 'fa fa-hard-drive' + url: 'https://example.com' services: - title: '/Cloud' @@ -29,3 +33,24 @@ services: url: '/pihole' type: 'pihole' keywords: 'cloud storage files' + + - title: '/Cloud' + subtitle: 'Private Cloud Utilities' + icon: 'fas fa-cloud' + items: + - title: 'NAS' + subtitle: 'Network Attached Storage' + icon: 'fas fa-hard-drive' + target: '_blank' + url: '/NAS' + type: prowlarr + + keywords: 'cloud storage files' + + - title: 'PiHole' + subtitle: 'A DNS Hole' + icon: 'fas fa-hard-drive' + target: '_blank' + url: '/pihole' + type: 'pihole' + keywords: 'cloud storage files' diff --git a/src/lib/components/Brand.svelte b/src/lib/components/Brand.svelte index 7d7d170..5e25ee2 100644 --- a/src/lib/components/Brand.svelte +++ b/src/lib/components/Brand.svelte @@ -2,7 +2,6 @@ import type { BrandConfig } from '$lib/config'; export let brand: BrandConfig = {}; - export let size = 48; export let color = 'var(--text)'; console.log(brand); @@ -11,11 +10,7 @@ } -
+
{#if brand.logo} {#if brand.asmask != true} logo @@ -26,25 +21,21 @@
diff --git a/src/lib/components/Header.svelte b/src/lib/components/Header.svelte new file mode 100644 index 0000000..9f23bf5 --- /dev/null +++ b/src/lib/components/Header.svelte @@ -0,0 +1,54 @@ + + +
+
+
+ +
+ {#if section.subtitle} +

{section.subtitle}

+ {/if} +

{section.title}

+
+
+
+ +
diff --git a/src/lib/components/LayoutButton.svelte b/src/lib/components/LayoutButton.svelte new file mode 100644 index 0000000..5fef59a --- /dev/null +++ b/src/lib/components/LayoutButton.svelte @@ -0,0 +1,19 @@ + + + + {#if $layoutDirection == 'column'} + + {:else} + + {/if} + diff --git a/src/lib/components/ServiceCard.svelte b/src/lib/components/ServiceCard.svelte index 1f78ec1..ebf6673 100644 --- a/src/lib/components/ServiceCard.svelte +++ b/src/lib/components/ServiceCard.svelte @@ -8,7 +8,9 @@ const component = getServiceComponent(service.type || ''); -

{service.title}

-{#if component != undefined} - -{/if} +
+

{service.title}

+ {#if component != undefined} + + {/if} +
diff --git a/src/lib/components/ServiceGroup.svelte b/src/lib/components/ServiceGroup.svelte index ed26ae7..6c375d7 100644 --- a/src/lib/components/ServiceGroup.svelte +++ b/src/lib/components/ServiceGroup.svelte @@ -1,11 +1,14 @@ -{#each group.items as service, i} - -{/each} +
+ {#each group.items as service, i} + + {/each} +
diff --git a/src/lib/components/ThemeVariantButton.svelte b/src/lib/components/ThemeVariantButton.svelte index 6ab2f0f..024f2e5 100644 --- a/src/lib/components/ThemeVariantButton.svelte +++ b/src/lib/components/ThemeVariantButton.svelte @@ -1,5 +1,5 @@ - - - {#if $themeVariant == 'default'} - - {:else if $themeVariant == 'light'} - - {:else if $themeVariant == 'dark'} - - {/if} - + + {#if $themeVariant == 'default'} + + {:else if $themeVariant == 'light'} + + {:else if $themeVariant == 'dark'} + + {/if} diff --git a/src/lib/config.ts b/src/lib/config.ts index 8f267e8..027b904 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -9,6 +9,10 @@ export interface SectionConfig extends BrandConfig { subtitle?: string; } +export interface LinkConfig extends SectionConfig { + url: string; +} + export interface ServiceConfig extends SectionConfig { url: string; target?: string; @@ -28,10 +32,13 @@ export type ColorConfig = Record; export interface Config extends SectionConfig { services: Array; + columns: number; colors: { light: ColorConfig; dark: ColorConfig; }; + links: Array; + [x: string]: unknown; } diff --git a/src/lib/server/config.ts b/src/lib/server/config.ts index 3e1410a..e5f4f6a 100644 --- a/src/lib/server/config.ts +++ b/src/lib/server/config.ts @@ -1,7 +1,13 @@ import configData from '../../config.yml'; import { readFile, watch } from 'fs/promises'; import * as yml from 'js-yaml'; -import type { ColorConfig, Config, ServiceConfig, ServiceGroupConfig } from '$lib/config'; +import type { + ColorConfig, + Config, + LinkConfig, + ServiceConfig, + ServiceGroupConfig +} from '$lib/config'; const requiredService: Required = { title: '', @@ -23,16 +29,27 @@ const requiredServiceGroup: Required = { items: [requiredService] }; +const requiredLink: Required = { + title: '', + subtitle: '', + logo: '', + icon: '', + asmask: false, + url: '' +}; + export const requiredConfig: Required = { title: '', subtitle: '', logo: '', icon: '', asmask: false, + columns: 3, colors: { light: {}, dark: {} }, + links: [requiredLink], services: [requiredServiceGroup] }; @@ -95,6 +112,7 @@ defaultDarkConfig['background-image'] = ''; export const defaultConfig: Config = { title: 'Flanders', + columns: 3, colors: { light: defaultLightConfig, dark: defaultDarkConfig diff --git a/src/lib/stores/layout.ts b/src/lib/stores/layout.ts new file mode 100644 index 0000000..8da1c15 --- /dev/null +++ b/src/lib/stores/layout.ts @@ -0,0 +1,6 @@ +import { persistentWritable } from '$lib/persistentStore'; +import type { Writable } from 'svelte/store'; + +export type LayoutDirection = 'column' | 'row'; + +export const layoutDirection: Writable = persistentWritable('layout', 'column'); diff --git a/src/lib/themeVariant.ts b/src/lib/stores/themeVariant.ts similarity index 71% rename from src/lib/themeVariant.ts rename to src/lib/stores/themeVariant.ts index 5e7a7ed..5a25402 100644 --- a/src/lib/themeVariant.ts +++ b/src/lib/stores/themeVariant.ts @@ -1,4 +1,4 @@ -import { persistentWritable } from './persistentStore'; +import { persistentWritable } from '$lib/persistentStore'; export type ThemeVariant = 'default' | 'dark' | 'light'; diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index c848f11..ab732be 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -3,7 +3,7 @@ import 'bulma/css/bulma.min.css'; import '@fortawesome/fontawesome-free/css/all.min.css'; - import { themeVariant } from '$lib/themeVariant'; + import { themeVariant } from '$lib/stores/themeVariant'; import { browser } from '$app/environment'; $: { if (browser) { diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index ad31de1..e711dc9 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,13 +1,14 @@ @@ -40,35 +44,17 @@ - {@html renderColorVariables()} + {@html renderCssVariables()} -
-
-
- -
- {#if data.config.subtitle} - {data.config.subtitle} - {/if} -

{data.config.title}

-
-
-
- -
+
- {#each data.config.services as group, i} - - {/each} +
+ {#each data.config.services as group, i} + + {/each} +
+ +