Skip to content

Commit

Permalink
Revert "chore(Table): remove deprecated selectors (#1902)" (#1968)
Browse files Browse the repository at this point in the history
This reverts commit 92bb52e.

+ Resolve table conflicts during a rebase
  • Loading branch information
tujoworker committed May 31, 2023
1 parent a870ed0 commit 684e222
Show file tree
Hide file tree
Showing 30 changed files with 106 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,43 @@ export const TableClassHelpers = () => (
</ComponentBox>
)

export const TableWithoutClasses = () => (
<ComponentBox hideCode data-visual-test="table-no-classes">
<Table.ScrollView>
<table className="dnb-table">
<thead>
<tr>
<th>Header</th>
<th className="dnb-table--sortable dnb-table--reversed">
<Th.SortButton text="Sortable" />
</th>
<th className="dnb-table--sortable dnb-table--active">
<Th.SortButton text="Active" />
</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1</td>
<td>Row 1</td>
<td>Row 1</td>
</tr>
<tr>
<td>Row 2</td>
<td>Row 2</td>
<td>Row 2</td>
</tr>
<tr>
<td>Row 3</td>
<td>Row 3</td>
<td>Row 3</td>
</tr>
</tbody>
</table>
</Table.ScrollView>
</ComponentBox>
)

export const TableLongHeader = () => (
<ComponentBox hideCode data-visual-test="table-header">
<Table.ScrollView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ TableVariantFixed,
TableStackedContainer,
TableContainerEmptyHeaderFooter,
TableClassHelpers,
TableWithoutClasses,
TableLongHeader,
TableSticky,
TableStickyMaxHeight,
Expand Down Expand Up @@ -112,6 +113,7 @@ With no (empty) `head` and `foot` content.

<PaginationTable />

### Example usage of class helpers
### Example usage without and with classes

<TableWithoutClasses />
<TableClassHelpers />
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Table', () => {
})

