File tree Expand file tree Collapse file tree 5 files changed +96
-17
lines changed
Expand file tree Collapse file tree 5 files changed +96
-17
lines changed Original file line number Diff line number Diff line change 33 < div class ="Header-logo ">
44 < a href ="{{ site.github.url }}/ "> {{ site.data.settings.title }}</ a >
55 </ div >
6+
67 < nav class ="Header-nav ">
78 {% for item in site.data.settings.menu %}
89 {% if item.external %}
9- < a href ="{{ item.url }} " target ="_blank " rel ="noopener nofollow ">
10+ < a href ="{{ item.url }} " target ="_blank " rel ="noopener nofollow ">
1011 {{ item.name }}
11- </ a >
12+ </ a >
1213 {% else %}
1314 < a href ="{{ site.github.url }}{{ item.url }} "> {{ item.name }}</ a >
1415 {% endif %}
1516 {% endfor %}
17+
18+ <!-- 🌙☀️ Theme Toggle Button -->
19+ < button id ="theme-toggle " class ="theme-toggle " aria-label ="Toggle theme ">
20+ 🌙
21+ </ button >
1622 </ nav >
1723 </ div >
24+
1825 < div class ="Header-border ">
1926 ==============================================================================================================================================================
2027 </ div >
Original file line number Diff line number Diff line change 1313
1414 {% include footer.html %}
1515
16- < div >
16+ </ div >
17+
18+ <!-- ✅ Load theme toggle script -->
19+ < script src ="{{ '/assets/js/script.js' | relative_url }} "> </ script >
1720
1821</ body >
1922
20- </ html >
23+ </ html >
Original file line number Diff line number Diff line change 1+ $background-light : #ffffff ;
2+ $font-light : #000000 ;
3+ $primary-color-light : #ff7f00 ;
4+
5+ $background-dark : #000000 ;
6+ $font-dark : #ffffff ;
7+ $primary-color-dark : #ff7f00 ;
8+
9+
110html , body {
211 font-family : $body-font ;
312 font-size : 16px ;
413 line-height : 1.5 ;
514 background-color : $background-color ;
615 color : $font-color ;
716
17+ transition : background-color 0.4s ease , color 0.4s ease ;
18+
819 @media (max-width : $large-screen ) {
920 font-size : 14px ;
1021 }
@@ -18,21 +29,41 @@ html, body {
1829 }
1930}
2031
21- .Site {
22- max-width : 880 px ;
23- margin : 0 auto ;
24- padding : 2 rem ;
32+
33+ body {
34+ background-color : $background-light ;
35+ color : $font-light ;
2536}
2637
2738a {
28- color : $primary-color ;
39+ color : $primary-color-light ;
2940 text-decoration : none ;
41+ transition : color 0.3s ease ;
3042
3143 & :hover {
32- color : rgba ($primary-color , 0.8 );
44+ color : lighten ($primary-color-light , 10 % );
3345 }
3446}
3547
48+ body .dark-mode {
49+ background-color : $background-dark ;
50+ color : $font-dark ;
51+ }
52+
53+ body .dark-mode a {
54+ color : $primary-color-dark ;
55+
56+ & :hover {
57+ color : lighten ($primary-color-dark , 10% );
58+ }
59+ }
60+
61+ .Site {
62+ max-width : 880px ;
63+ margin : 0 auto ;
64+ padding : 2rem ;
65+ }
66+
3667p {
3768 margin-bottom : 1rem ;
3869}
6798 font-size : 1.2rem ;
6899 margin-top : 0.5rem ;
69100 margin-bottom : 0.5rem ;
70- }
101+ }
Original file line number Diff line number Diff line change 66 margin-top : 0.4rem ;
77 overflow : hidden ;
88 user-select : none ;
9- color : $font-color ; // makes the divider white-ish
9+ color : $font-color ;
1010 }
1111
1212 & -inner {
13- display : flex ;
13+ display : flex ;
1414 justify-content : space-between ;
1515 align-items : center ;
1616 padding : 1rem 0 ;
1717 }
1818
1919 & -logo {
2020 font-size : 2.2rem ;
21- color : $font-color ; // Make sure logo is visible too
21+ color : $font-color ;
2222
2323 @media (max-width : $small-screen ) {
2424 font-size : 1.8rem ;
2525 }
2626 }
2727
28+ .theme-toggle {
29+ background : none ;
30+ border : 1px solid $primary-color-dark ;
31+ color : $primary-color-dark ;
32+ border-radius : 8px ;
33+ padding : 0.4rem 0.8rem ;
34+ cursor : pointer ;
35+ margin-left : 1.5rem ;
36+ font-size : 1.1rem ;
37+ transition : background 0.2s ease , color 0.2s ease ;
38+
39+ & :hover {
40+ background : $primary-color-dark ;
41+ color : #000 ;
42+ }
43+ }
44+
45+
2846 & -nav {
2947 display : flex ;
3048 font-size : 1.3rem ;
3452 }
3553
3654 a {
37- color : $primary-color ; // bright orange
38- opacity : 1 ; // fully visible
55+ color : $primary-color ;
56+ opacity : 1 ;
3957 margin-left : 1.5rem ;
4058 text-decoration : none ;
4159 font-weight : 500 ;
Original file line number Diff line number Diff line change 1- // Place JS here
1+ // script.js
2+ document . addEventListener ( "DOMContentLoaded" , ( ) => {
3+ const toggleButton = document . getElementById ( "theme-toggle" ) ;
4+ const body = document . body ;
5+
6+ const savedTheme = localStorage . getItem ( "theme" ) ;
7+ if ( savedTheme === "dark" ) {
8+ body . classList . add ( "dark-mode" ) ;
9+ toggleButton . textContent = "☀️" ; // show sun icon for dark mode
10+ } else {
11+ body . classList . remove ( "dark-mode" ) ;
12+ toggleButton . textContent = "🌙" ; // show moon icon for light mode
13+ }
14+
15+ // Toggle between light and dark mode
16+ toggleButton . addEventListener ( "click" , ( ) => {
17+ const isDarkMode = body . classList . toggle ( "dark-mode" ) ;
18+ localStorage . setItem ( "theme" , isDarkMode ? "dark" : "light" ) ;
19+ toggleButton . textContent = isDarkMode ? "☀️" : "🌙" ;
20+ } ) ;
21+ } ) ;
You can’t perform that action at this time.
0 commit comments