feat(ui): Implement Dropdown Menu components for language switcher
- Add DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, and DropdownMenuItem components - Refactor LanguageSwitcher to use new Dropdown Menu components - Update Navbar to use LanguageSwitcher component with improved language selection UI - Remove legacy language toggle logic from Navbar
This commit is contained in:
parent
1242d9179d
commit
ecc85ba98b
7 changed files with 164 additions and 42 deletions
17
src/components/ui/dropdown-menu/DropdownMenu.vue
Normal file
17
src/components/ui/dropdown-menu/DropdownMenu.vue
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<script setup lang="ts">
|
||||
import { DropdownMenuRoot } from 'radix-vue'
|
||||
|
||||
defineOptions({
|
||||
name: 'DropdownMenu'
|
||||
})
|
||||
|
||||
defineSlots<{
|
||||
default?: (props: {}) => any
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DropdownMenuRoot v-bind="$attrs">
|
||||
<slot />
|
||||
</DropdownMenuRoot>
|
||||
</template>
|
||||
31
src/components/ui/dropdown-menu/DropdownMenuContent.vue
Normal file
31
src/components/ui/dropdown-menu/DropdownMenuContent.vue
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<script setup lang="ts">
|
||||
import { DropdownMenuContent, type DropdownMenuContentProps } from 'radix-vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
defineOptions({
|
||||
name: 'DropdownMenuContent'
|
||||
})
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<DropdownMenuContentProps & {
|
||||
class?: string
|
||||
}>(),
|
||||
{
|
||||
sideOffset: 4,
|
||||
align: 'start',
|
||||
class: ''
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DropdownMenuContent
|
||||
:class="cn(
|
||||
'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
|
||||
props.class
|
||||
)"
|
||||
v-bind="{ ...props, ...$attrs }"
|
||||
>
|
||||
<slot />
|
||||
</DropdownMenuContent>
|
||||
</template>
|
||||
34
src/components/ui/dropdown-menu/DropdownMenuItem.vue
Normal file
34
src/components/ui/dropdown-menu/DropdownMenuItem.vue
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<script setup lang="ts">
|
||||
import { DropdownMenuItem, type DropdownMenuItemProps } from 'radix-vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
defineOptions({
|
||||
name: 'DropdownMenuItem'
|
||||
})
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<
|
||||
DropdownMenuItemProps & {
|
||||
class?: string
|
||||
inset?: boolean
|
||||
}
|
||||
>(),
|
||||
{
|
||||
class: '',
|
||||
inset: false
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DropdownMenuItem
|
||||
:class="cn(
|
||||
'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
||||
inset && 'pl-8',
|
||||
props.class
|
||||
)"
|
||||
v-bind="{ ...props, ...$attrs }"
|
||||
>
|
||||
<slot />
|
||||
</DropdownMenuItem>
|
||||
</template>
|
||||
22
src/components/ui/dropdown-menu/DropdownMenuTrigger.vue
Normal file
22
src/components/ui/dropdown-menu/DropdownMenuTrigger.vue
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<script setup lang="ts">
|
||||
import { DropdownMenuTrigger } from 'radix-vue'
|
||||
|
||||
defineOptions({
|
||||
name: 'DropdownMenuTrigger'
|
||||
})
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
asChild?: boolean
|
||||
}>(),
|
||||
{
|
||||
asChild: false
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DropdownMenuTrigger v-bind="{ ...props, ...$attrs }">
|
||||
<slot />
|
||||
</DropdownMenuTrigger>
|
||||
</template>
|
||||
4
src/components/ui/dropdown-menu/index.ts
Normal file
4
src/components/ui/dropdown-menu/index.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export { default as DropdownMenu } from './DropdownMenu.vue'
|
||||
export { default as DropdownMenuTrigger } from './DropdownMenuTrigger.vue'
|
||||
export { default as DropdownMenuContent } from './DropdownMenuContent.vue'
|
||||
export { default as DropdownMenuItem } from './DropdownMenuItem.vue'
|
||||
Loading…
Add table
Add a link
Reference in a new issue