File size: 6,287 Bytes
75fefa7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
import CurvyRect from "@/components/shared/layout/curvy-rect";
import { cn } from "@/utils/cn";
import { ArrowUpRight } from "lucide-react";

interface Props {
  navigationItems: {
    label: string;
    items: {
      icon: React.ReactNode;
      label: string;
      description: string;
      href: string;
      target?: string;
      big?: boolean;
      ctas?: { label: string; href: string; target?: string }[];
      sectionLabel?: string;
      iconClassName?: string;
    }[];
  }[];
  sideLabel: string;
  sideContent: React.ReactNode;
  sideItem: {
    icon: React.ReactNode;
    label: string;
    description: string;
    href: string;
    target?: string;
  };
}

export default function HeaderDropdownContent({
  navigationItems,
  sideLabel,
  sideContent,
  sideItem,
}: Props) {
  return (
    <div className="lg-max:max-w-[unset] container lg:flex gap-16">
      {navigationItems.map((item, index) => (
        <div className="flex-1" key={index}>
          <GroupLabel label={item.label} />

          {/* Default section (items without sectionLabel) */}
          <div
            className={cn(
              "grid gap-x-16",
              navigationItems.length === 1 && "lg:grid-cols-2",
            )}
          >
            {item.items
              .filter((it) => !it.sectionLabel && !it.big)
              .map((it) => (
                <Item item={it} key={it.label} />
              ))}
            {item.items
              .filter((it) => !it.sectionLabel && it.big)
              .map((it) => (
                <ItemBig item={it} key={it.label} />
              ))}
          </div>

          {/* Additional sections within the same column */}
          {Array.from(
            new Set(
              item.items
                .map((it) => it.sectionLabel)
                .filter(Boolean) as string[],
            ),
          ).map((section) => (
            <div key={section}>
              {/* <GroupLabel label={section} /> */}
              <div
                className={cn(
                  "grid gap-x-16",
                  navigationItems.length === 1 && "lg:grid-cols-2",
                )}
              >
                {item.items
                  .filter((it) => it.sectionLabel === section && !it.big)
                  .map((it) => (
                    <Item item={it} key={it.label} />
                  ))}
                {item.items
                  .filter((it) => it.sectionLabel === section && it.big)
                  .map((it) => (
                    <ItemBig item={it} key={it.label} />
                  ))}
              </div>
            </div>
          ))}

          <div className="h-42 border-t border-border-faint border-x -mt-1 relative lg-max:hidden">
            <CurvyRect
              className="-top-1 absolute -left-1 w-[calc(100%+2px)]"
              top
            />
            <CurvyRect
              className="bottom-full absolute -left-1 w-[calc(100%+2px)]"
              bottom
            />
          </div>
        </div>
      ))}

      <div className="flex-1 max-w-360 relative">
        <div className="h-full w-1 absolute top-0 left-0 bg-border-faint" />
        <GroupLabel label={sideLabel} />

        <div className="hidden lg:contents">{sideContent}</div>

        <Item item={sideItem} />

        <div className="h-42 border-t border-border-faint border-r -mt-1 relative lg-max:hidden">
          <CurvyRect
            className="-top-1 absolute left-0 w-[calc(100%+1px)]"
            top
          />
          <CurvyRect
            className="bottom-full absolute left-0 w-[calc(100%+1px)]"
            bottom
          />
        </div>
      </div>
    </div>
  );
}

const GroupLabel = ({ label }: { label: string }) => {
  return (
    <div className="text-body-medium py-16 lg:py-20 lg:border-x border-b border-border-faint px-24 lg:px-44 text-black-alpha-64">
      {label}
    </div>
  );
};

const Item = ({
  item,
}: {
  item: {
    icon: React.ReactNode;
    label: string;
    description: string;
    href: string;
    target?: string;
    iconClassName?: string;
  };
}) => {
  return (
    <a
      className="flex items-start gap-16 py-16 pl-24 lg-max:[&_svg]:size-24 lg:pl-44 group border-x hover:bg-black-alpha-2 border-b border-border-faint transition-all hover:text-heat-100"
      href={item.href}
      key={item.label}
      target={item.target}
    >
      <div className={item.iconClassName}>{item.icon}</div>

      <div className="min-w-0 flex-1">
        <div className="text-label-medium">{item.label}</div>

        <div className="text-body-medium mt-4 text-black-alpha-64 lg-max:hidden">
          {item.description}
        </div>
      </div>
    </a>
  );
};

const ItemBig = ({
  item,
}: {
  item: {
    icon: React.ReactNode;
    label: string;
    description: string;
    href: string;
    target?: string;
    ctas?: { label: string; href: string; target?: string }[];
    iconClassName?: string;
  };
}) => {
  return (
    <div
      className="flex items-start gap-16 py-22 pl-24 lg-max:[&_svg]:size-24 lg:pl-44 group border-x border-b transition-colors border-border-faint"
      key={item.label}
    >
      <div className={item.iconClassName}>{item.icon}</div>

      <div className="min-w-0 flex-1">
        <a
          href={item.href}
          target={item.target}
          className="text-label-medium inline-block hover:text-heat-100 transition-colors"
        >
          {item.label}
        </a>

        <div className="text-body-medium mt-4 text-black-alpha-64 lg-max:hidden">
          {item.description}
        </div>

        {item.ctas && item.ctas.length > 0 && (
          <div className="mt-12 flex items-center gap-8 lg-max:hidden">
            {item.ctas.map((cta) => (
              <a
                key={cta.label}
                href={cta.href}
                target={cta.target}
                className="inline-flex items-center gap-6 px-12 py-6 rounded-6 text-label-small text-heat-100 bg-heat-4 hover:bg-heat-8 transition-colors whitespace-nowrap shrink-0"
              >
                <span>{cta.label}</span>
                <ArrowUpRight className="size-14" aria-hidden="true" />
              </a>
            ))}
          </div>
        )}
      </div>
    </div>
  );
};