Files
FixIt/layouts/_partials/base/header.html
T
Cell 8af8e806d7 feat(assets): integrate UnoCSS for utility classes and presetIcons (#795)
* refactor(assets): integrate UnoCSS for utility classes

- Add UnoCSS with presetWind3 as pre-built CSS (assets/css/unocss.css)
- Add uno.config.ts with theme breakpoints, colors, safelist, and blocklist
- Replace SCSS utility classes with UnoCSS atomic classes:
  - d-none → hidden
  - d-none-desktop → sm:hidden
  - d-none-mobile → max-sm:hidden
  - order-* (safelist)
  - variant-numeric → tabular-nums lining-nums
- Rename .blur to .is-blur to avoid UnoCSS conflict
- Add @unocss-skip comments for SVG path elements to prevent false positives
- Remove redundant _utilities.scss ($orders map) and simplify _common.scss
- Update documentation (CLAUDE.md, CONTRIBUTING.md, copilot-instructions.md)

* refactor(assets): replace 404/offline SCSS with UnoCSS atomic classes

- Replace _404.scss styles with atomic classes on template elements
- Replace _offline.scss styles with atomic classes on template elements
- Keep selectors (id/class) as user customization hooks
- Delete assets/scss/pages/_404.scss and _offline.scss

* refactor(assets): simplify SCSS with UnoCSS atomic classes

- Replace _bilibili.scss with atomic classes (relative, aspect-video, inset-0)
- Replace _version.scss with atomic classes (whitespace-nowrap, align-text-bottom)
- Replace _noscript-warning.scss with atomic classes (bg-danger, fixed, z-200)
- Add semantic z-index shortcuts (z-hide, z-auto, z-base, z-loading, z-sticky, z-fixed)
- Add h1-h6 to UnoCSS blocklist to prevent false positives
- Use Source path for UnoCSS CSS loading to enable Hugo minify

* chore(assets): minor SCSS and template cleanup

* fix(assets): add secondary color to UnoCSS theme config

text-secondary was broken because the secondary color mapping was missing.

* feat(assets): add UnoCSS presetIcons support and z-index shortcuts

- Add presetIcons preset with empty collections (ready for custom icon sets)
- Add @iconify/json and @iconify/utils devDependencies
- Add semantic z-index shortcuts (z-hide, z-auto, z-base, z-loading, z-sticky, z-fixed)
- Add secondary color to UnoCSS theme config

* refactor(assets): replace SVG icons with UnoCSS presetIcons

- Add Lucide and Octicons icon collections to presetIcons config
- Replace arrow-up/down and enter-key SVGs with Lucide icons
- Replace alert icons (info, light-bulb, report, alert, stop) with Octicons
- Delete replaced SVG files from assets/images/icons/
- Keep custom SVGs (csdn, plume, rootme)

* refactor(layouts): redesign 404 and offline pages with UnoCSS

- Replace translate-y-[30vh] with self-stretch flex centering below header
- Remove arbitrary values (text-[3.6rem], text-[1.8rem], etc.)
- Restore @page print styles in _common.scss
- Simplify offline page layout (icon + title + text)
- Fix hardcoded #57606a → text-secondary
2026-06-27 06:27:12 +08:00

306 lines
15 KiB
HTML

{{- $buildDrafts := .Page.Draft -}}
{{- $relLangURL := relLangURL "" -}}
{{- /* Desktop header */ -}}
<header class="desktop animate__faster{{ if .Site.Params.header.blur }} is-blur{{ end }}" id="header-desktop">
<div class="header-wrapper"{{ if .Site.Params.githubCorner.enable }} data-github-corner="{{ .Site.Params.githubCorner.position }}"{{ end }}>
<div class="header-title">
<a href="{{ $relLangURL }}" title="{{ .Site.Title }}" class="header-title-link">
{{- with .Site.Params.header.title -}}
{{- with .logo -}}
{{- dict "Src" . "Class" "logo" "Alt" $.Site.Title "Width" 32 "Height" 32 | partial "plugin/image.html" -}}
{{- end -}}
{{- with .pre -}}
<span class="header-title-pre">{{ . | safeHTML }}</span>
{{- end -}}
{{- if .typeit -}}
{{- $.Store.Set "hasTyped" true -}}
<span class="typeit" data-group="header-desktop"><template>{{ .name | default $.Site.Title }}</template></span>
{{- else -}}
<span class="header-title-text">{{ .name | default $.Site.Title }}</span>
{{- end -}}
{{- with .post -}}
<span class="header-title-post">{{ . | safeHTML }}</span>
{{- end -}}
{{- else -}}
<span class="header-title-text">{{ .Site.Title }}</span>
{{- end -}}
</a>
{{- with .Site.Params.header.subtitle -}}
{{- if .typeit -}}
{{- $.Store.Set "hasTyped" true -}}
<span class="typeit header-subtitle" data-group="header-desktop"><template>{{ .name }}</template></span>
{{- else -}}
<span class="header-subtitle">{{ .name }}</span>
{{- end -}}
{{- end -}}
</div>
<nav>
<ul class="menu">
{{- range .Site.Menus.main -}}
{{- $url := .URL -}}
{{- with $url -}}
{{- $url = . | relLangURL -}}
{{- end -}}
{{- with .Page -}}
{{- $url = .RelPermalink -}}
{{- end -}}
{{- if (ne .Params.Draft true) | or $buildDrafts | and (ne .Params.Type "mobile") -}}
<li class="menu-item{{ if $.IsMenuCurrent `main` . | or ($.HasMenuCurrent `main` .) | or (eq $.RelPermalink $url) }} active{{ end }}{{ with .Params.Class }} {{ . }}{{ end }}{{ if .HasChildren }} has-children{{ end }}">
<a class="menu-link"
{{- with $url }} href="{{ $url }}"{{ else }} href="javascript:void(0);"{{ end }}
{{- with .Title }} title="{{ . }}"{{ end }}
{{- if (urls.Parse $url).Host }} rel="noopener noreferrer" target="_blank"{{ end -}}
>
{{- with .Pre -}}{{- . | safeHTML }} {{ end }}
{{- with .Params.Icon -}}{{ dict "Class" (printf "%v fa-sm" .) | partial "plugin/icon.html" }} {{ end }}
{{- .Name }}
{{- with .Post }} {{ . | safeHTML -}}{{- end -}}
</a>
{{- if .HasChildren -}}
{{ dict "Class" "dropdown-icon fa-solid fa-chevron-down" | partial "plugin/icon.html" }}
<ul class="sub-menu">
{{- range $k, $v := .Children -}}
{{- $url := $v.URL -}}
{{- with $url -}}
{{- $url = . | relLangURL -}}
{{- end -}}
{{- with $v.Page -}}
{{- $url = .RelPermalink -}}
{{- end -}}
{{- if (ne $v.Params.Draft true) | or $buildDrafts | and (ne $v.Params.Type "mobile") -}}
{{- if $k | and $v.Params.Divided -}}
<li class="menu-item-divider" aria-hidden="true"></li>
{{- end -}}
<li class="menu-item{{ if $.IsMenuCurrent `main` $v | or ($.HasMenuCurrent `main` $v) | or (eq $.RelPermalink $url) }} active{{ end }}{{ with $v.Params.Class }} {{ . }}{{ end }}">
<a class="menu-link"
{{- with $url }} href="{{ $url }}"{{ else }} href="javascript:void(0);"{{ end }}
{{- with $v.Title }} title="{{ . }}"{{ end }}
{{- if (urls.Parse $url).Host }} rel="noopener noreferrer" target="_blank"{{ end -}}
>
{{- with $v.Pre -}}{{- . | safeHTML }} {{ end }}
{{- with $v.Params.Icon -}}{{ dict "Class" (printf "%v fa-sm" .) | partial "plugin/icon.html" }} {{ end }}
{{- $v.Name }}
{{- with $v.Post }} {{ . | safeHTML -}}{{- end -}}
</a>
</li>
{{- end -}}
{{- end -}}
</ul>
{{- end -}}
</li>
{{- end -}}
{{- end -}}
{{- if .Site.Menus.main -}}
<li class="menu-item delimiter"></li>
{{- end -}}
{{- if .Site.Params.search.enable -}}
<li class="menu-item search">
<button type="button" class="search-trigger desktop" aria-label="{{ T "assets.search" }}" title="{{ T "assets.search" }}">
{{ dict "Class" "fa-solid fa-search" | partial "plugin/icon.html" }}
{{ T "assets.search" }}
<kbd></kbd>
</button>
</li>
<li class="menu-item delimiter"></li>
{{- end -}}
<li class="menu-item theme-switch-item">
<button type="button" class="theme-switch" aria-label="{{ T "header.switchTheme" }}" title="{{ T "header.switchTheme" }}">
{{- dict "Class" "fa-solid fa-adjust" | partial "plugin/icon.html" -}}
</button>
</li>
{{- if hugo.IsMultilingual -}}
<li class="menu-item language-switch">
<button type="button" aria-label="{{ T "header.selectLanguage" }}" title="{{ T "header.selectLanguage" }}">
{{- dict "Class" "fa-solid fa-language" | partial "plugin/icon.html" -}}
</button>
<ul class="sub-menu">
{{- if (eq .Kind "404") -}}
{{- range hugo.Sites -}}
{{- if ne . $.Site -}}
{{- $link := printf "%v/404.html" .LanguagePrefix -}}
<li class="menu-item">
<a href="{{ $link }}" class="menu-link" title="{{- .Language.LanguageName -}}">
{{- .Language.LanguageName -}}
</a>
</li>
{{- end -}}
{{- end -}}
{{- else if .IsTranslated -}}
{{- range .AllTranslations -}}
<li class="menu-item">
{{- if ne .Lang $.Lang -}}
<a href="{{ .RelPermalink }}" class="menu-link" title="{{ .Language.LanguageName }}">{{ .Language.LanguageName }}</a>
{{- else -}}
<span class="text-secondary" title="{{ .Language.LanguageName }}">{{ .Language.LanguageName }}</span>
{{- end -}}
</li>
{{- end -}}
{{- else -}}
<li class="menu-item">{{- T "header.noMoretTranslations" -}}</li>
{{- end -}}
</ul>
</li>
{{- end -}}
{{- /* Custom menu items in the desktop header */ -}}
{{- block "custom-menu:desktop" . }}{{ end -}}
</ul>
</nav>
</div>
</header>
{{- /* Mobile header */ -}}
<header class="mobile animate__faster{{ if .Site.Params.header.blur }} is-blur{{ end }}" id="header-mobile">
<div class="header-container">
<div class="header-wrapper">
<div class="header-title">
<a href="{{ $relLangURL }}" title="{{ .Site.Title }}" class="header-title-link">
{{- with .Site.Params.header.title -}}
{{- with .logo -}}
{{- dict "Src" . "Class" "logo" "Alt" $.Site.Title "Width" 26 "Height" 26 | partial "plugin/image.html" -}}
{{- end -}}
{{- with .pre -}}
<span class="header-title-pre">{{ . | safeHTML }}</span>
{{- end -}}
{{- if .typeit -}}
{{- $.Store.Set "hasTyped" true -}}
<span class="typeit" data-group="header-mobile"><template>{{ .name | default $.Site.Title }}</template></span>
{{- else -}}
<span class="header-title-text">{{ .name | default $.Site.Title }}</span>
{{- end -}}
{{- with .post -}}
<span class="header-title-post">{{ . | safeHTML }}</span>
{{- end -}}
{{- else -}}
<span class="header-title-text">{{ .Site.Title }}</span>
{{- end -}}
</a>
{{- with .Site.Params.header.subtitle -}}
{{- if .typeit -}}
{{- $.Store.Set "hasTyped" true -}}
<span class="typeit header-subtitle" data-group="header-mobile"><template>{{ .name }}</template></span>
{{- else -}}
<span class="header-subtitle">{{- .name -}}</span>
{{- end -}}
{{- end -}}
</div>
{{- if .Site.Params.search.enable -}}
<button type="button" class="search-trigger mobile" aria-label="{{ T "assets.search" }}">
{{- dict "Class" "fa-solid fa-search" | partial "plugin/icon.html" -}}
</button>
{{- end -}}
<button type="button" class="theme-switch" aria-label="{{ T "header.switchTheme" }}">
{{- dict "Class" "fa-solid fa-adjust" | partial "plugin/icon.html" -}}
</button>
<button type="button" class="menu-toggle" id="menu-toggle-mobile" aria-controls="menu-mobile" aria-expanded="false" aria-labelledby="menu-mobile">
<span></span><span></span><span></span>
</button>
</div>
<nav>
<ul class="menu" id="menu-mobile">
{{- $currentPage := . -}}
{{- range .Site.Menus.main -}}
{{- $url := .URL -}}
{{- with $url -}}
{{- $url = . | relLangURL -}}
{{- end -}}
{{- with .Page -}}
{{- $url = .RelPermalink -}}
{{- end -}}
{{- if (ne .Params.Draft true) | or $buildDrafts | and (ne .Params.Type "desktop") -}}
<li class="menu-item{{ if $.IsMenuCurrent `main` . | or ($.HasMenuCurrent `main` .) | or (eq $.RelPermalink $url) }} active{{ end }}{{ with .Params.Class }} {{ . }}{{ end }}">
{{- if .HasChildren -}}
<span class="nested-item">
<a class="menu-link"
{{- with $url }} href="{{ $url }}"{{ else }} href="javascript:void(0);"{{ end }}
{{- with .Title }} title="{{ . }}"{{ end }}
{{- if (urls.Parse $url).Host }} rel="noopener noreferrer" target="_blank"{{ end -}}
>
{{- with .Pre -}}{{- . | safeHTML }} {{ end }}
{{- with .Params.Icon -}}{{ dict "Class" (printf "%v fa-sm" .) | partial "plugin/icon.html" }} {{ end }}
{{- .Name }}
{{- with .Post }} {{ . | safeHTML -}}{{- end -}}
</a>
{{ dict "Class" "dropdown-icon fa-solid fa-chevron-right" | partial "plugin/icon.html" }}
</span>
<ul class="sub-menu">
{{- range $k, $v := .Children -}}
{{- $url := $v.URL -}}
{{- with $url -}}
{{- $url = . | relLangURL -}}
{{- end -}}
{{- with $v.Page -}}
{{- $url = .RelPermalink -}}
{{- end -}}
{{- if (ne $v.Params.Draft true) | or $buildDrafts | and (ne $v.Params.Type "desktop") -}}
{{- if $k | and $v.Params.Divided -}}
<li class="menu-item menu-item-divider" aria-hidden="true"></li>
{{- end -}}
<li class="menu-item{{ if $.IsMenuCurrent `main` $v | or ($.HasMenuCurrent `main` $v) | or (eq $.RelPermalink $url) }} active{{ end }}{{ with $v.Params.Class }} {{ . }}{{ end }}">
<a class="menu-link"
{{- with $url }} href="{{ $url }}"{{ else }} href="javascript:void(0);"{{ end }}
{{- with $v.Title }} title="{{ . }}"{{ end }}
{{- if (urls.Parse $url).Host }}rel="noopener noreferrer" target="_blank"{{ end -}}
>
{{- with $v.Pre -}}{{- . | safeHTML }} {{ end }}
{{- with $v.Params.Icon -}}{{ dict "Class" (printf "%v fa-sm" .) | partial "plugin/icon.html" }} {{ end }}
{{- $v.Name }}
{{- with $v.Post }} {{ . | safeHTML -}}{{- end -}}
</a>
</li>
{{- end -}}
{{- end -}}
</ul>
{{- else -}}
<a class="menu-link"
{{- with $url }} href="{{ $url }}"{{ else }} href="javascript:void(0);"{{ end }}
{{- with .Title }} title="{{ . }}"{{ end }}
{{- if (urls.Parse $url).Host }} rel="noopener noreferrer" target="_blank"{{ end -}}
>
{{- with .Pre -}}{{- . | safeHTML }} {{ end }}
{{- with .Params.Icon -}}{{ dict "Class" (printf "%v fa-sm" .) | partial "plugin/icon.html" }} {{ end }}
{{- .Name }}
{{- with .Post }} {{ . | safeHTML -}}{{- end -}}
</a>
{{- end -}}
</li>
{{- end -}}
{{- end -}}
<li class="menu-item menu-system">
{{- if hugo.IsMultilingual -}}
<span class="menu-system-item language-switch">
<button type="button" aria-label="{{ T "header.selectLanguage" }}" title="{{ T "header.selectLanguage" }}">
{{- .Language.LanguageName -}}
{{- dict "Class" "dropdown-icon fa-solid fa-chevron-down" | partial "plugin/icon.html" -}}
</button>
<select id="language-select" class="language-select" onchange="location = this.value;">
{{- if eq .Kind "404" -}}
{{- range hugo.Sites -}}
{{- $link := printf "%v/404.html" .LanguagePrefix -}}
<option value="{{ $link }}"{{ if eq . $.Site }} selected disabled{{ end }}>
{{- .Language.LanguageName -}}
</option>
{{- end -}}
{{- else if .IsTranslated -}}
{{- range .AllTranslations -}}
<option value="{{ .RelPermalink }}"{{ if eq .Lang $.Lang }} selected disabled{{ end }}>
{{- .Language.LanguageName -}}
</option>
{{- end -}}
{{- else -}}
<option disabled>{{- T "header.noMoretTranslations" -}}</option>
{{- end -}}
</select>
</span>
{{- end -}}
{{- /* Custom menu items in the mobile header */ -}}
{{- block "custom-menu:mobile" . }}{{ end -}}
</li>
</ul>
</nav>
</div>
</header>