From a4d41717fb1fbf78107f50b1372d7bafff7c011a Mon Sep 17 00:00:00 2001 From: eltrac Date: Mon, 30 Mar 2026 17:45:24 +0800 Subject: perf: reduce rotate-* classes and use style attr instead --- assets/css/utils/_utility.scss | 10 ++++++++++ layouts/_partials/posts/webmention-summary.html | 13 +++++++------ layouts/fiction/section.html | 10 +++------- uno.config.js | 3 --- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/assets/css/utils/_utility.scss b/assets/css/utils/_utility.scss index ce11796c..b37cc742 100644 --- a/assets/css/utils/_utility.scss +++ b/assets/css/utils/_utility.scss @@ -50,3 +50,13 @@ details.no-mark summary::marker { content: "" } content-visibility: auto; contain-intrinsic-size: auto 500px; } + +/* Dynamic rotation for webmention avatars */ +.group:hover img[style*="--rotate-amount"] { + transform: rotate(var(--rotate-amount)); +} + +/* Dynamic rotation for fiction section items */ +div[style*="--rotation-deg"]:hover { + transform: rotate(0deg) scale(1.1) !important; +} diff --git a/layouts/_partials/posts/webmention-summary.html b/layouts/_partials/posts/webmention-summary.html index 5dd6bb77..a3a7265d 100644 --- a/layouts/_partials/posts/webmention-summary.html +++ b/layouts/_partials/posts/webmention-summary.html @@ -18,12 +18,13 @@ {{ $author := index (index $authors 0) "properties" }} {{ $photo := or (index . "extra" "proxied-photo") (index $author.photo 0) }} - - {{ $value := math.Floor (mul math.Rand 80) }} - {{ $rotate := cond (lt $value 40) (sub 10 $value) (sub $value 30) }} - Profile Picture + + {{ $value := math.Floor (mul math.Rand 80) }} + {{ $rotate := cond (lt $value 40) (sub 10 $value) (sub $value 30) }} + Profile Picture {{ end }}
diff --git a/layouts/fiction/section.html b/layouts/fiction/section.html index beda5ba2..9bbf122f 100644 --- a/layouts/fiction/section.html +++ b/layouts/fiction/section.html @@ -7,19 +7,15 @@ {{ $rotationDeg := add (math.Floor (mul (math.Rand) 7)) -4 }} {{- $deg := int $rotationDeg -}} - {{- $rotateClass := cond (ge $deg 0) - (printf "rotate-%d" $deg) - (printf "-rotate-%d" (mul -1 $deg)) - -}} {{ $steps := slice 60 70 80 90 100 }} {{ $opacity := index $steps (int (math.Floor (mul (math.Rand) 5))) }} {{ $opacityClass := printf "opacity-%d" $opacity }}
+ {{ $opacityClass }} + transition hover:opacity-100 hover:scale-110" + style="view-transition-name: post-{{ .File.UniqueID }}; {{ if ne $deg 0 }}--rotation-deg: {{ $deg }}deg; transform: rotate({{ $deg }}deg);{{ end }}"> 《{{ .Title }}》
{{- end }} diff --git a/uno.config.js b/uno.config.js index a627b272..61831a43 100644 --- a/uno.config.js +++ b/uno.config.js @@ -40,9 +40,6 @@ export default defineConfig({ ...'absolute bottom-full left-1/2 transform -translate-x-1/2 translate-y-1 bg-black/80 text-white px-2.5 py-1.5 rounded text-xs whitespace-nowrap opacity-0 invisible transition-all duration-300 pointer-events-none mb-2 z-1000 group-hover:opacity-100 group-hover:visible group-hover:translate-y-0 dark:bg-white/90 dark:text-black'.split(' '), ...range(10, i => `opacity-${i * 10}`), - ...rangeWithPrefixes(50, 'rotate', ['', '-', 'group-hover:', 'group-hover:-']), - ...rangeWithPrefixes(5, 'translate-x', ['', '-']), - ...rangeWithPrefixes(5, 'translate-y', ['', '-']), ...rangeWithPrefixes(30, 'w', ['', 'md:', 'lg:']), ...rangeWithPrefixes(30, 'h', ['', 'md:']), ...rangeWithPrefixes(30, 'right', ['', 'md:', '-', 'md:-']), -- cgit v1.2.3