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 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
17 changes: 9 additions & 8 deletions script/github-actions/code-coverage-format-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,31 @@ const regex = /([^A-Za-z0-9/()%-])+\s/g;

const codeCoverageData = codeCoverageReport.replace(regex, ',').split(',');

let codeCoverageHTML = '<table> \n <thead> \n <tr> \n'; // html format
let codeCoverageHTML =
'<va-table> \n <va-table-row slot="headers" key="header"> \n'; // html format
tjheffner marked this conversation as resolved.
Show resolved Hide resolved

codeCoverageData.forEach((data, index) => {
if (data === '') {
// ignore empty data
codeCoverageHTML += '';
} else if (index < 5) {
// create table header
codeCoverageHTML += `<th> ${data} </th> \n`;
codeCoverageHTML += `<span> ${data} </span> \n`;
} else if (index === 5) {
// seperate table header from data
codeCoverageHTML += `<th> ${data} </th> \n </tr> \n </thead> \n <tbody> \n`;
// separate table header from data
codeCoverageHTML += `<span> ${data} </span> \n </va-table-row> \n`;
} else if ((index - 1) % 5 === 0) {
// start of row in table body
codeCoverageHTML += `<tr> \n <td> ${data} </td> \n`;
codeCoverageHTML += `<va-table-row> \n <span> ${data} </span> \n`;
} else if ((index - 1) % 5 === 4) {
// end of row in table body
codeCoverageHTML += `<td> ${data} </td> \n </tr> \n`;
codeCoverageHTML += `<span> ${data} </span> \n </va-table-row> \n`;
} else {
// row in table body
codeCoverageHTML += `<td> ${data} </td> \n`;
codeCoverageHTML += `<span> ${data} </span> \n`;
}
});

codeCoverageHTML += `</tbody> \n </table>`; // close html
codeCoverageHTML += `</va-table>`; // close html

console.log(codeCoverageHTML); // eslint-disable-line no-console
40 changes: 17 additions & 23 deletions src/site/paragraphs/table.drupal.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -27,46 +27,40 @@
}
{% endcomment %}

<table data-template="paragraphs/table" data-entity-id="{{ entity.entityId }}" class="va-table va-table--responsive" role="table">
<va-table data-template="paragraphs/table" data-entity-id="{{ entity.entityId }}" role="table">
{% if entity.fieldTable.caption %}
<caption>{{ entity.fieldTable.caption }}</caption>
{% 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>
<va-table-row slot="headers" key="header">
{% for column in value %}
<span role="columnheader" scope="col">{{ column }}</span>
{% endfor %}
</va-table-row>
{% else %}
<tr class="vads-u-padding-top--5" role="row">
<va-table-row class="vads-u-padding-top--5" role="row">
{% for column in value %}
{% if forloop.first == true %}
<th
<span
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">
</span>
<span class="column-value table-row-header-responsive" role="rowheader" scope="row">
<dfn class="vads-u-display--block"> {{ column }} </dfn>
</th>
</span>
{% else %}
<td class="vads-u-padding-bottom--0 column-label vads-u-font-weight--bold medium-screen:vads-u-display--none" role="cell">
<span 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">
</span>
<span class="column-value" role="cell">
<dfn class="vads-u-display--block"> {{ column }} </dfn>
</td>
</span>
{% endif %}
{% endfor %}
</tr>
{% endif %}
{% if forloop.last %}
</tbody>
</va-table-row>
{% endif %}
{% endfor %}
</table>
</va-table>
Loading