Skip to content

Commit

Permalink
Improved HTML table rendering
Browse files Browse the repository at this point in the history
fixes #17
  • Loading branch information
minimaluminium committed Jan 3, 2024
1 parent c060944 commit ebc4792
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion assets/built/screen.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/built/screen.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/built/source.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/built/source.js.map

Large diffs are not rendered by default.

49 changes: 20 additions & 29 deletions assets/css/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -2204,51 +2204,42 @@ unless a heading is the very first element in the post content */
border: 0;
}

.gh-content table:not(.gist table) {
display: inline-block;
width: auto;
max-width: 100%;
overflow-x: auto;
.gh-content .gh-table {
overflow-x: scroll;
-webkit-overflow-scrolling: touch;
}

.gh-content .gh-table table {
width: 100%;
font-family: var(--font-sans);
font-size: 1.6rem;
font-size: 1.5rem;
white-space: nowrap;
vertical-align: top;
border-spacing: 0;
border-collapse: collapse;
-webkit-overflow-scrolling: touch;
background: radial-gradient(ellipse at left, rgb(0 0 0 / 0.2) 0%, rgb(0 0 0 / 0) 75%) 0 center, radial-gradient(ellipse at right, rgb(0 0 0 / 0.2) 0%, rgb(0 0 0 / 0) 75%) 100% center;
background-repeat: no-repeat;
background-attachment: scroll, scroll;
background-size: 10px 100%, 10px 100%;
}

.gh-content table:not(.gist table) td:first-child {
background-image: linear-gradient(to right, rgb(255 255 255 / 1) 50%, rgb(255 255 255 / 0) 100%);
background-repeat: no-repeat;
background-size: 20px 100%;
}

.gh-content table:not(.gist table) td:last-child {
background-image: linear-gradient(to left, rgb(255 255 255 / 1) 50%, rgb(255 255 255 / 0) 100%);
background-repeat: no-repeat;
background-position: 100% 0;
background-size: 20px 100%;
}

.gh-content table:not(.gist table) th {
.gh-content .gh-table table th {
font-size: 1.2rem;
font-weight: 700;
color: var(--color-darkgrey);
text-align: left;
text-transform: uppercase;
letter-spacing: 0.2px;
background-color: var(--color-white);
}

.gh-content table:not(.gist table) th,
.gh-content table:not(.gist table) td {
.gh-content .gh-table table :is(th, td),
.gh-content .gh-table table td {
padding: 6px 12px;
border: 1px solid var(--color-light-gray);
border-bottom: 1px solid var(--color-border);
}

.gh-content .gh-table table :is(th, td):first-child {
padding-left: 0;
}

.gh-content .gh-table table :is(th, td):last-child {
padding-right: 0;
}

/* 16. Cards
Expand Down
12 changes: 12 additions & 0 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,16 @@
if (!document.body.classList.contains('home-template') && !document.body.classList.contains('post-template')) {
pagination();
}
})();

/* Responsive HTML table */
(function () {
const tables = document.querySelectorAll('.gh-content > table:not(.gist table)');
const wrapper = document.createElement('div');
wrapper.className = 'gh-table';

tables.forEach(function (table) {
table.parentNode.insertBefore(wrapper, table);
wrapper.appendChild(table);
});
})();

0 comments on commit ebc4792

Please sign in to comment.