@@ -2,6 +2,7 @@ import { THEME, THEME_LOCAL_STORAGE_KEY } from '../constants/theme';
2
2
import PropTypes from 'prop-types' ;
3
3
import { useLocalStorage } from 'react-use' ;
4
4
import { useEffect } from 'react' ;
5
+ import Tooltip from './Tooltip/Tooltip' ;
5
6
6
7
const { DARK , LIGHT } = THEME ;
7
8
@@ -35,41 +36,47 @@ export default function HelloDarkness() {
35
36
} ;
36
37
const themeSwitcher = ( ) => switchTheme ( theme === DARK ? LIGHT : DARK ) ;
37
38
return (
38
- < button
39
- aria-label = {
39
+ < Tooltip
40
+ content = {
40
41
theme === DARK ? 'Switch to light theme' : 'Switch to dark theme'
41
42
}
42
- className = "bg-transparent border-none cursor-pointer text-[16px] p-0 inline-flex items-center text-gray-100 hover:text-blue-200 transition-colors duration-200"
43
- onClick = { themeSwitcher }
44
- data-testid = "hello-darkness"
45
43
>
46
- { theme === DARK ? (
47
- < span className = "inline-flex items-center justify-center" >
44
+ < button
45
+ aria-label = {
46
+ theme === DARK ? 'Switch to light theme' : 'Switch to dark theme'
47
+ }
48
+ className = "bg-transparent border-none cursor-pointer text-[16px] p-0 inline-flex items-center text-gray-100 hover:text-blue-200 transition-colors duration-200"
49
+ onClick = { themeSwitcher }
50
+ data-testid = "hello-darkness"
51
+ >
52
+ { theme === DARK ? (
53
+ < span className = "inline-flex items-center justify-center" >
54
+ < svg
55
+ width = "16"
56
+ height = "16"
57
+ viewBox = "0 0 24 24"
58
+ xmlns = "http://www.w3.org/2000/svg"
59
+ >
60
+ < path
61
+ d = "M20.742 13.045a8.086 8.086 0 0 1-2.077.271c-2.135 0-4.14-.83-5.646-2.336a8.026 8.026 0 0 1-2.064-7.723A1 1 0 0 0 9.73 2.034a10.014 10.014 0 0 0-4.489 2.582c-3.898 3.898-3.898 10.243 0 14.143a9.936 9.936 0 0 0 7.072 2.93 9.93 9.93 0 0 0 7.07-2.929 10.007 10.007 0 0 0 2.583-4.491 1 1 0 0 0-1.224-1.224Zm-2.772 4.301a7.947 7.947 0 0 1-5.656 2.343 7.952 7.952 0 0 1-5.658-2.344c-3.118-3.119-3.118-8.195 0-11.314a7.923 7.923 0 0 1 2.06-1.483 10.027 10.027 0 0 0 2.89 7.848 9.973 9.973 0 0 0 7.848 2.891 8.037 8.037 0 0 1-1.484 2.059Z"
62
+ fill = "currentColor"
63
+ />
64
+ </ svg >
65
+ </ span >
66
+ ) : (
48
67
< svg
49
68
width = "16"
50
69
height = "16"
51
70
viewBox = "0 0 24 24"
52
71
xmlns = "http://www.w3.org/2000/svg"
53
72
>
54
73
< path
55
- d = "M20.742 13.045a8.086 8.086 0 0 1 -2.077.271c-2.135 0-4.14-.83-5.646-2.336a8.026 8.026 0 0 1-2.064-7.723A1 1 0 0 0 9.73 2.034a10.014 10.014 0 0 0-4.489 2.582c-3.898 3.898-3.898 10.243 0 14.143a9.936 9.936 0 0 0 7.072 2.93 9.93 9.93 0 0 0 7.07-2.929 10.007 10.007 0 0 0 2.583-4.491 1 1 0 0 0-1.224 -1.224Zm-2.772 4.301a7.947 7.947 0 0 1-5.656 2.343 7.952 7.952 0 0 1-5.658-2.344c-3.118-3.119-3.118-8.195 0-11.314a7.923 7.923 0 0 1 2.06-1.483 10.027 10.027 0 0 0 2.89 7.848 9.973 9.973 0 0 0 7.848 2.891 8.037 8.037 0 0 1-1.484 2.059Z "
74
+ d = "M12 18.14a.722.722 0 0 0-.722.722v2.166a.722.722 0 0 0 1.444 0v -2.166a.722.722 0 0 0-.722-.721ZM12 2.25a.722.722 0 0 0-.722.722v2.166a.722.722 0 0 0 1.444 0V2.972A.722.722 0 0 0 12 2.25ZM5.86 12a.722.722 0 0 0-.723-.722H2.972a.722.722 0 0 0 0 1.444h2.165A.722.722 0 0 0 5.86 12ZM21.028 11.278h-2.165a.722.722 0 0 0 0 1.444h2.165a.722.722 0 0 0 0-1.444ZM7.148 16.13a.72.72 0 0 0-.51.21l-1.533 1.534a.72.72 0 1 0 1.022 1.022l1.532 -1.533a.724.724 0 0 0-.51-1.233ZM16.852 7.87a.72.72 0 0 0 .51-.21l1.533-1.533a.72.72 0 0 0 .211-.511.72.72 0 0 0-.722-.722.72.72 0 0 0-.51.21L16.34 6.639a.72.72 0 0 0-.211.51.72.72 0 0 0 .722.722ZM6.127 5.105a.72.72 0 0 0-.511-.211.72.72 0 0 0-.722.722.72.72 0 0 0 .21.51L6.638 7.66a.72.72 0 0 0 .511.211.72.72 0 0 0 .722-.722.72.72 0 0 0-.21-.51L6.126 5.105ZM17.363 16.34a.72.72 0 1 0-1.022 1.022l1.532 1.533a.72.72 0 0 0 1.022 0 .72.72 0 0 0 0-1.021l-1.532-1.533ZM12 7.5c-2.48 0-4.5 2.02-4.5 4.5s2.02 4.5 4.5 4.5 4.5-2.02 4.5-4.5-2.02-4.5-4.5-4.5Z "
56
75
fill = "currentColor"
57
76
/>
58
77
</ svg >
59
- </ span >
60
- ) : (
61
- < svg
62
- width = "16"
63
- height = "16"
64
- viewBox = "0 0 24 24"
65
- xmlns = "http://www.w3.org/2000/svg"
66
- >
67
- < path
68
- d = "M12 18.14a.722.722 0 0 0-.722.722v2.166a.722.722 0 0 0 1.444 0v-2.166a.722.722 0 0 0-.722-.721ZM12 2.25a.722.722 0 0 0-.722.722v2.166a.722.722 0 0 0 1.444 0V2.972A.722.722 0 0 0 12 2.25ZM5.86 12a.722.722 0 0 0-.723-.722H2.972a.722.722 0 0 0 0 1.444h2.165A.722.722 0 0 0 5.86 12ZM21.028 11.278h-2.165a.722.722 0 0 0 0 1.444h2.165a.722.722 0 0 0 0-1.444ZM7.148 16.13a.72.72 0 0 0-.51.21l-1.533 1.534a.72.72 0 1 0 1.022 1.022l1.532-1.533a.724.724 0 0 0-.51-1.233ZM16.852 7.87a.72.72 0 0 0 .51-.21l1.533-1.533a.72.72 0 0 0 .211-.511.72.72 0 0 0-.722-.722.72.72 0 0 0-.51.21L16.34 6.639a.72.72 0 0 0-.211.51.72.72 0 0 0 .722.722ZM6.127 5.105a.72.72 0 0 0-.511-.211.72.72 0 0 0-.722.722.72.72 0 0 0 .21.51L6.638 7.66a.72.72 0 0 0 .511.211.72.72 0 0 0 .722-.722.72.72 0 0 0-.21-.51L6.126 5.105ZM17.363 16.34a.72.72 0 1 0-1.022 1.022l1.532 1.533a.72.72 0 0 0 1.022 0 .72.72 0 0 0 0-1.021l-1.532-1.533ZM12 7.5c-2.48 0-4.5 2.02-4.5 4.5s2.02 4.5 4.5 4.5 4.5-2.02 4.5-4.5-2.02-4.5-4.5-4.5Z"
69
- fill = "currentColor"
70
- />
71
- </ svg >
72
- ) }
73
- </ button >
78
+ ) }
79
+ </ button >
80
+ </ Tooltip >
74
81
) ;
75
82
}
0 commit comments