From 8d9bb3fac74a35e47b47a87a0ae9c6e12bf8a4c9 Mon Sep 17 00:00:00 2001 From: Esteban Borai Date: Sun, 26 May 2024 21:34:48 -0400 Subject: [PATCH] feat: ui update --- bun.lockb | Bin 123295 -> 123295 bytes src/hooks.server.ts | 19 ++- src/i18n/en/index.ts | 2 +- src/i18n/es/index.ts | 2 +- src/i18n/hu/index.ts | 2 +- src/i18n/i18n-svelte.ts | 22 +++- src/i18n/i18n-types.ts | 193 ++++++++++++++-------------- src/i18n/i18n-util.async.ts | 38 +++--- src/i18n/i18n-util.sync.ts | 32 ++--- src/i18n/i18n-util.ts | 92 ++++++++----- src/lib/components/Header.svelte | 5 +- src/lib/components/Sidebar.svelte | 33 +++-- src/routes/[lang=lang]/+page.svelte | 2 - src/routes/[lang=lang]/+page.ts | 18 +-- 14 files changed, 252 insertions(+), 208 deletions(-) diff --git a/bun.lockb b/bun.lockb index 1041e210efdf6d1430fc9ac367c169755b5853d8..822135c23f3bf8c57cee954f44423ef45fcb652b 100755 GIT binary patch delta 1926 zcmW;AH>{up0EhA1!fi~3k&(rOk&%&+k=qyiBrN}U#stJE=eXkM+8V2{={Iw=llU#pYhh|YC7IZo(auT$WRUZGRs zg8mIU6|NZEs8i#H;Y~UX?ik&y)1q;UI>rvoTXhob(Yj41#R2V7C&Lk)+jVlB(7i*a zz!|+ebxK^&ze}gW6@vqv8aE8@)@g9Z=pLOGjY=J3hvvOH3HE5+r<3A<_We2;j_5p~ zljDT$gE|Gy=sl!U;)4FeIu))M)H*e87#`|0xMTE)PK(AFb&MUFkLo1YqxG0hiUZn@ z>tr~h^Mp>06S|E~firqf>Xf*k|CCOJD+W*N)VN{zj820)M$hWBXgsHmu|xBDodkQd zTAdUJw9o2fIHGe-C&vlh7jz1o(R)#+#0CBHIu))Myrfg(hT+RP4el6qIxQNnsAKHV zd{rmG99BTrqfCr^XG#cXS%uF?v_0 zMdLknj2)UsItlh@y|0tvfc6JE8II@-Iyp}0eyCI6jNV5&B`)ZHtW)8N!6!O3ZWw;5 z)8LNLXF4q!pQ~f+&>VFV?9uu{C&dBnFLg2;(fLXz#|ho9bqbu(`$nh41^sVzDqJ!6 zPN&8V!%3&X9i#7cS~Px8$Jn9yqfUZ7T0iNeIH3KrPKF~ozv$#Rq5G>&firruPKgWp zzv)!CV(`08jT?r4=rp)v^rudX#$W0fJ2d~+Nw7!jSSLL`b#T!I7oPv;`0T&`0XbHw AbpQYW delta 1926 zcmW;AH>{up0Ecm1xQ)p$GP0O3GBPqUavLKfiG$>9*s)`Iik){h?A+-ob}Ub^W5L3Zlo|BmQfqRw$b_fnk#XY?-9DRDvna-9lS z46e|raliBrN}U#stJE=eXkM+8V2{={Iw=llU#pYhh|YC7IZo(auT$WRUZGRs zg8mIU6|NZEs8i#H;Y~UX?ik&y)1q;UI>rvoTXhob(Yj41#R2V7C&Lk)+jVlB(7i*a zz!|+ebxK^&ze}gW6@vqv8aE8@)@g9Z=pLOGjY=J3hvvOH3HE5+r<3A<_We2;j_5p~ zljDT$gE|Gy=sl!U;)4FeIu))M)H*e87#`|0xMOr$r$yrtb&MUFkLo1YqxG0hiUZn@ z>tr~h^Mp>06S|E~firqf>Xf*k|CCOJD+W*N)VN{zj820)M$hWBXgsHmu|xBDodkQd zTAdUJw9n{dIHGe_C&vlh7jz1o(R)#+#0C9xIu))Myrfg(hT+RP4el6qIxQNnsAKHV zd{rmG99BTrqfCr^XG#cXS%uF?v_0 zMdLknj2)UsItlh@y|0tvfc6JE8II@-Iyp}0eyCI6jNV5&B`)ZHtW)8N!6!O3ZWw;5 z)8LNLXF4q!pQ~f+&>VFV?9uu{C&dBnFLg2;(fLXz#|ho9bqbu(`$nh41^sVzDqJ!6 zPN&8V!%3&X9i#7cS~Px8$Jn9yqfUZ7T0iNeIH3KrPKF~ozv$#Rq5G>&firruPKgWp zzv)!CV(`08jT?r4=rp)v^rudX#$W0fJ2d~+Nw7!jSSLL`d2rDM7oPj)_{_im0g7Fy AH~;_u diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 362bf3d3..fa82c498 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -1,12 +1,13 @@ import { detectLocale, i18n, isLocale } from '$i18n/i18n-util'; import { loadAllLocales } from '$i18n/i18n-util.sync'; import type { Handle, RequestEvent } from '@sveltejs/kit'; +import { sequence } from '@sveltejs/kit/hooks'; import { initAcceptLanguageHeaderDetector } from 'typesafe-i18n/detectors'; loadAllLocales(); const L = i18n(); -export const handle: Handle = async ({ event, resolve }) => { +export const i18nHandle: Handle = async ({ event, resolve }) => { // read language slug const [, lang] = event.url.pathname.split('/'); @@ -41,3 +42,19 @@ const getPreferredLocale = ({ request }: RequestEvent) => { return detectLocale(acceptLanguageDetector); }; + +export const metaHandle: Handle = async ({ event, resolve }) => { + const lang = 'es-419'; + const defaultTheme = 'dark'; + + return await resolve(event, { + transformPageChunk({ done, html }) { + //Only do it at the very end of the rendering process + if (done) { + return html.replace('%lang%', lang).replace('%theme%', defaultTheme); + } + }, + }); +}; + +export const handle = sequence(metaHandle, i18nHandle); diff --git a/src/i18n/en/index.ts b/src/i18n/en/index.ts index 06887d7f..045b4566 100644 --- a/src/i18n/en/index.ts +++ b/src/i18n/en/index.ts @@ -13,7 +13,7 @@ const en = { }, HOMEPAGE: { HI: `Hey, I'm {name:string} {surname:string},`, - ABOUT: `Software Developer with Web & Systems Experience. Favourite language is Rust but I also do TypeScript and Svelte.`, + ABOUT: `Software Developer with Web & Systems Experience`, SOCIAL_LINKS: 'Social Networks', LATEST_NOTES: 'Latest Note', }, diff --git a/src/i18n/es/index.ts b/src/i18n/es/index.ts index f85c977e..9a9b1efc 100644 --- a/src/i18n/es/index.ts +++ b/src/i18n/es/index.ts @@ -13,7 +13,7 @@ const es = { }, HOMEPAGE: { HI: `Hola soy {name:string} {surname:string},`, - ABOUT: `Desarrollador de Software con experiencia en Web y Desarrollo de Sistemas. Mi lenguaje favorito es ', Rust Rust, pero también escribo TypeScript y Svelte.`, + ABOUT: `Desarrollador de Software con experiencia en Web y Desarrollo de Sistemas`, SOCIAL_LINKS: 'Redes Sociales', LATEST_NOTES: 'Nota más reciente', }, diff --git a/src/i18n/hu/index.ts b/src/i18n/hu/index.ts index d2c0c223..6adf84aa 100644 --- a/src/i18n/hu/index.ts +++ b/src/i18n/hu/index.ts @@ -13,7 +13,7 @@ const hu = { }, HOMEPAGE: { HI: 'Jó napot kívánok {surname:string} {name:string} vagyok,', - ABOUT: `Szoftvermérnök webes és rendszertapasztalattal. A kedvenc nyelv a ', Rust Rust, de én is TypeScript és Svelte.`, + ABOUT: `Szoftvermérnök webes és rendszertapasztalattal`, SOCIAL_LINKS: 'Közösségi hálók', LATEST_NOTES: 'Legújabb jegyzet', }, diff --git a/src/i18n/i18n-svelte.ts b/src/i18n/i18n-svelte.ts index 6cdffb3e..bbc52ae5 100644 --- a/src/i18n/i18n-svelte.ts +++ b/src/i18n/i18n-svelte.ts @@ -1,12 +1,22 @@ // This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. /* eslint-disable */ -import { initI18nSvelte } from 'typesafe-i18n/svelte' -import type { Formatters, Locales, TranslationFunctions, Translations } from './i18n-types' -import { loadedFormatters, loadedLocales } from './i18n-util' +import { initI18nSvelte } from 'typesafe-i18n/svelte'; +import type { + Formatters, + Locales, + TranslationFunctions, + Translations, +} from './i18n-types'; +import { loadedFormatters, loadedLocales } from './i18n-util'; -const { locale, LL, setLocale } = initI18nSvelte(loadedLocales, loadedFormatters) +const { locale, LL, setLocale } = initI18nSvelte< + Locales, + Translations, + TranslationFunctions, + Formatters +>(loadedLocales, loadedFormatters); -export { locale, LL, setLocale } +export { locale, LL, setLocale }; -export default LL +export default LL; diff --git a/src/i18n/i18n-types.ts b/src/i18n/i18n-types.ts index f8715fba..85bde4e1 100644 --- a/src/i18n/i18n-types.ts +++ b/src/i18n/i18n-types.ts @@ -1,107 +1,108 @@ // This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. /* eslint-disable */ -import type { BaseTranslation as BaseTranslationType, LocalizedString, RequiredParams } from 'typesafe-i18n' +import type { + BaseTranslation as BaseTranslationType, + LocalizedString, + RequiredParams, +} from 'typesafe-i18n'; -export type BaseTranslation = BaseTranslationType -export type BaseLocale = 'en' +export type BaseTranslation = BaseTranslationType; +export type BaseLocale = 'en'; -export type Locales = - | 'en' - | 'es' - | 'hu' +export type Locales = 'en' | 'es' | 'hu'; -export type Translation = RootTranslation +export type Translation = RootTranslation; -export type Translations = RootTranslation +export type Translations = RootTranslation; type RootTranslation = { - LAYOUT: { - NAV: { - /** - * H​o​m​e - */ - HOME: string - /** - * N​o​t​e​s - */ - NOTES: string - } - FOOTER: { - /** - * M​a​d​e​ ​w​i​t​h​ ​�​�​ ​a​n​d​ ​❤​️​ ​b​y​ ​E​s​t​e​b​a​n​ ​B​o​r​a​i​ ​©​ ​{​s​t​a​r​t​}​ ​-​ ​{​e​n​d​} - * @param {number} end - * @param {number} start - */ - COPYRGHT: RequiredParams<'end' | 'start'> - /** - * S​o​u​r​c​e​ ​C​o​d​e - */ - SOURCE_CODE: string - } - } - HOMEPAGE: { - /** - * H​e​y​,​ ​I​'​m​ ​<​s​p​a​n​ ​c​l​a​s​s​=​"​f​o​n​t​-​s​e​m​i​b​o​l​d​"​>​{​n​a​m​e​}​ ​{​s​u​r​n​a​m​e​}​<​/​s​p​a​n​>​, - * @param {string} name - * @param {string} surname - */ - HI: RequiredParams<'name' | 'surname'> - /** - * S​o​f​t​w​a​r​e​ ​D​e​v​e​l​o​p​e​r​ ​w​i​t​h​ ​W​e​b​ ​&​ ​S​y​s​t​e​m​s​ ​E​x​p​e​r​i​e​n​c​e​.​ ​F​a​v​o​u​r​i​t​e​ ​l​a​n​g​u​a​g​e​ ​i​s​ ​<​s​p​a​n​ ​c​l​a​s​s​=​"​h​e​r​o​-​e​m​p​h​a​s​i​s​-​o​r​a​n​g​e​"​>​R​u​s​t​<​/​s​p​a​n​>​ ​b​u​t​ ​I​ ​a​l​s​o​ ​d​o​ ​<​s​p​a​n​ ​c​l​a​s​s​=​"​h​e​r​o​-​e​m​p​h​a​s​i​s​-​b​l​u​e​"​>​T​y​p​e​S​c​r​i​p​t​<​/​s​p​a​n​>​ ​a​n​d​ ​<​s​p​a​n​ ​c​l​a​s​s​=​"​h​e​r​o​-​e​m​p​h​a​s​i​s​-​r​e​d​"​>​S​v​e​l​t​e​<​/​s​p​a​n​>​. - */ - ABOUT: string - /** - * S​o​c​i​a​l​ ​N​e​t​w​o​r​k​s - */ - SOCIAL_LINKS: string - /** - * L​a​t​e​s​t​ ​N​o​t​e - */ - LATEST_NOTES: string - } -} + LAYOUT: { + NAV: { + /** + * H​o​m​e + */ + HOME: string; + /** + * N​o​t​e​s + */ + NOTES: string; + }; + FOOTER: { + /** + * M​a​d​e​ ​w​i​t​h​ ​�​�​ ​a​n​d​ ​❤​️​ ​b​y​ ​E​s​t​e​b​a​n​ ​B​o​r​a​i​ ​©​ ​{​s​t​a​r​t​}​ ​-​ ​{​e​n​d​} + * @param {number} end + * @param {number} start + */ + COPYRGHT: RequiredParams<'end' | 'start'>; + /** + * S​o​u​r​c​e​ ​C​o​d​e + */ + SOURCE_CODE: string; + }; + }; + HOMEPAGE: { + /** + * H​e​y​,​ ​I​'​m​ ​<​s​p​a​n​ ​c​l​a​s​s​=​"​f​o​n​t​-​s​e​m​i​b​o​l​d​"​>​{​n​a​m​e​}​ ​{​s​u​r​n​a​m​e​}​<​/​s​p​a​n​>​, + * @param {string} name + * @param {string} surname + */ + HI: RequiredParams<'name' | 'surname'>; + /** + * S​o​f​t​w​a​r​e​ ​D​e​v​e​l​o​p​e​r​ ​w​i​t​h​ ​W​e​b​ ​&​ ​S​y​s​t​e​m​s​ ​E​x​p​e​r​i​e​n​c​e + */ + ABOUT: string; + /** + * S​o​c​i​a​l​ ​N​e​t​w​o​r​k​s + */ + SOCIAL_LINKS: string; + /** + * L​a​t​e​s​t​ ​N​o​t​e + */ + LATEST_NOTES: string; + }; +}; export type TranslationFunctions = { - LAYOUT: { - NAV: { - /** - * Home - */ - HOME: () => LocalizedString - /** - * Notes - */ - NOTES: () => LocalizedString - } - FOOTER: { - /** - * Made with 🧉 and ❤️ by Esteban Borai © {start} - {end} - */ - COPYRGHT: (arg: { end: number, start: number }) => LocalizedString - /** - * Source Code - */ - SOURCE_CODE: () => LocalizedString - } - } - HOMEPAGE: { - /** - * Hey, I'm {name} {surname}, - */ - HI: (arg: { name: string, surname: string }) => LocalizedString - /** - * Software Developer with Web & Systems Experience. Favourite language is Rust but I also do TypeScript and Svelte. - */ - ABOUT: () => LocalizedString - /** - * Social Networks - */ - SOCIAL_LINKS: () => LocalizedString - /** - * Latest Note - */ - LATEST_NOTES: () => LocalizedString - } -} + LAYOUT: { + NAV: { + /** + * Home + */ + HOME: () => LocalizedString; + /** + * Notes + */ + NOTES: () => LocalizedString; + }; + FOOTER: { + /** + * Made with 🧉 and ❤️ by Esteban Borai © {start} - {end} + */ + COPYRGHT: (arg: { end: number; start: number }) => LocalizedString; + /** + * Source Code + */ + SOURCE_CODE: () => LocalizedString; + }; + }; + HOMEPAGE: { + /** + * Hey, I'm {name} {surname}, + */ + HI: (arg: { name: string; surname: string }) => LocalizedString; + /** + * Software Developer with Web & Systems Experience + */ + ABOUT: () => LocalizedString; + /** + * Social Networks + */ + SOCIAL_LINKS: () => LocalizedString; + /** + * Latest Note + */ + LATEST_NOTES: () => LocalizedString; + }; +}; -export type Formatters = {} +export type Formatters = {}; diff --git a/src/i18n/i18n-util.async.ts b/src/i18n/i18n-util.async.ts index 088b2bd8..6a9fb94d 100644 --- a/src/i18n/i18n-util.async.ts +++ b/src/i18n/i18n-util.async.ts @@ -1,28 +1,34 @@ // This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. /* eslint-disable */ -import { initFormatters } from './formatters' -import type { Locales, Translations } from './i18n-types' -import { loadedFormatters, loadedLocales, locales } from './i18n-util' +import { initFormatters } from './formatters'; +import type { Locales, Translations } from './i18n-types'; +import { loadedFormatters, loadedLocales, locales } from './i18n-util'; const localeTranslationLoaders = { - en: () => import('./en'), - es: () => import('./es'), - hu: () => import('./hu'), -} + en: () => import('./en'), + es: () => import('./es'), + hu: () => import('./hu'), +}; -const updateDictionary = (locale: Locales, dictionary: Partial): Translations => - loadedLocales[locale] = { ...loadedLocales[locale], ...dictionary } +const updateDictionary = ( + locale: Locales, + dictionary: Partial, +): Translations => + (loadedLocales[locale] = { ...loadedLocales[locale], ...dictionary }); -export const importLocaleAsync = async (locale: Locales): Promise => - (await localeTranslationLoaders[locale]()).default as unknown as Translations +export const importLocaleAsync = async ( + locale: Locales, +): Promise => + (await localeTranslationLoaders[locale]()).default as unknown as Translations; export const loadLocaleAsync = async (locale: Locales): Promise => { - updateDictionary(locale, await importLocaleAsync(locale)) - loadFormatters(locale) -} + updateDictionary(locale, await importLocaleAsync(locale)); + loadFormatters(locale); +}; -export const loadAllLocalesAsync = (): Promise => Promise.all(locales.map(loadLocaleAsync)) +export const loadAllLocalesAsync = (): Promise => + Promise.all(locales.map(loadLocaleAsync)); export const loadFormatters = (locale: Locales): void => - void (loadedFormatters[locale] = initFormatters(locale)) + void (loadedFormatters[locale] = initFormatters(locale)); diff --git a/src/i18n/i18n-util.sync.ts b/src/i18n/i18n-util.sync.ts index 2c142eed..2be6db97 100644 --- a/src/i18n/i18n-util.sync.ts +++ b/src/i18n/i18n-util.sync.ts @@ -1,28 +1,28 @@ // This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. /* eslint-disable */ -import { initFormatters } from './formatters' -import type { Locales, Translations } from './i18n-types' -import { loadedFormatters, loadedLocales, locales } from './i18n-util' +import { initFormatters } from './formatters'; +import type { Locales, Translations } from './i18n-types'; +import { loadedFormatters, loadedLocales, locales } from './i18n-util'; -import en from './en' -import es from './es' -import hu from './hu' +import en from './en'; +import es from './es'; +import hu from './hu'; const localeTranslations = { - en, - es, - hu, -} + en, + es, + hu, +}; export const loadLocale = (locale: Locales): void => { - if (loadedLocales[locale]) return + if (loadedLocales[locale]) return; - loadedLocales[locale] = localeTranslations[locale] as unknown as Translations - loadFormatters(locale) -} + loadedLocales[locale] = localeTranslations[locale] as unknown as Translations; + loadFormatters(locale); +}; -export const loadAllLocales = (): void => locales.forEach(loadLocale) +export const loadAllLocales = (): void => locales.forEach(loadLocale); export const loadFormatters = (locale: Locales): void => - void (loadedFormatters[locale] = initFormatters(locale)) + void (loadedFormatters[locale] = initFormatters(locale)); diff --git a/src/i18n/i18n-util.ts b/src/i18n/i18n-util.ts index bf94b24c..a302a501 100644 --- a/src/i18n/i18n-util.ts +++ b/src/i18n/i18n-util.ts @@ -1,39 +1,63 @@ // This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. /* eslint-disable */ -import { i18n as initI18n, i18nObject as initI18nObject, i18nString as initI18nString } from 'typesafe-i18n' -import type { LocaleDetector } from 'typesafe-i18n/detectors' -import type { LocaleTranslationFunctions, TranslateByString } from 'typesafe-i18n' -import { detectLocale as detectLocaleFn } from 'typesafe-i18n/detectors' -import { initExtendDictionary } from 'typesafe-i18n/utils' -import type { Formatters, Locales, Translations, TranslationFunctions } from './i18n-types' - -export const baseLocale: Locales = 'en' - -export const locales: Locales[] = [ - 'en', - 'es', - 'hu' -] - -export const isLocale = (locale: string): locale is Locales => locales.includes(locale as Locales) - -export const loadedLocales: Record = {} as Record - -export const loadedFormatters: Record = {} as Record - -export const extendDictionary = initExtendDictionary() - -export const i18nString = (locale: Locales): TranslateByString => initI18nString(locale, loadedFormatters[locale]) +import { + i18n as initI18n, + i18nObject as initI18nObject, + i18nString as initI18nString, +} from 'typesafe-i18n'; +import type { LocaleDetector } from 'typesafe-i18n/detectors'; +import type { + LocaleTranslationFunctions, + TranslateByString, +} from 'typesafe-i18n'; +import { detectLocale as detectLocaleFn } from 'typesafe-i18n/detectors'; +import { initExtendDictionary } from 'typesafe-i18n/utils'; +import type { + Formatters, + Locales, + Translations, + TranslationFunctions, +} from './i18n-types'; + +export const baseLocale: Locales = 'en'; + +export const locales: Locales[] = ['en', 'es', 'hu']; + +export const isLocale = (locale: string): locale is Locales => + locales.includes(locale as Locales); + +export const loadedLocales: Record = {} as Record< + Locales, + Translations +>; + +export const loadedFormatters: Record = {} as Record< + Locales, + Formatters +>; + +export const extendDictionary = initExtendDictionary(); + +export const i18nString = (locale: Locales): TranslateByString => + initI18nString(locale, loadedFormatters[locale]); export const i18nObject = (locale: Locales): TranslationFunctions => - initI18nObject( - locale, - loadedLocales[locale], - loadedFormatters[locale] - ) - -export const i18n = (): LocaleTranslationFunctions => - initI18n(loadedLocales, loadedFormatters) - -export const detectLocale = (...detectors: LocaleDetector[]): Locales => detectLocaleFn(baseLocale, locales, ...detectors) + initI18nObject( + locale, + loadedLocales[locale], + loadedFormatters[locale], + ); + +export const i18n = (): LocaleTranslationFunctions< + Locales, + Translations, + TranslationFunctions +> => + initI18n( + loadedLocales, + loadedFormatters, + ); + +export const detectLocale = (...detectors: LocaleDetector[]): Locales => + detectLocaleFn(baseLocale, locales, ...detectors); diff --git a/src/lib/components/Header.svelte b/src/lib/components/Header.svelte index a899b235..02b03823 100644 --- a/src/lib/components/Header.svelte +++ b/src/lib/components/Header.svelte @@ -1,8 +1,8 @@ -
- +
+ Esteban Borai Profile

Esteban Borai

-
diff --git a/src/lib/components/Sidebar.svelte b/src/lib/components/Sidebar.svelte index 818b729d..cdf98778 100644 --- a/src/lib/components/Sidebar.svelte +++ b/src/lib/components/Sidebar.svelte @@ -15,11 +15,6 @@ import type { Locales } from '$i18n/i18n-types'; const LINKS = [ - { - icon: Home, - text: $LL.LAYOUT.NAV.HOME(), - href: `/${$page.params.lang}`, - }, { icon: Repo, href: `/${$page.params.lang}/notes`, @@ -51,7 +46,9 @@ currentTheme = localStorage.theme === 'dark' || (!('theme' in localStorage) && - window.matchMedia('(prefers-color-scheme: dark)').matches) ? 'dark' : 'light'; + window.matchMedia('(prefers-color-scheme: dark)').matches) + ? 'dark' + : 'light'; if (currentTheme === 'dark') { document.documentElement.classList.add('dark'); @@ -63,11 +60,11 @@ }); function changeTheme(theme: 'light' | 'dark'): void { - const removeClass = theme === 'light' ? 'dark' : 'light'; + const removeClass = theme === 'light' ? 'dark' : 'light'; - document.documentElement.classList.remove(removeClass); - document.documentElement.classList.add(theme); - localStorage.theme = theme; + document.documentElement.classList.remove(removeClass); + document.documentElement.classList.add(theme); + localStorage.theme = theme; } function changeLanguage(locale: Locales): void { @@ -83,14 +80,16 @@ } const handleLanguageChange = (ev: Event) => { - const lang = (ev.target as unknown as { value: string; }).value as Locales; + const lang = (ev.target as unknown as { value: string }).value as Locales; changeLanguage(lang); - } + }; const handleThemeChange = (ev: Event) => { - const theme = (ev.target as unknown as { value: string; }).value as 'dark' | 'light'; + const theme = (ev.target as unknown as { value: string }).value as + | 'dark' + | 'light'; changeTheme(theme); - } + };