Skip to content

Commit 121920a

Browse files
committed
Migrate MatomoOptOut to ShadCN
1 parent 219c230 commit 121920a

File tree

1 file changed

+18
-27
lines changed

1 file changed

+18
-27
lines changed

src/components/MatomoOptOut.tsx

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { useEffect, useState } from "react"
2-
import { Checkbox, Flex } from "@chakra-ui/react"
32

43
import Text from "@/components/OldText"
54

65
import { MATOMO_LS_KEY } from "@/lib/utils/matomo"
76

7+
import Checkbox from "../../tailwind/ui/Checkbox"
8+
89
const MatomoOptOut = () => {
910
const [loading, setLoading] = useState<boolean>(true)
1011
const [isOptedOut, setIsOptedOut] = useState<boolean>(false)
@@ -22,28 +23,15 @@ const MatomoOptOut = () => {
2223
setLoading(false)
2324
}, [])
2425

25-
const handleCheckbox = ({
26-
target: { checked },
27-
}: React.ChangeEvent<HTMLInputElement>): void => {
26+
const handleCheckbox = (checked: boolean): void => {
2827
// Set local opt-out state based on check mark
2928
// Note: `checked` in the UI refers to being opted-in
3029
setIsOptedOut(!checked)
3130
// Save selection to localStorage
3231
localStorage.setItem(MATOMO_LS_KEY, String(!checked))
3332
}
3433
return (
35-
<Flex
36-
border="1px solid"
37-
borderColor="border"
38-
bgColor="background.base"
39-
borderRadius="base"
40-
p={6}
41-
direction="column"
42-
mb={4}
43-
mt={8}
44-
align="flex-start"
45-
justify="space-between"
46-
>
34+
<div className="mb-4 mt-8 flex flex-col rounded border border-body-light bg-background p-6">
4735
<Text color="fail">
4836
You can opt out of being tracked by Matomo Analytics and prevent the
4937
website from analysing the actions you take using the website. This will
@@ -53,18 +41,21 @@ const MatomoOptOut = () => {
5341
{loading ? (
5442
"Loading preferences..."
5543
) : (
56-
<Checkbox
57-
id="matomo"
58-
isChecked={!isOptedOut}
59-
onChange={handleCheckbox}
60-
me={2}
61-
>
62-
{isOptedOut
63-
? "You are opted out. Check this box to opt-in."
64-
: "You are not opted out. Uncheck this box to opt-out."}
65-
</Checkbox>
44+
<div className="flex items-center">
45+
<Checkbox
46+
id="matomo"
47+
checked={!isOptedOut}
48+
onCheckedChange={handleCheckbox}
49+
className="me-2"
50+
/>
51+
<label htmlFor="matomo">
52+
{isOptedOut
53+
? "You are opted out. Check this box to opt-in."
54+
: "You are not opted out. Uncheck this box to opt-out."}
55+
</label>
56+
</div>
6657
)}
67-
</Flex>
58+
</div>
6859
)
6960
}
7061

0 commit comments

Comments
 (0)