@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 +53 -2
- package/dist/client.js.map +1 -1
- package/dist/components/navigation/navbar/github-star.d.ts +5 -3
- package/dist/components/navigation/navbar/github-star.d.ts.map +1 -1
- package/dist/index.js +53 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/style.css +37 -0
|
@@ -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)
|
|
11
|
-
*
|
|
12
|
-
*
|
|
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;
|
|
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
|
@@ -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
|
-
|
|
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__ */
|
|
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",
|