@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.
package/dist/client.js CHANGED
@@ -10,7 +10,7 @@ import Link3 from 'next/link';
10
10
  import Image from 'next/image';
11
11
  import { createPortal } from 'react-dom';
12
12
  import { useRouter } from 'next/navigation';
13
- import { 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';
13
+ import { 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';
14
14
  import { useTheme } from 'next-themes';
15
15
  import { useLocale } from '@next-library/core/hooks';
16
16
  import { Slot } from '@radix-ui/react-slot';
@@ -4236,9 +4236,18 @@ function writeCachedCount(repo, count) {
4236
4236
  } catch {
4237
4237
  }
4238
4238
  }
4239
+ function hasEngaged() {
4240
+ try {
4241
+ return localStorage.getItem("nl-star-engaged") === "1";
4242
+ } catch {
4243
+ return false;
4244
+ }
4245
+ }
4239
4246
  function GithubStar({ repoUrl }) {
4240
4247
  const repo = repoUrl ? parseGithubRepo(repoUrl) : null;
4241
4248
  const [count, setCount] = useState(null);
4249
+ const [nudge, setNudge] = useState(false);
4250
+ const [engaged, setEngaged] = useState(true);
4242
4251
  useEffect(() => {
4243
4252
  if (!repo) return;
4244
4253
  const cached = readCachedCount(repo);
@@ -4259,9 +4268,34 @@ function GithubStar({ repoUrl }) {
4259
4268
  });
4260
4269
  return () => controller.abort();
4261
4270
  }, [repo]);
4271
+ useEffect(() => {
4272
+ if (!repoUrl) return;
4273
+ const already = hasEngaged();
4274
+ setEngaged(already);
4275
+ if (already) return;
4276
+ const reduce = typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
4277
+ let nudgedThisSession = false;
4278
+ try {
4279
+ nudgedThisSession = sessionStorage.getItem("nl-star-nudged") === "1";
4280
+ } catch {
4281
+ }
4282
+ if (reduce || nudgedThisSession) return;
4283
+ const start = setTimeout(() => {
4284
+ setNudge(true);
4285
+ try {
4286
+ sessionStorage.setItem("nl-star-nudged", "1");
4287
+ } catch {
4288
+ }
4289
+ const stop = setTimeout(() => setNudge(false), 2400);
4290
+ cleanups.push(() => clearTimeout(stop));
4291
+ }, 1800);
4292
+ const cleanups = [() => clearTimeout(start)];
4293
+ return () => cleanups.forEach((fn) => fn());
4294
+ }, [repoUrl]);
4262
4295
  if (!repoUrl) {
4263
4296
  return null;
4264
4297
  }
4298
+ const markTwinkle = !engaged;
4265
4299
  return /* @__PURE__ */ jsxs(
4266
4300
  "a",
4267
4301
  {
@@ -4270,9 +4304,26 @@ function GithubStar({ repoUrl }) {
4270
4304
  rel: "noopener noreferrer",
4271
4305
  "aria-label": "Star on GitHub",
4272
4306
  "data-testid": "github-star-link",
4273
- 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",
4307
+ onClick: () => {
4308
+ try {
4309
+ localStorage.setItem("nl-star-engaged", "1");
4310
+ } catch {
4311
+ }
4312
+ setEngaged(true);
4313
+ setNudge(false);
4314
+ },
4315
+ 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" : ""}`,
4274
4316
  children: [
4275
- /* @__PURE__ */ jsx(Star, { className: "size-3.5", "aria-hidden": "true" }),
4317
+ /* @__PURE__ */ jsxs("span", { className: "nl-star-ico relative inline-flex", children: [
4318
+ /* @__PURE__ */ jsx(
4319
+ Star,
4320
+ {
4321
+ className: `size-3.5 nl-star-mark${markTwinkle ? " nl-star-mark--twinkle" : ""}`,
4322
+ "aria-hidden": "true"
4323
+ }
4324
+ ),
4325
+ nudge && /* @__PURE__ */ jsx(Star, { className: "nl-star-fly size-3.5", "aria-hidden": "true" })
4326
+ ] }),
4276
4327
  /* @__PURE__ */ jsx("span", { children: "Star" }),
4277
4328
  count !== null && /* @__PURE__ */ jsx(
4278
4329
  "span",
@@ -4990,56 +5041,47 @@ function CopyPageButton({
4990
5041
  const claudeUrl = `https://claude.ai/new?q=${encodedMessage}`;
4991
5042
  window.open(claudeUrl, "_blank", "noopener,noreferrer");
4992
5043
  }
4993
- return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
4994
- /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
4995
- Button,
4996
- {
4997
- variant: "outline",
4998
- size: "sm",
4999
- className: cn(
5000
- "flex gap-2 text-sm font-medium items-center",
5001
- isCopied && "opacity-70",
5002
- className
5044
+ 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";
5045
+ return /* @__PURE__ */ jsxs(
5046
+ "div",
5047
+ {
5048
+ role: "group",
5049
+ "aria-label": _askAboutThisPage,
5050
+ className: cn(
5051
+ // Segmented control: one border, dividers between the three actions.
5052
+ "inline-flex items-stretch overflow-hidden rounded-md border bg-card shadow-xs divide-x divide-border",
5053
+ className
5054
+ ),
5055
+ children: [
5056
+ /* @__PURE__ */ jsxs(
5057
+ "button",
5058
+ {
5059
+ type: "button",
5060
+ onClick: handleCopy,
5061
+ title: copyPageDescription,
5062
+ "aria-live": "polite",
5063
+ className: cn(segment, isCopied && "text-muted-foreground"),
5064
+ children: [
5065
+ isCopied ? /* @__PURE__ */ jsx(CheckIcon, { className: "size-3.5", "aria-hidden": true }) : /* @__PURE__ */ jsx(CopyIcon, { className: "size-3.5", "aria-hidden": true }),
5066
+ isCopied ? copied : copyPage
5067
+ ]
5068
+ }
5003
5069
  ),
5004
- children: [
5005
- /* @__PURE__ */ jsx(CopyIcon, { width: "16" }),
5006
- isCopied ? copied : copyPage,
5007
- /* @__PURE__ */ jsx(ChevronDownIcon, { width: "14", className: "opacity-50" })
5008
- ]
5009
- }
5010
- ) }),
5011
- /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "min-w-[200px]", children: [
5012
- /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: handleCopy, children: [
5013
- /* @__PURE__ */ jsx(CopyIcon, { width: "16", className: "mr-2" }),
5014
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
5015
- /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: copyPage }),
5016
- /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: copyPageDescription })
5017
- ] })
5018
- ] }),
5019
- pageUrl && /* @__PURE__ */ jsxs(Fragment, { children: [
5020
- /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: handleOpenInChatGPT, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
5021
- /* @__PURE__ */ jsx(ChatGPTIcon, { className: "w-4 h-4 shrink-0" }),
5022
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col flex-1", children: [
5023
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
5024
- /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: openInChatGPT }),
5025
- /* @__PURE__ */ jsx(ExternalLinkIcon, { width: "12", className: "text-muted-foreground shrink-0" })
5026
- ] }),
5027
- /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: askQuestionsDescription })
5028
- ] })
5029
- ] }) }),
5030
- /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: handleOpenInClaude, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
5031
- /* @__PURE__ */ jsx(ClaudeIcon, { className: "w-4 h-4 shrink-0" }),
5032
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col flex-1", children: [
5033
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
5034
- /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: openInClaude }),
5035
- /* @__PURE__ */ jsx(ExternalLinkIcon, { width: "12", className: "text-muted-foreground shrink-0" })
5036
- ] }),
5037
- /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: askQuestionsDescription })
5070
+ pageUrl && /* @__PURE__ */ jsxs(Fragment, { children: [
5071
+ /* @__PURE__ */ jsxs("button", { type: "button", onClick: handleOpenInChatGPT, title: askQuestionsDescription, className: segment, children: [
5072
+ /* @__PURE__ */ jsx(ChatGPTIcon, { className: "size-3.5 shrink-0" }),
5073
+ /* @__PURE__ */ jsx("span", { children: openInChatGPT }),
5074
+ /* @__PURE__ */ jsx(ExternalLinkIcon, { className: "size-3 text-muted-foreground", "aria-hidden": true })
5075
+ ] }),
5076
+ /* @__PURE__ */ jsxs("button", { type: "button", onClick: handleOpenInClaude, title: askQuestionsDescription, className: segment, children: [
5077
+ /* @__PURE__ */ jsx(ClaudeIcon, { className: "size-3.5 shrink-0" }),
5078
+ /* @__PURE__ */ jsx("span", { children: openInClaude }),
5079
+ /* @__PURE__ */ jsx(ExternalLinkIcon, { className: "size-3 text-muted-foreground", "aria-hidden": true })
5038
5080
  ] })
5039
- ] }) })
5040
- ] })
5041
- ] })
5042
- ] });
5081
+ ] })
5082
+ ]
5083
+ }
5084
+ );
5043
5085
  }
5044
5086
  function track(event, data) {
5045
5087
  if (typeof window !== "undefined") {