From c8ac87835378df557a24292c16bc15eeeac0b183 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Wed, 26 Nov 2025 13:08:35 -0600 Subject: [PATCH] Polish banned states and confirm --- app/assets/images/cancel.svg | 1 + app/assets/stylesheets/avatars.css | 20 ++++++++++++++++++++ app/views/accounts/users/_user.html.erb | 2 +- app/views/users/_ban_button.html.erb | 12 +++++++----- app/views/users/show.html.erb | 2 +- 5 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 app/assets/images/cancel.svg diff --git a/app/assets/images/cancel.svg b/app/assets/images/cancel.svg new file mode 100644 index 0000000..3327c05 --- /dev/null +++ b/app/assets/images/cancel.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/stylesheets/avatars.css b/app/assets/stylesheets/avatars.css index 4407272..9c3b520 100644 --- a/app/assets/stylesheets/avatars.css +++ b/app/assets/stylesheets/avatars.css @@ -7,6 +7,7 @@ inline-size: var(--avatar-size, 5ch); margin: 0; place-items: center; + position: relative; img { aspect-ratio: 1; @@ -16,6 +17,25 @@ inline-size: var(--avatar-size, 5ch); max-inline-size: 100%; object-fit: cover; + + .banned & { + opacity: 0.5; + } + } + + .banned &:after { + background: url(cancel.svg) no-repeat center center; + block-size: auto; + content: ""; + filter: invert(0%); + inline-size: var(--avatar-size, 5ch); + inset: 0; + max-inline-size: 100%; + position: absolute; + + @media (prefers-color-scheme: dark) { + filter: invert(100%); + } } } diff --git a/app/views/accounts/users/_user.html.erb b/app/views/accounts/users/_user.html.erb index 4f5f952..470e7f8 100644 --- a/app/views/accounts/users/_user.html.erb +++ b/app/views/accounts/users/_user.html.erb @@ -1,4 +1,4 @@ -
  • "> +
  • ">
    <%= avatar_tag user, loading: :lazy %>
    diff --git a/app/views/users/_ban_button.html.erb b/app/views/users/_ban_button.html.erb index 398b738..3cfab48 100644 --- a/app/views/users/_ban_button.html.erb +++ b/app/views/users/_ban_button.html.erb @@ -1,13 +1,15 @@ <% if user.active? %> <%= button_to user_ban_path(user), method: :post, - class: "btn btn--negative full-width", - data: { turbo_confirm: "Are you sure you want to ban this user?" } do %> - Ban user + class: "btn full-width", + data: { turbo_confirm: "Are you sure you want to ban this user? This will log them out, delete their messages, and block their IP addresses." } do %> + <%= image_tag "cancel.svg", aria: { hidden: "true", label: "Ban #{@user.name}" } %> + Ban <%= user.name %> <% end %> <% else %> <%= button_to user_ban_path(user), method: :delete, - class: "btn full-width", + class: "btn btn--negative full-width", data: { turbo_confirm: "Are you sure you want to remove the ban on this user?" } do %> - Remove ban + <%= image_tag "cancel.svg", aria: { hidden: "true", label: "Ban #{@user.name}" } %> + Remove ban <% end %> <% end %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 94872e6..8fb4a28 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -16,7 +16,7 @@ <% end %>
    -
    +
    ">
    <%= image_tag fresh_user_avatar_path(@user), alt: "Profile avatar", class: "avatar" %>