@next-library/theme 1.0.11 → 1.0.13

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.
@@ -1 +1 @@
1
- {"version":3,"file":"copy-page-button.d.ts","sourceRoot":"","sources":["../../../src/components/markdown/copy-page-button.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAyCjD,UAAU,0BAA0B;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,mBAAmB;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,0BAA0B,CAAC;CAC3C;AAED,wBAAgB,cAAc,CAAC,EAC7B,UAAU,EACV,OAAO,EACP,YAAY,EACZ,SAAS,EACT,MAAa,EACb,YAAiB,GAClB,EAAE,mBAAmB,2CAmIrB"}
1
+ {"version":3,"file":"copy-page-button.d.ts","sourceRoot":"","sources":["../../../src/components/markdown/copy-page-button.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAyCjD,UAAU,0BAA0B;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,mBAAmB;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,0BAA0B,CAAC;CAC3C;AAED,wBAAgB,cAAc,CAAC,EAC7B,UAAU,EACV,OAAO,EACP,YAAY,EACZ,SAAS,EACT,MAAa,EACb,YAAiB,GAClB,EAAE,mBAAmB,2CAkHrB"}
@@ -7,9 +7,11 @@ export declare function parseGithubRepo(repoUrl: string): string | null;
7
7
  export declare function formatStarCount(count: number): string;
8
8
  /**
9
9
  * "Star on GitHub" control for the navbar, styled like the other navbar
10
- * controls (32px tall, bordered, design tokens) instead of GitHub's embedded
11
- * iframe button, which was 20px tall, used GitHub's own typography and never
12
- * lined up with its neighbours. The star count is fetched once per session.
10
+ * controls (32px tall, bordered, design tokens). The star count is fetched once
11
+ * per session. A gentle nudge invites a star: once per session, shortly after
12
+ * load, a gold star flies up into the button (the "star given" moment), and the
13
+ * mark twinkles periodically until the visitor clicks through. Both respect
14
+ * prefers-reduced-motion and stop for good once the visitor has engaged.
13
15
  */
14
16
  export declare function GithubStar({ repoUrl }: GithubStarProps): import("react/jsx-runtime").JSX.Element | null;
15
17
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"github-star.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/navbar/github-star.tsx"],"names":[],"mappings":"AAKA,UAAU,eAAe;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD,sEAAsE;AACtE,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI9D;AAED,oCAAoC;AACpC,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIrD;AAqBD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,EAAE,eAAe,kDAsDtD"}
1
+ {"version":3,"file":"github-star.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/navbar/github-star.tsx"],"names":[],"mappings":"AAKA,UAAU,eAAe;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD,sEAAsE;AACtE,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI9D;AAED,oCAAoC;AACpC,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIrD;AA6BD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,EAAE,eAAe,kDA2GtD"}
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import Link2 from 'next/link';
8
8
  import Image from 'next/image';
9
9
  import { clsx } from 'clsx';
10
10
  import { twMerge } from 'tailwind-merge';
11
- import { ArrowLeft, ArrowRight, Pencil, AlertTriangle, Search, Loader2, ArrowUp, ArrowDown, CornerDownLeft, CheckIcon, CircleIcon, ChevronRightIcon, LanguagesIcon, XIcon, PanelLeftIcon, FolderOpenIcon, FolderClosedIcon, ChevronRight, ChevronDown, FileTextIcon, Menu, Star, GithubIcon, MoreHorizontal, Home, ExternalLinkIcon, CopyIcon, ChevronDownIcon, CookieIcon, ChevronUpIcon, FolderUp, ChevronLeft, Check, Copy } from 'lucide-react';
11
+ import { ArrowLeft, ArrowRight, Pencil, AlertTriangle, Search, Loader2, ArrowUp, ArrowDown, CornerDownLeft, CheckIcon, CircleIcon, ChevronRightIcon, LanguagesIcon, XIcon, PanelLeftIcon, FolderOpenIcon, FolderClosedIcon, ChevronRight, ChevronDown, FileTextIcon, Menu, Star, GithubIcon, MoreHorizontal, Home, ExternalLinkIcon, CopyIcon, CookieIcon, ChevronDownIcon, ChevronUpIcon, FolderUp, ChevronLeft, Check, Copy } from 'lucide-react';
12
12
  import { useScroll, useMotionValueEvent, motion } from 'motion/react';
13
13
  import { createPortal } from 'react-dom';
14
14
  import { useRouter } from 'next/navigation';
@@ -5153,9 +5153,18 @@ function writeCachedCount(repo, count) {
5153
5153
  } catch {
5154
5154
  }
