Brand
Wordmark glow
The big wordmark across an area in the footer gray over a faint 20px dot grid; a mouse lights the dots near it and the letters it crosses in the spectrum, the light easing after the pointer. The footer's other look (the site's footer uses the dispersion field's light by default).
Install
React apps get the React files; every other stack gets the web component.
npx spyglass-ds add wordmark-glow<script type="module" src="/spyglass-ds/elements/wordmark-glow.js"></script>Usage
A footer or a closing band ending on the wordmark, with the footer's card as its children.
Never
- The wordmark in a color, or the glow without the pointer: it stays the footer gray
- More than once on a page
- Moving with reduced motion: the letters keep a still glow
Adds with it: logo
Props
The web component takes the same as attributes or properties (<spyglass-wordmark-glow>); title is heading there.
<WordmarkGlow>
| Prop | Type | Default |
|---|---|---|
children | ReactNode What follows the wordmark inside the area. | |
className | string |
Examples
The same example in React and as web components; both render identically.
import { WordmarkGlow } from '@/react/components/visuals/WordmarkGlow'
// The footer's other look: the wordmark over its dot grid, a card pulled up over the descender. Point at the dots and
// the letters (768 wide and up) and they light in the spectrum.
export default function Footer() {
return (
<WordmarkGlow className="mx-auto w-full max-w-[calc(var(--ds-layout-content)+2*var(--ds-layout-gutter))] px-(--ds-layout-gutter) pt-16 pb-8">
<div className="relative z-1 -mt-[2.54%] rounded-panel border border-edge bg-surface-raised p-12 max-md:p-6">
<p className="type-body text-fg-soft">Acme's footer links sit here.</p>
</div>
</WordmarkGlow>
)
}<!-- The footer's other look: the wordmark over its dot grid, a card pulled up over the descender. Point at the dots and
the letters (768 wide and up) and they light in the spectrum. -->
<spyglass-wordmark-glow class="mx-auto w-full max-w-[calc(var(--ds-layout-content)+2*var(--ds-layout-gutter))] px-(--ds-layout-gutter) pt-16 pb-8">
<div class="relative z-1 -mt-[2.54%] rounded-panel border border-edge bg-surface-raised p-12 max-md:p-6">
<p class="type-body text-fg-soft">Acme's footer links sit here.</p>
</div>
</spyglass-wordmark-glow>Source
'use client'
import { useEffect, useRef, type CSSProperties, type ReactNode } from 'react'
import { LOGOS } from '@/lib/logos'
import { startWordmarkGlow } from '@/lib/effects/wordmark-glow'
import { GLOW_CSS, wordmarkMask } from '@/lib/effects/wordmark-glow-css'
import { cn } from '@/react/lib/cn'
// The site's wordmark glow (effect/WordmarkGlow with site/Footer/FooterWordmarkGlow): the big wordmark across the
// area in the footer gray over a faint 20px dot grid; a mouse lights the dots near it in the spectrum and, over the
// wordmark, its letters, the light easing after the pointer and leaving when it does. `children` follow the wordmark
// inside the area (a footer's card, pulled up over the descender). The site's footer uses the dispersion field's
// light instead by default; this is its other look. Only for a fine pointer; with reduced motion the letters keep a
// still glow and the dots stay plain. Decoration: the wordmark is hidden from assistive tech.
export interface WordmarkGlowProps {
/** What follows the wordmark inside the area. */
children?: ReactNode
className?: string
}
export function WordmarkGlow({ children, className }: WordmarkGlowProps) {
const ref = useRef<HTMLDivElement>(null)
useEffect(() => {
const area = ref.current
return area ? startWordmarkGlow(area) : undefined
}, [])
const w = LOGOS.wordmark
return (
<div ref={ref} data-ds="wordmark-glow" className={cn('relative isolate', className)} style={{ '--ds-glow-wordmark': wordmarkMask() } as CSSProperties}>
<style href="ds-wordmark-glow" precedence="ds">{GLOW_CSS}</style>
<span className="ds-glow-grid" aria-hidden="true" />
<span className="ds-glow-dots" data-glow-dots="" aria-hidden="true" />
<div className="relative w-full [container-type:inline-size]" data-glow-word="" aria-hidden="true" style={{ aspectRatio: `${w.width} / ${w.height}` }}>
<svg viewBox={`0 0 ${w.width} ${w.height}`} className="absolute inset-0 block size-full fill-wordmark-gray" dangerouslySetInnerHTML={{ __html: w.body }} />
<span className="ds-glow-letters" data-glow-letters="" />
</div>
{children}
</div>
)
}
export default WordmarkGlow// The site's wordmark glow (effect/WordmarkGlow): over an area with a 20px dot grid, a mouse lights the dots near it
// (260px) in the spectrum, a conic sweep centred above the wordmark, and over the big wordmark lights its letters the
// same way; the light eases after the pointer (masks moving over 480ms) and leaves when it does. The area holds
// [data-glow-dots] and [data-glow-word] with [data-glow-letters] inside (found in `root`, a shadow root for the element). Only for a fine pointer without reduced motion.
type Layers = { position: string; size: string; after: { position: string; size: string }[] };
const px = (el: Element, name: string, fallback: number) => parseFloat(getComputedStyle(el).getPropertyValue(name)) || fallback;
export function startWordmarkGlow(area: HTMLElement, root: ParentNode = area): () => void {
const dots = root.querySelector<HTMLElement>("[data-glow-dots]");
const word = root.querySelector<HTMLElement>("[data-glow-word]");
const letters = word?.querySelector<HTMLElement>("[data-glow-letters]");
if (!dots || !word || !letters) return () => {};
if (!window.matchMedia("(hover: hover) and (pointer: fine)").matches) return () => {};
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return () => {};
const radius = px(area, "--ds-footer-glow-radius", 260);
const centre = px(area, "--ds-glow-centre", 0.375);
const offset = getComputedStyle(area).getPropertyValue("--ds-glow-dot-offset").trim() || "4px";
const size = `${2 * radius}px ${2 * radius}px`;
let raf = 0;
let x = 0;
let y = 0;
let overWord = false;
let wordLit = false;
let areaLit = false;
const place = (el: HTMLElement, layers: Layers, box: DOMRect, on: boolean) => {
const lx = x - box.left;
const ly = y - box.top;
const at = on ? `${lx - radius}px ${ly - radius}px` : `${lx}px ${ly}px`;
el.style.maskPosition = [layers.position, ...layers.after.map((l) => l.position), at].join(", ");
el.style.maskSize = [layers.size, ...layers.after.map((l) => l.size), on ? size : "0px 0px"].join(", ");
};
const dotLayers: Layers = {
position: `${offset} ${offset}`,
size: "var(--ds-glow-dot-pitch) var(--ds-glow-dot-pitch)",
after: [{ position: "0 0", size: "100% 100%" }],
};
const letterLayers: Layers = { position: "0 0", size: "100% 100%", after: [] };
const frame = () => {
raf = 0;
const a = area.getBoundingClientRect();
const w = word.getBoundingClientRect();
dots.style.setProperty(
"--glow-at",
`${w.left - a.left + w.width / 2}px ${w.top - a.top + w.height / 2 - centre * w.width}px`,
);
areaLit = true;
place(dots, dotLayers, a, true);
if (overWord || wordLit) {
place(letters, letterLayers, w, overWord);
wordLit = overWord;
}
};
const move = (e: PointerEvent) => {
if (e.pointerType === "touch") return;
x = e.clientX;
y = e.clientY;
overWord = e.composedPath().includes(word);
if (!raf) raf = requestAnimationFrame(frame);
};
const leave = (e: PointerEvent) => {
if (e.pointerType === "touch") return;
cancelAnimationFrame(raf);
raf = 0;
x = e.clientX;
y = e.clientY;
if (areaLit) place(dots, dotLayers, area.getBoundingClientRect(), false);
if (wordLit) place(letters, letterLayers, word.getBoundingClientRect(), false);
areaLit = false;
wordLit = false;
overWord = false;
};
area.addEventListener("pointermove", move, { passive: true });
area.addEventListener("pointerleave", leave, { passive: true });
return () => {
cancelAnimationFrame(raf);
area.removeEventListener("pointermove", move);
area.removeEventListener("pointerleave", leave);
};
}import { LOGOS } from '@/lib/logos'
// The wordmark glow's look (effect/WordmarkGlow/WordmarkGlow.effect.module.css), shared by both flavors: the dot grid
// fading in over 128px from the top, the spectrum (Blue, Green, Yellow, Orange, Red, Cyan) swept round a point above
// the wordmark, shown through the dots and the letters only where the pointer's circle is. Reduced motion: no dots, the
// letters lit still around the sweep's centre.
export const GLOW_CSS = `
.ds-glow-grid, .ds-glow-dots, .ds-glow-letters { position: absolute; inset: 0; pointer-events: none; }
.ds-glow-grid {
mask-image: linear-gradient(transparent, var(--ds-color-black) var(--ds-glow-dot-fade));
background-image: radial-gradient(circle, var(--ds-glow-dot-color) 1px, transparent 1px);
background-position: var(--ds-glow-dot-offset) var(--ds-glow-dot-offset);
background-size: var(--ds-glow-dot-pitch) var(--ds-glow-dot-pitch);
}
.ds-glow-dots, .ds-glow-letters {
background-image: repeating-conic-gradient(from 0deg at var(--glow-at, 50% 50%), var(--ds-color-blue) 0deg, var(--ds-color-green) 15deg, var(--ds-color-yellow) 30deg, var(--ds-color-orange) 45deg, var(--ds-color-red) 60deg, var(--ds-color-cyan) 75deg, var(--ds-color-blue) 90deg);
opacity: var(--ds-glow-strength);
mix-blend-mode: screen;
mask-repeat: repeat, no-repeat;
mask-composite: intersect;
mask-position: var(--ds-glow-dot-offset) var(--ds-glow-dot-offset), 50% 50%;
transition: mask-position var(--ds-duration-slow) var(--ds-easing-glow), mask-size var(--ds-duration-slow) var(--ds-easing-glow);
}
.ds-glow-dots {
mask-image: radial-gradient(circle, var(--ds-color-white) 1px, transparent 2px), linear-gradient(transparent, var(--ds-color-black) var(--ds-glow-dot-fade)), radial-gradient(circle closest-side, var(--ds-color-black) 0%, transparent 75%);
mask-repeat: repeat, no-repeat, no-repeat;
mask-position: var(--ds-glow-dot-offset) var(--ds-glow-dot-offset), 0 0, 50% 50%;
mask-size: var(--ds-glow-dot-pitch) var(--ds-glow-dot-pitch), 100% 100%, 0 0;
}
.ds-glow-letters {
--glow-at: 50% calc(50% - 100cqi * var(--ds-glow-centre));
mask-image: var(--ds-glow-wordmark), radial-gradient(circle closest-side, var(--ds-color-black) 0%, transparent 75%);
mask-repeat: no-repeat;
mask-position: 0 0, 50% 50%;
mask-size: 100% 100%, 0 0;
}
@media (prefers-reduced-motion: reduce) {
.ds-glow-letters { mask-size: 100% 100%, calc(2 * var(--ds-footer-glow-radius)) calc(2 * var(--ds-footer-glow-radius)); transition: none; }
.ds-glow-dots { display: none; }
}
`
/** The wordmark as a mask image (the letters' shape). */
export function wordmarkMask(): string {
const w = LOGOS.wordmark
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${w.width} ${w.height}">${w.body}</svg>`
return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`
}// Joins class names, skipping falsy ones: cn('a', on && 'b', ['c', undefined]). It does not merge conflicting
// utilities (no tailwind-merge), as Vue's class binding does not: the library's classes are written not to compete,
// and a className from the caller is appended after them, as Vue appends a fallthrough class.
export type ClassValue = string | false | null | undefined | 0 | ClassValue[]
export function cn(...values: ClassValue[]): string {
const out: string[] = []
for (const v of values) {
if (!v) continue
if (Array.isArray(v)) {
const s = cn(...v)
if (s) out.push(s)
}
else out.push(v)
}
return out.join(' ')
}import { html, unsafeCSS } from 'lit'
import { unsafeSVG } from 'lit/directives/unsafe-svg.js'
import { DsElement, define } from '@/elements/lib/element'
import { LOGOS } from '@/lib/logos'
import { startWordmarkGlow } from '@/lib/effects/wordmark-glow'
import { GLOW_CSS, wordmarkMask } from '@/lib/effects/wordmark-glow-css'
import styles from 'virtual:tw'
// WordmarkGlow.tsx as <spyglass-wordmark-glow>: the big wordmark over a faint dot grid; a mouse lights the dots and the
// letters near it in the spectrum. Children go after the wordmark (the default slot). The host is the area: the page's
// classes size and pad it. Only for a fine pointer.
/**
* @summary The big wordmark whose dots and letters light up under the pointer.
* @slot - What follows the wordmark inside the area.
*/
export class WordmarkGlow extends DsElement {
static styles = [DsElement.styles, styles, unsafeCSS(GLOW_CSS)]
private stop: (() => void) | null = null
connectedCallback() {
super.connectedCallback()
if (this.hasUpdated && !this.stop) this.start()
}
disconnectedCallback() {
super.disconnectedCallback()
this.stop?.()
this.stop = null
}
private start() {
this.style.setProperty('--ds-glow-wordmark', wordmarkMask())
this.stop = startWordmarkGlow(this, this.renderRoot)
}
protected firstUpdated(changed: Map<PropertyKey, unknown>) {
super.firstUpdated(changed)
this.start()
}
render() {
const w = LOGOS.wordmark
return html`<span class="ds-glow-grid" aria-hidden="true"></span><span class="ds-glow-dots" data-glow-dots="" aria-hidden="true"></span><div class="relative w-full [container-type:inline-size]" data-glow-word="" aria-hidden="true" style=${`aspect-ratio: ${w.width} / ${w.height}`}><svg viewBox="0 0 ${w.width} ${w.height}" class="absolute inset-0 block size-full fill-wordmark-gray">${unsafeSVG(w.body)}</svg><span class="ds-glow-letters" data-glow-letters=""></span></div><slot></slot>`
}
}
define('wordmark-glow', WordmarkGlow)/* The host is the area, as WordmarkGlow.tsx's root: the page's classes size and pad it. */
:host {
position: relative;
isolation: isolate;
display: block;
}Reference: Site effect/WordmarkGlow (WordmarkGlow.tsx, WordmarkGlow.effect.module.css) and site/Footer/FooterWordmarkGlow: glow radius --footer-glow-radius 260px, centre 0.375 of the width above the word, dots --footer-dot-pitch 20px at white 0.1 fading in over 128px, strength 0.8, the spectrum swept every 90 degrees, masks easing over --dur-footer-glow 450ms on --ease-footer-glow.