File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ const ButtonPrint = ( ) => {
2+
3+ const handlePrint = ( ) => {
4+ window . print ( ) ;
5+ } ;
6+
7+ return (
8+ < button
9+ type = "button"
10+ onClick = { handlePrint } aria-label = "Imprimir"
11+ className = "group" >
12+ < span class = "text-nowrap inline-block py-2" >
13+ < small class = "text-base group-hover:underline" > imprimir</ small > < span class = "hidden lg:inline" > < kbd > cmd</ kbd > +< kbd > P</ kbd > </ span >
14+ </ span >
15+ </ button >
16+ ) ;
17+ } ;
18+
19+ export default ButtonPrint ;
Original file line number Diff line number Diff line change 1+ "use client" ;
2+ import { useEffect , useState } from "preact/hooks" ;
3+
4+ const DarkMode = ( ) => {
5+ const [ isDarkMode , setIsDarkMode ] = useState ( false ) ;
6+
7+ useEffect ( ( ) => {
8+ const savedTheme = localStorage . getItem ( "theme" ) ;
9+ const isDarkModeClient = savedTheme ? savedTheme === "dark" : window . matchMedia ( "(prefers-color-scheme: dark)" ) . matches ;
10+ if ( isDarkModeClient ) {
11+ setIsDarkMode ( true ) ;
12+ }
13+ } , [ ] ) ;
14+
15+ useEffect ( ( ) => {
16+ if ( isDarkMode ) {
17+ document . documentElement . classList . add ( "dark" ) ;
18+ localStorage . setItem ( "theme" , "dark" ) ;
19+ } else {
20+ document . documentElement . classList . remove ( "dark" ) ;
21+ localStorage . setItem ( "theme" , "light" ) ;
22+ }
23+ } , [ isDarkMode ] ) ;
24+
25+ const toggleDarkMode = ( ) => {
26+ setIsDarkMode ( ! isDarkMode ) ;
27+ } ;
28+
29+ return (
30+ < button
31+ onClick = { toggleDarkMode }
32+ className = "print:hidden"
33+ >
34+ { isDarkMode
35+ ? (
36+ < svg
37+ xmlns = "http://www.w3.org/2000/svg"
38+ width = "20"
39+ height = "20"
40+ fill = "none"
41+ viewBox = "0 0 24 24"
42+ stroke-width = "1.5"
43+ stroke = "currentColor"
44+ className = "w-6 h-6"
45+ >
46+ < path
47+ strokeLinecap = "round"
48+ strokeLinejoin = "round"
49+ d = "M12 3v1.5M12 19.5V21M4.219 4.219l1.061 1.061M18.719 18.719l1.061 1.061M3 12h1.5M19.5 12H21M4.219 19.781l1.061-1.061M18.719 5.281l1.061-1.061M12 7.5a4.5 4.5 0 100 9 4.5 4.5 0 000-9z"
50+ />
51+ </ svg >
52+ )
53+ : (
54+ < svg
55+ xmlns = "http://www.w3.org/2000/svg"
56+ width = "20"
57+ height = "20"
58+ viewBox = "0 0 24 24"
59+ fill = "none"
60+ stroke = "currentColor"
61+ stroke-width = "1.5"
62+ stroke-linecap = "round"
63+ stroke-linejoin = "round"
64+ className = "w-6 h-6"
65+ >
66+ < path d = "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z" > </ path >
67+ </ svg >
68+ ) }
69+ </ button >
70+ ) ;
71+ } ;
72+
73+ export default DarkMode ;
You can’t perform that action at this time.
0 commit comments