5155
5155
  }
5156
+ function hasEngaged() {
5157
+ try {
5158
+ return localStorage.getItem("nl-star-engaged") === "1";
5159
+ } catch {
5160
+ return false;
5161
+ }
5162
+ }
5156
5163
  function GithubStar2({ repoUrl }) {
5157
5164
  const repo = repoUrl ? parseGithubRepo(repoUrl) : null;
5158
5165
  const [count, setCount] = useState(null);
5166
+ const [nudge, setNudge] = useState(false);
5167
+ const [engaged, setEngaged] = useState(true);
5159
5168
  useEffect(() => {
5160
5169
  if (!repo) return;
5161
5170
  const cached = readCachedCount(repo);
@@ -5176,9 +5185,34 @@ function GithubStar2({ repoUrl }) {
5176
5185
  });
5177
5186
  return () => controller.abort();
5178
5187
  }, [repo]);
5188
+ useEffect(() => {
5189
+ if (!repoUrl) return;
5190
+ const already = hasEngaged();
5191
+ setEngaged(already);
5192
+ if (already) return;
5193
+ const reduce = typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
5194
+ let nudgedThisSession = false;
5195
+ try {
5196
+ nudgedThisSession = sessionStorage.getItem("nl-star-nudged") === "1";
5197
+ } catch {
5198
+ }
5199
+ if (reduce || nudgedThisSession) return;
5200
+ const start = setTimeout(() => {
5201
+ setNudge(true);
5202
+ try {
5203
+ sessionStorage.setItem("nl-star-nudged", "1");
5204
+ } catch {
5205
+ }
5206
+ const stop = setTimeout(() => setNudge(false), 2400);
5207
+ cleanups.push(() => clearTimeout(stop));
5208
+ }, 1800);
5209
+ const cleanups = [() => clearTimeout(start)];
5210
+ return () => cleanups.forEach((fn) => fn());
5211
+ }, [repoUrl]);
5179
5212
  if (!repoUrl) {
5180
5213
  return null;
5181
5214
  }
