Skip to content

Commit b5d401a

Browse files
lenis2000claude
andcommitted
Replace single icon toggle with dual sun/moon toggle switch
- Show both sun and moon icons simultaneously in toggle button - Add sliding thumb indicator that moves between icons - Sun icon highlighted in light mode, moon in dark mode - Click anywhere on the button to toggle between modes - Smooth sliding animation when switching themes Co-authored-by: Claude <noreply@anthropic.com> 🤖 Generated with Claude Code
1 parent 59eb079 commit b5d401a

File tree

3 files changed

+78
-67
lines changed

3 files changed

+78
-67
lines changed

_includes/footer.html

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -78,34 +78,7 @@
7878
// Apply theme to document
7979
function applyTheme(theme) {
8080
document.documentElement.setAttribute('data-theme', theme);
81-
updateThemeIcon(theme);
82-
}
83-
84-
// Update the theme toggle icon
85-
function updateThemeIcon(theme) {
86-
const icons = document.querySelectorAll('#theme-icon, #theme-icon-mobile');
87-
88-
icons.forEach(icon => {
89-
if (icon) {
90-
// Add rotation animation
91-
icon.style.transform = 'rotate(180deg)';
92-
93-
setTimeout(() => {
94-
if (theme === 'dark') {
95-
icon.classList.remove('fa-sun');
96-
icon.classList.add('fa-moon');
97-
} else {
98-
icon.classList.remove('fa-moon');
99-
icon.classList.add('fa-sun');
100-
}
101-
102-
// Reset rotation after icon change
103-
setTimeout(() => {
104-
icon.style.transform = '';
105-
}, 10);
106-
}, 150);
107-
}
108-
});
81+
// No need to update icons as both are always visible
10982
}
11083

11184
// Toggle theme

_includes/navbar.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@
1919
</div>
2020

2121
<!-- Dark mode toggle for mobile -->
22-
<button class="theme-toggle-single d-md-none me-2" id="theme-toggle-mobile" title="Toggle dark mode">
23-
<i class="fas fa-sun" id="theme-icon-mobile"></i>
22+
<button class="theme-toggle-dual d-md-none me-2" id="theme-toggle-mobile" title="Toggle dark mode">
23+
<span class="toggle-track">
24+
<i class="fas fa-sun"></i>
25+
<i class="fas fa-moon"></i>
26+
<span class="toggle-thumb"></span>
27+
</span>
2428
</button>
2529

2630
<!-- Secondary menu toggle - right side (only for special pages) -->
@@ -68,8 +72,12 @@
6872
</ul>
6973
<ul class="navbar-nav ms-auto align-items-center">
7074
<li class="nav-item d-flex align-items-center">
71-
<button class="theme-toggle-single me-2" id="theme-toggle" title="Toggle dark mode">
72-
<i class="fas fa-sun" id="theme-icon"></i>
75+
<button class="theme-toggle-dual me-2" id="theme-toggle" title="Toggle dark mode">
76+
<span class="toggle-track">
77+
<i class="fas fa-sun"></i>
78+
<i class="fas fa-moon"></i>
79+
<span class="toggle-thumb"></span>
80+
</span>
7381
</button>
7482
</li>
7583
<li class="nav-item">

css/main.css

Lines changed: 65 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -608,81 +608,111 @@ footer {
608608
border-top: 1px solid var(--border-color);
609609
}
610610

