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

Allow for classes, rowspan, colspan and attributes on row headers #1367

Merged
merged 4 commits into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Allow passing classes for table row headers
  • Loading branch information
36degrees committed May 22, 2019
commit 7f7d473d0a85512428b06f0f51c09098be9bde04
2 changes: 1 addition & 1 deletion src/components/table/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<tr class="govuk-table__row">
{% for cell in row %}
{% if loop.first and params.firstCellIsHeader %}
<th class="govuk-table__header" scope="row">{{ cell.html | safe if cell.html else cell.text }}</th>
<th class="govuk-table__header{%- if cell.classes %} {{ cell.classes }}{% endif %}" scope="row">{{ cell.html | safe if cell.html else cell.text }}</th>
{% else %}
<td class="govuk-table__cell
{%- if cell.format %} govuk-table__cell--{{ cell.format }}{% endif %}
Expand Down
20 changes: 20 additions & 0 deletions src/components/table/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,26 @@ describe('Table', () => {
expect($lastTableHeader.hasClass('govuk-table__header')).toBeTruthy()
})

it('includes additional classes when the first row is a header', () => {
const $ = render('table', {
'firstCellIsHeader': true,
'rows': [
[
{
'text': 'January',
'classes': 'my-custom-class'
},
{
'text': '£85',
'format': 'numeric'
}
]
]
})

expect($('.govuk-table__row *:first-child').hasClass('my-custom-class')).toBeTruthy()
})

it('renders with thead', () => {
const args = examples['table with head']
const $ = render('table', args)
Expand Down