mirror of
https://github.com/rust-lang/book.git
synced 2026-12-01 14:46:07 -06:00
Merge pull request #4280 from rust-lang/fixes-counting-line-simplify
Ferris: always show, even when it’s small
This commit is contained in:
+22
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user