Skip to content

Commit

Permalink
Merge pull request #63 from greybaron/fix/random-stuff
Browse files Browse the repository at this point in the history
Fix/random stuff
  • Loading branch information
fnschmidt authored Aug 8, 2024
2 parents 02f2a02 + 627fe01 commit b12e303
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
15 changes: 14 additions & 1 deletion src/lib/DashboardModal.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { onMount, type SvelteComponent } from 'svelte';
import { onDestroy, onMount, type SvelteComponent } from 'svelte';
export let title: string;
export let parent: SvelteComponent;
Expand All @@ -11,6 +11,19 @@
onMount(() => {
closeButton.blur();
});
const htmlElement = document.documentElement;
const themeColorMeta = document.querySelector('meta[name="theme-color"]');
onMount(() => {
const isDarkMode = htmlElement.classList.contains('dark');
themeColorMeta?.setAttribute('content', isDarkMode ? 'rgb(23,23,23)' : 'rgb(139,139,139)');
});
onDestroy(() => {
const isDarkMode = htmlElement.classList.contains('dark');
themeColorMeta?.setAttribute('content', isDarkMode ? 'rgb(27,27,27)' : 'rgb(213,213,217)');
});
</script>

<div
Expand Down
14 changes: 14 additions & 0 deletions src/lib/cc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { browser } from '$app/environment';

export async function load_cc() {
if (browser) {
try {
const CookieConsent = await import('vanilla-cookieconsent');
const config = (await import('$lib/cookieconsent-config')).default;

CookieConsent.run(config);
} catch (error) {
console.warn('Failed to load cookieconsent (likely due to content filter)');
}
}
}
9 changes: 0 additions & 9 deletions src/lib/cookieconsent.svelte

This file was deleted.

13 changes: 9 additions & 4 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
}
const drawerStore = getDrawerStore();
import CookieConsentComponent from '$lib/cookieconsent.svelte';
import { load_cc } from '$lib/cc';
load_cc();
const popupRechtliches: PopupSettings = {
// Represents the type of event that opens/closed the popup
Expand Down Expand Up @@ -66,7 +66,6 @@
</div>
</div>

<CookieConsentComponent />
<Toast buttonDismiss="btn-icon btn-icon-sm variant-filled transition-none" />

<Drawer
Expand Down Expand Up @@ -147,7 +146,13 @@
{#if $page.url.pathname == '/impressum' || $page.url.pathname == '/datenschutz'}
<button
on:click={async () => {
goto('/');
const response = await fetch('/');

if (response.redirected) {
window.location.href = response.url;
} else {
goto('/');
}
}}
class="h-6 btn btn-sm variant-ghost-secondary text-xs"
>
Expand Down

0 comments on commit b12e303

Please sign in to comment.