From b793c97b4b67155f613465e787e73e69bab176ad Mon Sep 17 00:00:00 2001 From: Jesse Winton Date: Mon, 7 Apr 2025 15:29:09 -0400 Subject: [PATCH] update formatting --- .../product-pages/testimonials.svelte | 2 +- src/lib/components/shared/index.ts | 2 +- src/lib/providers/theme/helpers.ts | 58 +++++++++---------- src/lib/providers/theme/index.ts | 26 ++++----- src/routes/+layout.svelte | 2 +- .../functions/(components)/Platforms.svelte | 2 +- 6 files changed, 44 insertions(+), 48 deletions(-) diff --git a/src/lib/components/product-pages/testimonials.svelte b/src/lib/components/product-pages/testimonials.svelte index d8e15e4ce..29029283e 100644 --- a/src/lib/components/product-pages/testimonials.svelte +++ b/src/lib/components/product-pages/testimonials.svelte @@ -42,7 +42,7 @@
{#each Array.from({ length: 4 }) as _, i}
{#each testimonials as testimonial} diff --git a/src/lib/components/shared/index.ts b/src/lib/components/shared/index.ts index bc8aae154..00f2a7e14 100644 --- a/src/lib/components/shared/index.ts +++ b/src/lib/components/shared/index.ts @@ -1,2 +1,2 @@ -export { default as GithubStats} from './github-stats.svelte'; +export { default as GithubStats } from './github-stats.svelte'; export { default as DiscordLink } from './discord-link.svelte'; diff --git a/src/lib/providers/theme/helpers.ts b/src/lib/providers/theme/helpers.ts index 89f0747d0..c23b65c14 100644 --- a/src/lib/providers/theme/helpers.ts +++ b/src/lib/providers/theme/helpers.ts @@ -1,42 +1,42 @@ import { MEDIA } from './constants'; export const getTheme = (key: string, fallback?: string): string | undefined => { - if (typeof window === 'undefined') return undefined; - let theme: string | undefined = undefined; - try { - theme = localStorage.getItem(key) as string || undefined; - } catch (e) { - // Unsupported - } - return theme || fallback as string; + if (typeof window === 'undefined') return undefined; + let theme: string | undefined = undefined; + try { + theme = (localStorage.getItem(key) as string) || undefined; + } catch (e) { + // Unsupported + } + return theme || (fallback as string); }; export const disableAnimation = () => { - const css = document.createElement('style'); - css.appendChild( - document.createTextNode( - `*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}` - ) - ); - document.head.appendChild(css); + const css = document.createElement('style'); + css.appendChild( + document.createTextNode( + `*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}` + ) + ); + document.head.appendChild(css); - return () => { - // Force restyle - (() => window.getComputedStyle(document.body))(); + return () => { + // Force restyle + (() => window.getComputedStyle(document.body))(); - // Wait for next tick before removing - setTimeout(() => { - document.head.removeChild(css); - }, 1); - }; + // Wait for next tick before removing + setTimeout(() => { + document.head.removeChild(css); + }, 1); + }; }; export const getSystemTheme = (e?: MediaQueryList): string => { - if (!e && typeof window !== 'undefined') { - e = window.matchMedia(MEDIA); - } + if (!e && typeof window !== 'undefined') { + e = window.matchMedia(MEDIA); + } - const isDark = e?.matches; - const systemTheme = isDark ? 'dark' : 'light'; - return systemTheme; + const isDark = e?.matches; + const systemTheme = isDark ? 'dark' : 'light'; + return systemTheme; }; diff --git a/src/lib/providers/theme/index.ts b/src/lib/providers/theme/index.ts index 0c886d5ad..d9887ed06 100644 --- a/src/lib/providers/theme/index.ts +++ b/src/lib/providers/theme/index.ts @@ -1,34 +1,30 @@ +import { writable } from 'svelte/store'; - import { writable } from 'svelte/store'; - - export interface ThemeStore { +export interface ThemeStore { themes: string[]; forcedTheme?: string; theme?: string; resolvedTheme?: string; systemTheme?: string; - } +} - // Create the theme store - export const themeStore = writable({ +// Create the theme store +export const themeStore = writable({ themes: ['light', 'dark'], forcedTheme: undefined, theme: undefined, resolvedTheme: undefined, systemTheme: undefined - }); +}); +export const setTheme = (theme?: string) => themeStore.update((store) => ({ ...store, theme })); - export const setTheme = (theme?: string) => - themeStore.update((store) => ({ ...store, theme })); - - export const setResolvedTheme = (resolvedTheme?: string) => +export const setResolvedTheme = (resolvedTheme?: string) => themeStore.update((store) => ({ ...store, resolvedTheme })); - export const setSystemTheme = (systemTheme?: string) => +export const setSystemTheme = (systemTheme?: string) => themeStore.update((store) => ({ ...store, systemTheme })); - export const setThemes = (themes: string[]) => - themeStore.update((store) => ({ ...store, themes })); +export const setThemes = (themes: string[]) => themeStore.update((store) => ({ ...store, themes })); - export { default as ThemeProvider } from './theme.svelte'; +export { default as ThemeProvider } from './theme.svelte'; diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 3b558b697..2a5082b06 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -200,7 +200,7 @@ Skip to content diff --git a/src/routes/products/functions/(components)/Platforms.svelte b/src/routes/products/functions/(components)/Platforms.svelte index dc52690d8..119b3ab64 100644 --- a/src/routes/products/functions/(components)/Platforms.svelte +++ b/src/routes/products/functions/(components)/Platforms.svelte @@ -32,7 +32,7 @@