-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from renegadevi/development
big update, packages on latest, boilerplate v2.0
- Loading branch information
Showing
22 changed files
with
449 additions
and
423 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
} | ||
} | ||
html { | ||
@apply bg-slate-100; | ||
@apply bg-white; | ||
} | ||
html.dark { | ||
@apply bg-slate-900; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,75 @@ | ||
<script setup lang="ts"> | ||
const { locale } = useI18n(); | ||
const { locale, t } = useI18n(); | ||
const isOpen = ref(false); | ||
const dropdownRef = ref<HTMLElement | null>(null); | ||
// update local storage upon language change | ||
const toggleLocale = () => { | ||
localStorage.setItem("nuxt-lang", locale.value); | ||
}; | ||
// check for stored language on initial load. | ||
// Get initial language from localStorage or default to 'en-US' | ||
onMounted(() => { | ||
const storedLanguage = localStorage.getItem("nuxt-lang"); | ||
if (storedLanguage) { | ||
locale.value = storedLanguage; | ||
const savedLang = localStorage.getItem('nuxt-lang'); | ||
if (savedLang) { | ||
locale.value = savedLang; | ||
document.documentElement.dir = t('locale.dir'); | ||
} | ||
document.addEventListener('click', (event: MouseEvent) => { | ||
const target = event.target as Node; | ||
if (dropdownRef.value && !dropdownRef.value.contains(target)) { | ||
isOpen.value = false; | ||
} | ||
}); | ||
}); | ||
const setLanguage = (language: string) => { | ||
locale.value = language; | ||
// Save to localStorage | ||
localStorage.setItem('nuxt-lang', language); | ||
isOpen.value = false; | ||
document.documentElement.dir = t('locale.dir'); | ||
}; | ||
</script> | ||
|
||
|
||
<template> | ||
<form> | ||
<label for="languages" aria-label="icon"> | ||
<Icon name="prime:language" size="1.5em" /> | ||
</label> | ||
<select | ||
id="languages" | ||
v-model="$i18n.locale" | ||
aria-label="language" | ||
class="bg-transparent" | ||
@change="toggleLocale" | ||
<div class="w-auto" ref="dropdownRef"> | ||
<button | ||
@click="isOpen = !isOpen" | ||
class="flex items-center gap-2 rounded-lg p-2 px-4 text-gray-600 dark:text-white" | ||
:class="[ | ||
{ 'flex-row-reverse': t('locale.dir') === 'rtl' }, | ||
isOpen ? 'bg-gray-100 dark:bg-slate-700' : 'hover:bg-gray-100 dark:hover:bg-slate-700' | ||
]" | ||
> | ||
|
||
<Icon name="ph:translate" size="1.25em" /> | ||
<span>{{ $t("locale." + $i18n.locale) }}</span> | ||
<Icon | ||
name="ph:caret-down" | ||
class="h-4 w-4 transition-all duration-200" | ||
:class="{ 'rotate-180': isOpen }" | ||
/> | ||
</button> | ||
|
||
<div | ||
v-if="isOpen" | ||
class="absolute mt-1 min-w-32 rounded-lg bg-white shadow-lg border border-gray-100 dark:bg-slate-700 dark:border-slate-700 right-0" | ||
> | ||
<option | ||
v-for="language in $i18n.availableLocales" | ||
:key="language" | ||
:aria-label="$t('locale.' + language)" | ||
:value="language" | ||
:selected="$i18n.locale === language" | ||
class="dark:bg-slate-800" | ||
> | ||
{{ $t("locale." + language) }} | ||
</option> | ||
</select> | ||
</form> | ||
<ul> | ||
<li | ||
v-for="language in $i18n.availableLocales" | ||
:key="language" | ||
:class="[ | ||
'px-4 py-2 cursor-pointer rounded-md m-1 hover:bg-gray-100 text-gray-600 dark:text-white dark:hover:bg-slate-600', | ||
{ 'bg-gray-100 dark:bg-slate-600 ': $i18n.locale === language }, | ||
{ 'text-right': t('locale.dir') === 'rtl' } | ||
]" | ||
@click="() => setLanguage(language)" | ||
> | ||
{{ $t("locale." + language) }} | ||
</li> | ||
|
||
</ul> | ||
</div> | ||
|
||
</div> | ||
|
||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,25 @@ | ||
<script setup> | ||
const colorMode = useColorMode(); | ||
const themeConfig = { | ||
dark: { next: 'system', icon: 'ph:moon' }, | ||
system: { next: 'light', icon: 'ph:sun-horizon' }, | ||
light: { next: 'dark', icon: 'ph:sun' } | ||
}; | ||
const name = ref(null); | ||
const toggleColorMode = () => { | ||
const { next } = themeConfig[colorMode.preference]; | ||
Object.assign(colorMode, { preference: next, value: next }); | ||
name.value = themeConfig[next].icon; | ||
}; | ||
onMounted(() => { | ||
name.value = themeConfig[colorMode.preference].icon; | ||
}); | ||
</script> | ||
<template> | ||
<form> | ||
<label for="themes"><Icon name="gg:dark-mode" size="1.5em" /></label> | ||
<select | ||
id="themes" | ||
v-model="$colorMode.preference" | ||
aria-label="themes" | ||
class="border-1 border-l-3 mx-1 inline-block border-gray-900 bg-inherit text-sm" | ||
> | ||
<option | ||
class="dark:bg-slate-800" | ||
value="system" | ||
:aria-label="$t('themes.system')" | ||
> | ||
{{ $t("themes.system") }} | ||
</option> | ||
<option | ||
class="dark:bg-slate-800" | ||
value="light" | ||
:aria-label="$t('themes.light')" | ||
> | ||
{{ $t("themes.light") }} | ||
</option> | ||
<option | ||
class="dark:bg-slate-800" | ||
value="dark" | ||
:aria-label="$t('themes.dark')" | ||
> | ||
{{ $t("themes.dark") }} | ||
</option> | ||
</select> | ||
</form> | ||
<ClientOnly> | ||
<button v-bind="$attrs" class="cursor-pointer flex w-10 h-10" @click="toggleColorMode" aria-label="Toggle color modes"> | ||
<Icon :name size="24" /> | ||
</button> | ||
</ClientOnly> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
// @ts-check | ||
import withNuxt from './.nuxt/eslint.config.mjs' | ||
import nuxtConfig from './.nuxt/eslint.config.mjs' | ||
const baseConfig = Array.isArray(nuxtConfig) ? nuxtConfig : [nuxtConfig] | ||
|
||
export default withNuxt( | ||
// Your custom configs here | ||
) | ||
export default [ | ||
...baseConfig, | ||
{ | ||
files: ['**/*.{js,ts,vue}'], | ||
rules: { | ||
// custom rules here | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.