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

Replace table with va-table web component #1817

Merged
merged 5 commits into from
Dec 18, 2023
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
2 changes: 1 addition & 1 deletion script/github-actions/code-coverage-format-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ codeCoverageData.forEach((data, index) => {
// create table header
codeCoverageHTML += `<th> ${data} </th> \n`;
} else if (index === 5) {
// seperate table header from data
// separate table header from data
codeCoverageHTML += `<th> ${data} </th> \n </tr> \n </thead> \n <tbody> \n`;
} else if ((index - 1) % 5 === 0) {
// start of row in table body
Expand Down
66 changes: 23 additions & 43 deletions src/site/paragraphs/table.drupal.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -26,47 +26,27 @@
}
}
{% endcomment %}

<table data-template="paragraphs/table" data-entity-id="{{ entity.entityId }}" class="va-table va-table--responsive" role="table">
{% if entity.fieldTable.caption %}
<caption>{{ entity.fieldTable.caption }}</caption>
<va-table data-template="paragraphs/table" data-entity-id="{{ entity.entityId }}" role="table">
{% assign colLabels = entity.fieldTable.value.0 %}
{% for value in entity.fieldTable.value %}
{% if forloop.first == true %}
<va-table-row slot="headers" key="header">
{% for column in value %}
{% if column == "" or column == nil %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how, but --- was being rendered to fields that came through as empty or null, so I've added a check here and just render a span with some whitespace if the value is null.

Copy link
Contributor

@jamigibbs jamigibbs Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a default behavior of the web component for handling missing data: https://design.va.gov/storybook/?path=/docs/components-va-table--missing-data

Screenshot 2023-12-18 at 9 00 05 AM

<span role="columnheader"> </span>
{% else %}
<span role="columnheader" scope="col">{{ column }}</span>
{% endif %}
{% endfor %}
</va-table-row>
{% else %}
<va-table-row>
{% for column in value %}
<span>
{{ column }}
</span>
{% endfor %}
</va-table-row>
{% endif %}
{% assign colLabels = entity.fieldTable.value.0 %}
{% for value in entity.fieldTable.value %}
{% if forloop.first == true %}
<thead>
<tr role="row">
{% for column in value %}
<th role="columnheader" scope="col">{{ column }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% else %}
<tr class="vads-u-padding-top--5" role="row">
{% for column in value %}
{% if forloop.first == true %}
<th
class="vads-u-padding-bottom--0 column-label vads-u-font-weight--bold medium-screen:vads-u-display--none" role="rowheader" scope="row"
>
<dfn> {{colLabels | getValueFromObjPath: forloop.index0}} </dfn>
</th>
<th class="column-value table-row-header-responsive" role="rowheader" scope="row">
<dfn class="vads-u-display--block"> {{ column }} </dfn>
</th>
{% else %}
<td class="vads-u-padding-bottom--0 column-label vads-u-font-weight--bold medium-screen:vads-u-display--none" role="cell">
<dfn> {{colLabels | getValueFromObjPath: forloop.index0}} </dfn>
</td>
<td class="column-value" role="cell">
<dfn class="vads-u-display--block"> {{ column }} </dfn>
</td>
{% endif %}
{% endfor %}
</tr>
{% endif %}
{% if forloop.last %}
</tbody>
{% endif %}
{% endfor %}
</table>
{% endfor %}
</va-table>
Loading