@next-library/theme 1.0.12 → 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
@@ -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",