From 3b180e590bbf9c3c8ec9a0b08416b6b9e6aed41d Mon Sep 17 00:00:00 2001 From: DokterKaj <54882101+DokterKaj@users.noreply.github.com> Date: Wed, 16 Oct 2024 00:40:12 +0800 Subject: [PATCH] simplify with `:focus-within` to fix right-click taking two tries + add "Unblur post" tooltip --- static/style.css | 77 +++++++++++++++++++++----------------------- templates/utils.html | 18 +++++------ 2 files changed, 45 insertions(+), 50 deletions(-) diff --git a/static/style.css b/static/style.css index 61d3235c..9130ce03 100644 --- a/static/style.css +++ b/static/style.css @@ -1141,8 +1141,8 @@ a.search_subreddit:hover { filter: blur(0.25rem); } -.post_blurred .post_thumbnail a * { - filter: blur(0.3rem); +.post_blurred .post_thumbnail * { + filter: blur(0.25rem); } /* Unblur on hover */ @@ -1150,50 +1150,45 @@ a.search_subreddit:hover { .post_blurred .post_media_content:not([tabindex]):hover ~ .post_body, .post_blurred .post_media_content:not([tabindex]):has(~ .post_body:hover) *, .post_blurred .post_body:not([tabindex]):hover, -.post_blurred .post_thumbnail:not([tabindex]):hover a * { +.post_blurred .post_thumbnail:not([tabindex]):hover * { filter: none; } /* Unblur on click */ -.post_blurred { - .post_media_content[tabindex], - .post_body[tabindex], - .post_thumbnail[tabindex] { - cursor: pointer; - /* Disable links when link is not focused */ - a:not(:focus) { - pointer-events: none; - } - } - - /* Enable links when content is focused */ - .post_media_content:focus a, - .post_media_content:focus ~ .post_body a, - .post_media_content:has(~ .post_body:focus) a, - .post_body:focus a, - .post_thumbnail:focus a, - /* Keep enabling links when a link is focused */ - .post_media_content:has(*:focus) a, - .post_media_content:has(*:focus) ~ .post_body a, - .post_media_content:has(~ .post_body a:focus) a, - .post_body:has(a:focus) a { - pointer-events: auto !important; - } +.post_blurred .post_media_content[tabindex]:not(:focus-within) *, +.post_blurred .post_body[tabindex]:not(:focus-within) a, +.post_blurred .post_thumbnail[tabindex]:not(:focus-within) a { + pointer-events: none; +} - /* Unblur when content is focused */ - .post_media_content:focus *, - .post_media_content:focus ~ .post_body, - .post_media_content:has(~ .post_body:focus) *, - .post_body:focus, - .post_thumbnail:focus a *, - /* Keep unblurring when link or video is focused */ - .post_media_content:has(*:focus) *, - .post_media_content:has(*:focus) ~ .post_body, - .post_media_content:has(~ .post_body a:focus) *, - .post_body:has(a:focus), - .post_thumbnail a:focus * { - filter: none; - } +.post_blurred .post_media_content[tabindex]:not(:focus-within), +.post_blurred .post_body[tabindex]:not(:focus-within), +.post_blurred .post_thumbnail[tabindex]:not(:focus-within) { + cursor: pointer; +} + +.post_blurred .post_media_content:focus-within *, +.post_blurred .post_media_content:focus-within ~ .post_body, +.post_blurred .post_media_content:has(~ .post_body:focus-within) *, +.post_blurred .post_body:focus-within, +.post_blurred .post_thumbnail:focus-within * { + filter: none; +} + +.post_blurred .post_media_content:focus-within *, +.post_blurred .post_media_content:focus-within ~ .post_body a, +.post_blurred .post_media_content:has(~ .post_body:focus-within) *, +.post_blurred .post_body:focus-within a, +.post_blurred .post_thumbnail:focus-within a { + pointer-events: unset !important; +} + +.post_blurred .post_media_content:focus-within, +.post_blurred .post_media_content:focus-within ~ .post_body, +.post_blurred .post_media_content:has(~ .post_body:focus-within), +.post_blurred .post_body:focus-within, +.post_blurred .post_thumbnail:focus-within { + cursor: unset !important; } .post_media_image svg { diff --git a/templates/utils.html b/templates/utils.html index 2355228a..8ac87edd 100644 --- a/templates/utils.html +++ b/templates/utils.html @@ -100,7 +100,7 @@