diff --git a/src/components/component/playground.jsx b/src/components/component/playground.jsx index 50169b9..fd41436 100644 --- a/src/components/component/playground.jsx +++ b/src/components/component/playground.jsx @@ -19,9 +19,9 @@ export function Playground() { const [defaultHue, setDefaultHue] = useState(0); - const [defaultSaturation, setDefaultSaturation] = useState(100); + const [defaultSaturation, setDefaultSaturation] = useState(85); - const [defaultBrightness, setDefaultBrightness] = useState(100); + const [defaultBrightness, setDefaultBrightness] = useState(65); const [rValue, setRValue] = useState(255); @@ -31,7 +31,7 @@ export function Playground() { const [hexValue, setHexValue] = useState("#FF0000"); - + const [sliderMode, setSliderMode] = useState("hsl"); const rgbToHex = (r, g, b) => { return `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)}`; @@ -41,6 +41,15 @@ export function Playground() { localStorage.removeItem('uploadedImage'); }, []); + useEffect(() => { + const rgb = hslToRgb(defaultHue, defaultSaturation, defaultBrightness); + setRValue(rgb.r); + setGValue(rgb.g); + setBValue(rgb.b); + + setHexValue(rgbToHex(rgb.r, rgb.g, rgb.b)); + }, []); + useEffect(() => { const storedImage = localStorage.getItem('uploadedImage'); if (storedImage) { @@ -324,32 +333,61 @@ export function Playground() { -
-
-
Hue
- hvalueChanged(value)} - /> -
{defaultHue}°
-
-
-
Saturation
- svalueChanged(value)} - /> -
{defaultSaturation}%
-
-
-
Lightness
- _lvalueChanged(value)} - /> -
{defaultBrightness}%
-
-
+ {sliderMode === "hsl" ? ( +
+ +
+
Hue
+ hvalueChanged(value)} + /> +
{defaultHue}°
+
+
+
Saturation
+ svalueChanged(value)} + /> +
{defaultSaturation}%
+
+
+
Lightness
+ _lvalueChanged(value)} + /> +
{defaultBrightness}%
+
+
) : sliderMode === "rgb" ? ( +
+ +
+
Red
+ hvalueChanged(value)} + /> +
{defaultHue}°
+
+
+
Green
+ svalueChanged(value)} + /> +
{defaultSaturation}%
+
+
+
Blue
+ _lvalueChanged(value)} + /> +
{defaultBrightness}%
+
+
) : null}
@@ -367,7 +405,9 @@ export function Playground() { - @@ -393,7 +433,9 @@ export function Playground() { - diff --git a/tailwind.config.js b/tailwind.config.js index 0a5fa43..c203678 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -66,10 +66,15 @@ module.exports = { from: { height: "var(--radix-accordion-content-height)" }, to: { height: "0" }, }, + fadeInLeft: { + '0%': { opacity: '0', transform: 'translateX(-10px)' }, + '100%': { opacity: '1', transform: 'translateX(0)' }, + }, }, animation: { "accordion-down": "accordion-down 0.2s ease-out", "accordion-up": "accordion-up 0.2s ease-out", + fadeInLeft: 'fadeInLeft 0.5s ease-in-out', }, }, },