diff --git a/app.vue b/app.vue index 1fe435d..fb17d51 100644 --- a/app.vue +++ b/app.vue @@ -4,10 +4,12 @@ - diff --git a/bun.lockb b/bun.lockb index 48816cf..ebd1ebf 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/DropDown.vue b/components/DropDown.vue new file mode 100644 index 0000000..8e291bd --- /dev/null +++ b/components/DropDown.vue @@ -0,0 +1,84 @@ + + + isOpen = !isOpen' + > + {{ selectedOption || defaultOption }} + + + + {{ option.name }} + + + + + + diff --git a/components/FontSwitcher.vue b/components/FontSwitcher.vue deleted file mode 100644 index 64b71a5..0000000 --- a/components/FontSwitcher.vue +++ /dev/null @@ -1,26 +0,0 @@ - - - - {{ value.name }} - - - - - diff --git a/components/NavBar.vue b/components/NavBar.vue index 2913295..ba15cce 100644 --- a/components/NavBar.vue +++ b/components/NavBar.vue @@ -1,4 +1,27 @@ - - + + + + + + diff --git a/components/ThemeSwitcher.vue b/components/ThemeSwitcher.vue deleted file mode 100644 index b8ce74f..0000000 --- a/components/ThemeSwitcher.vue +++ /dev/null @@ -1,26 +0,0 @@ - - - - {{ value.name }} - - - - - diff --git a/composables/useFont.ts b/composables/useFont.ts deleted file mode 100644 index afc1faf..0000000 --- a/composables/useFont.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { ref, onMounted } from 'vue' - -const fontNames = Object.keys(fonts) - -export const useFont = () => { - const font = ref('jetbrains-mono') - - onMounted(() => { - const storedFont = localStorage.getItem('font') - if (storedFont) { - font.value = storedFont - document.body.classList.remove(...fontNames) - document.body.classList.add(storedFont) - } - }) - - const setFont = (newFont: string) => { - font.value = newFont - document.body.classList.remove(...fontNames) - document.body.classList.add(newFont) - localStorage.setItem('font', newFont) - } - - return { - font, - setFont, - } -} diff --git a/composables/useTheme.ts b/composables/useTheme.ts deleted file mode 100644 index 371e320..0000000 --- a/composables/useTheme.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { ref, onMounted } from 'vue' - -const themeNames = Object.keys(themes) - -export const useTheme = () => { - const theme = ref('catppuccin-mocha') - - onMounted(() => { - const storedTheme = localStorage.getItem('theme') - if (storedTheme) { - theme.value = storedTheme - document.body.classList.remove(...themeNames) - document.body.classList.add(storedTheme) - } - }) - - const setTheme = (newTheme: string) => { - theme.value = newTheme - document.body.classList.remove(...themeNames) - document.body.classList.add(newTheme) - localStorage.setItem('theme', newTheme) - } - - return { - theme, - setTheme, - } -} diff --git a/nuxt.config.ts b/nuxt.config.ts index 2f793de..aa2e5e5 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -3,7 +3,7 @@ import { fonts } from './utils/fonts' export default defineNuxtConfig({ compatibilityDate: '2024-04-03', devtools: { enabled: true }, - modules: ['@unocss/nuxt', '@vueuse/nuxt', '@nuxt/eslint', '@vue-macros/nuxt'], + modules: ['@unocss/nuxt', '@vueuse/nuxt', '@nuxt/eslint', '@vue-macros/nuxt', '@pinia/nuxt'], eslint: { config: { stylistic: { @@ -34,21 +34,49 @@ export default defineNuxtConfig({ { type: 'text/javascript', innerHTML: /* js */ ` - const theme = localStorage.getItem('theme') + // Function to get a cookie value by name + function getCookie(name) { + const nameEQ = name + "="; + const ca = document.cookie.split(';'); + for (let i = 0; i < ca.length; i++) { + let c = ca[i]; + while (c.charAt(0) === ' ') c = c.substring(1, c.length); + if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length); + } + return null; + } + + // Function to set a cookie with a name, value, and optional expiration days + function setCookie(name, value, days) { + let expires = ""; + if (days) { + const date = new Date(); + date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); + expires = "; expires=" + date.toUTCString(); + } + document.cookie = name + "=" + (value || "") + expires + "; path=/"; + } + + const theme = getCookie('theme'); - if (theme === 'system' || !theme) - document.body.classList.add( - window.matchMedia('(prefers-color-scheme: dark)').matches - ? 'dark' - : 'light' - ) - else - document.body.classList.add(theme) - - const font = localStorage.getItem('font') - - if (font) - document.body.classList.add(font) + // If no theme cookie exists, set it to 'catppuccin-mocha' + if (!theme) { + setCookie('theme', 'catppuccin-mocha'); + document.body.classList.add('catppuccin-mocha'); + } else { + document.body.classList.add(theme); // Apply the existing theme class + } + + // Retrieve the font value from cookies + const font = getCookie('font'); + + // If no font cookie exists, set it to 'jetbrains-mono' + if (!font) { + setCookie('font', 'jetbrains-mono'); + document.body.classList.add('jetbrains-mono'); + } else { + document.body.classList.add(font); // Apply the existing font class + } `, tagPosition: 'bodyClose', }, diff --git a/package.json b/package.json index ec7bd34..2d5e60c 100644 --- a/package.json +++ b/package.json @@ -15,12 +15,15 @@ "@fontsource/source-code-pro": "^5.0.19", "@fontsource/ubuntu-mono": "^5.0.21", "@nuxtjs/google-fonts": "^3.2.0", + "@unocss/reset": "^0.62.3", "nuxt": "^3.13.0", + "typescript-cookie": "^1.0.6", "unocss-preset-theme": "^0.13.0", "vue": "^3.4.38" }, "devDependencies": { "@nuxt/eslint": "^0.5.2", + "@pinia/nuxt": "^0.5.4", "@unocss/nuxt": "^0.62.3", "@vue-macros/nuxt": "^1.11.6", "@vueuse/nuxt": "^11.0.3" diff --git a/pages/index.vue b/pages/index.vue index 2349b66..6c80bf6 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1,7 +1,8 @@ - - - hi im mard - - + + hi im mard + diff --git a/utils/themes.ts b/utils/themes.ts index e916086..b957d24 100644 --- a/utils/themes.ts +++ b/utils/themes.ts @@ -4,7 +4,8 @@ export const themes = { colors: { text: '#3760bf', subtext: '#5c5f77', - bg: '#eff1f5', + base: '#eff1f5', + base2: '#e1e2e7', }, }, 'tokyonight-night': { @@ -12,39 +13,44 @@ export const themes = { colors: { text: '#c0caf5', subtext: '#a9b1d6', - bg: '#1a1b26', + base: '#1a1b26', + base2: '#24283b', }, }, 'catppuccin-latte': { - name: 'Catppuccin (Latte)', + name: 'Catppuccin Latte', colors: { text: '#4c4f69', subtext: '#5c5f77', - bg: '#eff1f5', + base: '#eff1f5', + base2: '#e6e9ef', }, }, 'catppuccin-frappe': { - name: 'Catppuccin (Frappe)', + name: 'Catppuccin Frappe', colors: { text: '#c6d0f5', subtext: '#b5bfe2', - bg: '#303446', + base: '#303446', + base2: '#292c3c', }, }, 'catppuccin-macchiato': { - name: 'Catppuccin (Macchiato)', + name: 'Catppuccin Macchiato', colors: { text: '#cad3f5', subtext: '#b8c0e0', - bg: '#24273a', + base: '#24273a', + base2: '#1e2030', }, }, 'catppuccin-mocha': { - name: 'Catppuccin (Mocha)', + name: 'Catppuccin Mocha', colors: { text: '#cdd6f4', subtext: '#bac2de', - bg: '#1e1e2e', + base: '#1e1e2e', + base2: '#181825', }, }, }