@m13v/seo-components 0.16.1 → 0.16.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m13v/seo-components",
3
- "version": "0.16.1",
3
+ "version": "0.16.3",
4
4
  "scripts": {
5
5
  "build:css": "tailwind -i src/_build.css -o dist/styles.css --minify",
6
6
  "bump:consumers": "bash scripts/bump-consumers.sh",
@@ -15,7 +15,7 @@ interface AnimatedBeamProps {
15
15
  /** Right side nodes (destinations) */
16
16
  to: BeamNode[];
17
17
  title?: string;
18
- /** Accent hex color for the hub fill and beam glow. Defaults to teal (#14b8a6). */
18
+ /** Accent hex color for the hub fill and beam glow. If omitted, reads the consumer's --seo-accent CSS variable (falling back to teal #14b8a6). */
19
19
  accentColor?: string;
20
20
  className?: string;
21
21
  }
@@ -31,9 +31,10 @@ export function AnimatedBeam({
31
31
  hub,
32
32
  to,
33
33
  title,
34
- accentColor = "#14b8a6",
34
+ accentColor,
35
35
  className = "",
36
36
  }: AnimatedBeamProps) {
37
+ const fillColor = accentColor ?? "var(--seo-accent, #14b8a6)";
37
38
  const width = 720;
38
39
  const height = 380;
39
40
  const centerX = width / 2;
@@ -62,9 +63,9 @@ export function AnimatedBeam({
62
63
  >
63
64
  <defs>
64
65
  <linearGradient id="beam-gradient" x1="0%" y1="0%" x2="100%" y2="0%">
65
- <stop offset="0%" stopColor={accentColor} stopOpacity="0" />
66
- <stop offset="50%" stopColor={accentColor} stopOpacity="1" />
67
- <stop offset="100%" stopColor={accentColor} stopOpacity="0" />
66
+ <stop offset="0%" style={{ stopColor: fillColor, stopOpacity: 0 }} />
67
+ <stop offset="50%" style={{ stopColor: fillColor, stopOpacity: 1 }} />
68
+ <stop offset="100%" style={{ stopColor: fillColor, stopOpacity: 0 }} />
68
69
  </linearGradient>
69
70
  <filter id="glow">
70
71
  <feGaussianBlur stdDeviation="3" result="blur" />
@@ -185,7 +186,7 @@ export function AnimatedBeam({
185
186
  width="144"
186
187
  height="72"
187
188
  rx="36"
188
- fill={accentColor}
189
+ style={{ fill: fillColor }}
189
190
  filter="url(#glow)"
190
191
  />
191
192
  <rect
@@ -75,41 +75,44 @@ export function FullSiteAnalytics({
75
75
  return;
76
76
  }
77
77
  let cancelled = false;
78
- // Defer init to idle to keep it off the critical path.
79
- const ric: (
80
- cb: IdleRequestCallback,
81
- opts?: IdleRequestOptions,
82
- ) => number =
83
- typeof window !== "undefined" && window.requestIdleCallback
84
- ? window.requestIdleCallback.bind(window)
85
- : (cb) => setTimeout(cb as unknown as () => void, 1) as unknown as number;
86
- const cic: (id: number) => void =
87
- typeof window !== "undefined" && window.cancelIdleCallback
88
- ? window.cancelIdleCallback.bind(window)
89
- : (id) => clearTimeout(id);
90
- const id = ric(
91
- () => {
92
- import("posthog-js").then((mod) => {
93
- if (cancelled) return;
94
- const lib = mod.default;
95
- lib.init(posthogKey, {
96
- api_host: posthogHost,
97
- person_profiles: personProfiles,
98
- capture_pageview: capturePageview,
99
- capture_pageleave: capturePageleave,
100
- });
101
- // Legacy: some helpers still read window.posthog. Setting this
102
- // is what 3 of 4 consumer sites forgot, which silently broke
103
- // newsletter_subscribed and schedule_click events.
104
- (window as unknown as { posthog: typeof lib }).posthog = lib;
105
- setPosthog(lib as unknown as PostHogLike);
78
+ let idleId: number | undefined;
79
+ let timeoutId: ReturnType<typeof setTimeout> | undefined;
80
+
81
+ const run = () => {
82
+ import("posthog-js").then((mod) => {
83
+ if (cancelled) return;
84
+ const lib = mod.default;
85
+ lib.init(posthogKey, {
86
+ api_host: posthogHost,
87
+ person_profiles: personProfiles,
88
+ capture_pageview: capturePageview,
89
+ capture_pageleave: capturePageleave,
106
90
  });
107
- },
108
- { timeout: 3000 },
109
- );
91
+ // Legacy: some helpers still read window.posthog. Setting this
92
+ // is what 3 of 4 consumer sites forgot, which silently broke
93
+ // newsletter_subscribed and schedule_click events.
94
+ (window as unknown as { posthog: typeof lib }).posthog = lib;
95
+ setPosthog(lib as unknown as PostHogLike);
96
+ });
97
+ };
98
+
99
+ // Defer init to idle to keep it off the critical path.
100
+ if (typeof window !== "undefined" && window.requestIdleCallback) {
101
+ idleId = window.requestIdleCallback(run, { timeout: 3000 });
102
+ } else {
103
+ timeoutId = setTimeout(run, 1);
104
+ }
105
+
110
106
  return () => {
111
107
  cancelled = true;
112
- cic(id);
108
+ if (
109
+ idleId !== undefined &&
110
+ typeof window !== "undefined" &&
111
+ window.cancelIdleCallback
112
+ ) {
113
+ window.cancelIdleCallback(idleId);
114
+ }
115
+ if (timeoutId !== undefined) clearTimeout(timeoutId);
113
116
  };
114
117
  }, [
115
118
  posthogKey,
@@ -81,7 +81,11 @@ export function IntegrationsGrid({
81
81
  ) : (
82
82
  <div
83
83
  className="flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-md text-sm font-semibold text-white"
84
- style={{ background: it.accent || "linear-gradient(135deg,#14b8a6,#22d3ee)" }}
84
+ style={{
85
+ background:
86
+ it.accent ||
87
+ "linear-gradient(135deg, var(--seo-accent, #14b8a6), var(--seo-accent-2, #22d3ee))",
88
+ }}
85
89
  aria-hidden="true"
86
90
  >
87
91
  {initial}
@@ -24,14 +24,15 @@ import React from "react";
24
24
  * </ShineBorder>
25
25
  */
26
26
 
27
- type TColorProp = `#${string}` | `#${string}`[];
27
+ type TColorProp = string | string[];
28
28
 
29
29
  interface ShineBorderProps {
30
30
  borderRadius?: number;
31
31
  borderWidth?: number;
32
32
  duration?: number;
33
- /** Hex color(s) for the shine gradient. Pass your brand accent color. Defaults to teal.
34
- * CSS custom properties are not supported here (conic gradient border trick). */
33
+ /** Color(s) for the shine gradient. Accepts any CSS color or a CSS custom
34
+ * property (e.g. `var(--seo-accent)`). Defaults to the consumer's
35
+ * `--seo-accent` value, falling back to teal (#14b8a6). */
35
36
  color?: TColorProp;
36
37
  className?: string;
37
38
  children: React.ReactNode;
@@ -41,10 +42,11 @@ export function ShineBorder({
41
42
  borderRadius = 8,
42
43
  borderWidth = 1,
43
44
  duration = 14,
44
- color = "#14b8a6",
45
+ color,
45
46
  className,
46
47
  children,
47
48
  }: ShineBorderProps) {
49
+ const resolvedColor = color ?? "var(--seo-accent, #14b8a6)";
48
50
  const outerBase =
49
51
  "relative grid min-h-[60px] w-fit min-w-[300px] place-items-center bg-white dark:bg-zinc-900 p-3 text-zinc-900 dark:text-zinc-100";
50
52
  const outerClass = className
@@ -71,7 +73,7 @@ export function ShineBorder({
71
73
  "--mask-linear-gradient":
72
74
  "linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",
73
75
  "--background-radial-gradient": `radial-gradient(transparent,transparent, ${
74
- Array.isArray(color) ? color.join(",") : color
76
+ Array.isArray(resolvedColor) ? resolvedColor.join(",") : resolvedColor
75
77
  },transparent,transparent)`,
76
78
  } as React.CSSProperties
77
79
  }