@@ -2,6 +2,7 @@ import { createFileRoute } from "@tanstack/react-router";
22import { useWebSocket } from "@/hooks/useWebSocket" ;
33import { aggregateHistoryPoints } from "@/lib/chart" ;
44import { useEmbedBranding } from "@/components/embed/useEmbedBranding" ;
5+ import { useEmbedTheme , type EmbedTheme } from "@/components/embed/useEmbedTheme" ;
56
67export const Route = createFileRoute ( "/embed/chart" ) ( {
78 component : EmbedChart ,
@@ -12,6 +13,7 @@ export const Route = createFileRoute("/embed/chart")({
1213 accent : ( search . accent as string ) ?? "#96E421" ,
1314 branding : String ( search . branding ?? "" ) ,
1415 scale : Number ( search . scale ?? 0.9 ) ,
16+ theme : ( String ( search . theme ?? "system" ) as EmbedTheme ) ,
1517 } ) ,
1618} ) ;
1719
@@ -47,11 +49,12 @@ function buildPath(points: { count: number }[], close: boolean): string {
4749}
4850
4951function EmbedChart ( ) {
50- const { website, token, bg, accent, branding, scale } = Route . useSearch ( ) ;
52+ const { website, token, bg, accent, branding, scale, theme } = Route . useSearch ( ) ;
5153 const { count, connected, history } = useWebSocket ( website || null , { token : token || undefined , recent : "10m" } ) ;
5254 const explicitBranding = branding === "1" || branding === "true" ;
5355 const showBranding = useEmbedBranding ( website , token , explicitBranding ) ;
5456 const size = Number . isFinite ( scale ) ? Math . min ( Math . max ( scale , 0.6 ) , 1.4 ) : 0.9 ;
57+ const t = useEmbedTheme ( theme === "dark" || theme === "light" ? theme : "system" ) ;
5558
5659 if ( ! website || ! token ) {
5760 return null ;
@@ -74,8 +77,8 @@ function EmbedChart() {
7477 style = { {
7578 width : 240 * size ,
7679 borderRadius : 18 * size ,
77- border : " 1px solid rgba(255, 255, 255, 0.1)" ,
78- background : bg === "transparent" ? "rgba(10, 10, 10, 0.85)" : bg ,
80+ border : ` 1px solid ${ t . border } ` ,
81+ background : bg === "transparent" ? t . bg : bg ,
7982 backdropFilter : "blur(18px)" ,
8083 boxShadow : "none" ,
8184 overflow : "hidden" ,
@@ -84,7 +87,7 @@ function EmbedChart() {
8487 >
8588 < div style = { { display : "flex" , alignItems : "center" , justifyContent : "space-between" , marginBottom : 8 * size } } >
8689 < div style = { { minWidth : 0 } } >
87- < p style = { { fontSize : 12 * size , color : "rgba(250,250,250,0.8)" , fontWeight : 500 , whiteSpace : "nowrap" , overflow : "hidden" , textOverflow : "ellipsis" } } >
90+ < p style = { { fontSize : 12 * size , color : t . textSecondary , fontWeight : 500 , whiteSpace : "nowrap" , overflow : "hidden" , textOverflow : "ellipsis" } } >
8891 Live visitors
8992 </ p >
9093 </ div >
@@ -98,13 +101,13 @@ function EmbedChart() {
98101 boxShadow : connected ? `0 0 0 ${ 4 * size } px color-mix(in srgb, ${ accent } 18%, transparent)` : "none" ,
99102 } }
100103 />
101- < span style = { { fontSize : 12 * size , color : "rgba(161,161,170,0.75)" } } > 10m</ span >
104+ < span style = { { fontSize : 12 * size , color : t . textMuted } } > 10m</ span >
102105 </ div >
103106 </ div >
104107
105108 < div style = { { display : "flex" , alignItems : "baseline" , gap : 8 * size , marginBottom : 8 * size } } >
106- < span style = { { fontSize : 28 * size , fontWeight : 750 , color : "#fafafa" , lineHeight : 1 , letterSpacing : "-0.04em" } } > { count } </ span >
107- < span style = { { fontSize : 12 * size , color : "#a1a1aa" } } > visitors</ span >
109+ < span style = { { fontSize : 28 * size , fontWeight : 750 , color : t . text , lineHeight : 1 , letterSpacing : "-0.04em" } } > { count } </ span >
110+ < span style = { { fontSize : 12 * size , color : t . textMuted } } > visitors</ span >
108111 </ div >
109112
110113 < svg viewBox = { `0 0 ${ W } ${ H } ` } preserveAspectRatio = "none" style = { { width : "100%" , height : 48 * size } } >
@@ -156,7 +159,7 @@ function EmbedChart() {
156159 display : "inline-block" ,
157160 marginTop : 6 * size ,
158161 fontSize : 10 * size ,
159- color : "rgba(255,255,255,0.48)" ,
162+ color : t . brandingText ,
160163 textDecoration : "none" ,
161164 letterSpacing : "0.01em" ,
162165 } }
0 commit comments