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

feat(table): table without header - FRONT-4437 #3407

Merged
merged 6 commits into from
Jun 18, 2024
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
3 changes: 3 additions & 0 deletions src/implementations/twig/components/table/table.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
{% endif %}

{% set _index = 1 %}
{% if _headers is not empty %}
<thead class="{{ _head_css_class }}">
{% for header in _headers %}
<tr class="{{ _row_css_class }}">
Expand All @@ -130,6 +131,8 @@
</tr>
{% endfor %}
</thead>
{% endif %}

<tbody class="{{ _body_css_class }}">
{% for row in _rows %}
{% set _row_css_class = 'ecl-table__row' %}
Expand Down
24 changes: 23 additions & 1 deletion src/implementations/twig/components/table/table.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,22 @@ import notes from './README.md';
const dataZebra = { ...dataDefault, zebra: true };

const getArgs = () => ({
header: true,
simple: false,
});

const getArgTypes = () => ({
header: {
name: 'header',
type: { name: 'boolean' },
description: 'See table with or without header',
table: {
type: { summary: 'boolean' },
defaultValue: { summary: true },
category: 'Optional',
},
},

simple: {
name: 'simple display',
type: { name: 'boolean' },
Expand All @@ -25,10 +37,20 @@ const getArgTypes = () => ({
defaultValue: { summary: false },
category: 'Display',
},
if: { arg: 'header' },
},
});

const prepareData = (data, args) => Object.assign(data, args);
const prepareData = (data, args) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

this way we break the simple control, we should still return an Object.assign to get it working again.

const dataClone = JSON.parse(JSON.stringify(data));

if (!args.header) {
delete dataClone.headers;
dataClone.simple = true;
}

return Object.assign(dataClone, args);
};

export default {
title: 'Components/Table',
Expand Down
12 changes: 12 additions & 0 deletions src/implementations/vanilla/components/table/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,18 @@ $table: null !default;
%ecl-table__row {
border-bottom: map.get($table, 'row-border');
border-top-width: 0;

&:first-child {
border-top: map.get($table, 'row-border');
}

// stylelint-disable-next-line no-descending-specificity
.ecl-table__head + .ecl-table__body &:first-child {
border-top-width: 0;
}
}

// stylelint-disable-next-line no-descending-specificity
.ecl-table__head .ecl-table__row:first-child {
border-bottom: map.get($table, 'header-border');

Expand Down Expand Up @@ -83,12 +93,14 @@ $table: null !default;

// Zebra
.ecl-table--zebra {
// stylelint-disable-next-line no-descending-specificity
.ecl-table__row:nth-of-type(even) {
background-color: map.get($table, 'zebra-background');
}
}

// Multi
// stylelint-disable-next-line no-descending-specificity
.ecl-table__head .ecl-table__row:not(:first-child) {
background-color: map.get($table, 'multi-head-background-empty');
border-bottom-width: 0;
Expand Down
9 changes: 9 additions & 0 deletions src/presets/ec/src/ec-default-print.scss
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ html {
@extend %ecl-table;
}

.ecl thead:not([class*='ecl-'], [class*='wt-']),
.ecl thead:is([class*='ecl-u-']) {
@extend %ecl-table__head;

& + tbody tr:first-child {
border-top-width: 0;
}
}

.ecl th:not([class*='ecl-'], [class*='wt-']),
.ecl th:is([class*='ecl-u-']) {
@extend %ecl-table__header;
Expand Down
4 changes: 4 additions & 0 deletions src/presets/ec/src/ec-default.scss
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@
.ecl thead:not([class*='ecl-'], [class*='wt-']),
.ecl thead:is([class*='ecl-u-']) {
@extend %ecl-table__head;

& + tbody tr:first-child {
border-top-width: 0;
}
}

.ecl th:not([class*='ecl-'], [class*='wt-']),
Expand Down
9 changes: 9 additions & 0 deletions src/presets/eu/src/eu-default-print.scss
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ html {
@extend %ecl-table;
}

.ecl thead:not([class*='ecl-'], [class*='wt-']),
.ecl thead:is([class*='ecl-u-']) {
@extend %ecl-table__head;

& + tbody tr:first-child {
border-top-width: 0;
}
}

.ecl th:not([class*='ecl-'], [class*='wt-']),
.ecl th:is([class*='ecl-u-']) {
@extend %ecl-table__header;
Expand Down
4 changes: 4 additions & 0 deletions src/presets/eu/src/eu-default.scss
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@
.ecl thead:not([class*='ecl-'], [class*='wt-']),
.ecl thead:is([class*='ecl-u-']) {
@extend %ecl-table__head;

& + tbody tr:first-child {
border-top-width: 0;
}
}

.ecl th:not([class*='ecl-'], [class*='wt-']),
Expand Down
2 changes: 1 addition & 1 deletion src/themes/ec/variables/_table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $table: (
multi-head-position: var(--s-m),
sort-icon-color: var(--c-d),
sort-icon-color-active: var(--c-d-60),
sort-icon-spacing: -10px,
sort-icon-spacing: -8px,
sort-arrow-top: calc(var(--s-m) + 3px),
sort-arrow-left: var(--s-m),
caption-font: var(--f-s),
Expand Down
Loading