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
22 changes: 22 additions & 0 deletions ferris.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,25 @@ body.ayu .not_desired_behavior {
.ferris-explain {
width: 100px;
}

/*
A bit of a hack to make small Ferris use the existing buttons container but
only show/hide the buttons on hover over the `pre`. Targeting `.listing`
increases the specificity of this rule.
*/
pre > .buttons {
visibility: visible;
opacity: 1;
transition: none;
}

pre > .buttons button {
visibility: hidden;
opacity: 0;
transition: visibility 0.1s linear, opacity 0.1s linear;
}

pre:hover > .buttons button {
visibility: visible;
opacity: 1;
}
6 changes: 4 additions & 2 deletions ferris.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ function attachFerrises(type) {
continue;
}

let lines = codeBlock.innerText.replace(/\n$/, "").split(/\n/).length;
let codeLines = codeBlock.innerText;
let extra = codeLines.endsWith("\n") ? 1 : 0;
let numLines = codeLines.split("\n").length - extra;

/** @type {'small' | 'large'} */
let size = lines < 4 ? "small" : "large";
let size = numLines < 4 ? "small" : "large";

let container = prepareFerrisContainer(codeBlock, size == "small");
if (!container) {
Expand Down