1
1
import { useEffect , useState } from "react"
2
- import { Checkbox , Flex } from "@chakra-ui/react"
3
-
4
- import Text from "@/components/OldText"
5
2
6
3
import { MATOMO_LS_KEY } from "@/lib/utils/matomo"
7
4
5
+ import Checkbox from "../../tailwind/ui/Checkbox"
6
+
8
7
const MatomoOptOut = ( ) => {
9
8
const [ loading , setLoading ] = useState < boolean > ( true )
10
9
const [ isOptedOut , setIsOptedOut ] = useState < boolean > ( false )
@@ -22,49 +21,39 @@ const MatomoOptOut = () => {
22
21
setLoading ( false )
23
22
} , [ ] )
24
23
25
- const handleCheckbox = ( {
26
- target : { checked } ,
27
- } : React . ChangeEvent < HTMLInputElement > ) : void => {
24
+ const handleCheckbox = ( checked : boolean ) : void => {
28
25
// Set local opt-out state based on check mark
29
26
// Note: `checked` in the UI refers to being opted-in
30
27
setIsOptedOut ( ! checked )
31
28
// Save selection to localStorage
32
29
localStorage . setItem ( MATOMO_LS_KEY , String ( ! checked ) )
33
30
}
34
31
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" >
48
34
You can opt out of being tracked by Matomo Analytics and prevent the
49
35
website from analysing the actions you take using the website. This will
50
36
prevent us from learning from your actions and creating a better website
51
37
experience for you and other users.
52
- </ Text >
38
+ </ p >
53
39
{ loading ? (
54
40
"Loading preferences..."
55
41
) : (
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 >
66
55
) }
67
- </ Flex >
56
+ </ div >
68
57
)
69
58
}
70
59
0 commit comments