-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(modrinth): selecting filters auto updates mods
- Loading branch information
Showing
8 changed files
with
97 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import * as React from 'react'; | ||
|
||
import { cn } from '@/lib/utils'; | ||
|
||
const Checkbox = React.forwardRef< | ||
React.ElementRef<'div'>, | ||
React.ComponentPropsWithoutRef<'div'> & { label?: string; onChange?: () => void } | ||
>(({ className, label, onChange, ...props }, ref) => { | ||
const [checked, setChecked] = React.useState(false); | ||
|
||
const toggleChecked = () => { | ||
setChecked((prev) => { | ||
const newCheckedState = !prev; | ||
if (onChange) onChange(); // Call the onChange handler when the checkbox is toggled | ||
return newCheckedState; | ||
}); | ||
}; | ||
|
||
return ( | ||
<div className='flex items-center gap-2 select-none'> | ||
{label && ( | ||
<span onClick={toggleChecked}> | ||
<span | ||
onClick={toggleChecked} | ||
className={cn( | ||
'inline-block rounded-lg w-full px-2 py-1 cursor-pointer transition-colors duration-200', | ||
checked | ||
? 'bg-green-800 text-white mb-2 select-none' | ||
: 'border-transparent hover:bg-gray-700 mb-2 select-none', | ||
)} | ||
{...props} | ||
ref={ref} | ||
> | ||
{label} | ||
</span> | ||
</span> | ||
)} | ||
</div> | ||
); | ||
}); | ||
|
||
Checkbox.displayName = 'Checkbox'; | ||
|
||
export { Checkbox }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters