Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ IdentityIdp/ImageSizeLinter:
- app/views/shared/_nav_branded.html.erb
- app/views/sign_up/completions/show.html.erb
- app/views/users/two_factor_authentication_setup/index.html.erb
- app/views/users/webauthn_setup/new.html.erb

IdentityIdp/RedirectBackLinter:
Enabled: true
Expand Down Expand Up @@ -1218,6 +1217,10 @@ Style/MultilineMemoization:
Style/MultilineWhenThen:
Enabled: true

Style/MutableConstant:
Enabled: true
EnforcedStyle: strict

Style/NegatedWhile:
Enabled: true

Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ gem 'redacted_struct'
gem 'redis', '>= 3.2.0'
gem 'redis-session-store', github: '18F/redis-session-store', tag: 'v1.0.1-18f'
gem 'retries'
gem 'rotp', '~> 6.1'
gem 'rotp', '~> 6.3', '>= 6.3.0'
gem 'rqrcode'
gem 'ruby-progressbar'
gem 'ruby-saml'
gem 'safe_target_blank', '>= 1.0.2'
gem 'saml_idp', github: '18F/saml_idp', tag: '0.19.2-18f'
gem 'saml_idp', github: '18F/saml_idp', tag: '0.19.3-18f'
gem 'scrypt'
gem 'simple_form', '>= 5.0.2'
gem 'stringex', require: false
Expand Down Expand Up @@ -115,7 +115,7 @@ group :development, :test do
gem 'psych'
gem 'rspec', '~> 3.12.0'
gem 'rspec-rails', '~> 6.0'
gem 'rubocop', '~> 1.59.0', require: false
gem 'rubocop', '~> 1.62.0', require: false
gem 'rubocop-performance', '~> 1.20.2', require: false
gem 'rubocop-rails', '>= 2.5.2', require: false
gem 'rubocop-rspec', require: false
Expand Down
30 changes: 15 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ GIT

GIT
remote: https://github.com/18F/saml_idp.git
revision: 4c858dab80cfe32081a7e6bd7cd76c43cc3ec778
tag: 0.19.2-18f
revision: 95369fdd9336773b9983c8de71eb35a8c92e9683
tag: 0.19.3-18f
specs:
saml_idp (0.19.2.pre.18f)
saml_idp (0.19.3.pre.18f)
activesupport
builder
faraday
Expand Down Expand Up @@ -199,10 +199,10 @@ GEM
aws-sigv4 (~> 1.1)
aws-sigv4 (1.8.0)
aws-eventstream (~> 1, >= 1.0.2)
axe-core-api (4.7.0)
axe-core-api (4.9.0)
dumb_delegator
virtus
axe-core-rspec (4.7.0)
axe-core-rspec (4.9.0)
axe-core-api
dumb_delegator
virtus
Expand Down Expand Up @@ -448,15 +448,15 @@ GEM
net-ssh (6.1.0)
newrelic_rpm (9.7.0)
nio4r (2.7.0)
nokogiri (1.16.2)
nokogiri (1.16.3)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
openssl (3.0.2)
openssl-signature_algorithm (1.2.1)
openssl (> 2.0, < 3.1)
orm_adapter (0.5.0)
parallel (1.24.0)
parser (3.3.0.0)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
pg (1.5.4)
Expand Down Expand Up @@ -580,7 +580,7 @@ GEM
rgeo-activerecord (7.0.1)
activerecord (>= 5.0)
rgeo (>= 1.0.0)
rotp (6.2.0)
rotp (6.3.0)
rouge (4.2.0)
rqrcode (2.1.0)
chunky_png (~> 1.0)
Expand Down Expand Up @@ -611,19 +611,19 @@ GEM
rspec-support (3.12.1)
rspec_junit_formatter (0.6.0)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (1.59.0)
rubocop (1.62.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.4)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-ast (1.31.2)
parser (>= 3.3.0.4)
rubocop-capybara (2.19.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.24.0)
Expand Down Expand Up @@ -836,13 +836,13 @@ DEPENDENCIES
redis (>= 3.2.0)
redis-session-store!
retries
rotp (~> 6.1)
rotp (~> 6.3, >= 6.3.0)
rqrcode
rspec (~> 3.12.0)
rspec-rails (~> 6.0)
rspec-retry
rspec_junit_formatter
rubocop (~> 1.59.0)
rubocop (~> 1.62.0)
rubocop-performance (~> 1.20.2)
rubocop-rails (>= 2.5.2)
rubocop-rspec
Expand Down
1 change: 1 addition & 0 deletions app/assets/images/mfa-options/security_key.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/mfa-options/security_key_mobile.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion app/assets/images/security-key.svg

This file was deleted.

