Skip to content
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
15 changes: 11 additions & 4 deletions assets/style/_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,21 @@ a.card:hover .card-meta { color: var(--color-primary-600); }
/* =========================================================================
* Tables
* ========================================================================= */
/* The render-table hook wraps every Markdown table in .table-wrap: wide
* tables scroll inside their own box on narrow screens instead of
* overflowing the page. Border + radius sit on the wrapper so the frame
* stays put while the table scrolls under it. */
.prose .table-wrap {
margin-top: 1.4rem;
overflow-x: auto;
border: 1px solid var(--color-line);
border-radius: var(--radius-md);
-webkit-overflow-scrolling: touch;
}
.prose table {
width: 100%;
border-collapse: collapse;
margin-top: 1.4rem;
font-size: var(--font-size-300);
border: 1px solid var(--color-line);
border-radius: var(--radius-md);
overflow: hidden;
}
.prose thead { background: var(--color-base-soft); }
.prose th {
Expand Down
34 changes: 34 additions & 0 deletions layouts/_default/_markup/render-table.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{- /* Wrap every Markdown table in a horizontal scroll container so wide
tables scroll within their own box on narrow screens instead of overflowing
the page (the border + radius live on the wrapper — see _components.scss). */ -}}
<div class="table-wrap">
<table
{{- range $k, $v := .Attributes }}
{{- if $v }}
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
{{- end }}
{{- end }}>
<thead>
{{- range .THead }}
<tr>
{{- range . }}
<th {{- with .Alignment }} style="text-align: {{ . }}"{{ end }}>
{{- .Text -}}
</th>
{{- end }}
</tr>
{{- end }}
</thead>
<tbody>
{{- range .TBody }}
<tr>
{{- range . }}
<td {{- with .Alignment }} style="text-align: {{ . }}"{{ end }}>
{{- .Text -}}
</td>
{{- end }}
</tr>
{{- end }}
</tbody>
</table>
</div>