Skip to content

Commit 870c7e7

Browse files
committed
Add inline variant to BrandingBadge component
1 parent d0bd65b commit 870c7e7

3 files changed

Lines changed: 48 additions & 52 deletions

File tree

apps/web/src/components/embed/BrandingBadge.tsx

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,56 @@ import type { ThemeColors } from "./useEmbedTheme";
22

33
interface Props {
44
theme?: ThemeColors;
5+
variant?: "overlay" | "inline";
6+
size?: number;
57
}
68

7-
export default function BrandingBadge({ theme }: Props) {
9+
const HREF = "https://livedot.dev?utm_source=embed&utm_medium=branding&utm_campaign=powered_by";
10+
11+
export default function BrandingBadge({ theme, variant = "overlay", size = 1 }: Props) {
812
const bg = theme?.bg ?? "rgba(10, 10, 10, 0.78)";
913
const border = theme?.border ?? "rgba(255, 255, 255, 0.12)";
1014
const text = theme?.text ?? "#fafafa";
11-
const textSecondary = theme?.brandingText ?? "rgba(255, 255, 255, 0.72)";
15+
const brandingText = theme?.brandingText ?? "rgba(255, 255, 255, 0.72)";
16+
const brandingBg = theme?.brandingBg ?? "rgba(255, 255, 255, 0.06)";
17+
const brandingBorder = theme?.brandingBorder ?? "rgba(255, 255, 255, 0.08)";
18+
19+
if (variant === "inline") {
20+
return (
21+
<a
22+
href={HREF}
23+
target="_blank"
24+
rel="noreferrer"
25+
aria-label="Powered by Livedot"
26+
style={{
27+
display: "inline-flex",
28+
alignItems: "center",
29+
gap: 8 * size,
30+
padding: `0 ${10 * size}px`,
31+
height: 28 * size,
32+
borderRadius: 999,
33+
background: brandingBg,
34+
border: `1px solid ${brandingBorder}`,
35+
flexShrink: 0,
36+
textDecoration: "none",
37+
}}
38+
>
39+
<img
40+
src="/logo.svg"
41+
alt=""
42+
aria-hidden="true"
43+
style={{ width: 18 * size, height: 18 * size, borderRadius: 6 * size, display: "block" }}
44+
/>
45+
<span style={{ fontSize: 11 * size, fontWeight: 600, color: brandingText, whiteSpace: "nowrap" }}>
46+
Powered by Livedot
47+
</span>
48+
</a>
49+
);
50+
}
1251

1352
return (
1453
<a
15-
href="https://livedot.dev"
54+
href={HREF}
1655
target="_blank"
1756
rel="noreferrer"
1857
aria-label="Powered by Livedot"
@@ -39,8 +78,8 @@ export default function BrandingBadge({ theme }: Props) {
3978
aria-hidden="true"
4079
style={{ width: 18, height: 18, borderRadius: 5, flexShrink: 0 }}
4180
/>
42-
<span style={{ fontSize: 11, lineHeight: 1, color: textSecondary }}>Powered by</span>
43-
<span style={{ fontSize: 12, lineHeight: 1, fontWeight: 700, letterSpacing: "-0.02em" }}>{" "}livedot</span>
81+
<span style={{ fontSize: 11, lineHeight: 1, color: brandingText }}>Powered by</span>
82+
<span style={{ fontSize: 12, lineHeight: 1, fontWeight: 700, letterSpacing: "-0.02em" }}> livedot</span>
4483
</a>
4584
);
4685
}

apps/web/src/routes/embed/chart.tsx

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useWebSocket } from "@/hooks/useWebSocket";
33
import { aggregateHistoryPoints } from "@/lib/chart";
44
import { useEmbedBranding } from "@/components/embed/useEmbedBranding";
55
import { useEmbedTheme, type EmbedTheme } from "@/components/embed/useEmbedTheme";
6+
import BrandingBadge from "@/components/embed/BrandingBadge";
67

78
export const Route = createFileRoute("/embed/chart")({
89
component: EmbedChart,
@@ -150,23 +151,7 @@ function EmbedChart() {
150151
<line x1="0" y1={H / 2} x2={W} y2={H / 2} stroke={accent} strokeOpacity="0.15" strokeWidth={1 * size} strokeDasharray="4 4" />
151152
)}
152153
</svg>
153-
{showBranding && (
154-
<a
155-
href="https://livedot.dev"
156-
target="_blank"
157-
rel="noreferrer"
158-
style={{
159-
display: "inline-block",
160-
marginTop: 6 * size,
161-
fontSize: 10 * size,
162-
color: t.brandingText,
163-
textDecoration: "none",
164-
letterSpacing: "0.01em",
165-
}}
166-
>
167-
Powered by Livedot
168-
</a>
169-
)}
154+
{showBranding && <BrandingBadge theme={t} variant="inline" size={size} />}
170155
</div>
171156
</div>
172157
);

apps/web/src/routes/embed/live.tsx

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createFileRoute } from "@tanstack/react-router";
22
import { useWebSocket } from "@/hooks/useWebSocket";
33
import { useEmbedBranding } from "@/components/embed/useEmbedBranding";
44
import { useEmbedTheme, type EmbedTheme } from "@/components/embed/useEmbedTheme";
5+
import BrandingBadge from "@/components/embed/BrandingBadge";
56

67
export const Route = createFileRoute("/embed/live")({
78
component: EmbedLive,
@@ -57,36 +58,7 @@ function EmbedLive() {
5758
<span style={{ fontSize: 34 * size, lineHeight: 1, fontWeight: 750, color: t.text, letterSpacing: "-0.04em" }}>
5859
{count}
5960
</span>
60-
{showBranding && (
61-
<a
62-
href="https://livedot.dev"
63-
target="_blank"
64-
rel="noreferrer"
65-
aria-label="Open Livedot"
66-
style={{
67-
display: "inline-flex",
68-
alignItems: "center",
69-
gap: 8 * size,
70-
padding: `0 ${10 * size}px`,
71-
height: 28 * size,
72-
borderRadius: 999,
73-
background: t.brandingBg,
74-
border: `1px solid ${t.brandingBorder}`,
75-
flexShrink: 0,
76-
textDecoration: "none",
77-
}}
78-
>
79-
<img
80-
src="/logo.svg"
81-
alt=""
82-
aria-hidden="true"
83-
style={{ width: 18 * size, height: 18 * size, borderRadius: 6 * size, display: "block" }}
84-
/>
85-
<span style={{ fontSize: 11 * size, fontWeight: 600, color: t.brandingText, whiteSpace: "nowrap" }}>
86-
Powered by Livedot
87-
</span>
88-
</a>
89-
)}
61+
{showBranding && <BrandingBadge theme={t} variant="inline" size={size} />}
9062
</div>
9163
);
9264
}

0 commit comments

Comments
 (0)