Skip to content

Commit

Permalink
Add classes to action items in the summary list component
Browse files Browse the repository at this point in the history
  • Loading branch information
danboscaro committed Mar 6, 2019
1 parent 500f30f commit 159cbf6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

([PR #N](https://github.com/alphagov/govuk-frontend/pull/N))

- Add classes to action items in the summary list component

([PR #1233](https://github.com/alphagov/govuk-frontend/pull/1233))

- Prevent horizontal jump as scrollbars appear

As content vertical height grows (e.g. autocomplete results appear), browsers
Expand Down
12 changes: 8 additions & 4 deletions src/components/summary-list/summary-list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ params:
type: string
required: false
description: Classes to add to the value wrapper
- name: actions.classes
type: string
required: false
description: Classes to add to the actions wrapper
- name: actions.items
type: array
required: false
description: Array of action item objects
params:
- name: classes
type: string
required: false
description: Classes to add to the actions wrapper
- name: href
type: string
required: true
Expand All @@ -52,6 +52,10 @@ params:
type: string
required: false
description: Actions rely on context from the surrounding content so may require additional accessible text, text supplied to this option is appended to the end, use `html` for more complicated scenarios.
- name: classes
type: string
required: false
description: Classes to add to the action item
- name: classes
type: string
required: false
Expand Down
2 changes: 1 addition & 1 deletion src/components/summary-list/template.njk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{%- macro _actionLink(action) %}
<a class="govuk-link" href="{{ action.href }}">
<a class="govuk-link {%- if action.classes %} {{ action.classes }}{% endif %}" href="{{ action.href }}">
{{ action.html | safe if action.html else action.text }}
{%- if action.visuallyHiddenText -%}
<span class="govuk-visually-hidden"> {{ action.visuallyHiddenText }}</span>
Expand Down
21 changes: 21 additions & 0 deletions src/components/summary-list/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,27 @@ describe('Data list', () => {

expect($secondAction.text().trim()).toBe('Second action')
})
it('renders classes on actions', async () => {
const $ = render('summary-list', {
rows: [
{
actions: {
items: [
{
text: 'Edit',
classes: 'govuk-link--no-visited-state'
}
]
}
}
]
})

const $component = $('.govuk-summary-list')
const $action = $component.find('.govuk-summary-list__actions > a')

expect($action.hasClass('govuk-link--no-visited-state')).toBeTruthy()
})
})
})
})

0 comments on commit 159cbf6

Please sign in to comment.