diff options
| author | Danilo M. <danix@danix.xyz> | 2026-04-15 21:42:04 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-04-15 21:42:04 +0200 |
| commit | 9934e042c1e97765ac839f6c3f06d30f02b5d9d0 (patch) | |
| tree | cf102ee79caf5d304e303956a1becd5fb680ca39 /themes/danix-xyz-hacker/layouts/partials | |
| parent | eb8a17482fc138c861db685f9efc86871bf2d7d2 (diff) | |
| download | danixxyz-9934e042c1e97765ac839f6c3f06d30f02b5d9d0.tar.gz danixxyz-9934e042c1e97765ac839f6c3f06d30f02b5d9d0.zip | |
Fix design system compliance: CSS variables, accessibility, and theme system
Core CSS improvements:
- Add --surface-rgb, --type-* (tech, life, quote, link, photo) custom properties
- Add --type-* semantic color classes for article badges
- Convert article badges from inline styles to CSS variable system
- Add prefers-color-scheme light fallback for no-JS users
- Add prefers-reduced-motion support to respect user accessibility settings
- Replace *:focus with *:focus-visible (keyboard-only outlines)
- Add clamp() fluid typography for hero-title and section-title
- Refactor container rules to mobile-first with 1060px breakpoint
Theme & Icon fixes:
- Fix theme toggle icon display with Alpine.js (was broken with Tailwind dark: classes)
- Add aria-hidden="true" to icon elements
- Update header with proper ARIA attributes on menu toggle
Accessibility enhancements:
- Add skip-to-main-content link in baseof.html
- Update hamburger menu with aria-expanded, aria-controls, aria-hidden
- Implement focus trap (Tab loops) within mobile menu
- Return focus to trigger button on menu close
- Add menu open/close state management with proper ARIA
Semantic HTML:
- Wrap article pages in <article> element (articles/single.html, _default/single.html)
- Fix quote article to use --type-quote border color instead of generic accent
Image optimization:
- Add loading="lazy" to profile image in index.html
- Add loading="lazy" to featured image in photo.html
Template fixes:
- Remove broken os.Getenv "THEME" runtime check from article-list-item.html
- Replace inline color styles with semantic .type-* classes
- Add 1060px lg: breakpoint to tailwind.config.js
i18n updates:
- Add skipToContent translations (en, it)
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Diffstat (limited to 'themes/danix-xyz-hacker/layouts/partials')
6 files changed, 12 insertions, 11 deletions
diff --git a/themes/danix-xyz-hacker/layouts/partials/article-header.html b/themes/danix-xyz-hacker/layouts/partials/article-header.html index 10808f9..b759909 100644 --- a/themes/danix-xyz-hacker/layouts/partials/article-header.html +++ b/themes/danix-xyz-hacker/layouts/partials/article-header.html @@ -6,9 +6,7 @@ <!-- Type badge --> {{ if $typeData }} <span - class="inline-flex items-center px-3 py-1 rounded text-sm font-semibold mb-4 transition-colors" - style="color: {{ $typeData.color_light }}; background-color: {{ $typeData.color_light }}20;" - data-theme-dark-color="{{ $typeData.color_dark }}" + class="inline-flex items-center px-3 py-1 rounded text-sm font-semibold mb-4 transition-colors type-{{ $articleType }}" > {{ i18n $articleType }} </span> diff --git a/themes/danix-xyz-hacker/layouts/partials/article-list-item.html b/themes/danix-xyz-hacker/layouts/partials/article-list-item.html index 652e171..1065f0b 100644 --- a/themes/danix-xyz-hacker/layouts/partials/article-list-item.html +++ b/themes/danix-xyz-hacker/layouts/partials/article-list-item.html @@ -1,8 +1,6 @@ {{ $articleType := .Params.type | default "life" }} {{ $typeConfig := .Site.Params.articleTypes }} {{ $typeData := index $typeConfig $articleType }} -{{ $isDark := strings.Contains (os.Getenv "THEME") "dark" }} -{{ $color := cond $isDark $typeData.color_dark $typeData.color_light }} <a href="{{ .RelPermalink }}" @@ -30,8 +28,7 @@ <!-- Type badge --> {{ if $typeData }} <span - class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium transition-colors" - style="color: {{ $color }}; background-color: {{ $color }}20;" + class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium transition-colors type-{{ $articleType }}" > {{ i18n $articleType }} </span> diff --git a/themes/danix-xyz-hacker/layouts/partials/article-types/photo.html b/themes/danix-xyz-hacker/layouts/partials/article-types/photo.html index f4ccf06..743e02a 100644 --- a/themes/danix-xyz-hacker/layouts/partials/article-types/photo.html +++ b/themes/danix-xyz-hacker/layouts/partials/article-types/photo.html @@ -3,6 +3,7 @@ <img src="{{ .Params.featured_image }}" alt="{{ .Title }}" + loading="lazy" class="w-full h-auto rounded-lg border border-border/30" /> {{ if .Params.featured_image_caption }} diff --git a/themes/danix-xyz-hacker/layouts/partials/article-types/quote.html b/themes/danix-xyz-hacker/layouts/partials/article-types/quote.html index 3df7327..f27d189 100644 --- a/themes/danix-xyz-hacker/layouts/partials/article-types/quote.html +++ b/themes/danix-xyz-hacker/layouts/partials/article-types/quote.html @@ -1,4 +1,4 @@ -<blockquote class="mb-8 pl-6 border-l-4 border-accent italic text-2xl text-text"> +<blockquote class="mb-8 pl-6 border-l-4 border-[--type-quote] italic text-2xl text-text"> "{{ .Params.quote_text }}" </blockquote> diff --git a/themes/danix-xyz-hacker/layouts/partials/hamburger-menu.html b/themes/danix-xyz-hacker/layouts/partials/hamburger-menu.html index bdcbca9..666db78 100644 --- a/themes/danix-xyz-hacker/layouts/partials/hamburger-menu.html +++ b/themes/danix-xyz-hacker/layouts/partials/hamburger-menu.html @@ -3,7 +3,8 @@ class="fixed inset-0 bg-black/50 backdrop-blur opacity-0 invisible transition-all duration-200 z-40" > <div - id="menu-panel" + id="hamburger-menu" + aria-hidden="true" class="fixed top-0 right-0 h-screen w-full max-w-sm bg-bg border-l border-border overflow-y-auto transform translate-x-full transition-transform duration-300 z-50" > <!-- Close button --> diff --git a/themes/danix-xyz-hacker/layouts/partials/header.html b/themes/danix-xyz-hacker/layouts/partials/header.html index 2ddb2e3..7f99748 100644 --- a/themes/danix-xyz-hacker/layouts/partials/header.html +++ b/themes/danix-xyz-hacker/layouts/partials/header.html @@ -48,17 +48,21 @@ <!-- Theme toggle button --> <button id="theme-toggle" + x-data="{ theme: localStorage.getItem('theme') || 'dark' }" + @click="theme = theme === 'dark' ? 'light' : 'dark'; document.documentElement.className = 'theme-' + theme; localStorage.setItem('theme', theme)" aria-label="{{ i18n "toggleTheme" }}" class="p-2 rounded hover:bg-surface transition-colors" > - <i data-feather="sun" class="w-5 h-5 hidden dark:block"></i> - <i data-feather="moon" class="w-5 h-5 block dark:hidden"></i> + <i x-show="theme === 'dark'" data-feather="sun" class="w-5 h-5" aria-hidden="true"></i> + <i x-show="theme === 'light'" data-feather="moon" class="w-5 h-5" aria-hidden="true"></i> </button> <!-- Hamburger menu button (mobile only) --> <button id="menu-toggle" aria-label="{{ i18n "toggleMenu" }}" + aria-expanded="false" + aria-controls="hamburger-menu" class="md:hidden p-2 rounded hover:bg-surface transition-colors" > <i data-feather="menu" class="w-5 h-5"></i> |
