SonicFrame v1.3.2

Themes and palettes

A theme is a whole player in one word: the layout, the button, the drawing, the font and a palette. Any theme wears any of the eight palettes, and your own options always win.

Picking a theme

createPlayer({ container, src, theme: 'bubble' });
createPlayer({ container, src, theme: 'pulse', palette: 'ocean' });

See all 24 themes in 8 palettes

The themes: default (SonicFrame as it always looked; no theme, or an unknown name, gives this one), bubble, pill, blocky, card, minimal, terminal, pulse, scope, neon, glass, soft, brutal, studio, retro, dots, paper, bold, stream, led, smooth, compact, bubbly, mono and classic.

Palettes

light, dark, ocean, forest, sunset, berry, paper and contrast, each checked for readable text and visible controls (WCAG contrast). 'auto' follows the system's light or dark; 'default' sets no color at all, so your page's --sonicframe-* variables show.

A palette is set as custom properties on the player, so plain CSS can still change one color (which properties each color sets). Or give your own; a color you leave out comes from light:

createPlayer({
    container,
    src,
    palette: {
        surface: '#101820', // the background
        text: '#f2f5f9', // the time
        muted: '#9aa7b8', // labels, the ruler
        border: '#2a3442',
        wave: '#3b4a5e', // bars not yet played
        progress: '#3ee6c1', // bars played
        accent: '#3ee6c1', // the play button
        onAccent: '#08110f', // icons on the accent
        marker: '#ff7a59',
        region: 'rgba(62, 230, 193, 0.18)',
        dim: 'rgba(255, 255, 255, 0.08)',
    },
});

Themes of your own

Start from any theme and change what you need. Register it to use its name everywhere, the HTML tag included (built-in names cannot be replaced):

import { defineTheme, registerTheme } from 'sonicframe/player';

const quiet = defineTheme({ extends: 'bubble', palette: 'dark', look: { corner: 0 } });
createPlayer({ container, src, theme: quiet });

registerTheme('brand-note', { extends: 'pill', wave: { knob: 14 } });
// <sonic-player theme="brand-note" …>

Fonts

SonicFrame ships no font files. The stacks name fonts already on the device: system, rounded, mono, serif, humanist, geometric, industrial, slab and handwritten. This site's own font picker uses them.

To use another font, bring it:

createPlayer({
    container,
    src,
    font: { family: 'Brand Sans', src: '/fonts/brand.woff2', fallback: 'humanist' },
});

It loads once per page, with the system stack behind it. An address is used only when it is http(s) or a relative path; your Content-Security-Policy decides the rest.

Lists to build a picker

sonicframe/player gives every name it knows, frozen, so a settings screen can list the choices without copying them:

Name What it holds
THEME_NAMES, THEMES The built-in themes' names, and each theme by name.
findTheme(name) A built-in or registered theme by name, or null.
PALETTE_NAMES, PALETTES, DEFAULT_PALETTE The palettes' names, each palette's colors, and SonicFrame's own colors.
FONT_NAMES, FONT_STACKS The font stacks' names, and each stack.
PART_NAMES, DEFAULT_LOOK The parts a look can place, and the look a player starts from.
resolveLook(base, look) A look laid over another, checked as the player checks it.
BACKGROUND_EFFECTS The background's effects.
PLAYER_ATTRIBUTES, PLAYER_LABELS, LANGUAGE_NAMES The tag's attributes, the player's labels in each language, and the built-in languages.