Skip to content

Commit c1e40c8

Browse files
committed
add doulbe drop down item to nav bar
1 parent 6f4b3a1 commit c1e40c8

File tree

5 files changed

+121
-4
lines changed

5 files changed

+121
-4
lines changed

content/global/index.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,22 @@
88
"logo": "/uploads/tinaDocsLogo.svg",
99
"navObjects": [
1010
{
11-
"href": "https://tina.io/tinadocs/docs",
12-
"label": "Documentation",
13-
"_template": "navLink"
11+
"label": "Products",
12+
"items": [
13+
{
14+
"labelLeft": "TinaCMS",
15+
"hrefLeft": "/",
16+
"labelRight": "Docs",
17+
"hrefRight": "/docs"
18+
},
19+
{
20+
"labelLeft": "TinaDocs",
21+
"hrefLeft": "/tinadocs",
22+
"labelRight": "Docs",
23+
"hrefRight": "/tinadocs/docs"
24+
}
25+
],
26+
"_template": "doubleNavItemDropDown"
1427
},
1528
{
1629
"href": "/pricing",

src/components/layout/nav/header.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { ModalButton } from "../../ui/modalButton";
1010
import { DropdownButton } from "../../ui/dropdownButton";
1111
import { GitHubButton } from "../../ui/githubButton";
1212
import { SearchBar } from "../../ui/searchBar";
13+
import { DoubleItemDropDownButton } from "../../ui/doubleItemDropDownButton";
1314

1415
const NavigationObjectRenderer = ({ navObject }: { navObject: any }) => {
1516
const template = navObject.__typename;
@@ -70,6 +71,8 @@ const NavigationObjectRenderer = ({ navObject }: { navObject: any }) => {
7071
</div>
7172
</>
7273
);
74+
case "GlobalHeaderNavObjectsDoubleNavItemDropDown":
75+
return <DoubleItemDropDownButton navObject={navObject} />;
7376

7477
default:
7578
return <span className="text-red-500">Unknown template: {template}</span>;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import Link from "next/link";
2+
import { useState } from "react";
3+
import { BiChevronDown } from "react-icons/bi";
4+
5+
export const DoubleItemDropDownButton = ({ navObject }: { navObject: any }) => {
6+
if (!navObject || !navObject.label) {
7+
return null;
8+
}
9+
10+
return (
11+
<li key={`$${navObject.label}`} className="group">
12+
<div className="relative group">
13+
<span className="flex items-center cursor-pointer text-neutral-text">
14+
{navObject.label}
15+
<BiChevronDown className="ml-1 w-3 h-3 transition-transform duration-200 group-hover:rotate-180" />
16+
</span>
17+
{navObject.items && navObject.items.length > 0 && (
18+
<ul className="absolute left-0 top-full mt-2 w-48 bg-background border rounded-lg shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 z-50">
19+
<div className="py-2">
20+
{navObject.items.map((subItem: any, subIndex: any) => (
21+
<div
22+
key={`${subIndex}-${subItem?.hrefLeft || "no-href"}`}
23+
className="flex items-center gap-2 px-4 py-2"
24+
>
25+
<Link
26+
className="text-muted-foreground hover:text-accent-foreground text-sm duration-150"
27+
href={subItem?.hrefLeft || "#"}
28+
>
29+
{subItem?.labelLeft || "No Label"}
30+
</Link>
31+
<span className="text-muted-foreground"></span>
32+
<Link
33+
className="text-muted-foreground hover:text-accent-foreground text-sm duration-150"
34+
href={subItem?.hrefRight || "#"}
35+
>
36+
{subItem?.labelRight || "No Label"}
37+
</Link>
38+
</div>
39+
))}
40+
</div>
41+
</ul>
42+
)}
43+
</div>
44+
</li>
45+
);
46+
};

tina/collection/global.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,60 @@ import { ColorPickerInput } from "../fields/color";
33
import { iconSchema } from "../fields/icon";
44
import { buttonVariantsArray } from "@/src/components/ui/button";
55

6+
const navDoubleLinkDropdown =
7+
{
8+
name: 'doubleNavItemDropDown',
9+
label: 'Double Nav Item Dropdown',
10+
type: 'object',
11+
ui: {
12+
itemProps: (item: any) => {
13+
return { label: `🥈 ${item?.label}` };
14+
},
15+
},
16+
fields: [
17+
{
18+
name: 'label',
19+
label: 'Label',
20+
type: 'string',
21+
},
22+
{
23+
name: 'items',
24+
label: 'Item',
25+
type: 'object',
26+
list: true,
27+
ui: {
28+
itemProps: (item: any) => {
29+
return {
30+
label: `🥈 ${item?.labelLeft} | ${item?.labelRight}`,
31+
};
32+
},
33+
},
34+
fields: [
35+
{
36+
name: 'labelLeft',
37+
label: 'Label Left',
38+
type: 'string',
39+
},
40+
{
41+
name: 'hrefLeft',
42+
label: 'href Left',
43+
type: 'string',
44+
},
45+
{
46+
name: 'labelRight',
47+
label: 'Label Right',
48+
type: 'string',
49+
},
50+
{
51+
name: 'hrefRight',
52+
label: 'href Right',
53+
type: 'string',
54+
},
55+
],
56+
},
57+
],
58+
}
59+
660
const navLink = {
761
name: "navLink",
862
label: "Nav Link",
@@ -152,6 +206,7 @@ const Global: Collection = {
152206
githubButton,
153207
ctaButton,
154208
demoModalButton,
209+
navDoubleLinkDropdown,
155210
],
156211
},
157212
],

tina/tina-lock.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)