Skip to content

Commit 08ed23a

Browse files
authored
Merge pull request #13961 from ethereum/migrateMatomoOptOut
Migrate MatomoOptOut to ShadCN
2 parents 219c230 + 73bf0a6 commit 08ed23a

File tree

1 file changed

+20
-31
lines changed

1 file changed

+20
-31
lines changed

src/components/MatomoOptOut.tsx

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { useEffect, useState } from "react"
2-
import { Checkbox, Flex } from "@chakra-ui/react"
3-
4-
import Text from "@/components/OldText"
52

63
import { MATOMO_LS_KEY } from "@/lib/utils/matomo"
74

5+
import Checkbox from "../../tailwind/ui/Checkbox"
6+
87
const MatomoOptOut = () => {
98
const [loading, setLoading] = useState<boolean>(true)
109
const [isOptedOut, setIsOptedOut] = useState<boolean>(false)
@@ -22,49 +21,39 @@ const MatomoOptOut = () => {
2221
setLoading(false)
2322
}, [])
2423

25-
const handleCheckbox = ({
26-
target: { checked },
27-
}: React.ChangeEvent<HTMLInputElement>): void => {
24+
const handleCheckbox = (checked: boolean): void => {
2825
// Set local opt-out state based on check mark
2926
// Note: `checked` in the UI refers to being opted-in
3027
setIsOptedOut(!checked)
3128
// Save selection to localStorage
3229
localStorage.setItem(MATOMO_LS_KEY, String(!checked))
3330
}
3431
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-
>
47-
<Text color="fail">
32+
<div className="mb-4 mt-8 flex flex-col rounded border border-body-light bg-background p-6">
33+
<p className="mb-5 text-error">
4834
You can opt out of being tracked by Matomo Analytics and prevent the
4935
website from analysing the actions you take using the website. This will
5036
prevent us from learning from your actions and creating a better website
5137
experience for you and other users.
52-
</Text>
38+
</p>
5339
{loading ? (
5440
"Loading preferences..."
5541
) : (
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>
42+
<div className="flex items-center">
43+
<Checkbox
44+
id="matomo"
45+
checked={!isOptedOut}
46+
onCheckedChange={handleCheckbox}
47+
className="me-2"
48+
/>
49+
<label htmlFor="matomo">
50+
{isOptedOut
51+
? "You are opted out. Check this box to opt-in."
52+
: "You are not opted out. Uncheck this box to opt-out."}
53+
</label>
54+
</div>
6655
)}
67-
</Flex>
56+
</div>
6857
)
6958
}
7059

0 commit comments

Comments
 (0)