import { writable } from "svelte/store";

// function to turn css rgb() strings to hex
export function rgbToHex(rgb: string) {
  let hex = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
  if (!hex) return rgb;
  return (
    "#" +
    hex
      .slice(1)
      .map((x) => {
        return ("0" + parseInt(x).toString(16)).slice(-2);
      })
      .join("")
  );
}

export const colors = writable({
  background: "#f0f0f0",
});