it('have to match a row scope only table layout', async () => {
const screenshot = await testPageScreenshot({
const screenshot = await makeScreenshot({
selector: '[data-visual-test="table-row-scope-only"] .dnb-table',
})
expect(screenshot).toMatchImageSnapshot()
Expand All @@ -53,7 +53,7 @@ describe('Table', () => {
})

it('have to match table empty container head and foot', async () => {
const screenshot = await testPageScreenshot({
const screenshot = await makeScreenshot({
selector: '[data-visual-test="table-container-empty"]',
})
expect(screenshot).toMatchImageSnapshot()
Expand Down Expand Up @@ -156,6 +156,14 @@ describe('Table', () => {
})
expect(screenshot).toMatchImageSnapshot()
})

it('have to match table without inner classes', async () => {
const selector = '[data-visual-test="table-no-classes"]'
const screenshot = await makeScreenshot({
selector,
})
expect(screenshot).toMatchImageSnapshot()
})
})

describe('Table with skeleton', () => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ exports[`Table scss have to match default theme snapshot 1`] = `
* Table theme
*
*/
/*
* Utilities
*/
/*
* Utilities
*/
.dnb-table {
text-align: left;
/* stylelint-disable */
/* stylelint-enable */
}
.dnb-table__th {
.dnb-table__th, .dnb-table thead th {
padding: 2rem 1rem 1rem;
font-weight: var(--font-weight-medium);
color: var(--theme-color-black-80, currentColor);
Expand All @@ -20,36 +25,40 @@ exports[`Table scss have to match default theme snapshot 1`] = `
vertical-align: bottom;
background-color: var(--color-white);
}
.dnb-table__td, tbody > tr > .dnb-table__th {
padding: 1rem;
color: var(--theme-color-black-80, currentColor);
font-size: var(--font-size-basis);
line-height: var(--line-height-basis);
vertical-align: baseline;
}
.dnb-table__size--medium .dnb-table__th {
.dnb-table__size--medium .dnb-table__th, .dnb-table__size--medium .dnb-table thead th {
padding: 1.375rem 1rem 0.875rem;
font-size: var(--font-size-small);
line-height: var(--line-height-small);
}
.dnb-table__size--medium .dnb-table__th .dnb-button__text {
.dnb-table__size--medium .dnb-table__th .dnb-button__text, .dnb-table__size--medium .dnb-table thead th .dnb-button__text {
line-height: inherit;
}
.dnb-table__size--small .dnb-table__th {
.dnb-table__size--small .dnb-table__th, .dnb-table__size--small .dnb-table thead th {
padding: 1.25rem 1rem 0.5rem;
font-size: var(--font-size-small);
line-height: var(--line-height-small);
}
tbody > tr > .dnb-table__th {
.dnb-table__td, .dnb-table tbody .dnb-table__th, .dnb-table tbody td, .dnb-table tbody th {
padding: 1rem;
color: var(--theme-color-black-80, currentColor);
font-size: var(--font-size-basis);
line-height: var(--line-height-basis);
vertical-align: baseline;
}
.dnb-table tbody .dnb-table__th, .dnb-table tbody th {
padding: 1rem;
vertical-align: baseline;
}
.dnb-table__size--medium tbody > tr > .dnb-table__th, .dnb-table__size--medium tbody > tr > .dnb-table__td {
.dnb-table__size--medium tbody .dnb-table__th, .dnb-table__size--medium tbody .dnb-table__td,
.dnb-table__size--medium .dnb-table tbody th,
.dnb-table__size--medium .dnb-table tbody td {
padding: 0.875rem 1rem;
font-size: var(--font-size-small);
line-height: var(--line-height-small);
}
.dnb-table__size--small tbody > tr > .dnb-table__th, .dnb-table__size--small tbody > tr > .dnb-table__td {
.dnb-table__size--small tbody .dnb-table__th, .dnb-table__size--small tbody .dnb-table__td,
.dnb-table__size--small .dnb-table tbody th,
.dnb-table__size--small .dnb-table tbody td {
padding: 0.625rem 1rem;
font-size: var(--font-size-small);
line-height: var(--line-height-small);
Expand Down Expand Up @@ -96,6 +105,9 @@ exports[`Table scss have to match snapshot 1`] = `
* Table component
*
*/
/*
* Utilities
*/
/*
* Button mixins
*
Expand Down Expand Up @@ -449,7 +461,7 @@ html[data-whatinput=keyboard] .dnb-table > thead > tr > th.dnb-table--active .dn
* Table component
*
*/
.dnb-table__th, .dnb-table__td {
.dnb-table thead th, .dnb-table tbody td, .dnb-table__th, .dnb-table__td {
position: relative;
border-spacing: 0;
word-break: keep-all;
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

.dnb-table {
& thead th,
& tbody td,
&__th,
&__td {
position: relative;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import '../../../style/core/utilities.scss';

@mixin tableBorder {
content: '';
position: absolute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
text-align: left;

// head
&__th {
&__th,
& thead th {
// spacing
padding: 2rem 1rem 1rem;

Expand All @@ -22,23 +23,7 @@
vertical-align: bottom;

background-color: var(--color-white);
}

// body data
&__td,
tbody > tr > &__th {
// spacing
padding: 1rem;

// typography
color: var(--theme-color-black-80, currentColor);
font-size: var(--font-size-basis);
line-height: var(--line-height-basis);
vertical-align: baseline;
}

// stylelint-disable-next-line
&__th {
.dnb-table__size--medium & {
// spacing
padding: 1.375rem 1rem 0.875rem;
Expand All @@ -62,18 +47,35 @@
}
}

// stylelint-disable-next-line
tbody > tr > &__th {
// body data
/* stylelint-disable */
&__td,
& tbody &__th,
& tbody td,
& tbody th {
// spacing
padding: 1rem;

// typography
color: var(--theme-color-black-80, currentColor);
font-size: var(--font-size-basis);
line-height: var(--line-height-basis);
vertical-align: baseline;
}

& tbody &__th,
& tbody th {
// spacing
padding: 1rem;

// typography
vertical-align: baseline;
}

// stylelint-disable-next-line
tbody > tr > &__th,
tbody > tr > &__td {
tbody &__th,
tbody &__td,
tbody th,
tbody td {
.dnb-table__size--medium & {
// spacing
padding: 0.875rem 1rem;
Expand All @@ -92,6 +94,7 @@
line-height: var(--line-height-small);
}
}
/* stylelint-enable */

// border
&:not(&--outline) > tbody > &__tr:last-of-type > &__td::after,
Expand Down

0 comments on commit 684e222

Please sign in to comment.