Skip to content

Commit 654cf0f

Browse files
committed
Fixed style issues.
1 parent 62ba0ec commit 654cf0f

File tree

5 files changed

+76
-15
lines changed

5 files changed

+76
-15
lines changed

config.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ internal_level = "warn"
2121
[extra.download]
2222

2323
repository = "https://github.com/lfe/lfe"
24-
prior_release = "2.0.1"
25-
current_release = "2.1.4"
24+
prior_release = "2.1.5"
25+
current_release = "2.2.0"
2626
pre_release = "refs/heads/develop"

static/css/site.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/js/site.js

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,21 @@ const HSThemeAppearance = {
77
const defaultTheme = 'default'
88
let theme = localStorage.getItem('hs_theme') || defaultTheme
99

10-
if (document.querySelector('html').classList.contains('dark')) return
10+
if (document.querySelector('html').classList.contains('dark')) {
11+
// Still need to set hs-dark-mode-active and toggle icons
12+
document.querySelector('html').classList.add('hs-dark-mode-active')
13+
const moonIcon = document.querySelector('[data-hs-theme-click-value="dark"]')
14+
const sunIcon = document.querySelector('[data-hs-theme-click-value="light"]')
15+
if (moonIcon) {
16+
moonIcon.classList.add('hidden')
17+
moonIcon.classList.remove('block')
18+
}
19+
if (sunIcon) {
20+
sunIcon.classList.remove('hidden')
21+
sunIcon.classList.add('block')
22+
}
23+
return
24+
}
1125
this.setAppearance(theme)
1226
},
1327
_resetStylesOnLoad() {
@@ -29,10 +43,45 @@ const HSThemeAppearance = {
2943
}
3044

3145
document.querySelector('html').classList.remove('dark')
46+
document.querySelector('html').classList.remove('light')
3247
document.querySelector('html').classList.remove('default')
3348
document.querySelector('html').classList.remove('auto')
3449

35-
document.querySelector('html').classList.add(this.getOriginalAppearance())
50+
const themeToApply = this.getOriginalAppearance()
51+
52+
// Only add 'dark' class for dark mode. Light mode = no class
53+
if (themeToApply === 'dark') {
54+
document.querySelector('html').classList.add('dark')
55+
}
56+
57+
// Manually toggle the hs-dark-mode-active class for icon visibility
58+
const htmlEl = document.querySelector('html')
59+
const moonIcon = document.querySelector('[data-hs-theme-click-value="dark"]')
60+
const sunIcon = document.querySelector('[data-hs-theme-click-value="light"]')
61+
62+
if (themeToApply === 'dark') {
63+
htmlEl.classList.add('hs-dark-mode-active')
64+
// In dark mode: hide moon, show sun
65+
if (moonIcon) {
66+
moonIcon.classList.add('hidden')
67+
moonIcon.classList.remove('block')
68+
}
69+
if (sunIcon) {
70+
sunIcon.classList.remove('hidden')
71+
sunIcon.classList.add('block')
72+
}
73+
} else {
74+
htmlEl.classList.remove('hs-dark-mode-active')
75+
// In light mode: show moon, hide sun
76+
if (moonIcon) {
77+
moonIcon.classList.remove('hidden')
78+
moonIcon.classList.add('block')
79+
}
80+
if (sunIcon) {
81+
sunIcon.classList.add('hidden')
82+
sunIcon.classList.remove('block')
83+
}
84+
}
3685

3786
setTimeout(() => {
3887
$resetStylesEl.remove()
@@ -66,10 +115,6 @@ window.addEventListener('load', () => {
66115
const $clickableThemes = document.querySelectorAll('[data-hs-theme-click-value]')
67116
const $switchableThemes = document.querySelectorAll('[data-hs-theme-switch]')
68117

69-
$clickableThemes.forEach($item => {
70-
$item.addEventListener('click', () => HSThemeAppearance.setAppearance($item.getAttribute('data-hs-theme-click-value'), true, $item))
71-
})
72-
73118
$switchableThemes.forEach($item => {
74119
$item.addEventListener('change', (e) => {
75120
HSThemeAppearance.setAppearance(e.target.checked ? 'dark' : 'default')
@@ -110,12 +155,27 @@ window.addEventListener('load', () => {
110155
return
111156
}
112157

158+
// Don't interfere with theme switcher clicks
159+
if (e.target.closest('[data-hs-theme-click-value]')) {
160+
return
161+
}
162+
113163
// Close if clicking outside the dropdown
114164
if (!dropdown.contains(e.target)) {
115165
closeDropdown()
116166
}
117167
})
118168

169+
// Use event delegation for theme switchers - MUST be after dropdown handler
170+
document.addEventListener('click', (e) => {
171+
const themeButton = e.target.closest('[data-hs-theme-click-value]')
172+
if (themeButton) {
173+
e.preventDefault()
174+
const themeValue = themeButton.getAttribute('data-hs-theme-click-value')
175+
HSThemeAppearance.setAppearance(themeValue, true, themeButton)
176+
}
177+
})
178+
119179
// Close dropdown when clicking a menu item
120180
dropdownMenu.querySelectorAll('a').forEach(function(link) {
121181
link.addEventListener('click', function() {
@@ -142,4 +202,3 @@ window.addEventListener('load', () => {
142202
}
143203
}
144204
})
145-

styles/site.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
@import "tailwindcss";
22

3+
@variant dark (.dark &);
4+
35
@layer components {
46
body {
57
@apply dark:bg-slate-900 min-h-[75rem];

templates/base/head-menu.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
{% set current_page = "/" ~ current_path %}
2020
{% set selected = "" %}
2121
{% set selected_style = "text-blue-600 sm:py-6 dark:text-blue-500" %}
22-
{% set unselected_style = "text-gray-500 hover:text-gray-400 sm:py-6 dark:text-gray-400 dark:hover:text-gray-500" %}
22+
{% set unselected_style = "text-gray-700 hover:text-gray-600 sm:py-6 dark:text-gray-400 dark:hover:text-gray-500" %}
2323
{% set style = unselected_style %}
2424

2525

@@ -69,7 +69,7 @@
6969
{% set selected = "" %}
7070
{% set style = unselected_style %}
7171

72-
<a class="font-medium text-gray-500 hover:text-gray-400 sm:py-6 dark:text-gray-400 dark:hover:text-gray-500" href="http://blog.lfe.io">
72+
<a class="font-medium text-gray-700 hover:text-gray-600 sm:py-6 dark:text-gray-400 dark:hover:text-gray-500" href="http://blog.lfe.io">
7373
Blog
7474
</a>
7575

@@ -103,13 +103,13 @@
103103
</div>
104104
</div>
105105

106-
<a class="flex items-center gap-x-2 font-medium text-gray-500 hover:text-blue-600 sm:border-l sm:border-gray-300 sm:my-6 sm:pl-6 dark:border-gray-700 dark:text-gray-400 dark:hover:text-blue-500"
106+
<a class="flex items-center gap-x-2 font-medium text-gray-700 hover:text-blue-600 sm:border-l sm:border-gray-300 sm:my-6 sm:pl-6 dark:border-gray-700 dark:text-gray-400 dark:hover:text-blue-500"
107107
aria-label="Github"
108108
href="https://github.com/lfe/lfe" >
109109
<i class="fab fa-github"></i>
110110
</a>
111111

112-
<a class="flex items-center gap-x-2 font-medium text-gray-500 hover:text-blue-600 dark:border-gray-700 dark:text-gray-400 dark:hover:text-blue-500"
112+
<a class="flex items-center gap-x-2 font-medium text-gray-700 hover:text-blue-600 dark:border-gray-700 dark:text-gray-400 dark:hover:text-blue-500"
113113
aria-label="Mastodon"
114114
href="https://fosstodon.org/web/@lfe"
115115
rel="me">

0 commit comments

Comments
 (0)