Skip to content

StingerNew

A stinger transition that wipes a paper panel across the canvas, holds the wordmark, then clears. Replay it on the site preview; on stream it plays once when the source is shown.

Scene change

C.KING

"use client";

import { useEffect, useState } from "react";
import { AnimatePresence, motion, useReducedMotion } from "motion/react";

import { OverlayRoot } from "@/components/stream/overlay-root";
import { RotateCcw } from "@/components/shared/site-icons";
import { STREAM_COPY } from "@/config/stream-copy";
import type { StreamLayout } from "@/config/stream-components";
import { ease } from "@/lib/motion";
import { cn } from "@/lib/utils";

const DEFAULTS = STREAM_COPY.stinger;

export function Stinger({
  layout,
  preview = false,
  eyebrow = DEFAULTS.eyebrow,
  wordmark = DEFAULTS.wordmark,
}: {
  layout: StreamLayout;
  preview?: boolean;
  eyebrow?: string;
  wordmark?: string;
}) {
  const mobile = layout === "mobile";
  const reduceMotion = useReducedMotion();
  const [cycle, setCycle] = useState(0);
  const [visible, setVisible] = useState(true);

  useEffect(() => {
    setVisible(true);
    const hide = window.setTimeout(() => setVisible(false), reduceMotion ? 900 : 1400);
    return () => window.clearTimeout(hide);
  }, [cycle, reduceMotion]);

  return (
    <OverlayRoot>
      <AnimatePresence>
        {visible ? (
          <motion.div
            key={cycle}
            className="absolute inset-0 bg-background"
            initial={reduceMotion ? { opacity: 0 } : { x: "-100%" }}
            animate={{ opacity: 1, x: 0 }}
            exit={reduceMotion ? { opacity: 0 } : { x: "100%" }}
            transition={{ duration: reduceMotion ? 0.2 : 0.5, ease: ease.inOut }}
          >
            <div className="absolute inset-[3.5cqw] border border-dashed border-foreground/25" />
            <div className="absolute inset-0 grid place-items-center text-center">
              <div>
                <p
                  className={cn(
                    "font-mono uppercase tracking-[0.28em] text-muted-foreground",
                    mobile ? "mb-[2cqw] text-[2.8cqw]" : "mb-[1cqw] text-[1.4cqw]",
                  )}
                >
                  {eyebrow}
                </p>
                <p
                  className={cn(
                    "font-serif font-medium tracking-tight text-foreground italic",
                    mobile ? "text-[14cqw]" : "text-[8cqw]",
                  )}
                >
                  {wordmark}
                </p>
              </div>
            </div>
          </motion.div>
        ) : null}
      </AnimatePresence>

      {preview ? (
        <button
          type="button"
          onClick={() => setCycle((value) => value + 1)}
          className={cn(
            "pointer-events-auto absolute inline-flex items-center gap-[0.8cqw] rounded-md border border-dashed bg-background/90 font-mono uppercase tracking-[0.18em] text-foreground transition-colors hover:bg-muted",
            mobile
              ? "right-[8cqw] bottom-[8cqw] px-[3cqw] py-[1.6cqw] text-[2.4cqw]"
              : "right-[4cqw] bottom-[4cqw] px-[1.4cqw] py-[0.7cqw] text-[1.2cqw]",
          )}
        >
          <RotateCcw className={mobile ? "size-[3cqw]" : "size-[1.4cqw]"} />
          Replay
        </button>
      ) : null}
    </OverlayRoot>
  );
}

Props

Layout

Desktop 16:9 for OBS, or mobile 9:16 for TikTok Live Studio.

Installation

Stinger is a browser-source overlay. Copy the URL for OBS or TikTok Live Studio. The live page has no site chrome and a transparent background.

In OBS, add a Browser source, paste the URL, and set the size to 1920 × 1080. Leave the page background transparent.

Usage

example.tsx

import { Stinger } from "@/components/stream/stinger";

export function Overlay() {
  return (
    <Stinger
      layout="desktop"
      eyebrow="Scene change"
      wordmark="C.KING"
      preview
    />
  );
}

Browser source

Paste this URL into OBS or TikTok Live Studio. The query params match the props below.

browser-source.tsx

// OBS Browser source, 1920×1080. Plays once when the source is shown.
const src = "https://chandlerking.dev/live/stinger?layout=desktop&eyebrow=Scene+change&wordmark=C.KING";

A paper wipe across the canvas with the wordmark, then a clear. Preview adds a replay control. On stream it plays once when the browser source is shown.

Props

