8000 Redesign of language selector #100 by DecDuck · Pull Request #101 · Drop-OSS/drop · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Redesign of language selector #100 #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 142 additions & 0 deletions components/LanguageSelector.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<template>
<div>
<Listbox v-model="wiredLocale" as="div">
<ListboxLabel class="block text-sm/6 font-medium text-zinc-400">{{
$t("selectLanguage")
}}</ListboxLabel>
<div class="relative mt-2">
<ListboxButton
class="grid w-full cursor-default grid-cols-1 rounded-md bg-zinc-900 py-1.5 pr-2 pl-3 text-left text-zinc-300 outline-1 -outline-offset-1 outline-zinc-700 focus:outline-2 focus:-outline-offset-2 focus:outline-blue-600 sm:text-sm/6"
>
<span class="col-start-1 row-start-1 flex items-center gap-3 pr-6">
<span alt="" class="-mt-0.5 shrink-0 rounded-full">{{
localeToEmoji(wiredLocale)
}}</span>
<span class="block truncate">{{
currentLocaleInformation?.name ?? wiredLocale
}}</span>
</span>
<ChevronUpDownIcon
class="col-start-1 row-start-1 size-5 self-center justify-self-end text-gray-500 sm:size-4"
aria-hidden="true"
/>
</ListboxButton>

<transition
leave-active-class="transition ease-in duration-100"
leave-from-class="opacity-100"
leave-to-class="opacity-0"
>
<ListboxOptions
class="absolute z-10 mt-1 max-h-56 w-full overflow-auto rounded-md bg-zinc-900 py-1 text-base shadow-lg ring-1 ring-black/5 focus:outline-hidden sm:text-sm"
>
<ListboxOption
v-for="listLocale in locales"
:key="listLocale.code"
v-slot="{ active, selected }"
as="template"
:value="listLocale.code"
>
<li
:class="[
active
? 'bg-blue-600 text-white outline-hidden'
: 'text-zinc-300',
'relative cursor-default py-2 pr-9 pl-3 select-none',
]"
>
<div class="flex items-center">
<span class="-mt-0.5 shrink-0 rounded-full">
{{ localeToEmoji(listLocale.code) }}
</span>
<span
:class="[
selected ? 'font-semibold' : 'font-normal',
'ml-3 block truncate',
]"
>{{ listLocale.name }}</span
>
</div>

<span
v-if="selected"
:class="[
active ? 'text-white' : 'text-blue-600',
'absolute inset-y-0 right-0 flex items-center pr-4',
]"
>
<CheckIcon class="size-5" aria-hidden="true" />
</span>
</li>
</ListboxOption>
</ListboxOptions>
</transition>
</div>
</Listbox>
<NuxtLink
class="mt-1 transition text-blue-500 hover:text-blue-600 text-sm"
to="https://translate.droposs.org/projects/drop/"
target="_blank"
>
<i18n-t
keypath="helpUsTranslate"
tag="span"
scope="global"
class="inline-flex items-center gap-x-1 hover:underline"
>
<template #arrow>
<ArrowTopRightOnSquareIcon class="size-4" />
</template>
</i18n-t>
</NuxtLink>

<DevOnly
><h1 class="mt-3 text-sm text-gray-500">{{ $t("welcome") }}</h1>
</DevOnly>
</div>
</template>

<script setup lang="ts">
import {
Listbox,
ListboxButton,
ListboxLabel,
ListboxOption,
ListboxOptions,
} from "@headlessui/vue";
import { ChevronUpDownIcon } from "@heroicons/vue/16/solid";
import { ArrowTopRightOnSquareIcon } from "@heroicons/vue/24/outline";

const { locales, locale, setLocale } = useI18n();

function localeToEmoji(local: string): string {
switch (local) {
case "en":
case "en-gb":
case "en-ca":
case "en-au":
case "en-us": {
return "🇺🇸";
}
case "en-pirate": {
return "🏴‍☠️";
}

default: {
return "❓";
}
}
}

const wiredLocale = computed({
get() {
return locale.value;
},
set(v) {
setLocale(v);
},
});
const currentLocaleInformation = computed(() =>
locales.value.find((e) => e.code == wiredLocale.value),
);
</script>
2 changes: 1 addition & 1 deletion components/LibraryDirectory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
name="search"
autocomplete="off"
class="block w-full rounded-md bg-zinc-900 py-2 pl-9 pr-2 text-sm text-zinc-100 outline outline-1 -outline-offset-1 outline-zinc-700 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-blue-600"
placeholder="$t('library.search')"
:placeholder="$t('library.search')"
/>
<MagnifyingGlassIcon
class="pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-zinc-400"
Expand Down
4 changes: 4 additions & 0 deletions components/UserFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<p class="text-sm leading-6 text-zinc-300">
{{ $t("drop.desc") }}
</p>

<LanguageSelector />

<div class="flex space-x-6">
<NuxtLink
v-for="item in navigation.social"
Expand Down Expand Up @@ -90,6 +93,7 @@

<script setup lang="ts">
import { IconsDiscordLogo, IconsGithubLogo } from "#components";

const { t } = useI18n();

const navigation = {
Expand Down
11 changes: 4 additions & 7 deletions components/UserHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
</transition>
</Menu>
</li>
<UserHeaderSelectLang />
<UserHeaderUserWidget />
</ol>
</div>
Expand Down Expand Up @@ -176,9 +175,7 @@
</UserHeaderWidget>
</li>
<li class="w-full">
<UserHeaderWidget class="w-full">
<UserHeaderSelectLang />
</UserHeaderWidget>
<UserHeaderWidget class="w-full" />
</li>
</div>
</nav>
Expand Down Expand Up @@ -209,7 +206,7 @@ const router = useRouter();
const { t } = useI18n();

const homepageURL = "/store";
const navigation: Array<NavigationItem> = [
const navigation: Ref<Array<NavigationItem>> = computed(() => [
{
prefix: "/store",
route: "/store",
Expand All @@ -230,9 +227,9 @@ const navigation: Array<NavigationItem> = [
route: "/news",
label: t("userHeader.links.news"),
},
];
]);

const currentPageIndex = useCurrentNavigationIndex(navigation);
const currentPageIndex = useCurrentNavigationIndex(navigation.value);

const notifications = useNotifications();
const unreadNotifications = computed(() =>
Expand Down
78 changes: 0 additions & 78 deletions components/UserHeader/SelectLang.vue

This file was deleted.

Loading
0