Skip to content

Commit 297edc6

Browse files
Refactor and unify header buttons
1 parent 6421f45 commit 297edc6

File tree

5 files changed

+50
-31
lines changed

5 files changed

+50
-31
lines changed

_includes/header.html

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ <h4>{{ site.heading }}</h4>
5353
<div class="navbar-item navbar-dark-mode__mobile" onclick="modeSwitcher()">
5454
<div class="buttons">
5555
<a class="button is-text">
56-
<span class="icon is-small">
57-
<img src="../assets/img/moon.svg" id="theme-toggle-img--mobile">
58-
</span>
56+
<span class="theme-toggle-btn" id="theme-toggle-img--mobile"></span>
5957
</a>
6058
</div>
6159
</div>
@@ -113,9 +111,7 @@ <h4>{{ site.heading }}</h4>
113111
</a>
114112
<!-- Theme Switcher Button -->
115113
<a class="button is-text" onclick="modeSwitcher()">
116-
<span class="icon is-small">
117-
<img src="../assets/img/moon.svg" id="theme-toggle-img">
118-
</span>
114+
<span class="theme-toggle-btn" id="theme-toggle-img"></span>
119115
</a>
120116
</div>
121117
</div>

assets/css/style.css

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,15 +1603,22 @@ label.margin-toggle:not(.sidenote-number) {
16031603

16041604
/* Command Palette Button Styles */
16051605
.cmd-palette-btn {
1606-
font-weight: 1000;
1607-
font-size: 25px;
1606+
font-weight: 600;
1607+
font-size: 1.25rem;
16081608
text-decoration: none;
16091609
}
16101610

16111611
/* ChatMK Button Styles */
16121612
.chatmk-btn {
1613-
font-weight: 1000;
1614-
font-size: 25px;
1613+
font-weight: 600;
1614+
font-size: 1.25rem;
1615+
text-decoration: none;
1616+
}
1617+
1618+
/* Theme Toggle Button Styles */
1619+
.theme-toggle-btn {
1620+
font-weight: 600;
1621+
font-size: 1.25rem;
16151622
text-decoration: none;
16161623
}
16171624

@@ -1630,7 +1637,10 @@ label.margin-toggle:not(.sidenote-number) {
16301637
.cmd-palette-btn:active,
16311638
.chatmk-btn:hover,
16321639
.chatmk-btn:focus,
1633-
.chatmk-btn:active {
1640+
.chatmk-btn:active,
1641+
.theme-toggle-btn:hover,
1642+
.theme-toggle-btn:focus,
1643+
.theme-toggle-btn:active {
16341644
outline: none !important;
16351645
box-shadow: none !important;
16361646
background-color: transparent !important;
@@ -1656,6 +1666,25 @@ a:has(.chatmk-btn):hover {
16561666
text-decoration: none !important;
16571667
}
16581668

1669+
/* Remove underline from theme toggle button links */
1670+
a:has(.theme-toggle-btn) {
1671+
text-decoration: none !important;
1672+
}
1673+
1674+
a:has(.theme-toggle-btn):hover {
1675+
text-decoration: none !important;
1676+
}
1677+
1678+
/* Smaller buttons on mobile screens */
1679+
@media screen and (max-width: 768px) {
1680+
.chatmk-btn,
1681+
.cmd-palette-btn,
1682+
.theme-toggle-btn {
1683+
font-size: 1.2rem;
1684+
font-weight: 600;
1685+
}
1686+
}
1687+
16591688
/* Mobile navbar positioning - keep command palette next to theme switcher */
16601689
@media screen and (max-width: 1023px) {
16611690
.navbar-brand {
@@ -1671,7 +1700,7 @@ a:has(.chatmk-btn):hover {
16711700

16721701
.mobile-buttons-group {
16731702
display: flex;
1674-
gap: 0;
1703+
gap: 0.5rem;
16751704
align-items: center;
16761705
margin-left: auto;
16771706
margin-right: 0.5rem;

assets/img/moon.svg

Lines changed: 0 additions & 3 deletions
This file was deleted.

assets/img/sun.svg

Lines changed: 0 additions & 3 deletions
This file was deleted.

assets/js/modeSwitcher.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ https://github.com/derekkedziora/jekyll-demo
44
Creative Commons Attribution 4.0 International License
55
*/
66

7-
// Utility to update theme toggle icons
8-
function changeIconImgSrc(src) {
9-
const img = document.getElementById("theme-toggle-img");
10-
const mobileImg = document.getElementById("theme-toggle-img--mobile");
7+
// Utility to update theme toggle symbols
8+
function changeIconSymbol(symbol) {
9+
const toggle = document.getElementById("theme-toggle-img");
10+
const mobileToggle = document.getElementById("theme-toggle-img--mobile");
1111
// Added null checks to prevent errors
12-
if (img) img.src = src;
13-
if (mobileImg) mobileImg.src = src;
12+
if (toggle) toggle.textContent = symbol;
13+
if (mobileToggle) mobileToggle.textContent = symbol;
1414
}
1515

1616
// Retrieve theme from sessionStorage
@@ -19,31 +19,31 @@ let theme = sessionStorage.getItem('theme');
1919
// Apply theme based on stored value or default to dark
2020
if (theme === "light") {
2121
document.documentElement.setAttribute('data-theme', 'light');
22-
changeIconImgSrc("../assets/img/moon.svg");
22+
changeIconSymbol("☾");
2323
} else {
2424
// Default to dark if no preference or saved theme is dark
2525
document.documentElement.setAttribute('data-theme', 'dark');
26-
changeIconImgSrc("../assets/img/sun.svg");
26+
changeIconSymbol("☀");
2727
sessionStorage.setItem('theme', 'dark');
2828
}
2929

3030
// Function to toggle theme manually
3131
function modeSwitcher() {
3232
// Get current theme from sessionStorage
3333
let currentTheme = sessionStorage.getItem('theme');
34-
let newTheme, iconSrc;
34+
let newTheme, iconSymbol;
3535

3636
if (currentTheme === 'dark') {
3737
newTheme = 'light';
38-
iconSrc = "../assets/img/moon.svg";
38+
iconSymbol = "";
3939
} else {
4040
newTheme = 'dark';
41-
iconSrc = "../assets/img/sun.svg";
41+
iconSymbol = "";
4242
}
4343

44-
// Apply the new theme and update icon
44+
// Apply the new theme and update symbol
4545
document.documentElement.setAttribute('data-theme', newTheme);
46-
changeIconImgSrc(iconSrc);
46+
changeIconSymbol(iconSymbol);
4747

4848
// Store the new theme for the current session
4949
sessionStorage.setItem('theme', newTheme);

0 commit comments

Comments
 (0)