PropTypeDefaultNotes
eyebrowstring"Scene change"Small line above the wordmark. Query `eyebrow`.
wordmarkstring"C.KING"Large italic mark in the center of the wipe. Query `wordmark`.
layout"desktop" | "mobile"RequiredCanvas orientation. Desktop is 1920×1080 for OBS. Mobile is 1080×1920 for TikTok Live Studio. Query `layout`.
previewbooleanfalseSite-only helpers: a sample webcam fill, a looping alert, and a stinger replay control. Leave it off on the live route.

Notes & Features

  • One play on stream. The panel wipes in, holds the wordmark, then wipes off. Show the browser source when you change scenes.
  • Replay. `preview` adds a replay button on the site. The live route has no button and plays once.
  • Reduced motion. The wipe becomes a fade, and the hold is shorter.
  • Motion. The wipe uses the `motion` package. Install it if you copy the file into another project.

Manual installation

Rather than the browser source, copy Stinger into a project. Install its dependencies, then copy all 2 files into the matching path.

Dependencies

terminal

npm install motion

Source files

src/components/stream/stinger.tsx

"use client";

import { useEffect, useState } from "react";
import { AnimatePresence, motion, useReducedMotion } from "motion/react";

import { OverlayRoot } from "@/components/stream/overlay-root";
import { RotateCcw } from "@/components/shared/site-icons";
import { STREAM_COPY } from "@/config/stream-copy";
import type { StreamLayout } from "@/config/stream-components";
import { ease } from "@/lib/motion";
import { cn } from "@/lib/utils";

const DEFAULTS = STREAM_COPY.stinger;

export function Stinger({
  layout,
  preview = false,
  eyebrow = DEFAULTS.eyebrow,
  wordmark = DEFAULTS.wordmark,
}: {
  layout: StreamLayout;
  preview?: boolean;
  eyebrow?: string;
  wordmark?: string;
}) {
  const mobile = layout === "mobile";
  const reduceMotion = useReducedMotion();
  const [cycle, setCycle] = useState(0);
  const [visible, setVisible] = useState(true);

  useEffect(() => {
    setVisible(true);
    const hide = window.setTimeout(() => setVisible(false), reduceMotion ? 900 : 1400);
    return () => window.clearTimeout(hide);
  }, [cycle, reduceMotion]);

  return (
    <OverlayRoot>
      <AnimatePresence>
        {visible ? (
          <motion.div
            key={cycle}
            className="absolute inset-0 bg-background"
            initial={reduceMotion ? { opacity: 0 } : { x: "-100%" }}
            animate={{ opacity: 1, x: 0 }}
            exit={reduceMotion ? { opacity: 0 } : { x: "100%" }}
            transition={{ duration: reduceMotion ? 0.2 : 0.5, ease: ease.inOut }}
          >
            <div className="absolute inset-[3.5cqw] border border-dashed border-foreground/25" />
            <div className="absolute inset-0 grid place-items-center text-center">
              <div>
                <p
                  className={cn(
                    "font-mono uppercase tracking-[0.28em] text-muted-foreground",
                    mobile ? "mb-[2cqw] text-[2.8cqw]" : "mb-[1cqw] text-[1.4cqw]",
                  )}
                >
                  {eyebrow}
                </p>
                <p
                  className={cn(
                    "font-serif font-medium tracking-tight text-foreground italic",
                    mobile ? "text-[14cqw]" : "text-[8cqw]",
                  )}
                >
                  {wordmark}
                </p>
              </div>
            </div>
          </motion.div>
        ) : null}
      </AnimatePresence>

      {preview ? (
        <button
          type="button"
          onClick={() => setCycle((value) => value + 1)}
          className={cn(
            "pointer-events-auto absolute inline-flex items-center gap-[0.8cqw] rounded-md border border-dashed bg-background/90 font-mono uppercase tracking-[0.18em] text-foreground transition-colors hover:bg-muted",
            mobile
              ? "right-[8cqw] bottom-[8cqw] px-[3cqw] py-[1.6cqw] text-[2.4cqw]"
              : "right-[4cqw] bottom-[4cqw] px-[1.4cqw] py-[0.7cqw] text-[1.2cqw]",
          )}
        >
          <RotateCcw className={mobile ? "size-[3cqw]" : "size-[1.4cqw]"} />
          Replay
        </button>
      ) : null}
    </OverlayRoot>
  );
}

src/components/stream/overlay-root.tsx

import type { ReactNode } from "react";

import { cn } from "@/lib/utils";

export function OverlayRoot({
  children,
  className,
}: {
  children: ReactNode;
  className?: string;
}) {
  return (
    <div
      className={cn(
        "@container relative h-full w-full overflow-hidden pointer-events-none",
        className,
      )}
    >
      {children}
    </div>
  );
}

Carve that warmth into me.

Vinland Saga
Chandler King

Building AnglerIQ & The Sozo CRM

Open to software engineering roles

Crafted by Chandler King · Kansas City, MO