diff --git a/CHANGELOG.md b/CHANGELOG.md index 43e6587ce2d..e5723098bac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Unreleased ### Improvements/Changes - Layout: Improve layout margins and typographical consistency across several content pages. (#5880, #5884, #5887, #5888) - Typography: Updated monospace font to Roboto Mono for consistency across login.gov sites. (#5891) +- Icons: Replaced custom button icons using U.S. Web Design system icons. (#5904) ### Accessibility diff --git a/app/assets/images/ico-download.svg b/app/assets/images/ico-download.svg deleted file mode 100644 index bf23b5f8651..00000000000 --- a/app/assets/images/ico-download.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/app/assets/images/ico-print.svg b/app/assets/images/ico-print.svg deleted file mode 100644 index 83278594b97..00000000000 --- a/app/assets/images/ico-print.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/app/assets/images/ico-refresh.svg b/app/assets/images/ico-refresh.svg deleted file mode 100644 index 2c0081eaba6..00000000000 --- a/app/assets/images/ico-refresh.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/app/assets/stylesheets/components/_icon.scss b/app/assets/stylesheets/components/_icon.scss index 5314c2f3fe2..950369f8307 100644 --- a/app/assets/stylesheets/components/_icon.scss +++ b/app/assets/stylesheets/components/_icon.scss @@ -1,24 +1,18 @@ -.ico { - &::before { - background-repeat: no-repeat; - background-size: 1rem; - content: ''; - display: inline-block; - height: 1rem; - margin: -0.125rem 0.5rem -0.125rem 0; - width: 1rem; +// Upstream: https://github.com/uswds/uswds/pull/4493 +.usa-icon { + .usa-button > &:first-child { + // Note: This diverges from the upstream pull request in a couple ways: + // 1. There should not be any margins offsetting to account for line height, since Login.gov + // Design System normalizes button line height to 1. + // 2. Float is replaced by `vertical-align`, since otherwise it will have the effect of having + // the icon appear to the far edge of the button, rather than next to the text. + vertical-align: bottom; + margin-right: 0.25rem; } - &.ico-download::before { - background-image: url('ico-download.svg'); - } - - &.ico-refresh::before { - background-image: url('ico-refresh.svg'); - } - - &.ico-print::before { - background-image: url('ico-print.svg'); + .usa-button:not(.usa-button--unstyled) > &:first-child { + margin-left: -0.5rem; + margin-right: 0.5rem; } } diff --git a/app/assets/stylesheets/print.scss b/app/assets/stylesheets/print.scss index 0749d805c36..8292aa80dea 100644 --- a/app/assets/stylesheets/print.scss +++ b/app/assets/stylesheets/print.scss @@ -3,8 +3,7 @@ footer, .usa-button, .usa-radio__input--bordered, - .usa-checkbox__input--bordered, - .ico { + .usa-checkbox__input--bordered { display: none; } } diff --git a/app/components/button_component.html.erb b/app/components/button_component.html.erb index 762ac4b710b..2c95172424a 100644 --- a/app/components/button_component.html.erb +++ b/app/components/button_component.html.erb @@ -1 +1,6 @@ -<%= button_tag(content, **tag_options, type: tag_type, class: css_class) %> +<%= action.call( + safe_join([icon_content, content&.strip].compact), + **tag_options, + type: tag_type, + class: css_class, + ) %> diff --git a/app/components/button_component.rb b/app/components/button_component.rb index ad6ea90ac22..46d08ce8833 100644 --- a/app/components/button_component.rb +++ b/app/components/button_component.rb @@ -1,9 +1,16 @@ class ButtonComponent < BaseComponent - attr_reader :type, :outline, :tag_options + attr_reader :action, :icon, :outline, :tag_options DEFAULT_BUTTON_TYPE = :button - def initialize(outline: false, **tag_options) + def initialize( + action: ->(content, **tag_options) { button_tag(content, **tag_options) }, + icon: nil, + outline: false, + **tag_options + ) + @action = action + @icon = icon @outline = outline @tag_options = tag_options end @@ -17,4 +24,8 @@ def css_class def tag_type tag_options.fetch(:type, DEFAULT_BUTTON_TYPE) end + + def icon_content + render IconComponent.new(icon: icon) if icon + end end diff --git a/app/components/clipboard_button_component.rb b/app/components/clipboard_button_component.rb index 4dce02116b9..4c0fd6bcfd2 100644 --- a/app/components/clipboard_button_component.rb +++ b/app/components/clipboard_button_component.rb @@ -2,10 +2,9 @@ class ClipboardButtonComponent < ButtonComponent attr_reader :clipboard_text, :tag_options def initialize(clipboard_text:, **tag_options) - super(**tag_options) + super(**tag_options, icon: :content_copy) @clipboard_text = clipboard_text - @tag_options = tag_options end def call @@ -13,11 +12,6 @@ def call end def content - safe_join( - [ - render(IconComponent.new(icon: :content_copy, class: 'position-absolute')), - content_tag(:span, t('links.copy'), class: 'padding-left-3'), - ], - ) + t('links.copy') end end diff --git a/app/views/idv/otp_verification/show.html.erb b/app/views/idv/otp_verification/show.html.erb index b5baca05f4e..f88159564bb 100644 --- a/app/views/idv/otp_verification/show.html.erb +++ b/app/views/idv/otp_verification/show.html.erb @@ -36,11 +36,14 @@ <% end %> -<%= button_to idv_resend_otp_path, - method: :post, - class: 'usa-button usa-button--outline ico ico-refresh margin-bottom-4' do %> - <%= t('links.two_factor_authentication.get_another_code') %> -<% end %> +<%= render ButtonComponent.new( + action: ->(content, **tag_options) do + button_to(idv_resend_otp_path, method: :post, **tag_options) { content } + end, + outline: true, + icon: :loop, + class: 'margin-bottom-4', + ).with_content(t('links.two_factor_authentication.get_another_code')) %>
<%= t('instructions.mfa.wrong_number') %>
diff --git a/app/views/shared/_personal_key.html.erb b/app/views/shared/_personal_key.html.erb
index 72044332d02..76c55fc5dec 100644
--- a/app/views/shared/_personal_key.html.erb
+++ b/app/views/shared/_personal_key.html.erb
@@ -8,21 +8,20 @@