Commit 0d3e249c authored by Ategon's avatar Ategon Committed by Grant
Browse files

Makes the palette ignore dark reader converting

parent 4d6b2177
Loading
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -151,6 +151,16 @@
    transition: scale 0.25s;
    cursor: pointer;

    .pallete-color-surface {
      position: absolute;
      z-index: 0;
      inset: 0;
      width: 100%;
      height: 100%;
      border-radius: 2px;
      pointer-events: none;
    }

    &:hover {
      scale: 1.075;
    }
+25 −3
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ import {
  type PointerEvent,
  useEffect,
  useMemo,
  useRef,
  useState,
} from "react";
import { createPortal } from "react-dom";
@@ -28,6 +29,29 @@ import {
  TEMPLATE_STYLE_ROWS,
} from "../../lib/template";

const PaletteColorSurface = ({ hex }: { hex: string }) => {
  const canvasRef = useRef<HTMLCanvasElement>(null);

  useEffect(() => {
    const context = canvasRef.current?.getContext("2d");
    if (!context) return;

    context.fillStyle = `#${hex}`;
    context.fillRect(0, 0, 1, 1);
  }, [hex]);

  return (
    <canvas
      ref={canvasRef}
      aria-hidden="true"
      className="pallete-color-surface"
      data-darkreader-ignore
      height={1}
      width={1}
    />
  );
};

const getPaletteSymbolBackgroundPosition = (index: number) => {
  const column = index % TEMPLATE_STYLE_COLUMNS;
  const row = Math.floor(index / TEMPLATE_STYLE_COLUMNS) % TEMPLATE_STYLE_ROWS;
@@ -598,9 +622,6 @@ export const Palette = () => {
                ]
                  .filter((a) => a)
                  .join(" ")}
                style={{
                  backgroundColor: "#" + color.hex,
                }}
                onClick={() => {
                  handleSelectPrimaryColor(color.id);
                }}
@@ -609,6 +630,7 @@ export const Palette = () => {
                  handleSelectSecondaryColor(color.id);
                }}
              >
                <PaletteColorSurface hex={color.hex} />
                {settings.get["palette.colors"] && (
                  <span aria-hidden="true" className="pallete-color-number">
                    {index}