Skip to content

Commit

Permalink
Merge pull request #446 from x-govuk/add-example-of-summary-list-with…
Browse files Browse the repository at this point in the history
…-missing-info

Add example of summary list with missing info
  • Loading branch information
peteryates authored Aug 29, 2023
2 parents cc04d76 + c0bf3ae commit b77b124
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions guide/content/components/summary-list.slim
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ p
using `actions: false`. Doing this makes the values column wider
consuming the remaining space.

== render('/partials/example.*',
caption: "Summary lists with missing information",
code: summary_list_with_missing_information) do

markdown:
If a row has missing information, include a link to add the information within the value column instead of as an action.

== render('/partials/example.*',
caption: "Building a summary list directly from data",
code: summary_list_from_rows,
Expand Down
19 changes: 19 additions & 0 deletions guide/lib/examples/summary_list_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ def summary_list_without_actions
SUMMARY_LIST_WITHOUT_ACTIONS
end

def summary_list_with_missing_information
<<~SUMMARY_LIST_WITH_MISSING_INFORMATION
= govuk_summary_list do |summary_list|
- summary_list.with_row do |row|
- row.with_key { 'Name' }
- row.with_value { 'Sherlock Holmes' }
- row.with_action(text: "Change", href: '#', visually_hidden_text: 'name')
- summary_list.with_row do |row|
- row.with_key(text: 'Address')
- row.with_value { govuk_link_to("Enter address", "#") }
- summary_list.with_row do |row|
- row.with_key(text: 'Phone number')
- row.with_value(text: '020 123 1234')
- row.with_action(text: "Change", href: '#', visually_hidden_text: 'phone number')
SUMMARY_LIST_WITH_MISSING_INFORMATION
end

def summary_list_from_rows
<<~SUMMARY_LIST_FROM_ROWS
= govuk_summary_list(rows: rows)
Expand Down

0 comments on commit b77b124

Please sign in to comment.