From 035c5f97a1743e7a8d25908f4c89606422a76cdd Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Wed, 17 Dec 2025 10:09:35 +0100 Subject: [PATCH 1/6] Use simpler selectors to target system comments --- app/assets/stylesheets/comments.css | 43 ++++++++++++---------- app/views/cards/comments/_comment.html.erb | 2 +- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/app/assets/stylesheets/comments.css b/app/assets/stylesheets/comments.css index 45c98fb13..7a434716e 100644 --- a/app/assets/stylesheets/comments.css +++ b/app/assets/stylesheets/comments.css @@ -96,7 +96,6 @@ .comment--system { --comment-padding-block: var(--block-space-half); - display: none; max-inline-size: var(--comment-max); text-align: center; transition: var(--dialog-duration) allow-discrete; @@ -106,24 +105,6 @@ display: flex; } - &:nth-last-child(1 of &):not(:has(~ * &) *):not(:has(~ &) *):not(:has(~ * &)):not(:has(&)) { - /* This unholy selector targets the last system comment in the document */ - /* Hat-tip, https://css-tip.com/last-element-dom/ */ - display: flex; - - .comment__history { - display: grid; - } - } - - &:nth-child(1 of &):not(:has(&) ~ * *):not(:has(&) ~ *):not(& ~ * *):not(& *) { - /* Targets the first system comment in the document to effectively */ - /* hide the "Show history" button if there's only one entry */ - .comment__history { - display: none; - } - } - &::before { /* Make up space for lack of avatar */ content: ""; @@ -176,4 +157,28 @@ display: none !important; } } + + .comment-wrapper--system { + display: none; + + .comments--system-expanded & { + display: flex; + } + } + + /* Show the last system comment */ + :nth-last-child(1 of .comment-wrapper--system) { + display: flex; + + .comment__history { + display: grid; + } + } + + /* Hide the "Show history" button if there's only one system comment */ + :nth-child(1 of .comment-wrapper--system) { + .comment__history { + display: none; + } + } } diff --git a/app/views/cards/comments/_comment.html.erb b/app/views/cards/comments/_comment.html.erb index de2b94c0d..c7f0a2480 100644 --- a/app/views/cards/comments/_comment.html.erb +++ b/app/views/cards/comments/_comment.html.erb @@ -1,6 +1,6 @@ <% cache comment do %> <%# Helper Dependency Updated: avatar_image_tag 2025-12-15 %> - <%= turbo_frame_tag comment, :container do %> + <%= turbo_frame_tag comment, :container, class: ["comment-wrapper", { "comment-wrapper--system": comment.creator.system? }] do %> <%# Cache bump 2025-12-14: action text attachment rendering changed for lightbox -%>
">