All files / player-ui/src theme.ts

100% Statements 3/3
100% Branches 3/3
100% Functions 2/2
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21                  50x       1x         11x    
import type { CSSResultOrNative } from 'lit';
 
/**
 * Style sheets a theme adds to every Be-Music element's shadow root, after the element's own structural styles. The
 * elements ship headless: layout, scrolling and sizing only. Colour, borders, backgrounds and type come from a theme
 * (such as `@be-music/player-ui/themes/basecoat`), from inherited custom properties, and from `::part` rules outside.
 */
export type BeMusicTheme = readonly CSSResultOrNative[];
 
const THEMES = new WeakMap<object, BeMusicTheme>();
 
/** Sets the theme elements of `registry` take when they render for the first time; elements already shown keep theirs. */
export function setBeMusicTheme(registry: CustomElementRegistry, theme: BeMusicTheme): void {
  THEMES.set(registry, theme);
}
 
/** The theme set for `registry`, or none. */
export function resolveBeMusicTheme(registry: CustomElementRegistry | undefined): BeMusicTheme {
  return (registry && THEMES.get(registry)) ?? [];
}