blob: e2a5a225cf15d913a6ecf83fd511600ffc17b63d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
import React from 'react';
import Link from 'next/link';
import { NavigationMenuLink } from "@/components/ui/navigation-menu";
import { cn } from "@/lib/utils";
import * as LucideIcons from "lucide-react";
import { MenuItem } from '@/config/menuConfig';
type GroupedMenuItems = {
[key: string]: MenuItem[];
};
interface GroupedMenuRendererProps {
items: MenuItem[];
lng: string;
}
const GroupedMenuRenderer = ({ items, lng }: GroupedMenuRendererProps) => {
// 그룹별로 아이템 분류
const groupItems = (items: MenuItem[]): GroupedMenuItems => {
return items.reduce((groups, item) => {
const group = item.group || 'default';
if (!groups[group]) {
groups[group] = [];
}
groups[group].push(item);
return groups;
}, {} as GroupedMenuItems);
};
const groupedItems = groupItems(items);
const groups = Object.keys(groupedItems);
return (
<div className="p-4 w-[600px]">
{groups.map((groupName, index) => (
<div key={groupName} className={cn("mb-4", index < groups.length - 1 && "pb-2 border-b border-border/30")}>
{groupName !== 'default' && (
<h3 className="text-sm font-semibold mb-2 text-primary">{groupName}</h3>
)}
<div className="grid grid-cols-2 gap-3">
{groupedItems[groupName].map((item) => (
<MenuListItem key={item.title} item={item} lng={lng} />
))}
</div>
</div>
))}
</div>
);
};
const MenuListItem = ({ item, lng }: { item: MenuItem; lng: string }) => {
return (
<NavigationMenuLink asChild>
<Link
href={`/${lng}${item.href}`}
className={cn(
"flex items-start space-x-2 rounded-md p-3 leading-none no-underline outline-none transition-colors",
"hover:bg-accent hover:text-accent-foreground",
"focus:bg-accent focus:text-accent-foreground",
item.disabled && "pointer-events-none opacity-60"
)}
>
<div className="space-y-1">
<div className="text-sm font-medium leading-none">{item.title}</div>
{item.description && (
<p className="line-clamp-2 text-xs leading-snug text-muted-foreground">
{item.description}
</p>
)}
</div>
</Link>
</NavigationMenuLink>
);
};
export default GroupedMenuRenderer;
|