diff --git a/docs/BRAND-STYLE-GUIDE.md b/docs/BRAND-STYLE-GUIDE.md index e9a0011e..e158d793 100644 --- a/docs/BRAND-STYLE-GUIDE.md +++ b/docs/BRAND-STYLE-GUIDE.md @@ -664,6 +664,21 @@ export function PrimaryButton({ children, ...props }) { --- +## Public Video Style Consistency Rule + +**All videos published to Nomad Karaoke distribution channels (YouTube, Google Drive, venue libraries) MUST use the standard Nomad Karaoke visual style.** No customization of colors, backgrounds, fonts, or other visual elements is permitted for public videos. + +This ensures: +- Consistent brand identity across the entire Nomad Karaoke catalog +- Professional, recognizable appearance at venues worldwide +- Uniform experience for audiences browsing the YouTube channel or venue libraries + +Only the **display artist name** and **display title** text can be overridden for public videos (e.g. to format a soundtrack or cover correctly). + +Custom video styling (backgrounds, colors, fonts) is available exclusively for **private** deliveries where the user takes full responsibility for distribution. + +--- + ## Checklist for Brand Compliance ### Landing Pages diff --git a/docs/archive/2026-03-04-visibility-step-customize-rework.md b/docs/archive/2026-03-04-visibility-step-customize-rework.md new file mode 100644 index 00000000..03a231d2 --- /dev/null +++ b/docs/archive/2026-03-04-visibility-step-customize-rework.md @@ -0,0 +1,70 @@ +# Visibility Step & Customize Rework + +**Date:** 2026-03-04 +**Branch:** feat/sess-20260304-1700-visibility-step-customize + +## Overview + +Rework the guided job creation flow to add a separate "Visibility" step before "Customize & Create", dedicated to deciding whether the created video should be published or private. Then rework the "Customize & Create" step based on the chosen visibility. + +## New "Visibility" Step + +On this step, we simply let the user choose between public or private, but we use it as an opportunity to ensure the user definitely understands what will happen. + +### Published (Public) + +Explain that "published" means: + +- The resulting karaoke video will be automatically uploaded to the Nomad Karaoke YouTube channel (with a link to https://www.youtube.com/@nomadkaraoke/videos for them to check that out) +- It will also be uploaded to a Google Drive which is shared with various karaoke venues, meaning the song will be available to sing at a variety of karaoke bars/venues around the world +- The user will get all the source files and highest quality output formats via a Dropbox folder link too, which they can download for their safekeeping +- We should encourage the user to choose this option as it's the most convenient way to make their song available to sing (via YouTube) and they'll be helping out other fans of the same song, bringing joy to people all over the world who love that song + +### Private + +Explain that "private" means: + +- The resulting karaoke video will NOT be uploaded to YouTube or Google Drive, and will only be provided via a Dropbox folder / via this site, for the user to download and use however they see fit +- If the user wants to perform the track at a venue, they'll be responsible for providing the files to the host at that venue +- If the user wants to upload the video to their own YouTube channel they can do so, but they likely won't be able to monetise it (the song licenses/copyrights are still owned by record labels in most cases) +- If the user wants to customise the video styles (e.g. background image, colors), they can do this if they choose private delivery + +## Reworked "Customize & Create" Step + +Once we have the new "Visibility" step in the flow, we also need to rework the "Customize & Create" flow: + +### Remove Private Checkbox + +The "private" checkbox on the current Customize & Create step is replaced by the new Visibility step. + +### Conditional Options Based on Visibility + +Since we'll now know already whether the video is private or public, we can show only the options which are allowed: + +- **For public videos**: Only the title card artist/title should be customisable +- **For private videos**: Allow customising almost anything + +### Side-by-Side Preview Canvases + +Show the two preview canvases (title screen, main karaoke) side by side in this part of the flow, not below each other, so the user doesn't need to scroll down. + +### Remove Redundant Thumbnails + +Uploaded images for custom backgrounds don't need thumbnails - that's redundant since they're shown on the preview canvas(es). + +### Improved Karaoke Preview Canvas + +The text in the karaoke preview canvas needs to be centered in the thumbnail and show 4 lines so it's more similar to how the actual karaoke videos get rendered (see reference screenshot of actual video output). + +### New Style Customisation Options + +There should be a way to change more aspects of the styles: + +- Change the text color and/or highlight color of the karaoke lyrics +- Use a solid color background (rather than an image) for either the title screen or karaoke video (or both with different colors) +- Add a few preset color buttons for both of these, including one which is the "green screen" color + +## Reference Screenshots + +- Current "Customize & Create" UI: see attached screenshot showing the existing layout with private checkbox, stacked canvases, and current style options +- Actual karaoke video output: see attached screenshot showing how lyrics appear in real videos (4 centered lines with highlight color) diff --git a/frontend/components/job/GuidedJobFlow.tsx b/frontend/components/job/GuidedJobFlow.tsx index e6ac5995..4cf8f6f7 100644 --- a/frontend/components/job/GuidedJobFlow.tsx +++ b/frontend/components/job/GuidedJobFlow.tsx @@ -9,6 +9,7 @@ import { Button } from "@/components/ui/button" import { BuyCreditsDialog } from "@/components/credits/BuyCreditsDialog" import { SongInfoStep } from "./steps/SongInfoStep" import { AudioSourceStep } from "./steps/AudioSourceStep" +import { VisibilityStep } from "./steps/VisibilityStep" import { CustomizeStep } from "./steps/CustomizeStep" import type { ColorOverrides } from "./steps/CustomizeStep" @@ -16,9 +17,9 @@ interface GuidedJobFlowProps { onJobCreated: () => void } -type Step = 1 | 2 | 3 +type Step = 1 | 2 | 3 | 4 -const STEP_LABELS = ["Song Info", "Choose Audio", "Customize & Create"] +const STEP_LABELS = ["Song Info", "Choose Audio", "Visibility", "Customize & Create"] /** * Upload custom style assets to an already-created job. @@ -75,7 +76,8 @@ async function uploadStyleAssets( // Step 3: Finalize with uploaded file types + color overrides const uploadedFileTypes = filesToUpload.map((f) => f.file_type) - const hasColorOverrides = colorOverrides.artist_color || colorOverrides.title_color + const hasColorOverrides = colorOverrides.artist_color || colorOverrides.title_color || + colorOverrides.sung_lyrics_color || colorOverrides.unsung_lyrics_color await api.completeStyleUploads( jobId, uploadedFileTypes, @@ -163,7 +165,8 @@ export function GuidedJobFlow({ onJobCreated }: GuidedJobFlowProps) { // Upload style assets in the background (non-blocking) const hasStyleCustomizations = karaokeBackground || introBackground || - colorOverrides.artist_color || colorOverrides.title_color + colorOverrides.artist_color || colorOverrides.title_color || + colorOverrides.sung_lyrics_color || colorOverrides.unsung_lyrics_color if (isPrivate && hasStyleCustomizations) { uploadStyleAssets(response.job_id, karaokeBackground, introBackground, colorOverrides) } @@ -435,6 +438,15 @@ export function GuidedJobFlow({ onJobCreated }: GuidedJobFlowProps) { )} {step === 3 && ( + setStep(4)} + onBack={() => setStep(2)} + /> + )} + + {step === 4 && ( setStep(2)} + onBack={() => setStep(3)} isSubmitting={isSubmitting} /> )} diff --git a/frontend/components/job/ImageUploadField.tsx b/frontend/components/job/ImageUploadField.tsx index a71c25e9..1abeb41d 100644 --- a/frontend/components/job/ImageUploadField.tsx +++ b/frontend/components/job/ImageUploadField.tsx @@ -10,6 +10,7 @@ interface ImageUploadFieldProps { file: File | null onChange: (file: File | null) => void disabled?: boolean + hidePreview?: boolean // Hide the image thumbnail (when a canvas preview is shown instead) } const MAX_SIZE_BYTES = 10 * 1024 * 1024 // 10MB @@ -21,7 +22,7 @@ function formatFileSize(bytes: number): string { return `${(bytes / (1024 * 1024)).toFixed(1)} MB` } -export function ImageUploadField({ label, description, file, onChange, disabled }: ImageUploadFieldProps) { +export function ImageUploadField({ label, description, file, onChange, disabled, hidePreview }: ImageUploadFieldProps) { const inputRef = useRef(null) const [dragOver, setDragOver] = useState(false) const [error, setError] = useState(null) @@ -74,8 +75,8 @@ export function ImageUploadField({ label, description, file, onChange, disabled {file ? (
- {/* 16:9 preview thumbnail */} - {previewUrl && ( + {/* 16:9 preview thumbnail (hidden when canvas preview is used instead) */} + {!hidePreview && previewUrl && ( // eslint-disable-next-line @next/next/no-img-element (null) + const effectiveSungColor = sungColor || DEFAULT_SUNG_COLOR + const effectiveUnsungColor = unsungColor || DEFAULT_UNSUNG_COLOR + const draw = useCallback(async () => { const canvas = canvasRef.current if (!canvas) return const ctx = canvas.getContext("2d") if (!ctx) return - // Draw background - try { - const img = await new Promise((resolve, reject) => { - const el = new Image() - el.onload = () => resolve(el) - el.onerror = reject - el.src = backgroundUrl - }) - ctx.drawImage(img, 0, 0, CANVAS_W, CANVAS_H) - } catch { - ctx.fillStyle = "#000000" + // Draw background: custom image > solid color > default Nomad theme image + const bgSrc = backgroundUrl || (backgroundColor ? null : "/karaoke-bg.png") + if (bgSrc) { + try { + const img = await new Promise((resolve, reject) => { + const el = new Image() + el.onload = () => resolve(el) + el.onerror = reject + el.src = bgSrc + }) + ctx.drawImage(img, 0, 0, CANVAS_W, CANVAS_H) + } catch { + ctx.fillStyle = backgroundColor || "#000000" + ctx.fillRect(0, 0, CANVAS_W, CANVAS_H) + } + } else { + ctx.fillStyle = backgroundColor || "#000000" ctx.fillRect(0, 0, CANVAS_W, CANVAS_H) } - // Draw sample lyrics in the lower third (where they typically appear) + // Draw 4 lines of sample lyrics, vertically centered const fontSize = 120 const fontFamily = "'Arial', 'Helvetica', sans-serif" ctx.font = `700 ${fontSize}px ${fontFamily}` @@ -48,34 +69,54 @@ export function KaraokeBackgroundPreview({ backgroundUrl }: KaraokeBackgroundPre ctx.textBaseline = "middle" const centerX = CANVAS_W / 2 - const lineHeight = fontSize * 1.4 - const baseY = CANVAS_H * 0.75 + const lineHeight = fontSize * 1.5 + const totalHeight = lineHeight * SAMPLE_LINES.length + const startY = (CANVAS_H - totalHeight) / 2 + lineHeight / 2 - // Line 1: partially "sung" (first half highlighted) - const words1 = SAMPLE_LINE_1.split(" ") - const midPoint = Math.ceil(words1.length / 2) - const sungPart = words1.slice(0, midPoint).join(" ") - const unsungPart = " " + words1.slice(midPoint).join(" ") + SAMPLE_LINES.forEach((line, i) => { + const y = startY + i * lineHeight - // Measure widths for positioning - const fullWidth1 = ctx.measureText(SAMPLE_LINE_1).width - const sungWidth = ctx.measureText(sungPart).width - const startX1 = centerX - fullWidth1 / 2 + if (i === 1) { + // Line 2: partially "sung" — highlight first portion + const words = line.split(" ") + const midPoint = 3 // "This is Califor" split mid-word effect + const sungText = words.slice(0, midPoint).join(" ") + // Simulate mid-word highlight: "Califor" is partially sung + const sungPart = sungText.slice(0, -2) + const transitionChar = sungText.slice(-2) + const unsungPart = words.slice(midPoint).join(" ") - // Draw sung portion - ctx.fillStyle = SUNG_COLOR - ctx.textAlign = "left" - ctx.fillText(sungPart, startX1, baseY) + const fullText = line + const fullWidth = ctx.measureText(fullText).width + const lineStartX = centerX - fullWidth / 2 - // Draw unsung portion - ctx.fillStyle = UNSUNG_COLOR - ctx.fillText(unsungPart, startX1 + sungWidth, baseY) + // Sung portion + ctx.fillStyle = effectiveSungColor + ctx.textAlign = "left" + ctx.fillText(sungPart, lineStartX, y) - // Line 2: all unsung - ctx.fillStyle = UNSUNG_COLOR - ctx.textAlign = "center" - ctx.fillText(SAMPLE_LINE_2, centerX, baseY + lineHeight) - }, [backgroundUrl]) + // Transition characters (still sung color) + const sungPartWidth = ctx.measureText(sungPart).width + ctx.fillStyle = effectiveSungColor + ctx.fillText(transitionChar, lineStartX + sungPartWidth, y) + + // Unsung portion + const transWidth = ctx.measureText(transitionChar).width + ctx.fillStyle = effectiveUnsungColor + ctx.fillText(" " + unsungPart, lineStartX + sungPartWidth + transWidth, y) + + ctx.textAlign = "center" + } else if (i === 0) { + // Line 1: fully sung (already passed) + ctx.fillStyle = effectiveSungColor + ctx.fillText(line, centerX, y) + } else { + // Lines 3-4: unsung (upcoming) + ctx.fillStyle = effectiveUnsungColor + ctx.fillText(line, centerX, y) + } + }) + }, [backgroundUrl, backgroundColor, effectiveSungColor, effectiveUnsungColor]) useEffect(() => { draw() diff --git a/frontend/components/job/TitleCardPreview.tsx b/frontend/components/job/TitleCardPreview.tsx index 3ca5038c..a903ced7 100644 --- a/frontend/components/job/TitleCardPreview.tsx +++ b/frontend/components/job/TitleCardPreview.tsx @@ -6,6 +6,7 @@ interface TitleCardPreviewProps { artist: string title: string customBackgroundUrl?: string // Object URL from File for custom background + backgroundColor?: string // Solid color hex (used when no customBackgroundUrl) titleColor?: string // Hex color override (default #ffffff) artistColor?: string // Hex color override (default #ffdf6b) } @@ -121,7 +122,7 @@ function drawTextBlock( } } -export function TitleCardPreview({ artist, title, customBackgroundUrl, titleColor, artistColor }: TitleCardPreviewProps) { +export function TitleCardPreview({ artist, title, customBackgroundUrl, backgroundColor, titleColor, artistColor }: TitleCardPreviewProps) { const canvasRef = useRef(null) const effectiveTitleColor = titleColor || TITLE_COLOR @@ -133,7 +134,7 @@ export function TitleCardPreview({ artist, title, customBackgroundUrl, titleColo const ctx = canvas.getContext("2d") if (!ctx) return - // Draw background image (custom or default) + // Draw background: custom image > solid color > default image try { if (customBackgroundUrl) { const img = await new Promise((resolve, reject) => { @@ -143,12 +144,15 @@ export function TitleCardPreview({ artist, title, customBackgroundUrl, titleColo el.src = customBackgroundUrl }) ctx.drawImage(img, 0, 0, CANVAS_W, CANVAS_H) + } else if (backgroundColor) { + ctx.fillStyle = backgroundColor + ctx.fillRect(0, 0, CANVAS_W, CANVAS_H) } else { const bgImg = await loadBgImage() ctx.drawImage(bgImg, 0, 0, CANVAS_W, CANVAS_H) } } catch { - ctx.fillStyle = "#000000" + ctx.fillStyle = backgroundColor || "#000000" ctx.fillRect(0, 0, CANVAS_W, CANVAS_H) } @@ -188,7 +192,7 @@ export function TitleCardPreview({ artist, title, customBackgroundUrl, titleColo artist ? effectiveArtistColor : "rgba(255,223,107,0.25)", fontFamily, ) - }, [artist, title, customBackgroundUrl, effectiveTitleColor, effectiveArtistColor]) + }, [artist, title, customBackgroundUrl, backgroundColor, effectiveTitleColor, effectiveArtistColor]) useEffect(() => { draw() diff --git a/frontend/components/job/__tests__/CustomizeStep.test.tsx b/frontend/components/job/__tests__/CustomizeStep.test.tsx index 2cbf0ea2..34aec1ee 100644 --- a/frontend/components/job/__tests__/CustomizeStep.test.tsx +++ b/frontend/components/job/__tests__/CustomizeStep.test.tsx @@ -3,39 +3,46 @@ import { CustomizeStep } from "../steps/CustomizeStep" // Mock canvas-based components — they require browser APIs not available in jsdom jest.mock("../TitleCardPreview", () => ({ - TitleCardPreview: ({ artist, title, customBackgroundUrl, titleColor, artistColor }: any) => ( + TitleCardPreview: ({ artist, title, customBackgroundUrl, titleColor, artistColor, backgroundColor }: any) => (
), })) jest.mock("../KaraokeBackgroundPreview", () => ({ - KaraokeBackgroundPreview: ({ backgroundUrl }: any) => ( -
+ KaraokeBackgroundPreview: ({ backgroundUrl, backgroundColor, sungColor, unsungColor }: any) => ( +
), })) jest.mock("../ImageUploadField", () => ({ - ImageUploadField: ({ label, file, onChange, disabled }: any) => ( -
- {label} + ImageUploadField: ({ label, description, file, onChange, disabled, hidePreview }: any) => ( +
+ {label && {label}} + {description && {description}} {file && {file.name}} - - + {hidePreview && }
), })) @@ -48,7 +55,6 @@ const defaultProps = { onDisplayArtistChange: jest.fn(), onDisplayTitleChange: jest.fn(), isPrivate: false, - onPrivateChange: jest.fn(), karaokeBackground: null as File | null, onKaraokeBackgroundChange: jest.fn(), introBackground: null as File | null, @@ -63,93 +69,139 @@ const defaultProps = { describe("CustomizeStep", () => { beforeEach(() => { jest.clearAllMocks() - // Mock URL.createObjectURL for the component's useMemo global.URL.createObjectURL = jest.fn(() => "blob:mock") global.URL.revokeObjectURL = jest.fn() }) - it("renders title card preview with artist and title", () => { + describe("public mode (isPrivate=false)", () => { + it("shows title card preview and display fields, but no style options", () => { + render() + + // Display override fields are shown + expect(screen.getByLabelText(/Title Card Artist/)).toBeInTheDocument() + expect(screen.getByLabelText(/Title Card Title/)).toBeInTheDocument() + + // Title card preview is shown + expect(screen.getByTestId("title-card-preview")).toBeInTheDocument() + + // No style customization or karaoke preview + expect(screen.queryByText("Custom Video Style")).not.toBeInTheDocument() + expect(screen.queryByTestId("karaoke-bg-preview")).not.toBeInTheDocument() + }) + + it("calls onConfirm when create button is clicked", () => { + render() + + fireEvent.click(screen.getByText("Create Karaoke Video")) + expect(defaultProps.onConfirm).toHaveBeenCalledTimes(1) + }) + + it("shows loading state when isSubmitting", () => { + render() + expect(screen.getByText("Creating...")).toBeInTheDocument() + }) + }) + + describe("private mode (isPrivate=true)", () => { + it("shows custom video style section with side-by-side previews", () => { + render() + + expect(screen.getByText("Custom Video Style")).toBeInTheDocument() + expect(screen.getByTestId("title-card-preview")).toBeInTheDocument() + expect(screen.getByTestId("karaoke-bg-preview")).toBeInTheDocument() + }) + + it("renders title card preview with artist and title", () => { + render() + + const preview = screen.getByTestId("title-card-preview") + expect(preview.getAttribute("data-artist")).toBe("Test Artist") + expect(preview.getAttribute("data-title")).toBe("Test Song") + }) + + it("uses displayArtist/displayTitle in preview when provided", () => { + render( + + ) + + const preview = screen.getByTestId("title-card-preview") + expect(preview.getAttribute("data-artist")).toBe("Custom Artist") + expect(preview.getAttribute("data-title")).toBe("Custom Title") + }) + + it("shows color pickers for title card and lyrics", () => { + render() + + expect(screen.getByText("Artist Color")).toBeInTheDocument() + expect(screen.getByText("Title Color")).toBeInTheDocument() + expect(screen.getByText("Highlight Color")).toBeInTheDocument() + expect(screen.getByText("Lyrics Color")).toBeInTheDocument() + }) + + it("passes color overrides to title card preview", () => { + render( + + ) + + const preview = screen.getByTestId("title-card-preview") + expect(preview.getAttribute("data-artist-color")).toBe("#ff0000") + expect(preview.getAttribute("data-title-color")).toBe("#00ff00") + }) + + it("passes lyrics color overrides to karaoke preview", () => { + render( + + ) + + const preview = screen.getByTestId("karaoke-bg-preview") + expect(preview.getAttribute("data-sung-color")).toBe("#ff0000") + expect(preview.getAttribute("data-unsung-color")).toBe("#00ff00") + }) + + it("shows background mode toggles", () => { + render() + + // Two sets of Default/Image/Color toggles (one per canvas) + const defaultBtns = screen.getAllByText("Default") + const imageBtns = screen.getAllByText("Image") + const colorBtns = screen.getAllByText("Color") + + expect(defaultBtns).toHaveLength(2) + expect(imageBtns).toHaveLength(2) + expect(colorBtns).toHaveLength(2) + }) + + it("calls onConfirm when create button is clicked", () => { + render() + + fireEvent.click(screen.getByText("Create Karaoke Video")) + expect(defaultProps.onConfirm).toHaveBeenCalledTimes(1) + }) + + it("shows loading state when isSubmitting", () => { + render() + expect(screen.getByText("Creating...")).toBeInTheDocument() + }) + }) + + it("calls onBack when back button is clicked", () => { render() - const preview = screen.getByTestId("title-card-preview") - expect(preview).toBeInTheDocument() - expect(preview.getAttribute("data-artist")).toBe("Test Artist") - expect(preview.getAttribute("data-title")).toBe("Test Song") - }) - - it("uses displayArtist/displayTitle in preview when provided", () => { - render( - - ) - - const preview = screen.getByTestId("title-card-preview") - expect(preview.getAttribute("data-artist")).toBe("Custom Artist") - expect(preview.getAttribute("data-title")).toBe("Custom Title") - }) - - it("does NOT show custom video style section when isPrivate is false", () => { - render() - - expect(screen.queryByText("Custom Video Style")).not.toBeInTheDocument() - expect(screen.queryByText("Karaoke Background")).not.toBeInTheDocument() - expect(screen.queryByText("Title Card Background")).not.toBeInTheDocument() - }) - - it("shows custom video style section when isPrivate is true", () => { - render() - - expect(screen.getByText("Custom Video Style")).toBeInTheDocument() - expect(screen.getByText("Karaoke Background")).toBeInTheDocument() - expect(screen.getByText("Title Card Background")).toBeInTheDocument() - }) - - it("shows color pickers when isPrivate is true", () => { - render() - - expect(screen.getByText("Artist Color")).toBeInTheDocument() - expect(screen.getByText("Title Color")).toBeInTheDocument() - }) - - it("passes color overrides to title card preview", () => { - render( - - ) - - const preview = screen.getByTestId("title-card-preview") - expect(preview.getAttribute("data-artist-color")).toBe("#ff0000") - expect(preview.getAttribute("data-title-color")).toBe("#00ff00") - }) - - it("toggles private checkbox and triggers onPrivateChange", () => { - render() - - const checkbox = screen.getByRole("checkbox") - fireEvent.click(checkbox) - - expect(defaultProps.onPrivateChange).toHaveBeenCalledWith(true) - }) - - it("calls onConfirm when create button is clicked", () => { - render() - - const button = screen.getByText("Create Karaoke Video") - fireEvent.click(button) - - expect(defaultProps.onConfirm).toHaveBeenCalledTimes(1) - }) - - it("shows loading state when isSubmitting", () => { - render() - - expect(screen.getByText("Creating...")).toBeInTheDocument() + fireEvent.click(screen.getByText("Back")) + expect(defaultProps.onBack).toHaveBeenCalledTimes(1) }) it("disables form controls when isSubmitting", () => { @@ -158,55 +210,4 @@ describe("CustomizeStep", () => { const createBtn = screen.getByText("Creating...").closest("button") expect(createBtn).toBeDisabled() }) - - it("calls onBack when back button is clicked", () => { - render() - - const backBtn = screen.getByText("Back") - fireEvent.click(backBtn) - - expect(defaultProps.onBack).toHaveBeenCalledTimes(1) - }) - - it("shows karaoke background preview when file is provided and isPrivate", () => { - const file = new File(["data"], "karaoke-bg.png", { type: "image/png" }) - - render( - - ) - - expect(screen.getByTestId("karaoke-bg-preview")).toBeInTheDocument() - }) - - it("does NOT show karaoke background preview when no file", () => { - render( - - ) - - expect(screen.queryByTestId("karaoke-bg-preview")).not.toBeInTheDocument() - }) - - it("passes custom intro background to title card preview", () => { - const file = new File(["data"], "intro-bg.png", { type: "image/png" }) - - render( - - ) - - const preview = screen.getByTestId("title-card-preview") - // Should have a blob URL for the custom background - expect(preview.getAttribute("data-custom-bg")).toBe("blob:mock") - }) }) diff --git a/frontend/components/job/steps/CustomizeStep.tsx b/frontend/components/job/steps/CustomizeStep.tsx index 457f6052..4fe2b161 100644 --- a/frontend/components/job/steps/CustomizeStep.tsx +++ b/frontend/components/job/steps/CustomizeStep.tsx @@ -1,10 +1,10 @@ "use client" -import { useEffect, useMemo, useRef } from "react" +import { useEffect, useMemo, useRef, useState } from "react" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" -import { ArrowLeft, Loader2, Palette } from "lucide-react" +import { ArrowLeft, Loader2, Palette, Image as ImageIcon, Paintbrush } from "lucide-react" import { TitleCardPreview } from "../TitleCardPreview" import { KaraokeBackgroundPreview } from "../KaraokeBackgroundPreview" import { ImageUploadField } from "../ImageUploadField" @@ -12,6 +12,8 @@ import { ImageUploadField } from "../ImageUploadField" export interface ColorOverrides { artist_color?: string title_color?: string + sung_lyrics_color?: string + unsung_lyrics_color?: string } interface CustomizeStepProps { @@ -22,7 +24,6 @@ interface CustomizeStepProps { onDisplayArtistChange: (value: string) => void onDisplayTitleChange: (value: string) => void isPrivate: boolean - onPrivateChange: (value: boolean) => void karaokeBackground: File | null onKaraokeBackgroundChange: (file: File | null) => void introBackground: File | null @@ -35,6 +36,163 @@ interface CustomizeStepProps { disabled?: boolean } +// Preset colors for solid backgrounds +const BG_PRESETS = [ + { label: "Black", color: "#000000" }, + { label: "Dark Blue", color: "#1a1a2e" }, + { label: "Dark Purple", color: "#16213e" }, + { label: "Green Screen", color: "#00b140" }, + { label: "White", color: "#ffffff" }, +] + +type BgMode = "default" | "image" | "solid" + +/** + * Generate a tiny 4x4 solid color PNG blob for uploading as a background. + * The backend expects an image file, so we create one client-side. + */ +function generateSolidColorBlob(hexColor: string): Promise { + return new Promise((resolve) => { + const canvas = document.createElement("canvas") + canvas.width = 4 + canvas.height = 4 + const ctx = canvas.getContext("2d")! + ctx.fillStyle = hexColor + ctx.fillRect(0, 0, 4, 4) + canvas.toBlob((blob) => { + resolve(new File([blob!], `solid-${hexColor.replace('#', '')}.png`, { type: "image/png" })) + }, "image/png") + }) +} + +function ColorPickerField({ + id, + label, + value, + defaultColor, + onChange, + disabled, +}: { + id: string + label: string + value?: string + defaultColor: string + onChange: (val: string | undefined) => void + disabled?: boolean +}) { + return ( +
+ +
+ onChange(e.target.value)} + disabled={disabled} + className="w-8 h-8 rounded border cursor-pointer" + style={{ borderColor: 'var(--card-border)' }} + /> + { + const val = e.target.value + if (val === "" || /^#[0-9A-Fa-f]{0,6}$/.test(val)) { + onChange(val || undefined) + } + }} + disabled={disabled} + className="font-mono text-xs h-8" + style={{ backgroundColor: 'var(--secondary)', borderColor: 'var(--card-border)', color: 'var(--text)' }} + /> +
+
+ ) +} + +function ColorPresetButtons({ + presets, + value, + onChange, + disabled, +}: { + presets: typeof BG_PRESETS + value?: string + onChange: (color: string) => void + disabled?: boolean +}) { + return ( +
+ {presets.map((preset) => ( + + ))} +
+ ) +} + +function BgModeToggle({ + mode, + onChange, + disabled, +}: { + mode: BgMode + onChange: (mode: BgMode) => void + disabled?: boolean +}) { + const options: { value: BgMode; label: string; icon: React.ReactNode }[] = [ + { value: "default", label: "Default", icon: null }, + { value: "image", label: "Image", icon: }, + { value: "solid", label: "Color", icon: }, + ] + + return ( +
+ {options.map((opt) => ( + + ))} +
+ ) +} + export function CustomizeStep({ artist, title, @@ -43,7 +201,6 @@ export function CustomizeStep({ onDisplayArtistChange, onDisplayTitleChange, isPrivate, - onPrivateChange, karaokeBackground, onKaraokeBackgroundChange, introBackground, @@ -55,13 +212,22 @@ export function CustomizeStep({ isSubmitting, disabled, }: CustomizeStepProps) { - // The displayed artist/title on the title card const previewArtist = displayArtist.trim() || artist const previewTitle = displayTitle.trim() || title + // Background mode state (private only) + const [karaokeBgMode, setKaraokeBgMode] = useState( + karaokeBackground ? "image" : "default" + ) + const [introBgMode, setIntroBgMode] = useState( + introBackground ? "image" : "default" + ) + const [karaokeSolidColor, setKaraokeSolidColor] = useState("#000000") + const [introSolidColor, setIntroSolidColor] = useState("#000000") + // Create stable object URLs for previews and revoke on cleanup - const prevKaraokeBlobUrl = useRef() - const prevIntroBlobUrl = useRef() + const prevKaraokeBlobUrl = useRef(undefined) + const prevIntroBlobUrl = useRef(undefined) const karaokeBackgroundUrl = useMemo( () => karaokeBackground ? URL.createObjectURL(karaokeBackground) : undefined, @@ -88,6 +254,129 @@ export function CustomizeStep({ return () => { if (introBackgroundUrl) URL.revokeObjectURL(introBackgroundUrl) } }, [introBackgroundUrl]) + // When switching background modes, update the file state accordingly + function handleKaraokeBgModeChange(mode: BgMode) { + setKaraokeBgMode(mode) + if (mode === "default" || mode === "solid") { + onKaraokeBackgroundChange(null) + } + if (mode === "solid") { + // Generate solid color blob + generateSolidColorBlob(karaokeSolidColor).then(onKaraokeBackgroundChange) + } + } + + function handleIntroBgModeChange(mode: BgMode) { + setIntroBgMode(mode) + if (mode === "default" || mode === "solid") { + onIntroBackgroundChange(null) + } + if (mode === "solid") { + generateSolidColorBlob(introSolidColor).then(onIntroBackgroundChange) + } + } + + function handleKaraokeSolidColorChange(color: string) { + setKaraokeSolidColor(color) + generateSolidColorBlob(color).then(onKaraokeBackgroundChange) + } + + function handleIntroSolidColorChange(color: string) { + setIntroSolidColor(color) + generateSolidColorBlob(color).then(onIntroBackgroundChange) + } + + // === PUBLIC MODE: Simple layout === + if (!isPrivate) { + return ( +
+
+
+

+ Customize & Create +

+

+ Confirm the artist and title for your title card. +

+
+ +
+ + {/* Title card preview */} +
+ +
+ + {/* Display override fields */} +
+
+ + onDisplayArtistChange(e.target.value)} + disabled={disabled || isSubmitting} + style={{ backgroundColor: 'var(--secondary)', borderColor: 'var(--card-border)', color: 'var(--text)' }} + /> +
+
+ + onDisplayTitleChange(e.target.value)} + disabled={disabled || isSubmitting} + style={{ backgroundColor: 'var(--secondary)', borderColor: 'var(--card-border)', color: 'var(--text)' }} + /> +
+
+

+ These default to your search values. Override for soundtracks, covers, or alternate formatting. +

+ + +
+ ) + } + + // === PRIVATE MODE: Full customization === return (
@@ -96,7 +385,7 @@ export function CustomizeStep({ Customize & Create

- Preview your title card and confirm your settings. + Customize your private video's appearance.

- {/* Title card preview - half width, centered */} -
- -
- -
-
- {/* Display override fields */}
@@ -164,137 +439,197 @@ export function CustomizeStep({ These default to your search values. Override for soundtracks, covers, or alternate formatting.

- {/* Privacy toggle */} -
-
- onPrivateChange(e.target.checked)} - disabled={disabled || isSubmitting} - className="mt-1 w-4 h-4 rounded border-border bg-secondary accent-[var(--brand-pink)] focus:ring-[var(--brand-pink)] focus:ring-offset-background" - /> -
- -

- Files delivered via Dropbox only. No YouTube or Google Drive upload. -

-
+ {/* Custom Video Style section */} +
+
+ +

+ Custom Video Style +

-
- {/* Custom Video Style section - only shown for private delivery */} - {isPrivate && ( -
-
- -

- Custom Video Style -

-
-

- Upload custom backgrounds and choose colors for your branded karaoke video. -

+ {/* Side-by-side preview canvases */} +
+ {/* Title Card Preview + Controls */} +
+
+ + +
- {/* Karaoke Background */} -
- - {karaokeBackgroundUrl && ( -
- + + {introBgMode === "image" && ( + + )} + + {introBgMode === "solid" && ( +
+ +
+ handleIntroSolidColorChange(e.target.value)} + disabled={disabled || isSubmitting} + className="w-8 h-8 rounded border cursor-pointer" + style={{ borderColor: 'var(--card-border)' }} + /> + { + const val = e.target.value + if (/^#[0-9A-Fa-f]{0,6}$/.test(val)) { + handleIntroSolidColorChange(val) + } + }} + disabled={disabled || isSubmitting} + className="font-mono text-xs h-8" + style={{ backgroundColor: 'var(--secondary)', borderColor: 'var(--card-border)', color: 'var(--text)' }} + /> +
)} + + {/* Title card text colors */} +
+ onColorOverridesChange({ ...colorOverrides, artist_color: val })} + disabled={disabled || isSubmitting} + /> + onColorOverridesChange({ ...colorOverrides, title_color: val })} + disabled={disabled || isSubmitting} + /> +
- {/* Title Card Background */} -
- +
+ + +
+ + -
- {/* Color overrides */} -
-
- -
- onColorOverridesChange({ ...colorOverrides, artist_color: e.target.value })} + {karaokeBgMode === "image" && ( + + )} + + {karaokeBgMode === "solid" && ( +
+ - { - const val = e.target.value - if (val === "" || /^#[0-9A-Fa-f]{0,6}$/.test(val)) { - onColorOverridesChange({ ...colorOverrides, artist_color: val || undefined }) - } - }} - disabled={disabled || isSubmitting} - className="font-mono text-xs h-8" - style={{ backgroundColor: 'var(--secondary)', borderColor: 'var(--card-border)', color: 'var(--text)' }} - /> -
-
-
- -
- onColorOverridesChange({ ...colorOverrides, title_color: e.target.value })} - disabled={disabled || isSubmitting} - className="w-8 h-8 rounded border cursor-pointer" - style={{ borderColor: 'var(--card-border)' }} - /> - { - const val = e.target.value - if (val === "" || /^#[0-9A-Fa-f]{0,6}$/.test(val)) { - onColorOverridesChange({ ...colorOverrides, title_color: val || undefined }) - } - }} - disabled={disabled || isSubmitting} - className="font-mono text-xs h-8" - style={{ backgroundColor: 'var(--secondary)', borderColor: 'var(--card-border)', color: 'var(--text)' }} /> +
+ handleKaraokeSolidColorChange(e.target.value)} + disabled={disabled || isSubmitting} + className="w-8 h-8 rounded border cursor-pointer" + style={{ borderColor: 'var(--card-border)' }} + /> + { + const val = e.target.value + if (/^#[0-9A-Fa-f]{0,6}$/.test(val)) { + handleKaraokeSolidColorChange(val) + } + }} + disabled={disabled || isSubmitting} + className="font-mono text-xs h-8" + style={{ backgroundColor: 'var(--secondary)', borderColor: 'var(--card-border)', color: 'var(--text)' }} + /> +
+ )} + + {/* Lyrics colors */} +
+ onColorOverridesChange({ ...colorOverrides, sung_lyrics_color: val })} + disabled={disabled || isSubmitting} + /> + onColorOverridesChange({ ...colorOverrides, unsung_lyrics_color: val })} + disabled={disabled || isSubmitting} + />
-

- Leave blank to use default Nomad theme colors. -

- )} + +

+ Leave colors blank to use default Nomad theme. Previews are approximate — final rendering may differ slightly. +

+
{/* Create button */} +
+ + {/* Published option */} + + + {/* Private option */} + + + {/* Continue button */} + +
+ ) +} diff --git a/frontend/public/karaoke-bg.png b/frontend/public/karaoke-bg.png new file mode 100644 index 00000000..0182adca Binary files /dev/null and b/frontend/public/karaoke-bg.png differ diff --git a/pyproject.toml b/pyproject.toml index ffa1ea67..19bc0991 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "karaoke-gen" -version = "0.131.0" +version = "0.132.0" description = "Generate karaoke videos with synchronized lyrics. Handles the entire process from downloading audio and lyrics to creating the final video with title screens." authors = ["Andrew Beveridge "] license = "MIT"