-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Append card title to summary list actions (#481)
This change appends the card title to action links when rendered within a summary card. It follows [the upstream change](alphagov/govuk-frontend#3961) introduced in govuk-frontend version 5. In the simplest case it works like the reference implementation: ```erb <%= govuk_summary_list(card: { title: "Shiny new widget" }) do |sl| %> <%= sl.with_row do |r| %> <%= r.with_key(text: "Price") %> <%= r.with_value(text: "£19.99") %> <%= r.with_action(href: "/widgets/1/edit", text: "Modify", visually_hidden_text: "this widget's price") %> <% end %> <% end %> ``` Here, the rendered HTML will now include the card title in the visually hidden text on the action: ```html <dl class="govuk-summary-list"> <div class="govuk-summary-list__row"> <dt class="govuk-summary-list__key">Price</dt> <dd class="govuk-summary-list__value">£19.99</dd> <dd class="govuk-summary-list__actions"> <a class="govuk-link" href="/a">Modify<span class="govuk-visually-hidden"> this widget's price (Shiny new widget)</span></a> </dd> </div> </dl> ``` Additionally the suffix text can be set manually. This allows it to be set without passing in `card: { ... }` when initialising the summary list. It might be useful when rendering the summary list within an outer card. It is set using the `action_suffix` keyword. ```erb <%= govuk_summary_card(title: "Shiny new widget") do %> <%= govuk_summary_list(action_suffix: "Shiny new widget") do |sl| %> <%= sl.with_row do |r| %> <%= r.with_key(text: "Price") %> <%= r.with_value(text: "£19.99") %> <%= r.with_action(href: "/widgets/1/edit", text: "Modify", visually_hidden_text: "this widget's price") %> <% end %> <% end %> <% end %> ``` This will output the same HTML as the above example. When both the `card` and `action_suffix` arguments are provided the `action_suffix` takes precedence, which offers a little more flexibility as there might be some cases other text would make more sense than the card's title. Fixes #479, #480
- Loading branch information
Showing
7 changed files
with
88 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 14 additions & 3 deletions
17
app/components/govuk_component/summary_list_component/row_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters