Implement Style Editor, Preview, and Settings Schema
This commit is contained in:
23
package-lock.json
generated
23
package-lock.json
generated
@@ -8,9 +8,11 @@
|
|||||||
"name": "open-chat-overlay",
|
"name": "open-chat-overlay",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"clsx": "^2.1.1",
|
||||||
"next": "16.1.1",
|
"next": "16.1.1",
|
||||||
"react": "19.2.3",
|
"react": "19.2.3",
|
||||||
"react-dom": "19.2.3"
|
"react-dom": "19.2.3",
|
||||||
|
"tailwind-merge": "^3.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/postcss": "^4",
|
"@tailwindcss/postcss": "^4",
|
||||||
@@ -2587,6 +2589,15 @@
|
|||||||
"integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==",
|
"integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/clsx": {
|
||||||
|
"version": "2.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz",
|
||||||
|
"integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/color-convert": {
|
"node_modules/color-convert": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||||
@@ -6029,6 +6040,16 @@
|
|||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/tailwind-merge": {
|
||||||
|
"version": "3.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.4.0.tgz",
|
||||||
|
"integrity": "sha512-uSaO4gnW+b3Y2aWoWfFpX62vn2sR3skfhbjsEnaBI81WD1wBLlHZe5sWf0AqjksNdYTbGBEd0UasQMT3SNV15g==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/dcastil"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/tailwindcss": {
|
"node_modules/tailwindcss": {
|
||||||
"version": "4.1.18",
|
"version": "4.1.18",
|
||||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.18.tgz",
|
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.18.tgz",
|
||||||
|
|||||||
@@ -9,9 +9,11 @@
|
|||||||
"lint": "eslint"
|
"lint": "eslint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"clsx": "^2.1.1",
|
||||||
"next": "16.1.1",
|
"next": "16.1.1",
|
||||||
"react": "19.2.3",
|
"react": "19.2.3",
|
||||||
"react-dom": "19.2.3"
|
"react-dom": "19.2.3",
|
||||||
|
"tailwind-merge": "^3.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/postcss": "^4",
|
"@tailwindcss/postcss": "^4",
|
||||||
|
|||||||
21
src/app/editor/page.tsx
Normal file
21
src/app/editor/page.tsx
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import StyleControls from '@/components/dashboard/StyleControls';
|
||||||
|
import PreviewFrame from '@/components/dashboard/PreviewFrame';
|
||||||
|
import { OverlaySettings, DEFAULT_SETTINGS } from '@/lib/types';
|
||||||
|
|
||||||
|
export default function EditorPage() {
|
||||||
|
const [settings, setSettings] = useState<OverlaySettings>(DEFAULT_SETTINGS);
|
||||||
|
|
||||||
|
const updateSettings = (newSettings: Partial<OverlaySettings>) => {
|
||||||
|
setSettings(prev => ({ ...prev, ...newSettings }));
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main className="flex h-screen w-screen overflow-hidden bg-zinc-50 dark:bg-zinc-950 text-zinc-900 dark:text-zinc-100">
|
||||||
|
<StyleControls settings={settings} updateSettings={updateSettings} />
|
||||||
|
<PreviewFrame settings={settings} />
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,62 +1,28 @@
|
|||||||
import Image from "next/image";
|
import Link from 'next/link';
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-screen items-center justify-center bg-zinc-50 font-sans dark:bg-black">
|
<div className="grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)]">
|
||||||
<main className="flex min-h-screen w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start">
|
<main className="flex flex-col gap-8 row-start-2 items-center sm:items-start">
|
||||||
<Image
|
<h1 className="text-4xl font-bold">OpenChat Overlay</h1>
|
||||||
className="dark:invert"
|
<p className="text-lg text-zinc-600 dark:text-zinc-400">
|
||||||
src="/next.svg"
|
A free, open-source alternative to StreamElements chat overlay.
|
||||||
alt="Next.js logo"
|
</p>
|
||||||
width={100}
|
|
||||||
height={20}
|
<div className="flex gap-4 items-center flex-col sm:flex-row">
|
||||||
priority
|
<Link
|
||||||
/>
|
href="/editor"
|
||||||
<div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
|
className="rounded-full border border-solid border-transparent transition-colors flex items-center justify-center bg-foreground text-background gap-2 hover:bg-[#383838] dark:hover:bg-[#ccc] text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5"
|
||||||
<h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
|
>
|
||||||
To get started, edit the page.tsx file.
|
Go to Style Editor
|
||||||
</h1>
|
</Link>
|
||||||
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
|
|
||||||
Looking for a starting point or more instructions? Head over to{" "}
|
|
||||||
<a
|
|
||||||
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
|
||||||
className="font-medium text-zinc-950 dark:text-zinc-50"
|
|
||||||
>
|
|
||||||
Templates
|
|
||||||
</a>{" "}
|
|
||||||
or the{" "}
|
|
||||||
<a
|
|
||||||
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
|
||||||
className="font-medium text-zinc-950 dark:text-zinc-50"
|
|
||||||
>
|
|
||||||
Learning
|
|
||||||
</a>{" "}
|
|
||||||
center.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-col gap-4 text-base font-medium sm:flex-row">
|
|
||||||
<a
|
<a
|
||||||
className="flex h-12 w-full items-center justify-center gap-2 rounded-full bg-foreground px-5 text-background transition-colors hover:bg-[#383838] dark:hover:bg-[#ccc] md:w-[158px]"
|
className="rounded-full border border-solid border-black/[.08] dark:border-white/[.145] transition-colors flex items-center justify-center hover:bg-[#f2f2f2] dark:hover:bg-[#1a1a1a] hover:border-transparent text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5 sm:min-w-44"
|
||||||
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
href="https://github.com"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
<Image
|
View on GitHub
|
||||||
className="dark:invert"
|
|
||||||
src="/vercel.svg"
|
|
||||||
alt="Vercel logomark"
|
|
||||||
width={16}
|
|
||||||
height={16}
|
|
||||||
/>
|
|
||||||
Deploy Now
|
|
||||||
</a>
|
|
||||||
<a
|
|
||||||
className="flex h-12 w-full items-center justify-center rounded-full border border-solid border-black/[.08] px-5 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-[158px]"
|
|
||||||
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
Documentation
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
77
src/components/dashboard/PreviewFrame.tsx
Normal file
77
src/components/dashboard/PreviewFrame.tsx
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import { OverlaySettings } from '@/lib/types';
|
||||||
|
|
||||||
|
interface PreviewFrameProps {
|
||||||
|
settings: OverlaySettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MOCK_MESSAGES = [
|
||||||
|
{ id: 1, user: 'StreamElements', color: '#5b99ff', text: 'Welcome to the stream! Enjoy your stay.', badges: ['moderator'] },
|
||||||
|
{ id: 2, user: 'Viewer123', color: '#ff5b5b', text: 'PogChamp this overlay is amazing!', badges: ['subscriber'] },
|
||||||
|
{ id: 3, user: 'Lurker', color: '#5bff89', text: 'Can I get a shoutout?', badges: [] },
|
||||||
|
{ id: 4, user: 'ProGamer', color: '#ffb35b', text: 'What game are we playing today? kappa', badges: ['subscriber', 'turbo'] },
|
||||||
|
];
|
||||||
|
|
||||||
|
export default function PreviewFrame({ settings }: PreviewFrameProps) {
|
||||||
|
// Convert hex to rgb for background opacity
|
||||||
|
const r = parseInt(settings.backgroundColor.slice(1, 3), 16);
|
||||||
|
const g = parseInt(settings.backgroundColor.slice(3, 5), 16);
|
||||||
|
const b = parseInt(settings.backgroundColor.slice(5, 7), 16);
|
||||||
|
const rgbaBackground = `rgba(${r}, ${g}, ${b}, ${settings.backgroundOpacity})`;
|
||||||
|
|
||||||
|
const containerStyle: React.CSSProperties = {
|
||||||
|
fontFamily: settings.fontFamily,
|
||||||
|
backgroundColor: 'transparent', // The frame background is transparent, messages have their own bg or the container has it?
|
||||||
|
// In many overlays, the messages themselves are transparent or the whole container has a background.
|
||||||
|
// Based on the CSS generator: .chat-message has the background. Wait, no.
|
||||||
|
// In generateOverlayCSS:
|
||||||
|
// .chat-message { background-color: var(--chat-bg-color); ... }
|
||||||
|
// So the background applies to individual messages.
|
||||||
|
};
|
||||||
|
|
||||||
|
const messageStyle: React.CSSProperties = {
|
||||||
|
backgroundColor: rgbaBackground,
|
||||||
|
color: settings.textColor,
|
||||||
|
textShadow: settings.textShadow,
|
||||||
|
fontSize: settings.fontSize,
|
||||||
|
marginBottom: settings.messageSpacing,
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex-1 bg-zinc-100 dark:bg-zinc-950 p-8 flex items-center justify-center h-full overflow-hidden">
|
||||||
|
<div className="relative w-full max-w-md aspect-[9/16] bg-[url('/file.svg')] bg-cover bg-center border-4 border-zinc-800 rounded-xl shadow-2xl overflow-hidden bg-zinc-800">
|
||||||
|
{/* Mock Stream Background (Optional) */}
|
||||||
|
<div className="absolute inset-0 bg-gradient-to-br from-indigo-900 to-purple-900 opacity-50"></div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
className="absolute inset-0 flex flex-col justify-end p-4"
|
||||||
|
style={containerStyle}
|
||||||
|
>
|
||||||
|
{MOCK_MESSAGES.map((msg) => (
|
||||||
|
<div key={msg.id} className="p-2 rounded mb-2 animate-in fade-in slide-in-from-bottom-2" style={messageStyle}>
|
||||||
|
<div className="flex flex-wrap items-baseline">
|
||||||
|
{settings.showBadges && msg.badges.length > 0 && (
|
||||||
|
<span className="mr-2 inline-flex gap-1">
|
||||||
|
{msg.badges.map(badge => (
|
||||||
|
<span key={badge} className="w-4 h-4 bg-zinc-400 rounded-sm inline-block" title={badge}></span>
|
||||||
|
))}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
<span
|
||||||
|
className="font-bold mr-2"
|
||||||
|
style={{ color: settings.usernameColor === 'twitch' ? msg.color : settings.textColor }}
|
||||||
|
>
|
||||||
|
{msg.user}:
|
||||||
|
</span>
|
||||||
|
<span>{msg.text}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="absolute top-4 right-4 text-xs text-zinc-500">Live Preview</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
168
src/components/dashboard/StyleControls.tsx
Normal file
168
src/components/dashboard/StyleControls.tsx
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import { OverlaySettings } from '@/lib/types';
|
||||||
|
|
||||||
|
interface StyleControlsProps {
|
||||||
|
settings: OverlaySettings;
|
||||||
|
updateSettings: (newSettings: Partial<OverlaySettings>) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function StyleControls({ settings, updateSettings }: StyleControlsProps) {
|
||||||
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement>) => {
|
||||||
|
const { name, value, type } = e.target;
|
||||||
|
let newValue: string | number | boolean = value;
|
||||||
|
|
||||||
|
if (type === 'range') {
|
||||||
|
newValue = parseFloat(value);
|
||||||
|
} else if (type === 'checkbox') {
|
||||||
|
newValue = (e.target as HTMLInputElement).checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSettings({ [name]: newValue });
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleEmoteChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const { name, checked } = e.target;
|
||||||
|
updateSettings({
|
||||||
|
emotes: {
|
||||||
|
...settings.emotes,
|
||||||
|
[name]: checked,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col gap-6 p-6 bg-white dark:bg-zinc-900 border-r border-zinc-200 dark:border-zinc-800 h-full overflow-y-auto w-80 shrink-0">
|
||||||
|
<h2 className="text-xl font-bold text-zinc-900 dark:text-white">Style Editor</h2>
|
||||||
|
|
||||||
|
{/* Font Family */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<label className="text-sm font-medium text-zinc-700 dark:text-zinc-300">Font Family</label>
|
||||||
|
<select
|
||||||
|
name="fontFamily"
|
||||||
|
value={settings.fontFamily}
|
||||||
|
onChange={handleChange}
|
||||||
|
className="w-full p-2 border rounded-md bg-zinc-50 dark:bg-zinc-800 border-zinc-300 dark:border-zinc-700 text-zinc-900 dark:text-white"
|
||||||
|
>
|
||||||
|
<option value="Inter, sans-serif">Inter</option>
|
||||||
|
<option value="Roboto, sans-serif">Roboto</option>
|
||||||
|
<option value="'Open Sans', sans-serif">Open Sans</option>
|
||||||
|
<option value="Lato, sans-serif">Lato</option>
|
||||||
|
<option value="Montserrat, sans-serif">Montserrat</option>
|
||||||
|
<option value="'Press Start 2P', cursive">Pixel Art</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Font Size */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<label className="text-sm font-medium text-zinc-700 dark:text-zinc-300">Font Size</label>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="fontSize"
|
||||||
|
value={settings.fontSize}
|
||||||
|
onChange={handleChange}
|
||||||
|
className="w-full p-2 border rounded-md bg-zinc-50 dark:bg-zinc-800 border-zinc-300 dark:border-zinc-700 text-zinc-900 dark:text-white"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Text Color */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<label className="text-sm font-medium text-zinc-700 dark:text-zinc-300">Text Color</label>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<input
|
||||||
|
type="color"
|
||||||
|
name="textColor"
|
||||||
|
value={settings.textColor}
|
||||||
|
onChange={handleChange}
|
||||||
|
className="h-10 w-10 p-0 border-0 rounded overflow-hidden cursor-pointer"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="textColor"
|
||||||
|
value={settings.textColor}
|
||||||
|
onChange={handleChange}
|
||||||
|
className="flex-1 p-2 border rounded-md bg-zinc-50 dark:bg-zinc-800 border-zinc-300 dark:border-zinc-700 text-zinc-900 dark:text-white uppercase"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Background Color */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<label className="text-sm font-medium text-zinc-700 dark:text-zinc-300">Background Color</label>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<input
|
||||||
|
type="color"
|
||||||
|
name="backgroundColor"
|
||||||
|
value={settings.backgroundColor}
|
||||||
|
onChange={handleChange}
|
||||||
|
className="h-10 w-10 p-0 border-0 rounded overflow-hidden cursor-pointer"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="backgroundColor"
|
||||||
|
value={settings.backgroundColor}
|
||||||
|
onChange={handleChange}
|
||||||
|
className="flex-1 p-2 border rounded-md bg-zinc-50 dark:bg-zinc-800 border-zinc-300 dark:border-zinc-700 text-zinc-900 dark:text-white uppercase"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Background Opacity */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<label className="text-sm font-medium text-zinc-700 dark:text-zinc-300 flex justify-between">
|
||||||
|
<span>Opacity</span>
|
||||||
|
<span>{Math.round(settings.backgroundOpacity * 100)}%</span>
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="range"
|
||||||
|
name="backgroundOpacity"
|
||||||
|
min="0"
|
||||||
|
max="1"
|
||||||
|
step="0.01"
|
||||||
|
value={settings.backgroundOpacity}
|
||||||
|
onChange={handleChange}
|
||||||
|
className="w-full accent-indigo-600 cursor-pointer"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Toggles */}
|
||||||
|
<div className="space-y-4 pt-4 border-t border-zinc-200 dark:border-zinc-800">
|
||||||
|
<label className="flex items-center gap-3 cursor-pointer">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="showBadges"
|
||||||
|
checked={settings.showBadges}
|
||||||
|
onChange={handleChange}
|
||||||
|
className="w-5 h-5 rounded border-zinc-300 text-indigo-600 focus:ring-indigo-500"
|
||||||
|
/>
|
||||||
|
<span className="text-sm font-medium text-zinc-700 dark:text-zinc-300">Show Badges</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label className="flex items-center gap-3 cursor-pointer">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="bttv"
|
||||||
|
checked={settings.emotes.bttv}
|
||||||
|
onChange={handleEmoteChange}
|
||||||
|
className="w-5 h-5 rounded border-zinc-300 text-indigo-600 focus:ring-indigo-500"
|
||||||
|
/>
|
||||||
|
<span className="text-sm font-medium text-zinc-700 dark:text-zinc-300">BTTV Emotes</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label className="flex items-center gap-3 cursor-pointer">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="seventv"
|
||||||
|
checked={settings.emotes.seventv}
|
||||||
|
onChange={handleEmoteChange}
|
||||||
|
className="w-5 h-5 rounded border-zinc-300 text-indigo-600 focus:ring-indigo-500"
|
||||||
|
/>
|
||||||
|
<span className="text-sm font-medium text-zinc-700 dark:text-zinc-300">7TV Emotes</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
33
src/lib/types.ts
Normal file
33
src/lib/types.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
export interface OverlaySettings {
|
||||||
|
fontFamily: string;
|
||||||
|
fontSize: string;
|
||||||
|
textColor: string;
|
||||||
|
backgroundColor: string;
|
||||||
|
backgroundOpacity: number;
|
||||||
|
showBadges: boolean;
|
||||||
|
textShadow: string;
|
||||||
|
messageSpacing: string;
|
||||||
|
usernameColor: string; // 'custom' or 'twitch'
|
||||||
|
emotes: {
|
||||||
|
bttv: boolean;
|
||||||
|
seventv: boolean;
|
||||||
|
ffz: boolean;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DEFAULT_SETTINGS: OverlaySettings = {
|
||||||
|
fontFamily: 'Inter, sans-serif',
|
||||||
|
fontSize: '16px',
|
||||||
|
textColor: '#ffffff',
|
||||||
|
backgroundColor: '#000000',
|
||||||
|
backgroundOpacity: 0.5,
|
||||||
|
showBadges: true,
|
||||||
|
textShadow: '1px 1px 2px rgba(0,0,0,0.8)',
|
||||||
|
messageSpacing: '0.5rem',
|
||||||
|
usernameColor: 'twitch',
|
||||||
|
emotes: {
|
||||||
|
bttv: true,
|
||||||
|
seventv: true,
|
||||||
|
ffz: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
75
src/lib/utils.ts
Normal file
75
src/lib/utils.ts
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
import { type ClassValue, clsx } from "clsx";
|
||||||
|
import { twMerge } from "tailwind-merge";
|
||||||
|
import { OverlaySettings } from "./types";
|
||||||
|
|
||||||
|
export function cn(...inputs: ClassValue[]) {
|
||||||
|
return twMerge(clsx(inputs));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function generateOverlayCSS(settings: OverlaySettings): string {
|
||||||
|
// Convert backgroundOpacity (0-1) to hex alpha if needed, or use rgba
|
||||||
|
// Here we assume CSS Injection will be used as a <style> tag or returned by API
|
||||||
|
|
||||||
|
const r = parseInt(settings.backgroundColor.slice(1, 3), 16);
|
||||||
|
const g = parseInt(settings.backgroundColor.slice(3, 5), 16);
|
||||||
|
const b = parseInt(settings.backgroundColor.slice(5, 7), 16);
|
||||||
|
const rgbaBackground = `rgba(${r}, ${g}, ${b}, ${settings.backgroundOpacity})`;
|
||||||
|
|
||||||
|
return `
|
||||||
|
:root {
|
||||||
|
--chat-font-family: ${settings.fontFamily};
|
||||||
|
--chat-font-size: ${settings.fontSize};
|
||||||
|
--chat-text-color: ${settings.textColor};
|
||||||
|
--chat-bg-color: ${rgbaBackground};
|
||||||
|
--chat-text-shadow: ${settings.textShadow};
|
||||||
|
--chat-spacing: ${settings.messageSpacing};
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: transparent;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
font-family: var(--chat-font-family);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-container {
|
||||||
|
width: 100%;
|
||||||
|
height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: flex-end;
|
||||||
|
padding: 1rem;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-message {
|
||||||
|
background-color: var(--chat-bg-color);
|
||||||
|
color: var(--chat-text-color);
|
||||||
|
text-shadow: var(--chat-text-shadow);
|
||||||
|
font-size: var(--chat-font-size);
|
||||||
|
margin-bottom: var(--chat-spacing);
|
||||||
|
padding: 0.5rem;
|
||||||
|
border-radius: 4px;
|
||||||
|
word-wrap: break-word;
|
||||||
|
animation: fadeIn 0.2s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.username {
|
||||||
|
font-weight: bold;
|
||||||
|
margin-right: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badges {
|
||||||
|
display: ${settings.showBadges ? 'inline-flex' : 'none'};
|
||||||
|
margin-right: 0.25rem;
|
||||||
|
vertical-align: middle;
|
||||||
|
gap: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from { opacity: 0; transform: translateY(10px); }
|
||||||
|
to { opacity: 1; transform: translateY(0); }
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user