@medialane/ui 0.58.0 → 0.59.0
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/components/portfolio-header.cjs +101 -0
- package/dist/components/portfolio-header.cjs.map +1 -0
- package/dist/components/portfolio-header.d.cts +32 -0
- package/dist/components/portfolio-header.d.ts +32 -0
- package/dist/components/portfolio-header.js +67 -0
- package/dist/components/portfolio-header.js.map +1 -0
- package/dist/components/portfolio-nav.cjs +128 -0
- package/dist/components/portfolio-nav.cjs.map +1 -0
- package/dist/components/portfolio-nav.d.cts +36 -0
- package/dist/components/portfolio-nav.d.ts +36 -0
- package/dist/components/portfolio-nav.js +94 -0
- package/dist/components/portfolio-nav.js.map +1 -0
- package/dist/components/portfolio-overview.cjs +147 -0
- package/dist/components/portfolio-overview.cjs.map +1 -0
- package/dist/components/portfolio-overview.d.cts +41 -0
- package/dist/components/portfolio-overview.d.ts +41 -0
- package/dist/components/portfolio-overview.js +113 -0
- package/dist/components/portfolio-overview.js.map +1 -0
- package/dist/index.cjs +9 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/portfolio-subnav.cjs +0 -94
- package/dist/components/portfolio-subnav.cjs.map +0 -1
- package/dist/components/portfolio-subnav.d.cts +0 -27
- package/dist/components/portfolio-subnav.d.ts +0 -27
- package/dist/components/portfolio-subnav.js +0 -60
- package/dist/components/portfolio-subnav.js.map +0 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var portfolio_header_exports = {};
|
|
31
|
+
__export(portfolio_header_exports, {
|
|
32
|
+
PortfolioHeader: () => PortfolioHeader
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(portfolio_header_exports);
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_link = __toESM(require("next/link"), 1);
|
|
37
|
+
var import_lucide_react = require("lucide-react");
|
|
38
|
+
var import_cn = require("../utils/cn.js");
|
|
39
|
+
var import_address_display = require("./address-display.js");
|
|
40
|
+
function StatChip({ stat }) {
|
|
41
|
+
if (stat.value == null) {
|
|
42
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "bg-muted rounded-full px-3 py-1 w-20 h-6 animate-pulse inline-block" });
|
|
43
|
+
}
|
|
44
|
+
const body = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
45
|
+
"span",
|
|
46
|
+
{
|
|
47
|
+
className: (0, import_cn.cn)(
|
|
48
|
+
"inline-flex items-baseline gap-1.5 rounded-full px-3 py-1 text-sm font-medium",
|
|
49
|
+
stat.highlight ? "bg-primary/10 text-primary" : "bg-muted text-muted-foreground"
|
|
50
|
+
),
|
|
51
|
+
children: [
|
|
52
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "tabular-nums font-semibold text-foreground/90", children: stat.value }),
|
|
53
|
+
stat.label
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
if (!stat.href) return body;
|
|
58
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_link.default, { href: stat.href, className: "active:opacity-80", children: body });
|
|
59
|
+
}
|
|
60
|
+
function PortfolioHeader({
|
|
61
|
+
address,
|
|
62
|
+
stats,
|
|
63
|
+
score,
|
|
64
|
+
className
|
|
65
|
+
}) {
|
|
66
|
+
const scoreChip = score && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2.5 rounded-xl border border-border bg-card px-3 py-2", children: [
|
|
67
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
68
|
+
"div",
|
|
69
|
+
{
|
|
70
|
+
className: "h-8 w-8 rounded-lg shrink-0 flex items-center justify-center text-sm font-black text-white",
|
|
71
|
+
style: { backgroundColor: score.badgeColor },
|
|
72
|
+
children: score.level
|
|
73
|
+
}
|
|
74
|
+
),
|
|
75
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "min-w-0 leading-tight", children: [
|
|
76
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs font-bold text-foreground truncate", children: score.levelName }),
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "text-[11px] text-muted-foreground tabular-nums", children: [
|
|
78
|
+
score.totalXp.toLocaleString(),
|
|
79
|
+
" XP"
|
|
80
|
+
] })
|
|
81
|
+
] })
|
|
82
|
+
] });
|
|
83
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_cn.cn)("space-y-3", className), children: [
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-start justify-between gap-4", children: [
|
|
85
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-1.5 min-w-0", children: [
|
|
86
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2 text-primary", children: [
|
|
87
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Briefcase, { className: "h-4 w-4" }),
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-xs font-semibold uppercase tracking-wider", children: "Portfolio" })
|
|
89
|
+
] }),
|
|
90
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_address_display.AddressDisplay, { address, chars: 6, className: "text-sm" })
|
|
91
|
+
] }),
|
|
92
|
+
score?.href ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_link.default, { href: score.href, className: "shrink-0 active:opacity-80", children: scoreChip }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "shrink-0", children: scoreChip })
|
|
93
|
+
] }),
|
|
94
|
+
stats && stats.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex items-center gap-2 flex-wrap", children: stats.map((stat, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatChip, { stat }, i)) })
|
|
95
|
+
] });
|
|
96
|
+
}
|
|
97
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
98
|
+
0 && (module.exports = {
|
|
99
|
+
PortfolioHeader
|
|
100
|
+
});
|
|
101
|
+
//# sourceMappingURL=portfolio-header.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/portfolio-header.tsx"],"sourcesContent":["\"use client\";\n\nimport Link from \"next/link\";\nimport { Briefcase } from \"lucide-react\";\nimport { cn } from \"../utils/cn.js\";\nimport { AddressDisplay } from \"./address-display.js\";\n\nexport interface PortfolioHeaderStat {\n label: string;\n /** Pass null while loading — renders a pulse placeholder. */\n value: string | number | null;\n href?: string;\n /** Primary-tinted chip for counts that need action (e.g. offers received). */\n highlight?: boolean;\n}\n\nexport interface PortfolioHeaderScore {\n level: number;\n levelName: string;\n badgeColor: string;\n totalXp: number;\n /** Where the score chip links (\"/rewards\"). */\n href?: string;\n}\n\nexport interface PortfolioHeaderProps {\n address: string;\n stats?: PortfolioHeaderStat[];\n score?: PortfolioHeaderScore | null;\n className?: string;\n}\n\nfunction StatChip({ stat }: { stat: PortfolioHeaderStat }) {\n if (stat.value == null) {\n return (\n <span className=\"bg-muted rounded-full px-3 py-1 w-20 h-6 animate-pulse inline-block\" />\n );\n }\n const body = (\n <span\n className={cn(\n \"inline-flex items-baseline gap-1.5 rounded-full px-3 py-1 text-sm font-medium\",\n stat.highlight\n ? \"bg-primary/10 text-primary\"\n : \"bg-muted text-muted-foreground\",\n )}\n >\n <span className=\"tabular-nums font-semibold text-foreground/90\">\n {stat.value}\n </span>\n {stat.label}\n </span>\n );\n if (!stat.href) return body;\n return (\n <Link href={stat.href} className=\"active:opacity-80\">\n {body}\n </Link>\n );\n}\n\n/**\n * Compact single-block portfolio header: eyebrow + address on the left, a\n * level/XP score chip on the right, and a row of stat chips beneath. Replaces\n * the stacked identity / stat-pills / ScoreSummaryCard blocks.\n */\nexport function PortfolioHeader({\n address,\n stats,\n score,\n className,\n}: PortfolioHeaderProps) {\n const scoreChip = score && (\n <div className=\"flex items-center gap-2.5 rounded-xl border border-border bg-card px-3 py-2\">\n <div\n className=\"h-8 w-8 rounded-lg shrink-0 flex items-center justify-center text-sm font-black text-white\"\n style={{ backgroundColor: score.badgeColor }}\n >\n {score.level}\n </div>\n <div className=\"min-w-0 leading-tight\">\n <p className=\"text-xs font-bold text-foreground truncate\">\n {score.levelName}\n </p>\n <p className=\"text-[11px] text-muted-foreground tabular-nums\">\n {score.totalXp.toLocaleString()} XP\n </p>\n </div>\n </div>\n );\n\n return (\n <div className={cn(\"space-y-3\", className)}>\n <div className=\"flex items-start justify-between gap-4\">\n <div className=\"space-y-1.5 min-w-0\">\n <div className=\"flex items-center gap-2 text-primary\">\n <Briefcase className=\"h-4 w-4\" />\n <span className=\"text-xs font-semibold uppercase tracking-wider\">\n Portfolio\n </span>\n </div>\n <AddressDisplay address={address} chars={6} className=\"text-sm\" />\n </div>\n {score?.href ? (\n <Link href={score.href} className=\"shrink-0 active:opacity-80\">\n {scoreChip}\n </Link>\n ) : (\n <div className=\"shrink-0\">{scoreChip}</div>\n )}\n </div>\n {stats && stats.length > 0 && (\n <div className=\"flex items-center gap-2 flex-wrap\">\n {stats.map((stat, i) => (\n <StatChip key={i} stat={stat} />\n ))}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmCM;AAjCN,kBAAiB;AACjB,0BAA0B;AAC1B,gBAAmB;AACnB,6BAA+B;AA2B/B,SAAS,SAAS,EAAE,KAAK,GAAkC;AACzD,MAAI,KAAK,SAAS,MAAM;AACtB,WACE,4CAAC,UAAK,WAAU,uEAAsE;AAAA,EAE1F;AACA,QAAM,OACJ;AAAA,IAAC;AAAA;AAAA,MACC,eAAW;AAAA,QACT;AAAA,QACA,KAAK,YACD,+BACA;AAAA,MACN;AAAA,MAEA;AAAA,oDAAC,UAAK,WAAU,iDACb,eAAK,OACR;AAAA,QACC,KAAK;AAAA;AAAA;AAAA,EACR;AAEF,MAAI,CAAC,KAAK,KAAM,QAAO;AACvB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Stat {
|
|
4
|
+
label: string;
|
|
5
|
+
/** Pass null while loading — renders a pulse placeholder. */
|
|
6
|
+
value: string | number | null;
|
|
7
|
+
href?: string;
|
|
8
|
+
/** Primary-tinted chip for counts that need action (e.g. offers received). */
|
|
9
|
+
highlight?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface PortfolioHeaderScore {
|
|
12
|
+
level: number;
|
|
13
|
+
levelName: string;
|
|
14
|
+
badgeColor: string;
|
|
15
|
+
totalXp: number;
|
|
16
|
+
/** Where the score chip links ("/rewards"). */
|
|
17
|
+
href?: string;
|
|
18
|
+
}
|
|
19
|
+
interface PortfolioHeaderProps {
|
|
20
|
+
address: string;
|
|
21
|
+
stats?: PortfolioHeaderStat[];
|
|
22
|
+
score?: PortfolioHeaderScore | null;
|
|
23
|
+
className?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Compact single-block portfolio header: eyebrow + address on the left, a
|
|
27
|
+
* level/XP score chip on the right, and a row of stat chips beneath. Replaces
|
|
28
|
+
* the stacked identity / stat-pills / ScoreSummaryCard blocks.
|
|
29
|
+
*/
|
|
30
|
+
declare function PortfolioHeader({ address, stats, score, className, }: PortfolioHeaderProps): react_jsx_runtime.JSX.Element;
|
|
31
|
+
|
|
32
|
+
export { PortfolioHeader, type PortfolioHeaderProps, type PortfolioHeaderScore, type PortfolioHeaderStat };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface PortfolioHeaderStat {
|
|
4
|
+
label: string;
|
|
5
|
+
/** Pass null while loading — renders a pulse placeholder. */
|
|
6
|
+
value: string | number | null;
|
|
7
|
+
href?: string;
|
|
8
|
+
/** Primary-tinted chip for counts that need action (e.g. offers received). */
|
|
9
|
+
highlight?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface PortfolioHeaderScore {
|
|
12
|
+
level: number;
|
|
13
|
+
levelName: string;
|
|
14
|
+
badgeColor: string;
|
|
15
|
+
totalXp: number;
|
|
16
|
+
/** Where the score chip links ("/rewards"). */
|
|
17
|
+
href?: string;
|
|
18
|
+
}
|
|
19
|
+
interface PortfolioHeaderProps {
|
|
20
|
+
address: string;
|
|
21
|
+
stats?: PortfolioHeaderStat[];
|
|
22
|
+
score?: PortfolioHeaderScore | null;
|
|
23
|
+
className?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Compact single-block portfolio header: eyebrow + address on the left, a
|
|
27
|
+
* level/XP score chip on the right, and a row of stat chips beneath. Replaces
|
|
28
|
+
* the stacked identity / stat-pills / ScoreSummaryCard blocks.
|
|
29
|
+
*/
|
|
30
|
+
declare function PortfolioHeader({ address, stats, score, className, }: PortfolioHeaderProps): react_jsx_runtime.JSX.Element;
|
|
31
|
+
|
|
32
|
+
export { PortfolioHeader, type PortfolioHeaderProps, type PortfolioHeaderScore, type PortfolioHeaderStat };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import Link from "next/link";
|
|
4
|
+
import { Briefcase } from "lucide-react";
|
|
5
|
+
import { cn } from "../utils/cn.js";
|
|
6
|
+
import { AddressDisplay } from "./address-display.js";
|
|
7
|
+
function StatChip({ stat }) {
|
|
8
|
+
if (stat.value == null) {
|
|
9
|
+
return /* @__PURE__ */ jsx("span", { className: "bg-muted rounded-full px-3 py-1 w-20 h-6 animate-pulse inline-block" });
|
|
10
|
+
}
|
|
11
|
+
const body = /* @__PURE__ */ jsxs(
|
|
12
|
+
"span",
|
|
13
|
+
{
|
|
14
|
+
className: cn(
|
|
15
|
+
"inline-flex items-baseline gap-1.5 rounded-full px-3 py-1 text-sm font-medium",
|
|
16
|
+
stat.highlight ? "bg-primary/10 text-primary" : "bg-muted text-muted-foreground"
|
|
17
|
+
),
|
|
18
|
+
children: [
|
|
19
|
+
/* @__PURE__ */ jsx("span", { className: "tabular-nums font-semibold text-foreground/90", children: stat.value }),
|
|
20
|
+
stat.label
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
if (!stat.href) return body;
|
|
25
|
+
return /* @__PURE__ */ jsx(Link, { href: stat.href, className: "active:opacity-80", children: body });
|
|
26
|
+
}
|
|
27
|
+
function PortfolioHeader({
|
|
28
|
+
address,
|
|
29
|
+
stats,
|
|
30
|
+
score,
|
|
31
|
+
className
|
|
32
|
+
}) {
|
|
33
|
+
const scoreChip = score && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2.5 rounded-xl border border-border bg-card px-3 py-2", children: [
|
|
34
|
+
/* @__PURE__ */ jsx(
|
|
35
|
+
"div",
|
|
36
|
+
{
|
|
37
|
+
className: "h-8 w-8 rounded-lg shrink-0 flex items-center justify-center text-sm font-black text-white",
|
|
38
|
+
style: { backgroundColor: score.badgeColor },
|
|
39
|
+
children: score.level
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 leading-tight", children: [
|
|
43
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs font-bold text-foreground truncate", children: score.levelName }),
|
|
44
|
+
/* @__PURE__ */ jsxs("p", { className: "text-[11px] text-muted-foreground tabular-nums", children: [
|
|
45
|
+
score.totalXp.toLocaleString(),
|
|
46
|
+
" XP"
|
|
47
|
+
] })
|
|
48
|
+
] })
|
|
49
|
+
] });
|
|
50
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("space-y-3", className), children: [
|
|
51
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-4", children: [
|
|
52
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1.5 min-w-0", children: [
|
|
53
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-primary", children: [
|
|
54
|
+
/* @__PURE__ */ jsx(Briefcase, { className: "h-4 w-4" }),
|
|
55
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-semibold uppercase tracking-wider", children: "Portfolio" })
|
|
56
|
+
] }),
|
|
57
|
+
/* @__PURE__ */ jsx(AddressDisplay, { address, chars: 6, className: "text-sm" })
|
|
58
|
+
] }),
|
|
59
|
+
score?.href ? /* @__PURE__ */ jsx(Link, { href: score.href, className: "shrink-0 active:opacity-80", children: scoreChip }) : /* @__PURE__ */ jsx("div", { className: "shrink-0", children: scoreChip })
|
|
60
|
+
] }),
|
|
61
|
+
stats && stats.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 flex-wrap", children: stats.map((stat, i) => /* @__PURE__ */ jsx(StatChip, { stat }, i)) })
|
|
62
|
+
] });
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
PortfolioHeader
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=portfolio-header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/portfolio-header.tsx"],"sourcesContent":["\"use client\";\n\nimport Link from \"next/link\";\nimport { Briefcase } from \"lucide-react\";\nimport { cn } from \"../utils/cn.js\";\nimport { AddressDisplay } from \"./address-display.js\";\n\nexport interface PortfolioHeaderStat {\n label: string;\n /** Pass null while loading — renders a pulse placeholder. */\n value: string | number | null;\n href?: string;\n /** Primary-tinted chip for counts that need action (e.g. offers received). */\n highlight?: boolean;\n}\n\nexport interface PortfolioHeaderScore {\n level: number;\n levelName: string;\n badgeColor: string;\n totalXp: number;\n /** Where the score chip links (\"/rewards\"). */\n href?: string;\n}\n\nexport interface PortfolioHeaderProps {\n address: string;\n stats?: PortfolioHeaderStat[];\n score?: PortfolioHeaderScore | null;\n className?: string;\n}\n\nfunction StatChip({ stat }: { stat: PortfolioHeaderStat }) {\n if (stat.value == null) {\n return (\n <span className=\"bg-muted rounded-full px-3 py-1 w-20 h-6 animate-pulse inline-block\" />\n );\n }\n const body = (\n <span\n className={cn(\n \"inline-flex items-baseline gap-1.5 rounded-full px-3 py-1 text-sm font-medium\",\n stat.highlight\n ? \"bg-primary/10 text-primary\"\n : \"bg-muted text-muted-foreground\",\n )}\n >\n <span className=\"tabular-nums font-semibold text-foreground/90\">\n {stat.value}\n </span>\n {stat.label}\n </span>\n );\n if (!stat.href) return body;\n return (\n <Link href={stat.href} className=\"active:opacity-80\">\n {body}\n </Link>\n );\n}\n\n/**\n * Compact single-block portfolio header: eyebrow + address on the left, a\n * level/XP score chip on the right, and a row of stat chips beneath. Replaces\n * the stacked identity / stat-pills / ScoreSummaryCard blocks.\n */\nexport function PortfolioHeader({\n address,\n stats,\n score,\n className,\n}: PortfolioHeaderProps) {\n const scoreChip = score && (\n <div className=\"flex items-center gap-2.5 rounded-xl border border-border bg-card px-3 py-2\">\n <div\n className=\"h-8 w-8 rounded-lg shrink-0 flex items-center justify-center text-sm font-black text-white\"\n style={{ backgroundColor: score.badgeColor }}\n >\n {score.level}\n </div>\n <div className=\"min-w-0 leading-tight\">\n <p className=\"text-xs font-bold text-foreground truncate\">\n {score.levelName}\n </p>\n <p className=\"text-[11px] text-muted-foreground tabular-nums\">\n {score.totalXp.toLocaleString()} XP\n </p>\n </div>\n </div>\n );\n\n return (\n <div className={cn(\"space-y-3\", className)}>\n <div className=\"flex items-start justify-between gap-4\">\n <div className=\"space-y-1.5 min-w-0\">\n <div className=\"flex items-center gap-2 text-primary\">\n <Briefcase className=\"h-4 w-4\" />\n <span className=\"text-xs font-semibold uppercase tracking-wider\">\n Portfolio\n </span>\n </div>\n <AddressDisplay address={address} chars={6} className=\"text-sm\" />\n </div>\n {score?.href ? (\n <Link href={score.href} className=\"shrink-0 active:opacity-80\">\n {scoreChip}\n </Link>\n ) : (\n <div className=\"shrink-0\">{scoreChip}</div>\n )}\n </div>\n {stats && stats.length > 0 && (\n <div className=\"flex items-center gap-2 flex-wrap\">\n {stats.map((stat, i) => (\n <StatChip key={i} stat={stat} />\n ))}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";AAmCM,cAIF,YAJE;AAjCN,OAAO,UAAU;AACjB,SAAS,iBA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oBAAC,QAAK,MAAM,MAAM,MAAM,WAAU,8BAC/B,qBACH,IAEA,oBAAC,SAAI,WAAU,YAAY,qBAAU;AAAA,OAEzC;AAAA,IACC,SAAS,MAAM,SAAS,KACvB,oBAAC,SAAI,WAAU,qCACZ,gBAAM,IAAI,CAAC,MAAM,MAChB,oBAAC,YAAiB,QAAH,CAAe,CAC/B,GACH;AAAA,KAEJ;AAEJ;","names":[]}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var portfolio_nav_exports = {};
|
|
31
|
+
__export(portfolio_nav_exports, {
|
|
32
|
+
PortfolioNav: () => PortfolioNav
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(portfolio_nav_exports);
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_link = __toESM(require("next/link"), 1);
|
|
37
|
+
var import_cn = require("../utils/cn.js");
|
|
38
|
+
const BADGE_VARIANT_CLASS = {
|
|
39
|
+
destructive: "bg-destructive text-destructive-foreground",
|
|
40
|
+
primary: "bg-primary text-primary-foreground",
|
|
41
|
+
warning: "bg-amber-500 text-white"
|
|
42
|
+
};
|
|
43
|
+
function CountBadge({
|
|
44
|
+
count,
|
|
45
|
+
variant
|
|
46
|
+
}) {
|
|
47
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
48
|
+
"span",
|
|
49
|
+
{
|
|
50
|
+
className: (0, import_cn.cn)(
|
|
51
|
+
"h-4 min-w-4 rounded-full text-[10px] font-bold flex items-center justify-center px-1",
|
|
52
|
+
BADGE_VARIANT_CLASS[variant ?? "primary"]
|
|
53
|
+
),
|
|
54
|
+
children: count
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
function matches(pathname, href) {
|
|
59
|
+
return pathname === href || pathname.startsWith(href + "/");
|
|
60
|
+
}
|
|
61
|
+
function PortfolioNav({
|
|
62
|
+
sections,
|
|
63
|
+
pathname,
|
|
64
|
+
badgeCounts = {},
|
|
65
|
+
className
|
|
66
|
+
}) {
|
|
67
|
+
const count = (badge) => badge ? badgeCounts[badge.key] ?? 0 : 0;
|
|
68
|
+
let activeSection = null;
|
|
69
|
+
let bestLen = -1;
|
|
70
|
+
for (const section of sections) {
|
|
71
|
+
const hrefs = [section.href, ...(section.children ?? []).map((c) => c.href)];
|
|
72
|
+
for (const href of hrefs) {
|
|
73
|
+
if (matches(pathname, href) && href.length > bestLen) {
|
|
74
|
+
bestLen = href.length;
|
|
75
|
+
activeSection = section;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const edgeBleed = "overflow-x-auto scrollbar-hide -mx-4 px-4 sm:-mx-6 sm:px-6 lg:-mx-8 lg:px-8";
|
|
80
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className, children: [
|
|
81
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", { className: (0, import_cn.cn)(edgeBleed, "border-b border-border/60"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex items-center min-w-max", children: sections.map((section) => {
|
|
82
|
+
const active = section === activeSection;
|
|
83
|
+
const rollup = (section.children ?? []).reduce(
|
|
84
|
+
(sum, child) => sum + count(child.badge),
|
|
85
|
+
0
|
|
86
|
+
);
|
|
87
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
88
|
+
import_link.default,
|
|
89
|
+
{
|
|
90
|
+
href: section.href,
|
|
91
|
+
className: (0, import_cn.cn)(
|
|
92
|
+
"relative flex items-center gap-1.5 px-3 py-2.5 text-sm whitespace-nowrap transition-colors shrink-0 border-b-2 min-h-10",
|
|
93
|
+
active ? "border-primary text-foreground font-medium" : "border-transparent text-muted-foreground hover:text-foreground"
|
|
94
|
+
),
|
|
95
|
+
children: [
|
|
96
|
+
section.label,
|
|
97
|
+
rollup > 0 && !active && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CountBadge, { count: rollup, variant: "destructive" })
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
section.href
|
|
101
|
+
);
|
|
102
|
+
}) }) }),
|
|
103
|
+
activeSection?.children && activeSection.children.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", { className: (0, import_cn.cn)(edgeBleed, "pt-3"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex items-center min-w-max gap-1.5", children: activeSection.children.map((child) => {
|
|
104
|
+
const active = matches(pathname, child.href);
|
|
105
|
+
const childCount = count(child.badge);
|
|
106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
107
|
+
import_link.default,
|
|
108
|
+
{
|
|
109
|
+
href: child.href,
|
|
110
|
+
className: (0, import_cn.cn)(
|
|
111
|
+
"flex items-center gap-1.5 rounded-full px-3.5 py-1.5 text-[13px] whitespace-nowrap transition-colors shrink-0",
|
|
112
|
+
active ? "bg-primary text-primary-foreground font-medium" : "bg-muted text-muted-foreground hover:text-foreground"
|
|
113
|
+
),
|
|
114
|
+
children: [
|
|
115
|
+
child.label,
|
|
116
|
+
child.badge && childCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CountBadge, { count: childCount, variant: child.badge.variant })
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
child.href
|
|
120
|
+
);
|
|
121
|
+
}) }) })
|
|
122
|
+
] });
|
|
123
|
+
}
|
|
124
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
125
|
+
0 && (module.exports = {
|
|
126
|
+
PortfolioNav
|
|
127
|
+
});
|
|
128
|
+
//# sourceMappingURL=portfolio-nav.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/portfolio-nav.tsx"],"sourcesContent":["\"use client\";\n\nimport Link from \"next/link\";\nimport { cn } from \"../utils/cn.js\";\n\nexport type PortfolioBadgeVariant = \"destructive\" | \"primary\" | \"warning\";\n\nexport interface PortfolioNavChild {\n label: string;\n href: string;\n /** Optional count badge. `key` indexes `badgeCounts`; `variant` sets color. */\n badge?: { key: string; variant?: PortfolioBadgeVariant };\n}\n\nexport interface PortfolioNavSection {\n label: string;\n /** Where the top-level tab links. For sections with children this is the first child. */\n href: string;\n /** Inner segments rendered as a pill row when the section is active. */\n children?: PortfolioNavChild[];\n}\n\nexport interface PortfolioNavProps {\n sections: PortfolioNavSection[];\n /** Current pathname — caller passes `usePathname()`. */\n pathname: string;\n /** Badge counts keyed by `child.badge.key`. A badge renders only when > 0. */\n badgeCounts?: Record<string, number>;\n className?: string;\n}\n\nconst BADGE_VARIANT_CLASS: Record<PortfolioBadgeVariant, string> = {\n destructive: \"bg-destructive text-destructive-foreground\",\n primary: \"bg-primary text-primary-foreground\",\n warning: \"bg-amber-500 text-white\",\n};\n\nfunction CountBadge({\n count,\n variant,\n}: {\n count: number;\n variant?: PortfolioBadgeVariant;\n}) {\n return (\n <span\n className={cn(\n \"h-4 min-w-4 rounded-full text-[10px] font-bold flex items-center justify-center px-1\",\n BADGE_VARIANT_CLASS[variant ?? \"primary\"],\n )}\n >\n {count}\n </span>\n );\n}\n\nfunction matches(pathname: string, href: string): boolean {\n return pathname === href || pathname.startsWith(href + \"/\");\n}\n\n/**\n * Two-level portfolio navigation: top-level underline tabs + a segmented pill\n * row when the active section has children. The active section is resolved by\n * the longest href match across section hrefs and child hrefs, so a root\n * \"Overview\" section (`/portfolio`) doesn't swallow every route.\n */\nexport function PortfolioNav({\n sections,\n pathname,\n badgeCounts = {},\n className,\n}: PortfolioNavProps) {\n const count = (badge?: { key: string }) =>\n badge ? (badgeCounts[badge.key] ?? 0) : 0;\n\n // Longest-match resolution of the active section.\n let activeSection: PortfolioNavSection | null = null;\n let bestLen = -1;\n for (const section of sections) {\n const hrefs = [section.href, ...(section.children ?? []).map((c) => c.href)];\n for (const href of hrefs) {\n if (matches(pathname, href) && href.length > bestLen) {\n bestLen = href.length;\n activeSection = section;\n }\n }\n }\n\n const edgeBleed =\n \"overflow-x-auto scrollbar-hide -mx-4 px-4 sm:-mx-6 sm:px-6 lg:-mx-8 lg:px-8\";\n\n return (\n <div className={className}>\n <nav className={cn(edgeBleed, \"border-b border-border/60\")}>\n <div className=\"flex items-center min-w-max\">\n {sections.map((section) => {\n const active = section === activeSection;\n // Rolled-up pending count across the section's children.\n const rollup = (section.children ?? []).reduce(\n (sum, child) => sum + count(child.badge),\n 0,\n );\n return (\n <Link\n key={section.href}\n href={section.href}\n className={cn(\n \"relative flex items-center gap-1.5 px-3 py-2.5 text-sm whitespace-nowrap transition-colors shrink-0 border-b-2 min-h-10\",\n active\n ? \"border-primary text-foreground font-medium\"\n : \"border-transparent text-muted-foreground hover:text-foreground\",\n )}\n >\n {section.label}\n {rollup > 0 && !active && (\n <CountBadge count={rollup} variant=\"destructive\" />\n )}\n </Link>\n );\n })}\n </div>\n </nav>\n {activeSection?.children && activeSection.children.length > 0 && (\n <nav className={cn(edgeBleed, \"pt-3\")}>\n <div className=\"flex items-center min-w-max gap-1.5\">\n {activeSection.children.map((child) => {\n const active = matches(pathname, child.href);\n const childCount = count(child.badge);\n return (\n <Link\n key={child.href}\n href={child.href}\n className={cn(\n \"flex items-center gap-1.5 rounded-full px-3.5 py-1.5 text-[13px] whitespace-nowrap transition-colors shrink-0\",\n active\n ? \"bg-primary text-primary-foreground font-medium\"\n : \"bg-muted text-muted-foreground hover:text-foreground\",\n )}\n >\n {child.label}\n {child.badge && childCount > 0 && (\n <CountBadge count={childCount} variant={child.badge.variant} />\n )}\n </Link>\n );\n })}\n </div>\n </nav>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6CI;AA3CJ,kBAAiB;AACjB,gBAAmB;AA4BnB,MAAM,sBAA6D;AAAA,EACjE,aAAa;AAAA,EACb,SAAS;AAAA,EACT,SAAS;AACX;AAEA,SAAS,WAAW;AAAA,EAClB;AAAA,EACA;AACF,GAGG;AACD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAW;AAAA,QACT;AAAA,QACA,oBAAoB,WAAW,SAAS;AAAA,MAC1C;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;AAEA,SAAS,QAAQ,UAAkB,MAAuB;AACxD,SAAO,aAAa,QAAQ,SAAS,WA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,UAAU;AACrC,YAAM,SAAS,QAAQ,UAAU,MAAM,IAAI;AAC3C,YAAM,aAAa,MAAM,MAAM,KAAK;AACpC,aACE;AAAA,QAAC,YAAAA;AAAA,QAAA;AAAA,UAEC,MAAM,MAAM;AAAA,UACZ,eAAW;AAAA,YACT;AAAA,YACA,SACI,mDACA;AAAA,UACN;AAAA,UAEC;AAAA,kBAAM;AAAA,YACN,MAAM,SAAS,aAAa,KAC3B,4CAAC,cAAW,OAAO,YAAY,SAAS,MAAM,MAAM,SAAS;AAAA;AAAA;AAAA,QAX1D,MAAM;AAAA,MAab;AAAA,IAEJ,CAAC,GACH,GACF;AAAA,KAEJ;AAEJ;","names":["Link"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
type PortfolioBadgeVariant = "destructive" | "primary" | "warning";
|
|
4
|
+
interface PortfolioNavChild {
|
|
5
|
+
label: string;
|
|
6
|
+
href: string;
|
|
7
|
+
/** Optional count badge. `key` indexes `badgeCounts`; `variant` sets color. */
|
|
8
|
+
badge?: {
|
|
9
|
+
key: string;
|
|
10
|
+
variant?: PortfolioBadgeVariant;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
interface PortfolioNavSection {
|
|
14
|
+
label: string;
|
|
15
|
+
/** Where the top-level tab links. For sections with children this is the first child. */
|
|
16
|
+
href: string;
|
|
17
|
+
/** Inner segments rendered as a pill row when the section is active. */
|
|
18
|
+
children?: PortfolioNavChild[];
|
|
19
|
+
}
|
|
20
|
+
interface PortfolioNavProps {
|
|
21
|
+
sections: PortfolioNavSection[];
|
|
22
|
+
/** Current pathname — caller passes `usePathname()`. */
|
|
23
|
+
pathname: string;
|
|
24
|
+
/** Badge counts keyed by `child.badge.key`. A badge renders only when > 0. */
|
|
25
|
+
badgeCounts?: Record<string, number>;
|
|
26
|
+
className?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Two-level portfolio navigation: top-level underline tabs + a segmented pill
|
|
30
|
+
* row when the active section has children. The active section is resolved by
|
|
31
|
+
* the longest href match across section hrefs and child hrefs, so a root
|
|
32
|
+
* "Overview" section (`/portfolio`) doesn't swallow every route.
|
|
33
|
+
*/
|
|
34
|
+
declare function PortfolioNav({ sections, pathname, badgeCounts, className, }: PortfolioNavProps): react_jsx_runtime.JSX.Element;
|
|
35
|
+
|
|
36
|
+
export { type PortfolioBadgeVariant, PortfolioNav, type PortfolioNavChild, type PortfolioNavProps, type PortfolioNavSection };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
type PortfolioBadgeVariant = "destructive" | "primary" | "warning";
|
|
4
|
+
interface PortfolioNavChild {
|
|
5
|
+
label: string;
|
|
6
|
+
href: string;
|
|
7
|
+
/** Optional count badge. `key` indexes `badgeCounts`; `variant` sets color. */
|
|
8
|
+
badge?: {
|
|
9
|
+
key: string;
|
|
10
|
+
variant?: PortfolioBadgeVariant;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
interface PortfolioNavSection {
|
|
14
|
+
label: string;
|
|
15
|
+
/** Where the top-level tab links. For sections with children this is the first child. */
|
|
16
|
+
href: string;
|
|
17
|
+
/** Inner segments rendered as a pill row when the section is active. */
|
|
18
|
+
children?: PortfolioNavChild[];
|
|
19
|
+
}
|
|
20
|
+
interface PortfolioNavProps {
|
|
21
|
+
sections: PortfolioNavSection[];
|
|
22
|
+
/** Current pathname — caller passes `usePathname()`. */
|
|
23
|
+
pathname: string;
|
|
24
|
+
/** Badge counts keyed by `child.badge.key`. A badge renders only when > 0. */
|
|
25
|
+
badgeCounts?: Record<string, number>;
|
|
26
|
+
className?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Two-level portfolio navigation: top-level underline tabs + a segmented pill
|
|
30
|
+
* row when the active section has children. The active section is resolved by
|
|
31
|
+
* the longest href match across section hrefs and child hrefs, so a root
|
|
32
|
+
* "Overview" section (`/portfolio`) doesn't swallow every route.
|
|
33
|
+
*/
|
|
34
|
+
declare function PortfolioNav({ sections, pathname, badgeCounts, className, }: PortfolioNavProps): react_jsx_runtime.JSX.Element;
|
|
35
|
+
|
|
36
|
+
export { type PortfolioBadgeVariant, PortfolioNav, type PortfolioNavChild, type PortfolioNavProps, type PortfolioNavSection };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import Link from "next/link";
|
|
4
|
+
import { cn } from "../utils/cn.js";
|
|
5
|
+
const BADGE_VARIANT_CLASS = {
|
|
6
|
+
destructive: "bg-destructive text-destructive-foreground",
|
|
7
|
+
primary: "bg-primary text-primary-foreground",
|
|
8
|
+
warning: "bg-amber-500 text-white"
|
|
9
|
+
};
|
|
10
|
+
function CountBadge({
|
|
11
|
+
count,
|
|
12
|
+
variant
|
|
13
|
+
}) {
|
|
14
|
+
return /* @__PURE__ */ jsx(
|
|
15
|
+
"span",
|
|
16
|
+
{
|
|
17
|
+
className: cn(
|
|
18
|
+
"h-4 min-w-4 rounded-full text-[10px] font-bold flex items-center justify-center px-1",
|
|
19
|
+
BADGE_VARIANT_CLASS[variant ?? "primary"]
|
|
20
|
+
),
|
|
21
|
+
children: count
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
function matches(pathname, href) {
|
|
26
|
+
return pathname === href || pathname.startsWith(href + "/");
|
|
27
|
+
}
|
|
28
|
+
function PortfolioNav({
|
|
29
|
+
sections,
|
|
30
|
+
pathname,
|
|
31
|
+
badgeCounts = {},
|
|
32
|
+
className
|
|
33
|
+
}) {
|
|
34
|
+
const count = (badge) => badge ? badgeCounts[badge.key] ?? 0 : 0;
|
|
35
|
+
let activeSection = null;
|
|
36
|
+
let bestLen = -1;
|
|
37
|
+
for (const section of sections) {
|
|
38
|
+
const hrefs = [section.href, ...(section.children ?? []).map((c) => c.href)];
|
|
39
|
+
for (const href of hrefs) {
|
|
40
|
+
if (matches(pathname, href) && href.length > bestLen) {
|
|
41
|
+
bestLen = href.length;
|
|
42
|
+
activeSection = section;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const edgeBleed = "overflow-x-auto scrollbar-hide -mx-4 px-4 sm:-mx-6 sm:px-6 lg:-mx-8 lg:px-8";
|
|
47
|
+
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
48
|
+
/* @__PURE__ */ jsx("nav", { className: cn(edgeBleed, "border-b border-border/60"), children: /* @__PURE__ */ jsx("div", { className: "flex items-center min-w-max", children: sections.map((section) => {
|
|
49
|
+
const active = section === activeSection;
|
|
50
|
+
const rollup = (section.children ?? []).reduce(
|
|
51
|
+
(sum, child) => sum + count(child.badge),
|
|
52
|
+
0
|
|
53
|
+
);
|
|
54
|
+
return /* @__PURE__ */ jsxs(
|
|
55
|
+
Link,
|
|
56
|
+
{
|
|
57
|
+
href: section.href,
|
|
58
|
+
className: cn(
|
|
59
|
+
"relative flex items-center gap-1.5 px-3 py-2.5 text-sm whitespace-nowrap transition-colors shrink-0 border-b-2 min-h-10",
|
|
60
|
+
active ? "border-primary text-foreground font-medium" : "border-transparent text-muted-foreground hover:text-foreground"
|
|
61
|
+
),
|
|
62
|
+
children: [
|
|
63
|
+
section.label,
|
|
64
|
+
rollup > 0 && !active && /* @__PURE__ */ jsx(CountBadge, { count: rollup, variant: "destructive" })
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
section.href
|
|
68
|
+
);
|
|
69
|
+
}) }) }),
|
|
70
|
+
activeSection?.children && activeSection.children.length > 0 && /* @__PURE__ */ jsx("nav", { className: cn(edgeBleed, "pt-3"), children: /* @__PURE__ */ jsx("div", { className: "flex items-center min-w-max gap-1.5", children: activeSection.children.map((child) => {
|
|
71
|
+
const active = matches(pathname, child.href);
|
|
72
|
+
const childCount = count(child.badge);
|
|
73
|
+
return /* @__PURE__ */ jsxs(
|
|
74
|
+
Link,
|
|
75
|
+
{
|
|
76
|
+
href: child.href,
|
|
77
|
+
className: cn(
|
|
78
|
+
"flex items-center gap-1.5 rounded-full px-3.5 py-1.5 text-[13px] whitespace-nowrap transition-colors shrink-0",
|
|
79
|
+
active ? "bg-primary text-primary-foreground font-medium" : "bg-muted text-muted-foreground hover:text-foreground"
|
|
80
|
+
),
|
|
81
|
+
children: [
|
|
82
|
+
child.label,
|
|
83
|
+
child.badge && childCount > 0 && /* @__PURE__ */ jsx(CountBadge, { count: childCount, variant: child.badge.variant })
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
child.href
|
|
87
|
+
);
|
|
88
|
+
}) }) })
|
|
89
|
+
] });
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
PortfolioNav
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=portfolio-nav.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/portfolio-nav.tsx"],"sourcesContent":["\"use client\";\n\nimport Link from \"next/link\";\nimport { cn } from \"../utils/cn.js\";\n\nexport type PortfolioBadgeVariant = \"destructive\" | \"primary\" | \"warning\";\n\nexport interface PortfolioNavChild {\n label: string;\n href: string;\n /** Optional count badge. `key` indexes `badgeCounts`; `variant` sets color. */\n badge?: { key: string; variant?: PortfolioBadgeVariant };\n}\n\nexport interface PortfolioNavSection {\n label: string;\n /** Where the top-level tab links. For sections with children this is the first child. */\n href: string;\n /** Inner segments rendered as a pill row when the section is active. */\n children?: PortfolioNavChild[];\n}\n\nexport interface PortfolioNavProps {\n sections: PortfolioNavSection[];\n /** Current pathname — caller passes `usePathname()`. */\n pathname: string;\n /** Badge counts keyed by `child.badge.key`. A badge renders only when > 0. */\n badgeCounts?: Record<string, number>;\n className?: string;\n}\n\nconst BADGE_VARIANT_CLASS: Record<PortfolioBadgeVariant, string> = {\n destructive: \"bg-destructive text-destructive-foreground\",\n primary: \"bg-primary text-primary-foreground\",\n warning: \"bg-amber-500 text-white\",\n};\n\nfunction CountBadge({\n count,\n variant,\n}: {\n count: number;\n variant?: PortfolioBadgeVariant;\n}) {\n return (\n <span\n className={cn(\n \"h-4 min-w-4 rounded-full text-[10px] font-bold flex items-center justify-center px-1\",\n BADGE_VARIANT_CLASS[variant ?? \"primary\"],\n )}\n >\n {count}\n </span>\n );\n}\n\nfunction matches(pathname: string, href: string): boolean {\n return pathname === href || pathname.startsWith(href + \"/\");\n}\n\n/**\n * Two-level portfolio navigation: top-level underline tabs + a segmented pill\n * row when the active section has children. The active section is resolved by\n * the longest href match across section hrefs and child hrefs, so a root\n * \"Overview\" section (`/portfolio`) doesn't swallow every route.\n */\nexport function PortfolioNav({\n sections,\n pathname,\n badgeCounts = {},\n className,\n}: PortfolioNavProps) {\n const count = (badge?: { key: string }) =>\n badge ? (badgeCounts[badge.key] ?? 0) : 0;\n\n // Longest-match resolution of the active section.\n let activeSection: PortfolioNavSection | null = null;\n let bestLen = -1;\n for (const section of sections) {\n const hrefs = [section.href, ...(section.children ?? []).map((c) => c.href)];\n for (const href of hrefs) {\n if (matches(pathname, href) && href.length > bestLen) {\n bestLen = href.length;\n activeSection = section;\n }\n }\n }\n\n const edgeBleed =\n \"overflow-x-auto scrollbar-hide -mx-4 px-4 sm:-mx-6 sm:px-6 lg:-mx-8 lg:px-8\";\n\n return (\n <div className={className}>\n <nav className={cn(edgeBleed, \"border-b border-border/60\")}>\n <div className=\"flex items-center min-w-max\">\n {sections.map((section) => {\n const active = section === activeSection;\n // Rolled-up pending count across the section's children.\n const rollup = (section.children ?? []).reduce(\n (sum, child) => sum + count(child.badge),\n 0,\n );\n return (\n <Link\n key={section.href}\n href={section.href}\n className={cn(\n \"relative flex items-center gap-1.5 px-3 py-2.5 text-sm whitespace-nowrap transition-colors shrink-0 border-b-2 min-h-10\",\n active\n ? \"border-primary text-foreground font-medium\"\n : \"border-transparent text-muted-foreground hover:text-foreground\",\n )}\n >\n {section.label}\n {rollup > 0 && !active && (\n <CountBadge count={rollup} variant=\"destructive\" />\n )}\n </Link>\n );\n })}\n </div>\n </nav>\n {activeSection?.children && activeSection.children.length > 0 && (\n <nav className={cn(edgeBleed, \"pt-3\")}>\n <div className=\"flex items-center min-w-max gap-1.5\">\n {activeSection.children.map((child) => {\n const active = matches(pathname, child.href);\n const childCount = count(child.badge);\n return (\n <Link\n key={child.href}\n href={child.href}\n className={cn(\n \"flex items-center gap-1.5 rounded-full px-3.5 py-1.5 text-[13px] whitespace-nowrap transition-colors shrink-0\",\n active\n ? \"bg-primary text-primary-foreground font-medium\"\n : \"bg-muted text-muted-foreground hover:text-foreground\",\n )}\n >\n {child.label}\n {child.badge && childCount > 0 && (\n <CountBadge count={childCount} variant={child.badge.variant} />\n )}\n </Link>\n );\n })}\n </div>\n </nav>\n )}\n </div>\n );\n}\n"],"mappings":";AA6CI,cA0DU,YA1DV;AA3CJ,OAAO,UAAU;AACjB,SAAS,UAAU;AA4BnB,MAAM,sBAA6D;AAAA,EACjE,aAAa;AAAA,EACb,SAAS;AAAA,EACT,SAAS;AACX;AAEA,SAAS,WAAW;AAAA,EAClB;AAAA,EACA;AACF,GAGG;AACD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,oBAAoB,WAAW,SAAS;AAAA,MAC1C;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;AAEA,SAAS,QAAQ,UAAkB,MAAuB;AACxD,SAAO,aAAa,QAAQ,SAAS,WAAW,OAAO,GAAG;AAC5D;AAQO,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AAAA,EACA,cAAc,CAAC;AAAA,EACf;AACF,GAAsB;AACpB,QAAM,QAAQ,CAAC,UACb,QAAS,YAAY,MAAM,GAAG,KAAK,IAAK;AAG1C,MAAI,gBAA4C;AAChD,MAAI,UAAU;AACd,aAAW,WAAW,UAAU;AAC9B,UAAM,QAAQ,CAAC,QAAQ,MAAM,IAAI,QAAQ,YAAY,CA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