Skip to content

Commit 37d756a

Browse files
committed
Adjust overlap of code buttons with code blocks.
1 parent f878266 commit 37d756a

File tree

6 files changed

+33
-17
lines changed

6 files changed

+33
-17
lines changed

src/renderer/html_handlebars/hbs_renderer.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -880,11 +880,8 @@ fn add_playground_pre(
880880
// we need to inject our own main
881881
let (attrs, code) = partition_source(code);
882882

883-
format!(
884-
"\n# #![allow(unused)]\n{}#fn main() {{\n{}#}}",
885-
attrs, code
886-
)
887-
.into()
883+
format!("# #![allow(unused)]\n{}#fn main() {{\n{}#}}", attrs, code)
884+
.into()
888885
};
889886
hide_lines(&content)
890887
}
@@ -1007,7 +1004,7 @@ mod tests {
10071004
fn add_playground() {
10081005
let inputs = [
10091006
("<code class=\"language-rust\">x()</code>",
1010-
"<pre class=\"playground\"><code class=\"language-rust\">\n<span class=\"boring\">#![allow(unused)]\n</span><span class=\"boring\">fn main() {\n</span>x()\n<span class=\"boring\">}\n</span></code></pre>"),
1007+
"<pre class=\"playground\"><code class=\"language-rust\"><span class=\"boring\">#![allow(unused)]\n</span><span class=\"boring\">fn main() {\n</span>x()\n<span class=\"boring\">}\n</span></code></pre>"),
10111008
("<code class=\"language-rust\">fn main() {}</code>",
10121009
"<pre class=\"playground\"><code class=\"language-rust\">fn main() {}\n</code></pre>"),
10131010
("<code class=\"language-rust editable\">let s = \"foo\n # bar\n\";</code>",
@@ -1037,7 +1034,7 @@ mod tests {
10371034
fn add_playground_edition2015() {
10381035
let inputs = [
10391036
("<code class=\"language-rust\">x()</code>",
1040-
"<pre class=\"playground\"><code class=\"language-rust edition2015\">\n<span class=\"boring\">#![allow(unused)]\n</span><span class=\"boring\">fn main() {\n</span>x()\n<span class=\"boring\">}\n</span></code></pre>"),
1037+
"<pre class=\"playground\"><code class=\"language-rust edition2015\"><span class=\"boring\">#![allow(unused)]\n</span><span class=\"boring\">fn main() {\n</span>x()\n<span class=\"boring\">}\n</span></code></pre>"),
10411038
("<code class=\"language-rust\">fn main() {}</code>",
10421039
"<pre class=\"playground\"><code class=\"language-rust edition2015\">fn main() {}\n</code></pre>"),
10431040
("<code class=\"language-rust edition2015\">fn main() {}</code>",
@@ -1061,7 +1058,7 @@ mod tests {
10611058
fn add_playground_edition2018() {
10621059
let inputs = [
10631060
("<code class=\"language-rust\">x()</code>",
1064-
"<pre class=\"playground\"><code class=\"language-rust edition2018\">\n<span class=\"boring\">#![allow(unused)]\n</span><span class=\"boring\">fn main() {\n</span>x()\n<span class=\"boring\">}\n</span></code></pre>"),
1061+
"<pre class=\"playground\"><code class=\"language-rust edition2018\"><span class=\"boring\">#![allow(unused)]\n</span><span class=\"boring\">fn main() {\n</span>x()\n<span class=\"boring\">}\n</span></code></pre>"),
10651062
("<code class=\"language-rust\">fn main() {}</code>",
10661063
"<pre class=\"playground\"><code class=\"language-rust edition2018\">fn main() {}\n</code></pre>"),
10671064
("<code class=\"language-rust edition2015\">fn main() {}</code>",
@@ -1085,7 +1082,7 @@ mod tests {
10851082
fn add_playground_edition2021() {
10861083
let inputs = [
10871084
("<code class=\"language-rust\">x()</code>",
1088-
"<pre class=\"playground\"><code class=\"language-rust edition2021\">\n<span class=\"boring\">#![allow(unused)]\n</span><span class=\"boring\">fn main() {\n</span>x()\n<span class=\"boring\">}\n</span></code></pre>"),
1085+
"<pre class=\"playground\"><code class=\"language-rust edition2021\"><span class=\"boring\">#![allow(unused)]\n</span><span class=\"boring\">fn main() {\n</span>x()\n<span class=\"boring\">}\n</span></code></pre>"),
10891086
("<code class=\"language-rust\">fn main() {}</code>",
10901087
"<pre class=\"playground\"><code class=\"language-rust edition2021\">fn main() {}\n</code></pre>"),
10911088
("<code class=\"language-rust edition2015\">fn main() {}</code>",

src/theme/ayu-highlight.css

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Original by Dempfi (https://github.com/dempfi/ayu)
88
overflow-x: auto;
99
background: #191f26;
1010
color: #e6e1cf;
11-
padding: 0.5em;
1211
}
1312

1413
.hljs-comment,

src/theme/css/chrome.css

+26-2
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,10 @@ pre {
208208
pre > .buttons {
209209
position: absolute;
210210
z-index: 100;
211-
right: 5px;
212-
top: 5px;
211+
right: 0px;
212+
top: 2px;
213+
margin: 0px;
214+
padding: 2px 0px;
213215

214216
color: var(--sidebar-fg);
215217
cursor: pointer;
@@ -225,7 +227,29 @@ pre > .buttons button {
225227
background: transparent;
226228
border: none;
227229
cursor: inherit;
230+
margin: 0px;
231+
padding: 0px 0.5rem;
232+
font-size: 14px;
233+
}
234+
@media (pointer: coarse) {
235+
pre > .buttons button {
236+
/* On mobile, make it easier to tap buttons. */
237+
padding: 0 1rem;
238+
}
239+
}
240+
code {
241+
padding: 1.6rem 1rem;
228242
}
243+
244+
/* FIXME: ACE editors overlap their buttons because ACE does absolute
245+
positioning within the code block which breaks padding. The only solution I
246+
can think of is to move the padding to the outer pre tag (or insert a div
247+
wrapper), but that would require fixing a whole bunch of CSS rules.
248+
*/
249+
.hljs.ace_editor {
250+
padding: 0rem 0rem;
251+
}
252+
229253
pre > .result {
230254
margin-top: 10px;
231255
}

src/theme/css/general.css

+1-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ h6:target::before {
8080

8181
.content {
8282
overflow-y: auto;
83-
padding: 0 15px;
84-
padding-bottom: 50px;
83+
padding: 0 5px 50px 5px;
8584
}
8685
.content main {
8786
margin-left: auto;

src/theme/highlight.css

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
overflow-x: auto;
6262
background: #f6f7f6;
6363
color: #000;
64-
padding: 0.5em;
6564
}
6665

6766
.hljs-emphasis {

src/theme/tomorrow-night.css

-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@
8181
overflow-x: auto;
8282
background: #1d1f21;
8383
color: #c5c8c6;
84-
padding: 0.5em;
85-
-webkit-text-size-adjust: none;
8684
}
8785

8886
.coffeescript .javascript,

0 commit comments

Comments
 (0)