4
4
< meta name ="viewport " content ="width=device-width, initial-scale=1 ">
5
5
< link rel ="stylesheet " href ="{{ url_for('static', filename='main.css') }} ">
6
6
< script src ="https://cdn.tailwindcss.com "> </ script >
7
- < script >
8
- var element = document . getElementById ( "html" ) ;
9
- function setPageTheme ( ) {
10
- if ( localStorage . theme === 'dark' || ( ! ( 'theme' in localStorage ) && window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches ) ) {
11
- element . classList . add ( 'dark' )
12
- } else {
13
- element . classList . remove ( 'dark' )
14
- }
15
- }
16
-
17
- function toggleDarkMode ( ) {
18
- if ( 'theme' in localStorage && localStorage . theme === 'light' ) {
19
- localStorage . theme = 'dark'
20
- setPageTheme ( ) ;
21
- } else {
22
- localStorage . theme = 'light'
23
- setPageTheme ( ) ;
24
- }
25
- }
26
-
27
- setPageTheme ( ) ;
28
- </ script >
7
+
29
8
< script >
30
9
tailwind . config = {
31
10
darkMode : 'class' ,
57
36
< h1 class ="text-3xl xs:text-4xl sm:text-5xl "> {% block heading %}{% endblock %}</ h1 >
58
37
< p class ="text-lg xs:text-xl sm:text-2xl "> Session Open Group Server</ p >
59
38
</ div >
60
- < button class ='h-12 px-1 bg-black text-white rounded ' onclick ="toggleDarkMode() "> Dark< br > Mode</ button >
39
+ < button id ="moonIcon " class ='px-1 rounded ' onclick ="toggleDarkMode() "> < img src ="{{ url_for('static', filename='moon-d-50-min.png') }} " alt ="moon "> </ button >
40
+ < button id ="sunIcon " style ="display: none; " class ='px-1 rounded ' onclick ="toggleDarkMode() "> < img src ="{{ url_for('static', filename='sun-w-50-min.png') }} " alt ="sun "> </ button >
61
41
</ div >
62
42
63
43
<!-- content/body -->
@@ -66,4 +46,34 @@ <h1 class="text-3xl xs:text-4xl sm:text-5xl">{% block heading %}{% endblock %}</
66
46
{% endblock %}
67
47
</ section >
68
48
</ body >
49
+ <!-- dark mode toggle js -->
50
+ < script >
51
+ var htmlElement = document . getElementById ( "html" ) ;
52
+ var moonIcon = document . getElementById ( "moonIcon" ) ;
53
+ var sunIcon = document . getElementById ( "sunIcon" ) ;
54
+
55
+ function setPageTheme ( ) {
56
+ if ( localStorage . theme === 'dark' || ( ! ( 'theme' in localStorage ) && window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches ) ) {
57
+ htmlElement . classList . add ( 'dark' )
58
+ sunIcon . style . display = 'block'
59
+ moonIcon . style . display = 'none'
60
+ } else {
61
+ htmlElement . classList . remove ( 'dark' )
62
+ sunIcon . style . display = 'none'
63
+ moonIcon . style . display = 'block'
64
+ }
65
+ }
66
+
67
+ function toggleDarkMode ( ) {
68
+ if ( 'theme' in localStorage && localStorage . theme === 'light' ) {
69
+ localStorage . theme = 'dark'
70
+ setPageTheme ( ) ;
71
+ } else {
72
+ localStorage . theme = 'light'
73
+ setPageTheme ( ) ;
74
+ }
75
+ }
76
+
77
+ setPageTheme ( ) ;
78
+ </ script >
69
79
</ html >
0 commit comments