Skip to content

Commit

Permalink
ensemble des modifications aportées à la page d'implémentation de la …
Browse files Browse the repository at this point in the history
…checkbox
  • Loading branch information
paullfhc committed Dec 17, 2024
1 parent 4f29a01 commit 3e5ca6e
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions ssr-testing/app/checkbox/page.tsx
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>
);
}
}

0 comments on commit 3e5ca6e

Please sign in to comment.