Skip to content

Commit 5a43b34

Browse files
committed
style: refactor header actions and theme toggle
- Updated CSS for header actions, introducing a new flex layout and base styles for action buttons. - Enhanced theme toggle button with improved accessibility attributes and visual feedback. - Adjusted HTML structure to accommodate GitHub link and theme toggle within a unified header actions group. - Removed outdated theme icon styles and streamlined theme icon animations for better performance.
1 parent ec8e7f2 commit 5a43b34

File tree

3 files changed

+145
-42
lines changed

3 files changed

+145
-42
lines changed

themes/default/assets/css/style.css

Lines changed: 124 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,15 @@ body {
582582
box-shadow: var(--shadow-sm);
583583
}
584584

585-
/* Theme Toggle in Header */
586-
.theme-toggle-header {
585+
/* Header Actions Group */
586+
.header-actions {
587+
display: flex;
588+
align-items: center;
589+
gap: var(--space-sm);
590+
}
591+
592+
/* Header Action Buttons - Base Style */
593+
.header-action-btn {
587594
background: none;
588595
border: 1px solid var(--border-medium);
589596
border-radius: 6px;
@@ -595,20 +602,92 @@ body {
595602
cursor: pointer;
596603
transition: var(--transition);
597604
color: var(--text-secondary);
605+
text-decoration: none;
598606
position: relative;
607+
overflow: hidden;
599608
}
600609

601-
.theme-toggle-header:hover {
610+
.header-action-btn:hover {
602611
background: var(--bg-tertiary);
603-
border-color: var(--border-medium);
604-
color: var(--text-primary);
612+
border-color: var(--primary-color);
613+
color: var(--primary-color);
614+
transform: translateY(-1px);
615+
box-shadow: var(--shadow-sm);
605616
}
606617

607-
.theme-toggle-header:focus {
618+
.header-action-btn:focus {
608619
outline: 2px solid var(--primary-color);
609620
outline-offset: 2px;
610621
}
611622

623+
.header-action-btn:active {
624+
transform: translateY(0);
625+
box-shadow: none;
626+
}
627+
628+
/* GitHub Link Specific Styles */
629+
.github-link svg {
630+
width: 20px;
631+
height: 20px;
632+
transition: var(--transition);
633+
}
634+
635+
.github-link:hover svg {
636+
transform: scale(1.1);
637+
}
638+
639+
/* Theme Toggle Specific Styles */
640+
.theme-toggle-header .theme-icon {
641+
position: absolute;
642+
font-size: 16px;
643+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
644+
display: flex;
645+
align-items: center;
646+
justify-content: center;
647+
}
648+
649+
/* Theme Icons Animation */
650+
.theme-icon-light,
651+
.theme-icon-dark {
652+
position: absolute;
653+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
654+
}
655+
656+
/* Light theme - show sun icon */
657+
[data-theme="light"] .theme-icon-light {
658+
opacity: 1;
659+
transform: rotate(0deg) scale(1);
660+
}
661+
662+
[data-theme="light"] .theme-icon-dark {
663+
opacity: 0;
664+
transform: rotate(180deg) scale(0.5);
665+
}
666+
667+
/* Dark theme - show moon icon */
668+
[data-theme="dark"] .theme-icon-light {
669+
opacity: 0;
670+
transform: rotate(-180deg) scale(0.5);
671+
}
672+
673+
[data-theme="dark"] .theme-icon-dark {
674+
opacity: 1;
675+
transform: rotate(0deg) scale(1);
676+
}
677+
678+
/* Theme Toggle in Header */
679+
.theme-toggle-header {
680+
/* Inherits from .header-action-btn */
681+
}
682+
683+
.theme-toggle-header:hover {
684+
/* Inherits from .header-action-btn:hover */
685+
}
686+
687+
.theme-toggle-header:focus {
688+
/* Inherits from .header-action-btn:focus */
689+
}
690+
612691
/* Page Actions */
613692
.page-actions {
614693
display: flex;
@@ -664,35 +743,6 @@ body {
664743
letter-spacing: 0.3px;
665744
}
666745

667-
/* Theme Icons */
668-
.theme-icon-light,
669-
.theme-icon-dark {
670-
position: absolute;
671-
transition: var(--transition);
672-
}
673-
674-
/* Light theme - show sun icon */
675-
[data-theme="light"] .theme-icon-light {
676-
opacity: 1;
677-
transform: rotate(0deg);
678-
}
679-
680-
[data-theme="light"] .theme-icon-dark {
681-
opacity: 0;
682-
transform: rotate(90deg);
683-
}
684-
685-
/* Dark theme - show moon icon */
686-
[data-theme="dark"] .theme-icon-light {
687-
opacity: 0;
688-
transform: rotate(-90deg);
689-
}
690-
691-
[data-theme="dark"] .theme-icon-dark {
692-
opacity: 1;
693-
transform: rotate(0deg);
694-
}
695-
696746
/* Mobile Menu Button - Hidden on desktop */
697747
.mobile-menu-toggle {
698748
display: none;
@@ -703,7 +753,7 @@ body {
703753
padding: 8px;
704754
border-radius: 6px;
705755
transition: var(--transition);
706-
margin-right: var(--space-md);
756+
margin-right: var(--space-xs);
707757
-webkit-tap-highlight-color: transparent;
708758
}
709759

@@ -1113,6 +1163,21 @@ body {
11131163
padding: 8px;
11141164
}
11151165

1166+
/* Header actions adjustments */
1167+
.header-actions {
1168+
gap: var(--space-xs);
1169+
}
1170+
1171+
.header-action-btn {
1172+
width: 40px;
1173+
height: 40px;
1174+
}
1175+
1176+
.github-link svg {
1177+
width: 18px;
1178+
height: 18px;
1179+
}
1180+
11161181
/* Page actions adjustments */
11171182
.page-actions {
11181183
margin-bottom: var(--space-md);
@@ -1192,4 +1257,27 @@ body {
11921257
.download-text {
11931258
font-size: 12px;
11941259
}
1260+
1261+
/* Header actions adjustments for small screens */
1262+
.header-actions {
1263+
gap: 4px;
1264+
}
1265+
1266+
.header-action-btn {
1267+
width: 32px;
1268+
height: 32px;
1269+
}
1270+
1271+
.github-link svg {
1272+
width: 16px;
1273+
height: 16px;
1274+
}
1275+
1276+
.theme-toggle-header .theme-icon {
1277+
font-size: 14px;
1278+
}
1279+
1280+
.navigation {
1281+
padding: var(--space-md);
1282+
}
11951283
}

themes/default/assets/js/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,11 @@ class Knowledge {
443443
document.documentElement.setAttribute('data-theme', theme);
444444
localStorage.setItem('knowledge-theme', theme);
445445

446-
// Update toggle button
446+
// Update toggle button aria-label
447447
const toggleBtn = document.querySelector('.theme-toggle-header');
448448
if (toggleBtn) {
449-
toggleBtn.textContent = theme === 'dark' ? '☀️' : '🌙';
450-
toggleBtn.setAttribute('aria-label', `Switch to ${theme === 'dark' ? 'light' : 'dark'} theme`);
449+
toggleBtn.setAttribute('aria-label', `Alternar para tema ${theme === 'dark' ? 'claro' : 'escuro'}`);
450+
toggleBtn.setAttribute('title', `Alternar para tema ${theme === 'dark' ? 'claro' : 'escuro'}`);
451451
}
452452

453453
// Atualizar meta theme-color para mobile

themes/default/layouts/default.html

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,24 @@ <h1 class="site-title">
7272

7373
<!-- Right side (for future elements like theme toggle, etc.) -->
7474
<div class="header-right">
75-
<button class="theme-toggle-header" aria-label="Toggle dark mode">
76-
🌙
77-
</button>
75+
<div class="header-actions">
76+
<a href="https://github.com/riligar/knowledge" target="_blank" class="header-action-btn github-link"
77+
title="Ver no GitHub" aria-label="Ver repositório no GitHub">
78+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none"
79+
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
80+
class="icon icon-tabler icons-tabler-outline icon-tabler-brand-github">
81+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
82+
<path
83+
d="M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5" />
84+
</svg>
85+
</a>
86+
87+
<button class="header-action-btn theme-toggle-header" aria-label="Alternar tema escuro/claro"
88+
title="Alternar tema">
89+
<span class="theme-icon theme-icon-light">☀️</span>
90+
<span class="theme-icon theme-icon-dark">🌙</span>
91+
</button>
92+
</div>
7893
</div>
7994
</div>
8095
</header>

0 commit comments

Comments
 (0)