Skip to content

Commit 4245bf7

Browse files
authored
feat: added table styling (#129)
1 parent b374a6e commit 4245bf7

File tree

3 files changed

+111
-64
lines changed

3 files changed

+111
-64
lines changed

assets/css/v2/style.css

Lines changed: 94 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
--color-footer: #1D1D1D;
2020
--color-footer-text: #E2E2E2;
2121
--color-product-title: #8D8D8D;
22+
--color-table-divider: #CCCCCC;
2223

2324
--sidebar-margin: 24px;
2425
--sidebar-line-box-side-length: 8px;
@@ -27,6 +28,13 @@
2728
--sidebar-width: 24rem;
2829
--sidebar-line-width: 11.5px;
2930
--side-gutter-width: 20rem;
31+
--table-top-bottom-spacing: 3rem;
32+
--table-row-space-between: 1.5rem;
33+
--table-min-column-spacing-narrow: 1.5rem;
34+
--table-min-column-spacing-wide: 0.75rem;
35+
--table-header-bottom-spacing: 1rem;
36+
--table-line-extension: 1rem;
37+
--table-line-height: 1px;
3038
--text-content-width-iphone-13: 30rem;
3139
--text-content-width-mbp-14: 40rem;
3240
--text-content-width-mbp-16: 50rem;
@@ -188,11 +196,6 @@ nav {
188196
min-width: 100%;
189197
}
190198

191-
.main-layout {
192-
display: grid;
193-
grid-template-columns: 1fr;
194-
}
195-
196199
.sidebar-layout {
197200
display: flex;
198201
flex-direction: column;
@@ -205,58 +208,6 @@ nav {
205208
}
206209
}
207210

208-
.text-content {
209-
grid-column-start: 1;
210-
}
211-
212-
@media (min-width: 1512px) { /* Macbook Pro 14 */
213-
.main-layout {
214-
display: grid;
215-
grid-template-columns: var(--sidebar-width) 1fr;
216-
column-gap: var(--component-gap);
217-
}
218-
219-
.content-layout {
220-
display: grid;
221-
grid-template-columns: var(--text-content-width-mbp-14) var(--side-gutter-width);
222-
column-gap: var(--component-gap);
223-
}
224-
225-
.content-layout .side-gutter {
226-
grid-column-start: 2;
227-
}
228-
229-
.base-layout {
230-
display: grid;
231-
grid-template-rows: repeat(2, auto);
232-
column-gap: var(--component-gap);
233-
}
234-
235-
.breadcrumb-layout {
236-
display: grid;
237-
grid-template-columns: var(--sidebar-width) 1fr;
238-
column-gap: var(--component-gap);
239-
align-items: center;
240-
margin: 0 2rem;
241-
}
242-
}
243-
244-
@media (min-width: 1728px) { /* Macbook Pro 16 */
245-
.content-layout {
246-
display: grid;
247-
grid-template-columns: var(--text-content-width-mbp-16) var(--side-gutter-width);
248-
column-gap: var(--component-gap);
249-
}
250-
}
251-
252-
@media (min-width: 2560px) { /* 4k Desktop */
253-
.content-layout {
254-
display: grid;
255-
grid-template-columns: var(--text-content-width-4k-display) var(--side-gutter-width);
256-
column-gap: var(--component-gap);
257-
}
258-
}
259-
260211
#searchbox {
261212
width: 24rem;
262213
display:none;
@@ -286,14 +237,21 @@ nav {
286237
flex-direction: column;
287238
}
288239

289-
.content-layout {
240+
.text-content {
241+
grid-column-start: 1;
290242
display: grid;
291-
grid-template-columns: var(--text-content-width-iphone-13) var(--side-gutter-width);
292-
column-gap: var(--component-gap);
293243
}
294244

295-
.text-content {
296-
grid-column-start: 1;
245+
.text-content > :not(.wide) {
246+
grid-column: 1;
247+
}
248+
249+
.text-content .wide {
250+
grid-column: 1 / -1;
251+
}
252+
253+
.text-content table {
254+
width: 100%;
297255
}
298256

299257
@media (min-width: 1512px) { /* Macbook Pro 14 */
@@ -310,6 +268,11 @@ nav {
310268
align-items: center;
311269
}
312270

271+
.text-content {
272+
grid-template-columns: var(--text-content-width-mbp-14) var(--side-gutter-width);
273+
column-gap: var(--component-gap);
274+
}
275+
313276
.main-layout {
314277
display: grid;
315278
grid-template-columns: var(--sidebar-width) 1fr;
@@ -333,6 +296,11 @@ nav {
333296
grid-template-columns: var(--text-content-width-mbp-16) var(--side-gutter-width);
334297
column-gap: var(--component-gap);
335298
}
299+
300+
.text-content {
301+
grid-template-columns: var(--text-content-width-mbp-16) var(--side-gutter-width);
302+
column-gap: var(--component-gap);
303+
}
336304
}
337305

338306
@media (min-width: 2560px) { /* 4k Desktop */
@@ -341,6 +309,11 @@ nav {
341309
grid-template-columns: var(--text-content-width-4k-display) var(--side-gutter-width);
342310
column-gap: var(--component-gap);
343311
}
312+
313+
.text-content {
314+
grid-template-columns: var(--text-content-width-4k-display) var(--side-gutter-width);
315+
column-gap: var(--component-gap);
316+
}
344317
}
345318

346319
.main {
@@ -672,6 +645,65 @@ h2 {
672645
margin: 3rem 0 1rem 0;
673646
}
674647

648+
/* tables */
649+
table {
650+
td {
651+
padding: var(--table-row-space-between) 0;
652+
}
653+
654+
th {
655+
font-weight: bold;
656+
text-align: start;
657+
vertical-align: top;
658+
padding-bottom: var(--table-header-bottom-spacing);
659+
}
660+
661+
tr {
662+
position: relative;
663+
}
664+
665+
tr::after {
666+
content: '';
667+
position: absolute;
668+
border-bottom: var(--table-line-height) solid var(--color-table-divider);
669+
bottom: 0;
670+
left: calc(-1 * var(--table-line-extension));
671+
width: calc(100% + (2 * var(--table-line-extension)));
672+
}
673+
}
674+
675+
.narrow table {
676+
min-width: 100%;
677+
margin: var(--table-top-bottom-spacing) 0;
678+
border-collapse: collapse;
679+
}
680+
681+
.wide table {
682+
margin: var(--table-top-bottom-spacing) 0;
683+
border-collapse: collapse;
684+
}
685+
686+
.narrow table th,
687+
.narrow table td {
688+
padding-left: var(--table-min-column-spacing-narrow);
689+
}
690+
691+
.wide table th,
692+
.wide table td {
693+
padding-left: var(--table-min-column-spacing-wide);
694+
}
695+
696+
table th:first-child,
697+
table td:first-child {
698+
padding-left: 0;
699+
}
700+
701+
table hr {
702+
color: var(--color-table-divider);
703+
border: none;
704+
border-bottom: var(--table-line-height) solid var(--color-table-divider);
705+
}
706+
675707
/* callouts */
676708
blockquote {
677709
border: 1px solid var(--color-foreground);

layouts/_default/baseof.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
}
7373
});
7474

75+
document.querySelectorAll(".table-v1").forEach((table) => {
76+
table.style.display = isNewTheme ? "none" : "";
77+
});
78+
7579
const mfElements = ['[data-mf="true"]'];
7680
mfElements.forEach((elementId) => {
7781
document.querySelectorAll(elementId).forEach(
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
{{ $htmlTable := .Inner | markdownify }}
22
{{ $class := .Get 0 }}
33
{{ $old := "<table>" }}
4-
{{ $new := printf "<table class=\"%s\">" $class }}
4+
{{ $new := printf "<table class=\"%s %s\">" $class "table-v1" }}
55
{{ $htmlTable := replace $htmlTable $old $new }}
6-
{{ $htmlTable | safeHTML }}
6+
{{ $htmlTable | safeHTML }}
7+
8+
<!-- Add default option for table of "narrow" if one is not provided -->
9+
{{ $narrowOption := "narrow" }}
10+
{{ $wideOption := "wide" }}
11+
{{ if and (not (strings.Contains $class $narrowOption)) (not (strings.Contains $class $wideOption)) }}
12+
{{ $class = printf "%s %s" $class $narrowOption }}
13+
{{ end }}
14+
15+
<div data-mf="true" style="display: none;" class="table-v2 {{ $class }}">
16+
{{ .Inner | markdownify }}
17+
</div>

0 commit comments

Comments
 (0)