File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
website/app/components/navbar Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { useSearchParams } from "@remix-run/react";
3
3
import { Input } from "@/ui/input" ;
4
4
import { Slider } from "@/ui/slider" ;
5
5
import { iconSizeParamKey , searchParamKey } from "@/data/searchParams" ;
6
+ import { useEffect , useState } from "react" ;
6
7
7
8
interface iSearchProps {
8
9
className ?: string ;
@@ -40,7 +41,9 @@ export const Search = (props: iSearchProps) => {
40
41
// 📏 Icon Size Slider:
41
42
export const IconSize = ( ) => {
42
43
const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
43
- const iconSizeValue = searchParams . get ( iconSizeParamKey ) || 45 ;
44
+ const [ iconSizeValue , setIconSizeValue ] = useState (
45
+ Number ( searchParams . get ( iconSizeParamKey ) ) || 45 ,
46
+ ) ;
44
47
45
48
const handleChange = ( value : number [ ] ) => {
46
49
const newSearchParams = new URLSearchParams ( searchParams ) ;
@@ -52,11 +55,15 @@ export const IconSize = () => {
52
55
setSearchParams ( newSearchParams ) ;
53
56
} ;
54
57
58
+ useEffect ( ( ) => {
59
+ handleChange ( [ iconSizeValue ] ) ;
60
+ } , [ iconSizeValue ] ) ;
61
+
55
62
return (
56
63
< Slider
57
64
title = "Icon Size"
58
- defaultValue = { [ Number ( iconSizeValue ) ] }
59
- onValueChange = { ( value ) => handleChange ( value ) }
65
+ value = { [ Number ( iconSizeValue ) ] }
66
+ onValueChange = { ( value ) => setIconSizeValue ( value [ 0 ] ) }
60
67
max = { 70 }
61
68
min = { 20 }
62
69
step = { 1 }
You can’t perform that action at this time.
0 commit comments