Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

939 B
Raw Blame
import { PROMPT_FONT_SIZE_PROPERTY, PROMPT_FONT_SIZES, type PromptFontSize } from './scale';
import { DEFAULT_THEME, THEMES_BY_ID } from './themes';

/** Apply root theme attributes without persisting hints; transient previews must not overwrite saved appearance. */
export const applyThemeToRoot = (themeId: string): void => {
  const root = document.documentElement;
  const theme = THEMES_BY_ID[themeId as keyof typeof THEMES_BY_ID] ?? DEFAULT_THEME;

  root.dataset.theme = theme.id;
  root.style.colorScheme = theme.colorScheme;
  // Keep native color-mode classes aligned for browser chrome and unoverridden Chakra defaults.
  root.classList.toggle('dark', theme.colorScheme === 'dark');
  root.classList.toggle('light', theme.colorScheme === 'light');
};

export const applyPromptFontSizeToRoot = (size: PromptFontSize): void => {
  document.documentElement.style.setProperty(PROMPT_FONT_SIZE_PROPERTY, PROMPT_FONT_SIZES[size]);
};