File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -43,3 +43,25 @@ body.ayu .not_desired_behavior {
4343.ferris-explain {
4444 width : 100px ;
4545}
46+
47+ /*
48+ A bit of a hack to make small Ferris use the existing buttons container but
49+ only show/hide the buttons on hover over the `pre`. Targeting `.listing`
50+ increases the specificity of this rule.
51+ */
52+ pre > .buttons {
53+ visibility : visible;
54+ opacity : 1 ;
55+ transition : none;
56+ }
57+
58+ pre > .buttons button {
59+ visibility : hidden;
60+ opacity : 0 ;
61+ transition : visibility 0.1s linear, opacity 0.1s linear;
62+ }
63+
64+ pre : hover > .buttons button {
65+ visibility : visible;
66+ opacity : 1 ;
67+ }
Original file line number Diff line number Diff line change @@ -40,10 +40,12 @@ function attachFerrises(type) {
4040 continue ;
4141 }
4242
43- let lines = codeBlock . innerText . replace ( / \n $ / , "" ) . split ( / \n / ) . length ;
43+ let codeLines = codeBlock . innerText ;
44+ let extra = codeLines . endsWith ( "\n" ) ? 1 : 0 ;
45+ let numLines = codeLines . split ( "\n" ) . length - extra ;
4446
4547 /** @type {'small' | 'large' } */
46- let size = lines < 4 ? "small" : "large" ;
48+ let size = numLines < 4 ? "small" : "large" ;
4749
4850 let container = prepareFerrisContainer ( codeBlock , size == "small" ) ;
4951 if ( ! container ) {
You can’t perform that action at this time.
0 commit comments