Type Alias Palette

Palette: {
    add(key: string, value: string): void;
    alias(from: string, to: string): void;
    get(key: string, fallback?: string): string;
    getOrAdd(key: string, fallback?: string): string;
    has(key: string): boolean;
    setElementBase(el: Element): void;
}

Manage a set of colours. Uses CSS variables as a fallback if colour is not added

Type declaration

  • add:function
    • Adds a colour with a given key

      Parameters

      • key: string
      • value: string

      Returns void

  • alias:function
    • Parameters

      • from: string
      • to: string

      Returns void

  • get:function
    • Returns a colour by name.

      If the colour is not found:

      1. Try to use a CSS variable --key, or
      2. The next fallback colour is used (array cycles)

      Parameters

      • key: string
      • Optionalfallback: string

      Returns string

  • getOrAdd:function
    • Gets a colour by key, adding and returning fallback if not present

      Parameters

      • key: string

        Key of colour

      • Optionalfallback: string

        Fallback colour if key is not found

      Returns string

  • has:function
    • Parameters

      • key: string

      Returns boolean

  • setElementBase:function
    • Parameters

      • el: Element

      Returns void