@0xchain/header 1.1.0-beta.43 → 1.1.0-beta.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib/Nav.js CHANGED
@@ -14,6 +14,7 @@ import { fetchUserProfile } from "@0xchain/auth";
14
14
  import { onUserEvent, USER_EVENTS, cleanUserEvent } from "./events.js";
15
15
  import { usePathname } from "next/navigation";
16
16
  import Explorer from "./Explorer.js";
17
+ import Products from "./Products.js";
17
18
  import { useIsChaindigg } from "./context.js";
18
19
  function Nav({ onClick = () => void 0, hideNews = false, hideLogin = false, user }) {
19
20
  const isChaindigg = useIsChaindigg();
@@ -51,6 +52,13 @@ function Nav({ onClick = () => void 0, hideNews = false, hideLogin = false, user
51
52
  return pathname2.includes(`/explorer`);
52
53
  }
53
54
  },
55
+ {
56
+ key: "/products",
57
+ label: /* @__PURE__ */ jsx(Products, { onClick }),
58
+ show: (pathname2) => {
59
+ return pathname2.includes("/widget");
60
+ }
61
+ },
54
62
  {
55
63
  baseUrl: process.env.NEXT_PUBLIC_BASE_URL,
56
64
  href: `/learn`,
@@ -137,7 +145,7 @@ function Nav({ onClick = () => void 0, hideNews = false, hideLogin = false, user
137
145
  "w-full md:w-auto h-11 md:h-auto cursor-pointer hover:text-primary",
138
146
  item.show(pathname) && "border-b-2 border-primary text-primary"
139
147
  ),
140
- children: item.href === pathname ? item.label : /* @__PURE__ */ jsx(
148
+ children: !item.href || item.href === pathname ? item.label : /* @__PURE__ */ jsx(
141
149
  LinkBar,
142
150
  {
143
151
  href: item.href,
@@ -181,10 +189,10 @@ function Nav({ onClick = () => void 0, hideNews = false, hideLogin = false, user
181
189
  {
182
190
  className: twMerge(
183
191
  "w-full md:px-4 md:py-1 md:h-auto font-bold md:w-auto cursor-pointer md:rounded-full",
184
- item.key === "/explorer" ? "h-auto" : "h-11",
192
+ item.key === "/explorer" || item.key === "/products" ? "h-auto" : "h-11",
185
193
  item.show(pathname) ? "md:text-primary md:bg-primary/10" : "md:hover:bg-border"
186
194
  ),
187
- children: item.href === pathname ? item.label : /* @__PURE__ */ jsx(
195
+ children: !item.href || item.href === pathname ? item.label : /* @__PURE__ */ jsx(
188
196
  LinkBar,
189
197
  {
190
198
  href: item.href,
@@ -0,0 +1,89 @@
1
+ 'use client';
2
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
3
+ import Translation from "@0xchain/translation";
4
+ import { useLocale } from "@0xchain/i18n/react";
5
+ import { Dropdown } from "antd";
6
+ import { useState } from "react";
7
+ import { Accordion, AccordionItem, AccordionTrigger } from "@0xchain/ui/accordion";
8
+ const PRODUCT_ITEMS = [
9
+ {
10
+ key: "widget",
11
+ href: "/widget",
12
+ label: /* @__PURE__ */ jsx(Translation, { value: "products.widget", parentKey: "menu" })
13
+ }
14
+ ];
15
+ function Products({
16
+ onClick,
17
+ onExpandChange
18
+ }) {
19
+ const locale = useLocale();
20
+ const [accordionValue, setAccordionValue] = useState("");
21
+ const handleClick = (e, href) => {
22
+ e?.preventDefault();
23
+ e?.stopPropagation();
24
+ onClick?.();
25
+ setAccordionValue("");
26
+ const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || "";
27
+ window.location.href = `${baseUrl}/${locale}${href}`;
28
+ };
29
+ const renderItemContent = (item) => /* @__PURE__ */ jsx("div", { className: "w-full h-full flex items-center gap-2 py-2 cursor-pointer font-medium", children: item.label });
30
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
31
+ /* @__PURE__ */ jsx("div", { className: "hidden md:block", children: /* @__PURE__ */ jsx(
32
+ Dropdown,
33
+ {
34
+ getPopupContainer: () => document.body,
35
+ classNames: {
36
+ root: "w-50"
37
+ },
38
+ arrow: { pointAtCenter: true },
39
+ placement: "bottom",
40
+ menu: {
41
+ items: PRODUCT_ITEMS.map((item) => ({
42
+ label: renderItemContent(item),
43
+ key: item.key,
44
+ onClick: (info) => handleClick(info.domEvent, item.href)
45
+ }))
46
+ },
47
+ children: /* @__PURE__ */ jsx("div", { className: "whitespace-nowrap flex items-center gap-1 rounded-lg", children: /* @__PURE__ */ jsx(Translation, { value: "products.product", parentKey: "menu" }) })
48
+ }
49
+ ) }),
50
+ /* @__PURE__ */ jsx("div", { className: "md:hidden w-full", children: /* @__PURE__ */ jsxs("div", { onClick: (e) => {
51
+ e.preventDefault();
52
+ e.stopPropagation();
53
+ }, children: [
54
+ /* @__PURE__ */ jsx(
55
+ Accordion,
56
+ {
57
+ type: "single",
58
+ collapsible: true,
59
+ className: "w-full",
60
+ value: accordionValue,
61
+ onValueChange: (value) => {
62
+ setAccordionValue(value);
63
+ onExpandChange?.(!!value);
64
+ },
65
+ children: /* @__PURE__ */ jsx(AccordionItem, { value: "products", className: "border-0", children: /* @__PURE__ */ jsx(AccordionTrigger, { className: "rounded-lg font-medium h-11 w-full flex py-2 justify-between items-center hover:no-underline focus-visible:ring-0 focus-visible:ring-offset-0", children: /* @__PURE__ */ jsx("div", { className: "flex w-full justify-between items-center", children: /* @__PURE__ */ jsx("span", { className: "text-foreground", children: /* @__PURE__ */ jsx(Translation, { value: "products.product", parentKey: "menu" }) }) }) }) })
66
+ }
67
+ ),
68
+ /* @__PURE__ */ jsx(
69
+ "div",
70
+ {
71
+ className: "grid transition-[grid-template-rows] duration-300 ease-in-out",
72
+ style: { gridTemplateRows: accordionValue ? "1fr" : "0fr" },
73
+ children: /* @__PURE__ */ jsx("div", { className: "overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-3 rounded-lg flex flex-col gap-2 max-h-[60vh] overflow-auto", children: PRODUCT_ITEMS.map((item) => /* @__PURE__ */ jsx(
74
+ "div",
75
+ {
76
+ className: "w-full",
77
+ onClick: (e) => handleClick(e, item.href),
78
+ children: renderItemContent(item)
79
+ },
80
+ item.key
81
+ )) }) })
82
+ }
83
+ )
84
+ ] }) })
85
+ ] });
86
+ }
87
+ export {
88
+ Products as default
89
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xchain/header",
3
- "version": "1.1.0-beta.43",
3
+ "version": "1.1.0-beta.45",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -42,19 +42,19 @@
42
42
  "tailwind-merge": "3.3.1"
43
43
  },
44
44
  "dependencies": {
45
- "@0xchain/i18n": "1.1.0-beta.43",
46
- "@0xchain/avatar": "1.1.0-beta.43",
47
- "@0xchain/image": "1.1.0-beta.43",
48
- "@0xchain/link": "1.1.0-beta.43",
49
- "@0xchain/ui": "1.1.0-beta.43",
50
- "@0xchain/auth": "1.1.0-beta.43",
51
- "@0xchain/translation": "1.1.0-beta.43",
52
- "@0xchain/better-link": "1.1.0-beta.43",
53
- "@0xchain/request": "1.1.0-beta.43",
54
- "@0xchain/iconfont": "1.1.0-beta.43",
55
- "@0xchain/with-login": "1.1.0-beta.43",
56
- "@0xchain/theme-toggle": "1.1.0-beta.43",
57
- "@0xchain/tooltip": "1.1.0-beta.43"
45
+ "@0xchain/i18n": "1.1.0-beta.45",
46
+ "@0xchain/auth": "1.1.0-beta.45",
47
+ "@0xchain/link": "1.1.0-beta.45",
48
+ "@0xchain/translation": "1.1.0-beta.45",
49
+ "@0xchain/image": "1.1.0-beta.45",
50
+ "@0xchain/better-link": "1.1.0-beta.45",
51
+ "@0xchain/avatar": "1.1.0-beta.45",
52
+ "@0xchain/ui": "1.1.0-beta.45",
53
+ "@0xchain/theme-toggle": "1.1.0-beta.45",
54
+ "@0xchain/with-login": "1.1.0-beta.45",
55
+ "@0xchain/iconfont": "1.1.0-beta.45",
56
+ "@0xchain/tooltip": "1.1.0-beta.45",
57
+ "@0xchain/request": "1.1.0-beta.45"
58
58
  },
59
59
  "nx": {
60
60
  "tags": [