All files / packages/theme-selector/src appearance.ts

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

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 22                                      38x    
// SPDX-License-Identifier: MIT
/**
 * Theme appearance (light/dark) resolution for DOM attributes.
 */
 
import { THEME_APPEARANCES } from '@lgtm-hq/turbo-themes-core';
 
export type ThemeAppearance = 'light' | 'dark';
 
/**
 * Resolves light/dark appearance for a theme ID.
 *
 * Falls back to `'dark'` when the theme is unknown (e.g. custom themes without
 * an explicit mapping).
 */
export function resolveThemeAppearance(
  themeId: string,
  appearances: Readonly<Record<string, ThemeAppearance>> = THEME_APPEARANCES,
): ThemeAppearance {
  return appearances[themeId] ?? 'dark';
}