36 changes: 35 additions & 1 deletion app/assets/stylesheets/email.css.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
@use 'uswds-core' as *;
@use 'uswds-core' as * with (
$theme-table-border-color: 'base-lighter',
$theme-table-header-background-color: 'base-lightest'
);
@use 'variables/app' as *;
@use 'variables/email' as *;

Expand Down Expand Up @@ -198,6 +201,10 @@ h6 {
@include u-font('sans', 'md');
}

.font-family-mono {
font-family: monospace;
}

.margin-bottom-0 {
@include u-margin-bottom(0);
}
Expand Down Expand Up @@ -269,3 +276,30 @@ h6 {
@extend %usa-list-item;
}
}

.usa-table {
@include usa-table;

border-collapse: separate;
border-spacing: 0;

tbody td {
border-top: 0;
}

thead th:first-child {
border-top-left-radius: units(0.5);
}

thead th:last-child {
border-top-right-radius: units(0.5);
}

tbody tr:last-child td:first-child {
border-bottom-left-radius: units(0.5);
}

tbody tr:last-child td:last-child {
border-bottom-right-radius: units(0.5);
}
}
13 changes: 11 additions & 2 deletions app/components/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
# Components

This folder contains a collection of components implemented using the [ViewComponent gem](https://viewcomponent.org/). Components are reusable user interface elements, and usually comprise of a component class and ERB template. They are similar to partials in many of their use-cases, but have a few advantages in the form of class-based presenter logic, testability, performance, and conveniences for loading JavaScript assets.
This folder contains a collection of components implemented using the [ViewComponent gem](https://viewcomponent.org/). Components are reusable user interface elements, and usually comprise of a component class and ERB template. They are similar to partials in many of their use-cases, but have a few advantages in the form of class-based presenter logic, testability, performance, and conveniences for loading accompanying script and style assets.

Each component must implement a class extending the `BaseComponent` class. If an accompanying `.html.erb` file exists, it will be used as the template for that component. Similarly, if an `.ts` or `.tsx` file exists, the bundle generated from that JavaScript will be loaded automatically any time the component is rendered.
Each component must implement a class extending the `BaseComponent` class.

Optional files:

- `.html.erb`: Used as the template for the component
- `.ts`: A corresponding JavaScript bundle will be created and loaded automatically any time the component is rendered
- `.scss`: A corresponding CSS stylesheet will be created and loaded automatically any time the component is rendered

Example:

```
components/
├─ example_component.rb
├─ example_component.html.erb
├─ example_component.scss
└─ example_component.ts
```

Expand Down
2 changes: 1 addition & 1 deletion app/components/alert_icon_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AlertIconComponent < BaseComponent
personal_key: 'status/personal-key.svg',
info_question: 'status/info-question.svg',
delete: 'status/delete.svg',
}
}.freeze
DEFAULT_WIDTH = 88
DEFAULT_HEIGHT = 88

Expand Down
2 changes: 1 addition & 1 deletion app/components/one_time_code_input_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class OneTimeCodeInputComponent < BaseComponent
alias_method :autofocus?, :autofocus

# @see https://tc39.es/ecma262/#prod-SyntaxCharacter
JS_REGEXP_SYNTAX_CHARACTER = Regexp.union(%w[^ $ \ . * + ? ( ) [ ] { } |])
JS_REGEXP_SYNTAX_CHARACTER = Regexp.union(%w[^ $ \ . * + ? ( ) [ ] { } |]).freeze

# @param [FormBuilder] form Form builder instance.
# @param [Symbol] name Field name. Defaults to `:code`.
Expand Down
58 changes: 58 additions & 0 deletions app/components/security_key_image_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# frozen_string_literal: true

class SecurityKeyImageComponent < BaseComponent
attr_reader :tag_options

def initialize(mobile:, **tag_options)
@mobile = mobile
@tag_options = tag_options
end

def mobile?
!!@mobile
end

def call
# rubocop:disable Rails/OutputSafety
Nokogiri::HTML5.fragment(read_svg).tap do |doc|
doc.at_css('svg').tap do |svg|
svg[:class] = css_class
svg[:role] = 'img'

tag_options.except(:class, :data, :aria).each do |key, value|
svg[key] = value
end
[:data, :aria].each do |prefix|
tag_options[prefix]&.each do |key, value|
svg[:"#{prefix}-#{key}"] = value
end
end

svg << "<title>#{title}</title>"
end
end.to_s.html_safe
# rubocop:enable Rails/OutputSafety
end

def css_class
[
'width-full',
'height-auto',
mobile? && 'security-key--mobile',
*tag_options[:class],
].select(&:present?).join(' ')
end

def title
mobile? ?
t('forms.webauthn_setup.step_2_image_mobile_alt') :
t('forms.webauthn_setup.step_2_image_alt')
end

def read_svg
Rails.root.join(
'app', 'assets', 'images', 'mfa-options',
(mobile? ? 'security_key_mobile.svg' : 'security_key.svg')
).read
end
end
Loading