@m13v/seo-components 0.16.2 → 0.17.0

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.2",
3
+ "version": "0.17.0",
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
@@ -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}
@@ -5,7 +5,9 @@ import React, { useEffect, useRef, useState } from "react";
5
5
  /**
6
6
  * Particles: renders an interactive canvas of floating particles that
7
7
  * subtly follow the mouse cursor. Great for ambient hero backgrounds.
8
- * Default color is teal (#14b8a6). Fully self-contained, canvas-based.
8
+ * If `color` is omitted, reads the consumer's `--seo-accent` CSS variable
9
+ * at mount (falling back to teal #14b8a6). Canvas paint cannot use CSS
10
+ * vars directly, so we resolve it once via getComputedStyle.
9
11
  *
10
12
  * @example
11
13
  * <Particles className="absolute inset-0" quantity={80} />
@@ -36,7 +38,9 @@ function useMousePosition(): MousePosition {
36
38
  }
37
39
 
38
40
  function hexToRgb(hex: string): number[] {
39
- hex = hex.replace("#", "");
41
+ hex = hex.replace("#", "").trim();
42
+ if (hex.length === 3) hex = hex.split("").map((c) => c + c).join("");
43
+ if (!/^[0-9a-fA-F]{6}$/.test(hex)) return [20, 184, 166]; // teal fallback
40
44
  const hexInt = parseInt(hex, 16);
41
45
  const red = (hexInt >> 16) & 255;
42
46
  const green = (hexInt >> 8) & 255;
@@ -44,6 +48,19 @@ function hexToRgb(hex: string): number[] {
44
48
  return [red, green, blue];
45
49
  }
46
50
 
51
+ function resolveAccentFromDOM(): string {
52
+ if (typeof window === "undefined") return "#14b8a6";
53
+ try {
54
+ const v = getComputedStyle(document.documentElement)
55
+ .getPropertyValue("--seo-accent")
56
+ .trim();
57
+ if (v && v.startsWith("#")) return v;
58
+ } catch {
59
+ // ignore
60
+ }
61
+ return "#14b8a6";
62
+ }
63
+
47
64
  interface ParticlesProps {
48
65
  className?: string;
49
66
  quantity?: number;
@@ -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
  }
@@ -17,7 +17,7 @@
17
17
  // 3. Consumer sites wrap their tree in <SeoAnalyticsProvider posthog={ph}>
18
18
  // (or use the all-in-one FullSiteAnalytics component).
19
19
 
20
- import { createContext, useCallback, useContext, useMemo, type ReactNode } from "react";
20
+ import { createContext, useCallback, useContext, useEffect, useMemo, type ReactNode } from "react";
21
21
 
22
22
  export interface PostHogLike {
23
23
  capture: (event: string, properties?: Record<string, unknown>) => void;
@@ -38,6 +38,18 @@ export interface SeoAnalyticsProviderProps {
38
38
  */
39
39
  export function SeoAnalyticsProvider({ posthog, children }: SeoAnalyticsProviderProps) {
40
40
  const value = useMemo(() => posthog ?? null, [posthog]);
41
+
42
+ // Mirror the instance onto window.posthog so non-React helpers
43
+ // (trackScheduleClick, legacy inline scripts) resolve without each
44
+ // consumer site remembering to hand-wire this line after posthog.init().
45
+ useEffect(() => {
46
+ if (!value) return;
47
+ if (typeof window === "undefined") return;
48
+ const w = window as unknown as { posthog?: PostHogLike };
49
+ if (w.posthog === value) return;
50
+ w.posthog = value;
51
+ }, [value]);
52
+
41
53
  return (
42
54
  <SeoAnalyticsContext.Provider value={value}>
43
55
  {children}