611-
/* Dark mode toggle button */
612-
.theme-toggle-single {
613-
background-color: rgba(0, 47, 108, 0.1);
611+
/* Dark mode toggle button with dual icons */
612+
.theme-toggle-dual {
613+
background: none;
614614
border: none;
615-
color: #002F6C;
616615
cursor: pointer;
617-
font-size: 1rem;
618-
padding: 0.5rem 0.75rem;
619-
transition: all 0.3s ease;
620-
border-radius: 20px;
616+
padding: 0;
621617
-webkit-tap-highlight-color: transparent;
622618
touch-action: manipulation;
623619
position: relative;
624620
z-index: 1000;
625621
}
626622

627-
/* Icon animation */
628-
.theme-toggle-single i {
629-
transition: transform 0.3s ease;
623+
.toggle-track {
624+
display: inline-flex;
625+
align-items: center;
626+
background-color: rgba(0, 47, 108, 0.15);
627+
border-radius: 20px;
628+
padding: 4px;
629+
position: relative;
630+
transition: background-color 0.3s ease;
631+
gap: 6px;
630632
}
631633

632-
.theme-toggle-single:active i {
633-
transform: rotate(180deg) scale(0.9);
634+
.toggle-track i {
635+
font-size: 0.9rem;
636+
padding: 4px 6px;
637+
position: relative;
638+
z-index: 2;
639+
transition: color 0.3s ease;
634640
}
635641

636-
/* In light navbar */
637-
.navbar-light .theme-toggle-single {
638-
background-color: rgba(0, 47, 108, 0.1);
642+
.toggle-track .fa-sun {
639643
color: #002F6C;
640644
}
641645

642-
.theme-toggle-single:hover {
643-
background-color: rgba(0, 47, 108, 0.2);
644-
transform: scale(1.05);
646+
.toggle-track .fa-moon {
647+
color: rgba(0, 47, 108, 0.4);
645648
}
646649

647-
.theme-toggle-single:active {
648-
transform: scale(0.95);
650+
.toggle-thumb {
651+
position: absolute;
652+
left: 4px;
653+
top: 4px;
654+
width: calc(50% - 4px);
655+
height: calc(100% - 8px);
656+
background-color: white;
657+
border-radius: 16px;
658+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
659+
transition: transform 0.3s ease;
649660
}
650661

651-
.theme-toggle-single:focus {
662+
.theme-toggle-dual:hover .toggle-track {
663+
background-color: rgba(0, 47, 108, 0.25);
664+
}
665+
666+
.theme-toggle-dual:focus {
652667
outline: none;
668+
}
669+
670+
.theme-toggle-dual:focus .toggle-track {
653671
box-shadow: 0 0 0 3px rgba(0, 47, 108, 0.3);
654672
}
655673

656-
/* Dark theme adjustments */
657-
[data-theme="dark"] .theme-toggle-single {
658-
background-color: rgba(255, 255, 255, 0.1);
659-
color: #e8e8e8;
674+
/* Dark theme state */
675+
[data-theme="dark"] .toggle-track {
676+
background-color: rgba(255, 255, 255, 0.15);
660677
}
661678

662-
[data-theme="dark"] .navbar-light .theme-toggle-single {
663-
background-color: rgba(255, 255, 255, 0.1);
679+
[data-theme="dark"] .toggle-track .fa-sun {
680+
color: rgba(255, 255, 255, 0.4);
681+
}
682+
683+
[data-theme="dark"] .toggle-track .fa-moon {
664684
color: #e8e8e8;
665685
}
666686

667-
[data-theme="dark"] .theme-toggle-single:hover {
668-
background-color: rgba(255, 255, 255, 0.2);
687+
[data-theme="dark"] .toggle-thumb {
688+
transform: translateX(100%);
689+
background-color: rgba(255, 255, 255, 0.9);
669690
}
670691

671-
[data-theme="dark"] .theme-toggle-single:focus {
692+
[data-theme="dark"] .theme-toggle-dual:hover .toggle-track {
693+
background-color: rgba(255, 255, 255, 0.25);
694+
}
695+
696+
[data-theme="dark"] .theme-toggle-dual:focus .toggle-track {
672697
box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
673698
}
674699

675700
/* Mobile styling */
676701
@media (max-width: 767px) {
677-
.theme-toggle-single {
678-
padding: 0.4rem 0.6rem;
679-
font-size: 0.9rem;
702+
.toggle-track {
703+
padding: 3px;
704+
gap: 4px;
705+
}
706+
707+
.toggle-track i {
708+
font-size: 0.8rem;
709+
padding: 3px 5px;
680710
}
681711
}
682712

683713
/* Align with nav items on desktop */
684714
@media (min-width: 768px) {
685-
.navbar-nav .theme-toggle-single {
715+
.navbar-nav .theme-toggle-dual {
686716
margin-top: 0.5rem;
687717
margin-bottom: 0.5rem;
688718
}

0 commit comments

Comments
 (0)