---
layout: null
permalink: '/assets/data/palettes.js'
eleventyExcludeFromCollections: true
---
import Color from 'https://colorjs.io/dist/color.js';

const palettes = {
{%- for palette in collections.palette | sort %}
{%- if not palette.data.unlisted %}
  {% set paletteId = palette.fileSlug -%}
  {%- set colors = palettes[paletteId] -%}
  '{{ paletteId }}': {
    id: '{{ paletteId }}',
    title: '{{ palette.data.title }}',
    colors: {
      {% for hue, tints in colors -%}
        '{{ hue }}': {
          {% for tint, value in tints -%}
            {%- if tint != '05' -%}
              '{{ '05' if tint == '5' else tint }}': '{{ value | safe }}',
            {%- endif %}
          {% endfor %}

          get key() {
            return this[this.maxChromaTint];
          }
        },
      {% endfor -%} // end colors
    }
  }, // end palette
{%- endif -%}
{% endfor %}
};

// Create Color instances for each color
for (let palette in palettes) {
  for (let hue in palettes[palette].colors) {
    let scale = palettes[palette].colors[hue];

    for (let tint in scale) {
      let color = scale[tint];
      try {
        if (Array.isArray(color)) {
          scale[tint] = new Color('oklch', color);
        }
        else if (typeof color === 'string' && isNaN(color)) {
          scale[tint] = new Color(color);
        }
      } catch (e) {
        console.error(e);
      }
    }
  }
}

export default palettes;
