Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: display the entire code block #610

Merged
merged 1 commit into from
May 13, 2022
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
7 changes: 0 additions & 7 deletions assets/css/_mixin/_details.scss

This file was deleted.

1 change: 0 additions & 1 deletion assets/css/_mixin/_index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@import "_compatibility";
@import "_link";
@import "_blur";
@import "_details";
5 changes: 2 additions & 3 deletions assets/css/_partial/_details.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
.details-content {
max-height: 0;
overflow-y: hidden;
@include details-transition-open;
transition: max-height 0.5s ease-out;
}

&.open {
Expand All @@ -29,8 +29,7 @@
}

.details-content {
max-height: 12000px;
@include details-transition-close;
max-height: none;
}
}
}
10 changes: 4 additions & 6 deletions assets/css/_partial/_single/_code.scss
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ code, pre, .highlight table, .highlight tr, .highlight td {

.table-wrapper {
max-height: 0;
overflow-y: hidden;
@include details-transition-open;
overflow: hidden;
transition: max-height 0.5s ease-out;
}

&.open {
Expand All @@ -191,11 +191,9 @@ code, pre, .highlight table, .highlight tr, .highlight td {
background: darken($code-background-color-black, 3%);
}
}

.table-wrapper {
max-height: 60vh;
overflow-y: auto;
@include details-transition-close;
max-height: none;
}

.arrow {
Expand Down
12 changes: 12 additions & 0 deletions assets/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,12 @@ function initDetails () {
forEach(document.getElementsByClassName('details'), $details => {
const $summary = $details.getElementsByClassName('details-summary')[0]
$summary.addEventListener('click', () => {
const content = $summary.nextElementSibling
if ($details.classList.contains('open')) {
content.style.maxHeight = null
} else {
content.style.maxHeight = content.scrollHeight + 'px'
}
$details.classList.toggle('open')
}, false)
})
Expand Down Expand Up @@ -521,6 +527,12 @@ function initHighlight () {
$title.classList.add('code-title')
$title.insertAdjacentHTML('afterbegin', '<i class="arrow fas fa-chevron-right fa-fw"></i>')
$title.addEventListener('click', () => {
const content = $chroma.getElementsByClassName('table-wrapper')[0]
if ($chroma.classList.contains('open')) {
content.style.maxHeight = null
} else {
content.style.maxHeight = content.scrollHeight + 'px'
}
$chroma.classList.toggle('open')
}, false)
$header.appendChild($title)
Expand Down