Skip to content

Commit 1149fb5

Browse files
authored
[Step Indicator] Add options to display large header first (#306)
## Changes - Adds `large_header` option - Adds `header_first` option ## Context In certain applications like MN, the header is shown before the step indicator segments and uses a larger text that displays the heading text prominently (compared to the "Step X of Y" text.) This PR adds some options to support this so we can switch to using the Strata step indicator partial instead of a custom one. ### Caveats I'm not entirely sure if there's an accessibility consideration here with placing the heading above the step indicator. The USWDS documentation states that a heading should be placed below the step indicator, but it's worded to focus on **having a heading** and not so much on having a heading **below** the indicator. ## Testing Updated lookbook. <img width="1716" height="350" alt="CleanShot 2026-03-30 at 17 19 56@2x" src="https://github.com/user-attachments/assets/96f39c97-c4d4-4a1f-9ee8-7a52960553ad" />
1 parent 212e137 commit 1149fb5

2 files changed

Lines changed: 34 additions & 11 deletions

File tree

app/previews/strata/shared/step_indicator_preview.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ def decision_made
5858
end
5959

6060
# @!endgroup
61+
62+
def large_header_first
63+
render template: "strata/shared/_step_indicator", locals: {
64+
steps: [ :in_progress, :submitted, :decision_made ],
65+
current_step: :submitted,
66+
large_header: true,
67+
header_first: true
68+
}
69+
end
6170
end
6271
end
6372
end

app/views/strata/shared/_step_indicator.html.erb

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# @param steps [Array<String, Symbol>] An array of step identifiers that will be displayed in order
55
# @param current_step [String, Symbol] The identifier of the current active step
66
# @param translation_scope [String] - I18n scope prefix, defaulting to 'strata.application_forms.steps'
7+
# @param large_header [Boolean] (optional) - Adds "font-heading-xl" class to the heading text
8+
# @param header_first [Boolean] (optional) - Shows the header above the segments with "margin-bottom-2" class
79
#
810
# Each step's display name is fetched from the i18n translations under strata.application_forms.steps
911
# Steps before and including the current step are marked as complete.
@@ -12,6 +14,8 @@ steps = steps.map(&:to_sym)
1214
current_step = current_step.to_sym
1315
current_step_index = steps.index(current_step) || -1
1416
translation_scope ||= "strata.application_forms.steps"
17+
large_header ||= false
18+
header_first ||= false
1519

1620
step_indicators = steps.map.with_index do |step, index|
1721
{
@@ -26,10 +30,27 @@ step_indicator_class = ""
2630
step_indicator_class += "usa-step-indicator--counters" if local_assigns[:type] == :counters
2731
%>
2832

33+
<% header_content = capture do %>
34+
<div class="<%= class_names("usa-step-indicator__header", "margin-bottom-2": header_first) %>">
35+
<h4 class="usa-step-indicator__heading display-flex flex-align-center">
36+
<span class="usa-step-indicator__heading-counter">
37+
<span class="usa-sr-only">Step</span>
38+
<span class="usa-step-indicator__current-step"><%= current_step_index + 1 %></span>
39+
<span class="usa-step-indicator__total-steps">of <%= steps.length %></span>
40+
</span>
41+
<span class="<%= class_names("usa-step-indicator__heading-text", "font-heading-xl": large_header) %>"><%= current_step_name %></span>
42+
</h4>
43+
</div>
44+
<% end %>
45+
2946
<div
3047
class="usa-step-indicator <%= step_indicator_class %>"
3148
aria-label="progress"
3249
>
50+
<% if header_first %>
51+
<%= header_content %>
52+
<% end %>
53+
3354
<ol class="usa-step-indicator__segments">
3455
<% step_indicators.each do |step_indicator| %>
3556
<li
@@ -52,15 +73,8 @@ step_indicator_class += "usa-step-indicator--counters" if local_assigns[:type] =
5273
</li>
5374
<% end %>
5475
</ol>
55-
56-
<div class="usa-step-indicator__header">
57-
<h4 class="usa-step-indicator__heading">
58-
<span class="usa-step-indicator__heading-counter">
59-
<span class="usa-sr-only">Step</span>
60-
<span class="usa-step-indicator__current-step"><%= current_step_index + 1 %></span>
61-
<span class="usa-step-indicator__total-steps">of <%= steps.length %></span>
62-
</span>
63-
<span class="usa-step-indicator__heading-text"><%= current_step_name %></span>
64-
</h4>
65-
</div>
76+
77+
<% unless header_first %>
78+
<%= header_content %>
79+
<% end %>
6680
</div>

0 commit comments

Comments
 (0)