5215
+ const markTwinkle = !engaged;
5182
5216
  return /* @__PURE__ */ jsxs(
5183
5217
  "a",
5184
5218
  {
@@ -5187,9 +5221,26 @@ function GithubStar2({ repoUrl }) {
5187
5221
  rel: "noopener noreferrer",
5188
5222
  "aria-label": "Star on GitHub",
5189
5223
  "data-testid": "github-star-link",
5190
- className: "ml-1 inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-[13px] font-medium text-foreground transition-colors hover:bg-accent",
5224
+ onClick: () => {
5225
+ try {
5226
+ localStorage.setItem("nl-star-engaged", "1");
5227
+ } catch {
5228
+ }
5229
+ setEngaged(true);
5230
+ setNudge(false);
5231
+ },
5232
+ className: `nl-star-btn ml-1 inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-[13px] font-medium text-foreground transition-colors hover:bg-accent${nudge ? " nl-star-btn--nudge" : ""}`,
5191
5233
  children: [
5192
- /* @__PURE__ */ jsx(Star, { className: "size-3.5", "aria-hidden": "true" }),
5234
+ /* @__PURE__ */ jsxs("span", { className: "nl-star-ico relative inline-flex", children: [
5235
+ /* @__PURE__ */ jsx(
5236
+ Star,
5237
+ {
5238
+ className: `size-3.5 nl-star-mark${markTwinkle ? " nl-star-mark--twinkle" : ""}`,
5239
+ "aria-hidden": "true"
5240
+ }
5241
+ ),
5242
+ nudge && /* @__PURE__ */ jsx(Star, { className: "nl-star-fly size-3.5", "aria-hidden": "true" })
5243
+ ] }),
5193
5244
  /* @__PURE__ */ jsx("span", { children: "Star" }),
5194
5245
  count !== null && /* @__PURE__ */ jsx(
5195
5246
  "span",
@@ -5907,56 +5958,47 @@ function CopyPageButton2({
5907
5958
  const claudeUrl = `https://claude.ai/new?q=${encodedMessage}`;
5908
5959
  window.open(claudeUrl, "_blank", "noopener,noreferrer");
5909
5960
  }
5910
- return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
5911
- /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
5912
- Button,
5913
- {
5914
- variant: "outline",
5915
- size: "sm",
5916
- className: cn(
5917
- "flex gap-2 text-sm font-medium items-center",
5918
- isCopied && "opacity-70",
5919
- className
5961
+ const segment = "inline-flex h-8 items-center gap-1.5 whitespace-nowrap px-2.5 text-[13px] font-medium text-foreground transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50";
5962
+ return /* @__PURE__ */ jsxs(
5963
+ "div",
5964
+ {
5965
+ role: "group",
5966
+ "aria-label": _askAboutThisPage,
5967
+ className: cn(
5968
+ // Segmented control: one border, dividers between the three actions.
5969
+ "inline-flex items-stretch overflow-hidden rounded-md border bg-card shadow-xs divide-x divide-border",
5970
+ className
5971
+ ),
5972
+ children: [
5973
+ /* @__PURE__ */ jsxs(
5974
+ "button",
5975
+ {
5976
+ type: "button",
5977
+ onClick: handleCopy,
5978
+ title: copyPageDescription,
5979
+ "aria-live": "polite",
5980
+ className: cn(segment, isCopied && "text-muted-foreground"),
5981
+ children: [
5982
+ isCopied ? /* @__PURE__ */ jsx(CheckIcon, { className: "size-3.5", "aria-hidden": true }) : /* @__PURE__ */ jsx(CopyIcon, { className: "size-3.5", "aria-hidden": true }),
5983
+ isCopied ? copied : copyPage
5984
+ ]
5985
+ }
5920
5986
  ),
5921
- children: [
5922
- /* @__PURE__ */ jsx(CopyIcon, { width: "16" }),
5923
- isCopied ? copied : copyPage,
5924
- /* @__PURE__ */ jsx(ChevronDownIcon, { width: "14", className: "opacity-50" })
5925
- ]
5926
- }
5927
- ) }),
5928
- /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "min-w-[200px]", children: [
5929
- /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: handleCopy, children: [
5930
- /* @__PURE__ */ jsx(CopyIcon, { width: "16", className: "mr-2" }),
5931
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
5932
- /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: copyPage }),
5933
- /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: copyPageDescription })
5934
- ] })
5935
- ] }),
5936
- pageUrl && /* @__PURE__ */ jsxs(Fragment, { children: [
5937
- /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: handleOpenInChatGPT, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
5938
- /* @__PURE__ */ jsx(ChatGPTIcon, { className: "w-4 h-4 shrink-0" }),
5939
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col flex-1", children: [
5940
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
5941
- /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: openInChatGPT }),
5942
- /* @__PURE__ */ jsx(ExternalLinkIcon, { width: "12", className: "text-muted-foreground shrink-0" })
5943
- ] }),
5944
- /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: askQuestionsDescription })
5945
- ] })
5946
- ] }) }),
5947
- /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: handleOpenInClaude, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
5948
- /* @__PURE__ */ jsx(ClaudeIcon, { className: "w-4 h-4 shrink-0" }),
5949
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col flex-1", children: [
5950
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
5951
- /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: openInClaude }),
5952
- /* @__PURE__ */ jsx(ExternalLinkIcon, { width: "12", className: "text-muted-foreground shrink-0" })
5953
- ] }),
5954
- /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: askQuestionsDescription })
5987
+ pageUrl && /* @__PURE__ */ jsxs(Fragment, { children: [
5988
+ /* @__PURE__ */ jsxs("button", { type: "button", onClick: handleOpenInChatGPT, title: askQuestionsDescription, className: segment, children: [
5989
+ /* @__PURE__ */ jsx(ChatGPTIcon, { className: "size-3.5 shrink-0" }),
5990
+ /* @__PURE__ */ jsx("span", { children: openInChatGPT }),
5991
+ /* @__PURE__ */ jsx(ExternalLinkIcon, { className: "size-3 text-muted-foreground", "aria-hidden": true })
5992
+ ] }),
5993
+ /* @__PURE__ */ jsxs("button", { type: "button", onClick: handleOpenInClaude, title: askQuestionsDescription, className: segment, children: [
5994
+ /* @__PURE__ */ jsx(ClaudeIcon, { className: "size-3.5 shrink-0" }),
5995
+ /* @__PURE__ */ jsx("span", { children: openInClaude }),
5996
+ /* @__PURE__ */ jsx(ExternalLinkIcon, { className: "size-3 text-muted-foreground", "aria-hidden": true })
5955
5997
  ] })
5956
- ] }) })
5957
- ] })
5958
- ] })
5959
- ] });
5998
+ ] })
5999
+ ]
6000
+ }
6001
+ );
5960
6002
  }
5961
6003
  function track(event, data) {
5962
6004
  if (typeof window !== "undefined") {