Files
FixIt/assets/scss/core/layouts/_header.scss
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

499 lines
10 KiB
SCSS

@use "core/functions" as *;
@use "core/mixins" as *;
@use "variables" as *;
$header-box-shadow: 0 0 1.5rem 0 light-dark(rgba(0, 0, 0, 0.125), rgba(255, 255, 255, 0.125));
header {
width: 100%;
transition: box-shadow 0.3s ease;
background-color: fi-var(header-background-color);
@include z-index(fixed);
&:hover {
box-shadow: $header-box-shadow;
}
@include scroll-state-query('scroller', 'scroll-state(scrollable: top)') {
box-shadow: $header-box-shadow;
}
&.is-blur {
@include scroll-state-query('scroller', 'scroll-state(scrollable: top)', '&') {
background-color: transparent;
backdrop-filter: saturate(1.2) blur(10px);
background-size: 4px 4px;
background-image: radial-gradient(transparent 1px, fi-var(header-background-color) 1px);
}
}
&.animate__animated.header__fadeInDown {
animation-name: #{$prefix}header-fade-in-down;
}
&.animate__animated.header__fadeOutUp {
animation-name: #{$prefix}header-fade-out-up;
}
@include media('print') {
display: none !important;
}
}
@keyframes #{$prefix}header-fade-in-down {
from {
translate: 0 -100% 0;
visibility: visible;
}
to {
translate: 0 0 0;
}
}
@keyframes #{$prefix}header-fade-out-up {
from {
translate: 0 0 0;
}
to {
visibility: hidden;
translate: 0 -100% 0;
}
}
.header-wrapper {
display: flex;
justify-content: space-between;
align-items: center;
gap: 0.75rem;
box-sizing: border-box;
width: 100%;
}
.header-title {
font-size: fi-var(header-title-font-size);
font-family: fi-var(header-title-font-family);
font-weight: bold;
line-height: 1;
padding: 0.25rem;
min-width: 10%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
flex: 10;
display: flex;
align-items: flex-end;
gap: 0.25rem;
.header-title-link {
display: flex;
align-items: center;
gap: 0.25rem;
// recommended size: 32px * 32px
.logo {
height: 32px;
width: auto;
}
}
.header-subtitle {
font-size: 0.75rem;
line-height: fi-var(header-title-font-size);
}
}
.menu {
margin: 0;
padding: 0;
.menu-item-divider {
list-style: none;
margin: 0.25rem 0.5rem;
height: 1px;
background-color: fi-var(menu-border-color);
}
.menu-item {
list-style: none;
.dropdown-icon {
margin-left: 0.25rem;
font-size: .875em;
color: fi-var(global-font-color);
&.open::before {
content: "\f078";
}
}
&.active {
>.menu-link,
>.nested-item>.menu-link {
font-weight: bold;
color: fi-var(menu-active-color);
}
}
.menu-link[href="javascript:void(0);"] {
color: inherit;
}
.menu-link i {
transform: perspective(1rem);
transition: transform 0.4s ease;
}
.menu-link:hover i {
transform: perspective(1rem) translateZ(0.2rem);
}
}
}
.theme-switch {
position: relative;
@include focus-visible-ring;
i {
display: inline-block;
rotate: 225deg;
scale: 1;
transform-origin: center;
@include theme-switch-mode('auto');
@include theme-switch-mode('light', '\f185');
@include theme-switch-mode('dark', '\f186');
@include media('reduce-motion') {
animation: none !important;
}
}
@include theme-switch-keyframes('auto', 180deg, 0.9, 0.7, 60%, 245deg, 1.08);
@include theme-switch-keyframes('light', 140deg, 0.82, 0.55, 55%, 250deg, 1.12);
@include theme-switch-keyframes('dark', 310deg, 0.86, 0.55, 55%, 205deg, 1.08);
}
#header-desktop {
display: block;
position: sticky;
top: 0;
height: fi-var(header-height);
line-height: fi-var(header-height);
box-sizing: border-box;
[data-header-desktop='normal'] & {
position: static;
}
nav {
overflow: hidden;
white-space: nowrap;
}
.header-wrapper {
padding: 0 2rem;
height: 100%;
&[data-github-corner='left'] {
padding-inline-start: fi-var(header-height);
}
&[data-github-corner='right'] {
padding-inline-end: fi-var(header-height);
}
.menu {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
> .menu-item {
&:hover .sub-menu {
display: block;
translate: -0.5rem 0;
}
&.language-switch:hover .sub-menu {
translate: calc(2.25rem - 100%) 0;
}
}
.menu-item {
padding: 0 0.5rem;
&.search {
display: flex;
align-items: center;
}
&.delimiter {
width: 0;
margin: 18.5px 0.5rem;
padding: 0;
border-left: 1.5px solid fi-var(global-border-color);
}
}
.sub-menu {
position: absolute;
margin: 0;
padding: 0.25rem 0;
display: none;
top: calc(#{fi-var(header-height)} - 0.75rem);
border: 1px solid fi-var(menu-border-color);
background-color: fi-var(header-background-color);
max-height: 60vh;
overflow-y: auto;
overscroll-behavior: contain;
transition: box-shadow 0.3s ease;
@include border-radius;
box-shadow: 0 0 1.5rem 0 light-dark(rgba(0, 0, 0, 0.1), rgba(255, 255, 255, 0.1));
.menu-item {
height: fi-var(submenu-height);
line-height: fi-var(submenu-height);
max-width: 15rem;
white-space: nowrap;
text-overflow: ellipsis;
overflow-x: hidden;
}
}
}
@include media('md', 'down') {
padding-inline: 1rem;
}
}
.search-trigger {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.375rem 0.75rem;
border: 1px solid fi-var(global-border-color-light);
background-color: fi-var(search-background-color);
color: fi-var(global-font-tertiary-color);
white-space: nowrap;
font-size: 0.875rem;
transition: color 0.2s, border-color 0.2s;
@include border-radius(0.5rem);
&:hover {
color: fi-var(global-font-color);
border-color: fi-var(global-border-color);
}
kbd {
padding: 0.0625rem 0.375rem;
font-family: inherit;
font-size: 0.6875rem;
line-height: 1.5;
background-color: light-dark(#dfe1e4, #353b45);
border: 1px solid fi-var(global-border-color);
@include border-radius(0.25rem);
&::after {
content: 'Ctrl K';
}
}
[data-platform='mac'] & kbd::after {
content: '⌘ K';
}
}
@include media('xs') {
display: none;
}
}
#header-mobile {
position: sticky;
top: 0;
height: fi-var(header-height);
line-height: fi-var(header-height);
[data-header-mobile='normal'] & {
position: static;
}
.header-container {
padding: 0;
margin: 0;
height: fi-var(header-height);
position: relative;
.header-wrapper {
height: 100%;
padding: 0 1rem;
font-size: 1.125rem;
transition: margin-top 0.3s ease;
.header-title {
max-width: 80%;
}
.search-trigger {
position: relative;
@include focus-visible-ring;
}
.search-trigger,
.theme-switch {
line-height: 1.25em;
}
.menu-toggle {
position: relative;
@include focus-visible-ring;
span {
display: block;
background-color: fi-var(global-font-color);
width: 20px;
height: 2px;
transition: all 0.3s ease-in-out;
@include border-radius(full);
}
span:not(:last-child) {
margin-bottom: 6px;
}
&.active {
span:nth-child(1) {
translate: 0 8px;
rotate: 45deg;
}
span:nth-child(2) {
opacity: 0;
}
span:nth-child(3) {
translate: 0 -8px;
rotate: -45deg;
}
}
}
}
.menu {
background-color: fi-var(header-background-color);
border-top: 2px solid fi-var(global-border-color-light);
display: none;
overflow-y: auto;
overscroll-behavior: contain;
max-height: 70vh;
box-shadow: 0 0.125rem 0.25rem light-dark(rgba(0, 0, 0, 0.1), rgba(255, 255, 255, 0.1));
@include scrollbar-width(none, 0);
.search-wrapper {
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
padding: 0.5rem 1rem;
position: sticky;
top: 0;
background-color: fi-var(header-background-color);
@include z-index(sticky);
}
.menu-item {
display: block;
position: relative;
line-height: 2.5rem;
padding: 0 1rem;
&:not(.menu-system):hover {
background-color: light-dark(#f2f2f3, #535355);
}
.menu-link {
display: block;
white-space: nowrap;
text-overflow: ellipsis;
overflow-x: hidden;
flex: 4;
}
& .nested-item {
display: flex;
justify-content: space-between;
align-items: center;
.menu-link {
max-width: 80%;
}
}
}
.menu-system {
display: flex;
justify-content: center;
gap: 0.25rem;
position: sticky;
bottom: 0;
line-height: 2.5rem;
padding: 0 1rem;
background-color: fi-var(header-background-color);
.menu-system-item {
padding-inline: 0.5rem;
}
.language-switch {
position: relative;
.language-select {
position: absolute;
opacity: 0;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
}
}
.sub-menu {
padding-left: 0;
display: none;
&.open {
display: block;
}
.menu-item:hover {
background-color: light-dark(#e7e7ea, #5d5d5f);
}
}
&.active {
display: block;
}
}
}
&.open {
.header-wrapper {
margin-top: calc(#{fi-var(header-height)} * -1);
}
.menu {
padding-top: 0;
border-top: none;
.menu-item {
display: none;
}
}
}
@include media('sm', 'up') {
display: none;
}
}