Skip to content
This repository was archived by the owner on Dec 11, 2021. It is now read-only.

Commit b2c7f79

Browse files
committed
Tables: Convert element styles to classes and add example using divs
1 parent e9e29a4 commit b2c7f79

File tree

3 files changed

+83
-102
lines changed

3 files changed

+83
-102
lines changed

Diff for: demos/tables.html

+54-23
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,69 @@ <h2>Tables</h2>
1919

2020
<p>Here's a paragraph to show spacing around the table. Aenean lacinia bibendum nulla sed consectetur. Maecenas faucibus mollis interdum..</p>
2121

22-
<table>
23-
<thead>
24-
<tr>
25-
<th scope="col">ID</th>
26-
<th scope="col">Product</th>
27-
<th scope="col">Category</th>
28-
<th scope="col">Price</th>
22+
<table class="table">
23+
<thead class="table-head">
24+
<tr class="table-row">
25+
<th class="table-heading" scope="col">ID</th>
26+
<th class="table-heading" scope="col">Product</th>
27+
<th class="table-heading" scope="col">Category</th>
28+
<th class="table-heading" scope="col">Price</th>
2929
</tr>
3030
</thead>
31-
<tbody>
32-
<tr>
33-
<th scope="row">1</th>
34-
<td>T-Shirt</td>
35-
<td>Apparel</td>
36-
<td>$12.99</td>
31+
<tbody class="table-body">
32+
<tr class="table-row">
33+
<th class="table-heading" scope="row">1</th>
34+
<td class="table-cell">T-Shirt</td>
35+
<td class="table-cell">Apparel</td>
36+
<td class="table-cell">$12.99</td>
3737
</tr>
38-
<tr>
39-
<th scope="row">2</th>
40-
<td>Sweat Shirt</td>
41-
<td>Apparel</td>
42-
<td>$24.99</td>
38+
<tr class="table-row">
39+
<th class="table-heading" scope="row">2</th>
40+
<td class="table-cell">Sweat Shirt</td>
41+
<td class="table-cell">Apparel</td>
42+
<td class="table-cell">$24.99</td>
4343
</tr>
44-
<tr>
45-
<th scope="row">3</th>
46-
<td>Necklace</td>
47-
<td>Accessories</td>
48-
<td>$29.99</td>
44+
<tr class="table-row">
45+
<th class="table-heading" scope="row">3</th>
46+
<td class="table-cell">Necklace</td>
47+
<td class="table-cell">Accessories</td>
48+
<td class="table-cell">$29.99</td>
4949
</tr>
5050
</tbody>
5151
</table>
5252

5353
<p>Here's a paragraph to show spacing around the table. Aenean lacinia bibendum nulla sed consectetur. Maecenas faucibus mollis interdum..</p>
5454

55+
<div class="table">
56+
<div class="table-head">
57+
<div class="table-row">
58+
<div class="table-heading" scope="col">ID</div>
59+
<div class="table-heading" scope="col">Product</div>
60+
<div class="table-heading" scope="col">Category</div>
61+
<div class="table-heading" scope="col">Price</div>
62+
</div>
63+
</div>
64+
<div class="table-body">
65+
<div class="table-row">
66+
<div class="table-heading" scope="row">1</div>
67+
<div class="table-cell">T-Shirt</div>
68+
<div class="table-cell">Apparel</div>
69+
<div class="table-cell">$12.99</div>
70+
</div>
71+
<div class="table-row">
72+
<div class="table-heading" scope="row">2</div>
73+
<div class="table-cell">Sweat Shirt</div>
74+
<div class="table-cell">Apparel</div>
75+
<div class="table-cell">$24.99</div>
76+
</div>
77+
<div class="table-row">
78+
<div class="table-heading" scope="row">3</div>
79+
<div class="table-cell">Necklace</div>
80+
<div class="table-cell">Accessories</div>
81+
<div class="table-cell">$29.99</div>
82+
</div>
83+
</div>
84+
</div>
85+
5586
</body>
5687
</html>

Diff for: scss/atoms/_tables.scss

-68
This file was deleted.

Diff for: scss/atoms/tables/_tables.scss

+29-11
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,47 @@
88
"dist/chassis",
99
"mixins";
1010

11-
table {
11+
.table {
12+
display: table;
1213
margin: map-get($table-base, margin);
1314
font-size: map-get($table-base, font-size);
1415
text-align: left;
1516
}
1617

17-
thead {
18-
border-bottom: map-get($table-base, border);
19-
> tr > th {
20-
border-top: 0;
21-
}
18+
/* thead */
19+
.table-head {
20+
display: table-header-group;
2221
}
2322

24-
td {
25-
border-top: map-get($table-base, border);
26-
padding: map-get($table-base, padding);
23+
/* tbody */
24+
.table-body {
25+
display: table-row-group;
26+
}
27+
28+
/* tfoot */
29+
.table-foot {
30+
display: table-footer-group;
31+
}
32+
33+
/* tr */
34+
.table-row {
35+
display: table-row;
2736
}
2837

29-
th {
38+
/* th */
39+
.table-heading {
40+
display: table-cell;
3041
border-top: map-get($table-base, border);
3142
padding: map-get($table-base, padding);
3243
color: map-get($colors-text, light);
3344
font-weight: 400;
3445
font-size: map-get($table-base, thead-font-size);
35-
white-space: nowrap;
46+
//white-space: nowrap;
47+
}
48+
49+
/* td */
50+
.table-cell {
51+
display: table-cell;
52+
border-top: map-get($table-base, border);
53+
padding: map-get($table-base, padding);
3654
}

0 commit comments

Comments
 (0)