From b8a1acefd8c3e562acbff2233c194e8143b4be5a Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Wed, 2 Apr 2025 14:22:42 -0500 Subject: [PATCH] Use mask icons everywhere --- app/assets/stylesheets/buttons.css | 19 +++++++------------ app/assets/stylesheets/icons.css | 2 ++ app/helpers/application_helper.rb | 7 +++++-- app/helpers/icons_helper.rb | 8 -------- app/views/comments/edit.html.erb | 2 +- app/views/events/_filter.html.erb | 8 ++++---- app/views/filters/_assignees.html.erb | 14 +++++++------- app/views/filters/_buckets.html.erb | 8 ++++---- app/views/filters/_creators.html.erb | 10 +++++----- app/views/filters/_dialog.html.erb | 4 ++-- app/views/filters/_indexed_by.html.erb | 12 ++++++------ app/views/filters/_stages.html.erb | 6 +++--- app/views/filters/_tags.html.erb | 12 ++++++------ 13 files changed, 52 insertions(+), 60 deletions(-) delete mode 100644 app/helpers/icons_helper.rb diff --git a/app/assets/stylesheets/buttons.css b/app/assets/stylesheets/buttons.css index ee383e95b..572775e25 100644 --- a/app/assets/stylesheets/buttons.css +++ b/app/assets/stylesheets/buttons.css @@ -27,18 +27,12 @@ opacity var( --transition), scale var( --transition); - img { - -webkit-touch-callout: none; - - pointer-events: none; - user-select: none; - } - /* Default icon styles */ - &:where(:has(img, svg)) { + &:where(:has(.icon, img, svg)) { text-align: start; - img, svg { + .icon, img, svg { + --icon-size: var(--btn-icon-size, 1.3em); block-size: var(--btn-icon-size, 1.3em); inline-size: var(--btn-icon-size, 1.3em); max-inline-size: unset; @@ -70,7 +64,8 @@ grid-area: 1/1; } - img { + .icon, img { + --icon-size: 100%; block-size: 100%; inline-size: 100%; max-inline-size: unset; @@ -85,7 +80,7 @@ /* Circle buttons */ &.btn--circle, - &:where(:has(.for-screen-reader):has(img, svg)) { + &:where(:has(.for-screen-reader):has(.icon, img, svg)) { --btn-border-radius: 50%; --btn-padding: 0; @@ -108,7 +103,7 @@ :is(input[type=radio]), :is(input[type=checkbox]) { --hover-size: 0; - + appearance: none; border-radius: var(--btn-border-radius); cursor: pointer; diff --git a/app/assets/stylesheets/icons.css b/app/assets/stylesheets/icons.css index f6040a424..6fab09ef1 100644 --- a/app/assets/stylesheets/icons.css +++ b/app/assets/stylesheets/icons.css @@ -8,6 +8,8 @@ mask-image: var(--svg); mask-repeat: no-repeat; mask-size: cover; + pointer-events: none; + user-select: none; } .icon--activity { --svg: url("activity.svg "); } diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4ceb92d12..a4d9e9ec5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3,7 +3,10 @@ module ApplicationHelper tag.title @page_title || "Fizzy" end - def icon_tag(name, aria: { hidden: true }, size: 24, **options) - image_tag "#{name}.svg", aria: aria, size: size, **options + def icon_tag(name, **options) + classes = class_names "icon icon--#{name}", options.delete(:class) + options["aria-hidden"] = true + + content_tag :span, "", class: classes, **options end end diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb deleted file mode 100644 index f441aa50d..000000000 --- a/app/helpers/icons_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -module IconsHelper - def icon(name, **options) - classes = class_names "icon icon--#{name}", options.delete(:class) - options["aria-hidden"] = true - - content_tag :span, "", class: classes, **options - end -end diff --git a/app/views/comments/edit.html.erb b/app/views/comments/edit.html.erb index a47b29369..e7d120acc 100644 --- a/app/views/comments/edit.html.erb +++ b/app/views/comments/edit.html.erb @@ -14,7 +14,7 @@ <%= tag.button type: :submit, class: "btn btn--negative flex-item-justify-end", form: dom_id(@comment, :delete_form), data: { turbo_confirm: "Are you sure you want to delete this comment?" } do %> - <%= icon_tag "trash", size: 16 %> + <%= icon_tag "trash" %> Delete <% end %> diff --git a/app/views/events/_filter.html.erb b/app/views/events/_filter.html.erb index bca5bbeb7..b791ea1c7 100644 --- a/app/views/events/_filter.html.erb +++ b/app/views/events/_filter.html.erb @@ -7,22 +7,22 @@ - Filter by Collection… - <%= form_with url: events_path, method: :get, class: "flex flex-column full-width popup__list", + <%= form_with url: events_path, method: :get, class: "flex flex-column full-width popup__list", data: { controller: "form" } do |form| %> <%= link_to "Show everything", events_path(clear_filter: true), class: "btn popup__item txt-nowrap" %> <% @buckets.each do |bucket| %> <% end %> <% end %> diff --git a/app/views/filters/_assignees.html.erb b/app/views/filters/_assignees.html.erb index 500d5c720..2fe0c9564 100644 --- a/app/views/filters/_assignees.html.erb +++ b/app/views/filters/_assignees.html.erb @@ -14,37 +14,37 @@ Assigned to… - <%= form_with url: bubbles_path, method: :get, class: "flex flex-column full-width popup__list", + <%= form_with url: bubbles_path, method: :get, class: "flex flex-column full-width popup__list", data: { controller: "form" } do |form| %> <% filter.as_params.except(:assignee_ids, :assignment_status).each do |key, value| %> <%= filter_hidden_field_tag key, value %> <% end %> - + <%= link_to bubbles_path(filter.as_params.except(:assignee_ids, :assignment_status)), class: "btn popup__item" do %> Clear all <% end %> - + <% Current.account.users.active.order(:name).each do |user| %> <% end %> <% end %> diff --git a/app/views/filters/_buckets.html.erb b/app/views/filters/_buckets.html.erb index 20449c917..2d03acf93 100644 --- a/app/views/filters/_buckets.html.erb +++ b/app/views/filters/_buckets.html.erb @@ -11,22 +11,22 @@ In Collection - <%= form_with url: bubbles_path, method: :get, class: "flex flex-column full-width popup__list", + <%= form_with url: bubbles_path, method: :get, class: "flex flex-column full-width popup__list", data: { controller: "form" } do |form| %> <% filter.as_params.except(:bucket_ids).each do |key, value| %> <%= filter_hidden_field_tag key, value %> <% end %> - + <% Current.user.buckets.order(:name).each do |bucket| %> <% end %> <% end %> diff --git a/app/views/filters/_creators.html.erb b/app/views/filters/_creators.html.erb index 557778c09..cacfc40c5 100644 --- a/app/views/filters/_creators.html.erb +++ b/app/views/filters/_creators.html.erb @@ -1,5 +1,5 @@ <% if filter.creators.any? %> -
- Added by… - <%= form_with url: bubbles_path, method: :get, class: "flex flex-column full-width popup__list", + <%= form_with url: bubbles_path, method: :get, class: "flex flex-column full-width popup__list", data: { controller: "form" } do |form| %> <% filter.as_params.except(:creator_ids).each do |key, value| %> <%= filter_hidden_field_tag key, value %> @@ -34,7 +34,7 @@ }, Current.user.id %> <%= form.label :creator_ids, "Me", for: form.field_id(:creator_ids, Current.user.id), class: "overflow-ellipsis" %> - <%= icon_tag "check", size: 18, class: "checked flex-item-justify-end" %> + <%= icon_tag "check", class: "checked flex-item-justify-end" %>
<% Current.account.users.active.without(Current.user).order(:name).each do |user| %> @@ -47,7 +47,7 @@ }, user.id %> <%= form.label :creator_ids, user.name, for: form.field_id(:creator_ids, user.id), class: "overflow-ellipsis" %> - <%= icon_tag "check", size: 18, class: "checked flex-item-justify-end" %> + <%= icon_tag "check", class: "checked flex-item-justify-end" %> <% end %> <% end %> diff --git a/app/views/filters/_dialog.html.erb b/app/views/filters/_dialog.html.erb index ecf1c1b9a..79db59813 100644 --- a/app/views/filters/_dialog.html.erb +++ b/app/views/filters/_dialog.html.erb @@ -4,7 +4,7 @@

- <%= icon_tag "filter", size: 30 %> + <%= icon_tag "filter" %> Filter

@@ -116,7 +116,7 @@
- + diff --git a/app/views/filters/_stages.html.erb b/app/views/filters/_stages.html.erb index 3d4a6203f..1b736da94 100644 --- a/app/views/filters/_stages.html.erb +++ b/app/views/filters/_stages.html.erb @@ -14,12 +14,12 @@ aria-label="In stage…" aria-description="In stage…" data-dialog-target="dialog" data-action="turbo:before-cache@document->dialog#close"> In stage… - <%= form_with url: bubbles_path, method: :get, class: "flex flex-column full-width popup__list", + <%= form_with url: bubbles_path, method: :get, class: "flex flex-column full-width popup__list", data: { controller: "form" } do |form| %> <% filter.as_params.except(:stage_ids).each do |key, value| %> <%= filter_hidden_field_tag key, value %> <% end %> - + <% workflow = Current.account.workflows.first %> <% workflow.stages.each do |stage| %> <% end %> <% end %> diff --git a/app/views/filters/_tags.html.erb b/app/views/filters/_tags.html.erb index 178f62098..4c6e28bc5 100644 --- a/app/views/filters/_tags.html.erb +++ b/app/views/filters/_tags.html.erb @@ -12,29 +12,29 @@ Tagged… - <%= form_with url: bubbles_path, method: :get, class: "flex flex-column full-width popup__list", + <%= form_with url: bubbles_path, method: :get, class: "flex flex-column full-width popup__list", data: { controller: "form" } do |form| %> <% filter.as_params.except(:tag_ids).each do |key, value| %> <%= filter_hidden_field_tag key, value %> <% end %> - + <%= link_to bubbles_path(filter.as_params.except(:tag_ids)), class: "btn popup__item" do %> Clear all <% end %> - + <% Current.account.tags.order(:title).each do |tag| %> <% end %> <% end %> - + <% end %>