-
Notifications
You must be signed in to change notification settings - Fork 852
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ensemble des modifications aportées à la page d'implémentation de la …
…checkbox
- Loading branch information
Showing
1 changed file
with
32 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,38 @@ | ||
'use client'; | ||
|
||
import * as React from 'react'; | ||
import * as Checkbox from '@radix-ui/react-checkbox'; | ||
|
||
export default function Page() { | ||
// État pour le div | ||
const [isDivChecked, setIsDivChecked] = React.useState(false); | ||
|
||
// État pour la case à cocher | ||
const [isCheckboxChecked, setIsCheckboxChecked] = React.useState(false); | ||
|
||
// Fonction pour alterner l’état du div | ||
const handleDivClick = () => { | ||
console.log('Div clicked:', !isDivChecked); | ||
setIsDivChecked((prev) => !prev); | ||
}; | ||
|
||
// Fonction pour alterner l’état de la checkbox | ||
const handleCheckedChange = (newChecked: boolean) => { | ||
console.log('Checkbox checked:', newChecked); | ||
setIsCheckboxChecked(newChecked); | ||
}; | ||
|
||
return ( | ||
<Checkbox.Root> | ||
[ <Checkbox.Indicator>✔</Checkbox.Indicator> ] | ||
</Checkbox.Root> | ||
<form> | ||
<div onClick={handleDivClick}> {/* Alterne l’état du div */} | ||
<Checkbox.Root | ||
checked={isCheckboxChecked} | ||
onCheckedChange={handleCheckedChange} // Alterne l’état de la checkbox | ||
> | ||
[ <Checkbox.Indicator>✔</Checkbox.Indicator> ] | ||
</Checkbox.Root> | ||
<span>test</span> | ||
</div> | ||
</form> | ||
); | ||
} | ||
} |