Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

926 B
Raw Blame
import { brandColors, StatusColors } from '@activepieces/shared';

let saved: BrandSeed = { primaryColor: brandColors.defaultPrimaryColor() };
let preview: BrandSeed | null = null;

function apply(seed: BrandSeed) {
  saved = seed;
  write(preview ?? saved);
}

function setPreview(seed: BrandSeed) {
  preview = seed;
  write(preview);
}

function clearPreview() {
  preview = null;
  write(saved);
}

function write({ primaryColor, statusColors = {} }: BrandSeed) {
  const { style } = document.documentElement;
  brandColors.variableNames().forEach((name) => style.removeProperty(name));
  Object.entries({
    ...brandColors.cssVariables({ primaryColor }),
    ...brandColors.statusCssVariables({ statusColors }),
  }).forEach(([name, value]) => style.setProperty(name, value));
}

export const brandSeed = { apply, setPreview, clearPreview };

type BrandSeed = {
  primaryColor: string;
  statusColors?: StatusColors;
};