Skip to content

Commit b59b2b6

Browse files
v1.3.1
1 parent 81f1adf commit b59b2b6

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "shadcn-theme-editor",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Shadcn Theme Editor",
55
"main": "dist/index.js",
66
"module": "dist/index.mjs",

src/components/item.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ThemeWithHSLColor } from "../lib/theme";
2-
import React, { useEffect, useState } from "react";
2+
import React, { useCallback, useEffect, useState } from "react";
33
import { Button } from "./ui/button";
44
import { copy2clipboard, HSL2ComputedColor, setStyleColor } from "../lib/utils";
55
import { useDebounceCallback } from "../hooks/useDebounceCallback";
@@ -17,10 +17,13 @@ export function Item({
1717
useEffect(() => {
1818
setColor(colord(theme.color).toHex());
1919
}, [theme]);
20-
const updateValue = useDebounceCallback(() => {
21-
setStyleColor(theme.variable, colord(color).toHsl());
22-
onSave();
23-
}, 0);
20+
const updateValue = useCallback(
21+
useDebounceCallback((color: string) => {
22+
setStyleColor(theme.variable, colord(color).toHsl());
23+
onSave();
24+
}, 0),
25+
[theme.variable]
26+
);
2427
return (
2528
<Button
2629
variant={"colorbtn"}
@@ -39,7 +42,9 @@ export function Item({
3942
// defaultValue={colord(color).toHex()}
4043
value={color}
4144
type="color"
42-
onChange={(e) => (setColor(e.target.value), updateValue())}
45+
onChange={(e) => (
46+
setColor(e.target.value), updateValue(e.target.value)
47+
)}
4348
className="absolute cursor-pointer inset-1/2 size-[calc(100%+12px)] -translate-x-1/2 -translate-y-1/2 flex-shrink-0 bg-transparent"
4449
/>
4550
</div>

0 commit comments

Comments
 (0)