"use client"; import { hsvaToHslString } from "@noya-app/noya-color"; import { clamp, round } from "@noya-app/noya-utils"; import React, { memo } from "react"; import { useColorPicker } from "../contexts/ColorPickerContext"; import { Interaction, Interactive } from "./Interactive"; import Pointer from "./Pointer"; interface ContainerProps { backgroundColor: string; children: React.ReactNode; } const Container: React.FC = ({ backgroundColor, children }) => (
{children}
); export default memo(function SaturationBase() { const [hsva, onChange] = useColorPicker(); const color = hsvaToHslString(hsva); const backgroundColor = hsvaToHslString({ h: hsva.h, s: 100, v: 100, a: 1 }); const handleMove = (interaction: Interaction) => { onChange({ s: interaction.left * 100, v: 100 - interaction.top * 100, }); }; const handleKey = (offset?: Interaction) => { // Saturation and brightness always fit into [0, 100] range if (!offset) return; onChange({ s: clamp(hsva.s + offset.left * 100, 0, 100), v: clamp(hsva.v - offset.top * 100, 0, 100), }); }; return ( ); });