From f662c9aa0f6318cb76159fcf87d500c0462d0986 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Wed, 2 Apr 2025 13:19:51 -0500 Subject: [PATCH 1/6] Add mask icon helper --- app/assets/stylesheets/icons.css | 72 ++++++++++++++++++++++++++++++++ app/helpers/icons_helper.rb | 8 ++++ 2 files changed, 80 insertions(+) create mode 100644 app/assets/stylesheets/icons.css create mode 100644 app/helpers/icons_helper.rb diff --git a/app/assets/stylesheets/icons.css b/app/assets/stylesheets/icons.css new file mode 100644 index 000000000..f6040a424 --- /dev/null +++ b/app/assets/stylesheets/icons.css @@ -0,0 +1,72 @@ +.icon { + -webkit-touch-callout: none; + background-color: currentColor; + block-size: var(--icon-size, 1em); + display: inline-block; + flex-shrink: 0; + inline-size: var(--icon-size, 1em); + mask-image: var(--svg); + mask-repeat: no-repeat; + mask-size: cover; +} + +.icon--activity { --svg: url("activity.svg "); } +.icon--add { --svg: url("add.svg "); } +.icon--alert { --svg: url("alert.svg "); } +.icon--arrow-left { --svg: url("arrow-left.svg "); } +.icon--arrow-right { --svg: url("arrow-right.svg "); } +.icon--art { --svg: url("art.svg "); } +.icon--assigned { --svg: url("assigned.svg "); } +.icon--bell-off { --svg: url("bell-off.svg "); } +.icon--bell { --svg: url("bell.svg "); } +.icon--blob { --svg: url("blob.svg "); } +.icon--bolt { --svg: url("bolt.svg "); } +.icon--bookmark-outline { --svg: url("bookmark-outline.svg "); } +.icon--bookmark { --svg: url("bookmark.svg "); } +.icon--bubble-add { --svg: url("bubble-add.svg "); } +.icon--bubbles { --svg: url("bubbles.svg "); } +.icon--calendar-add { --svg: url("calendar-add.svg "); } +.icon--calendar { --svg: url("calendar.svg "); } +.icon--camera { --svg: url("camera.svg "); } +.icon--chart { --svg: url("chart.svg "); } +.icon--check { --svg: url("check.svg "); } +.icon--close { --svg: url("close.svg "); } +.icon--comment { --svg: url("comment.svg "); } +.icon--copy-paste { --svg: url("copy-paste.svg "); } +.icon--crown { --svg: url("crown.svg "); } +.icon--drag { --svg: url("drag.svg "); } +.icon--email { --svg: url("email.svg "); } +.icon--everyone { --svg: url("everyone.svg "); } +.icon--filter { --svg: url("filter.svg "); } +.icon--globe { --svg: url("globe.svg "); } +.icon--grid { --svg: url("grid.svg "); } +.icon--history { --svg: url("history.svg "); } +.icon--home { --svg: url("home.svg "); } +.icon--hourglass { --svg: url("hourglass.svg "); } +.icon--inbox { --svg: url("inbox.svg "); } +.icon--logout { --svg: url("logout.svg "); } +.icon--menu-dots-horizontal { --svg: url("menu-dots-horizontal.svg "); } +.icon--minus { --svg: url("minus.svg "); } +.icon--password { --svg: url("password.svg "); } +.icon--pencil { --svg: url("pencil.svg "); } +.icon--person { --svg: url("person.svg "); } +.icon--picture-add { --svg: url("picture-add.svg "); } +.icon--picture-double { --svg: url("picture-double.svg "); } +.icon--picture-remove { --svg: url("picture-remove.svg "); } +.icon--pinned { --svg: url("pinned.svg "); } +.icon--pop { --svg: url("pop.svg "); } +.icon--qr-code { --svg: url("qr-code.svg "); } +.icon--reaction { --svg: url("reaction.svg "); } +.icon--refresh { --svg: url("refresh.svg "); } +.icon--remove-med { --svg: url("remove-med.svg "); } +.icon--remove { --svg: url("remove.svg "); } +.icon--rename { --svg: url("rename.svg "); } +.icon--settings { --svg: url("settings.svg "); } +.icon--share { --svg: url("share.svg "); } +.icon--sort-ascending { --svg: url("sort-ascending.svg "); } +.icon--sort-descending { --svg: url("sort-descending.svg "); } +.icon--tag { --svg: url("tag.svg "); } +.icon--temperature { --svg: url("temperature.svg "); } +.icon--thumb-up { --svg: url("thumb-up.svg "); } +.icon--trash { --svg: url("trash.svg "); } +.icon--unpinned { --svg: url("unpinned.svg"); } diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb new file mode 100644 index 000000000..f441aa50d --- /dev/null +++ b/app/helpers/icons_helper.rb @@ -0,0 +1,8 @@ +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 From b8a1acefd8c3e562acbff2233c194e8143b4be5a Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Wed, 2 Apr 2025 14:22:42 -0500 Subject: [PATCH 2/6] 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 %> From 51d907fca36a20681ea28d3829ec16be1f5e5255 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Wed, 2 Apr 2025 14:32:21 -0500 Subject: [PATCH 3/6] Replace stray image_tag instances and remove colorize class --- app/assets/stylesheets/colors.css | 16 ---------------- app/views/accounts/users/_invite.html.erb | 6 +++--- app/views/buckets/_access_toggle.erb | 2 +- app/views/buckets/edit.html.erb | 2 +- app/views/comments/_body.html.erb | 6 +++--- app/views/events/_event.html.erb | 6 +++--- app/views/first_runs/show.html.erb | 6 +++--- app/views/sessions/new.html.erb | 4 ++-- app/views/users/_transfer.html.erb | 4 ++-- app/views/users/edit.html.erb | 6 +++--- app/views/users/new.html.erb | 6 +++--- 11 files changed, 24 insertions(+), 40 deletions(-) diff --git a/app/assets/stylesheets/colors.css b/app/assets/stylesheets/colors.css index 354c24011..79e852697 100644 --- a/app/assets/stylesheets/colors.css +++ b/app/assets/stylesheets/colors.css @@ -54,22 +54,6 @@ } } -.colorize--white { - filter: invert(1); - - @media (prefers-color-scheme: dark) { - filter: invert(0); - } -} - -.colorize--black { - filter: invert(0); - - @media (prefers-color-scheme: dark) { - filter: invert(1); - } -} - .color-picker { --panel-border-color: var(--bubble-color); --panel-border-radius: 2em; diff --git a/app/views/accounts/users/_invite.html.erb b/app/views/accounts/users/_invite.html.erb index 37128deb4..e064d74bb 100644 --- a/app/views/accounts/users/_invite.html.erb +++ b/app/views/accounts/users/_invite.html.erb @@ -11,7 +11,7 @@
<%= tag.button class: "btn", data: { action: "dialog#open" } do %> - <%= image_tag "qr-code.svg", aria: { hidden: "true" }, size: 24, class: "colorize--black" %> + <%= icon_tag "qr-code" %> Show join link QR code <% end %> @@ -28,12 +28,12 @@
<%= button_to_copy_to_clipboard(url) do %> - <%= image_tag "copy-paste.svg", aria: { hidden: "true" }, size: 24, class: "colorize--black" %> + <%= icon_tag "copy-paste" %> Copy join link <% end %> <%= button_to account_join_code_path, method: :put, class: "btn btn--regenerate" do %> - <%= image_tag "refresh.svg", aria: { hidden: "true" }, size: 24, class: "colorize--black" %> + <%= icon_tag "refresh" %> Regenerate join link <% end %>
diff --git a/app/views/buckets/_access_toggle.erb b/app/views/buckets/_access_toggle.erb index 1b2482ef4..b45067866 100644 --- a/app/views/buckets/_access_toggle.erb +++ b/app/views/buckets/_access_toggle.erb @@ -11,7 +11,7 @@ - <%= image_tag "check.svg", size: 20, class: "toggler__visible-when-on colorize--black flex-item-no-shrink", aria: { hidden: "true" } %> + <%= icon_tag "check", class: "toggler__visible-when-on" %>