Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add classes to action items in the summary list component #1233

Merged
merged 1 commit into from
Mar 8, 2019
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 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))

🔧 Fixes:

- Pull Request Title goes here
Expand Down Expand Up @@ -63,7 +67,6 @@

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


- 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
danboscaro marked this conversation as resolved.
Show resolved Hide resolved
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 () => {
danboscaro marked this conversation as resolved.
Show resolved Hide resolved
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()
})
})
})
})