Merge pull request #1806 from ehuss/button-overlap
Make code buttons appear on hover (or tap on mobile)
This commit is contained in:
commit
cbf0ca027d
|
@ -880,11 +880,8 @@ fn add_playground_pre(
|
||||||
// we need to inject our own main
|
// we need to inject our own main
|
||||||
let (attrs, code) = partition_source(code);
|
let (attrs, code) = partition_source(code);
|
||||||
|
|
||||||
format!(
|
format!("# #![allow(unused)]\n{}#fn main() {{\n{}#}}", attrs, code)
|
||||||
"\n# #![allow(unused)]\n{}#fn main() {{\n{}#}}",
|
.into()
|
||||||
attrs, code
|
|
||||||
)
|
|
||||||
.into()
|
|
||||||
};
|
};
|
||||||
hide_lines(&content)
|
hide_lines(&content)
|
||||||
}
|
}
|
||||||
|
@ -1007,7 +1004,7 @@ mod tests {
|
||||||
fn add_playground() {
|
fn add_playground() {
|
||||||
let inputs = [
|
let inputs = [
|
||||||
("<code class=\"language-rust\">x()</code>",
|
("<code class=\"language-rust\">x()</code>",
|
||||||
"<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>"),
|
"<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>"),
|
||||||
("<code class=\"language-rust\">fn main() {}</code>",
|
("<code class=\"language-rust\">fn main() {}</code>",
|
||||||
"<pre class=\"playground\"><code class=\"language-rust\">fn main() {}\n</code></pre>"),
|
"<pre class=\"playground\"><code class=\"language-rust\">fn main() {}\n</code></pre>"),
|
||||||
("<code class=\"language-rust editable\">let s = \"foo\n # bar\n\";</code>",
|
("<code class=\"language-rust editable\">let s = \"foo\n # bar\n\";</code>",
|
||||||
|
@ -1037,7 +1034,7 @@ mod tests {
|
||||||
fn add_playground_edition2015() {
|
fn add_playground_edition2015() {
|
||||||
let inputs = [
|
let inputs = [
|
||||||
("<code class=\"language-rust\">x()</code>",
|
("<code class=\"language-rust\">x()</code>",
|
||||||
"<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>"),
|
"<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>"),
|
||||||
("<code class=\"language-rust\">fn main() {}</code>",
|
("<code class=\"language-rust\">fn main() {}</code>",
|
||||||
"<pre class=\"playground\"><code class=\"language-rust edition2015\">fn main() {}\n</code></pre>"),
|
"<pre class=\"playground\"><code class=\"language-rust edition2015\">fn main() {}\n</code></pre>"),
|
||||||
("<code class=\"language-rust edition2015\">fn main() {}</code>",
|
("<code class=\"language-rust edition2015\">fn main() {}</code>",
|
||||||
|
@ -1061,7 +1058,7 @@ mod tests {
|
||||||
fn add_playground_edition2018() {
|
fn add_playground_edition2018() {
|
||||||
let inputs = [
|
let inputs = [
|
||||||
("<code class=\"language-rust\">x()</code>",
|
("<code class=\"language-rust\">x()</code>",
|
||||||
"<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>"),
|
"<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>"),
|
||||||
("<code class=\"language-rust\">fn main() {}</code>",
|
("<code class=\"language-rust\">fn main() {}</code>",
|
||||||
"<pre class=\"playground\"><code class=\"language-rust edition2018\">fn main() {}\n</code></pre>"),
|
"<pre class=\"playground\"><code class=\"language-rust edition2018\">fn main() {}\n</code></pre>"),
|
||||||
("<code class=\"language-rust edition2015\">fn main() {}</code>",
|
("<code class=\"language-rust edition2015\">fn main() {}</code>",
|
||||||
|
@ -1085,7 +1082,7 @@ mod tests {
|
||||||
fn add_playground_edition2021() {
|
fn add_playground_edition2021() {
|
||||||
let inputs = [
|
let inputs = [
|
||||||
("<code class=\"language-rust\">x()</code>",
|
("<code class=\"language-rust\">x()</code>",
|
||||||
"<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>"),
|
"<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>"),
|
||||||
("<code class=\"language-rust\">fn main() {}</code>",
|
("<code class=\"language-rust\">fn main() {}</code>",
|
||||||
"<pre class=\"playground\"><code class=\"language-rust edition2021\">fn main() {}\n</code></pre>"),
|
"<pre class=\"playground\"><code class=\"language-rust edition2021\">fn main() {}\n</code></pre>"),
|
||||||
("<code class=\"language-rust edition2015\">fn main() {}</code>",
|
("<code class=\"language-rust edition2015\">fn main() {}</code>",
|
||||||
|
|
|
@ -8,7 +8,6 @@ Original by Dempfi (https://github.com/dempfi/ayu)
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
background: #191f26;
|
background: #191f26;
|
||||||
color: #e6e1cf;
|
color: #e6e1cf;
|
||||||
padding: 0.5em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.hljs-comment,
|
.hljs-comment,
|
||||||
|
|
|
@ -208,24 +208,63 @@ pre {
|
||||||
pre > .buttons {
|
pre > .buttons {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
right: 5px;
|
right: 0px;
|
||||||
top: 5px;
|
top: 2px;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 2px 0px;
|
||||||
|
|
||||||
color: var(--sidebar-fg);
|
color: var(--sidebar-fg);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
visibility: hidden;
|
||||||
|
opacity: 0;
|
||||||
|
transition: visibility 0.1s linear, opacity 0.1s linear;
|
||||||
|
}
|
||||||
|
pre:hover > .buttons {
|
||||||
|
visibility: visible;
|
||||||
|
opacity: 1
|
||||||
}
|
}
|
||||||
pre > .buttons :hover {
|
pre > .buttons :hover {
|
||||||
color: var(--sidebar-active);
|
color: var(--sidebar-active);
|
||||||
|
border-color: var(--icons-hover);
|
||||||
|
background-color: var(--theme-hover);
|
||||||
}
|
}
|
||||||
pre > .buttons i {
|
pre > .buttons i {
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
}
|
}
|
||||||
pre > .buttons button {
|
pre > .buttons button {
|
||||||
color: inherit;
|
|
||||||
background: transparent;
|
|
||||||
border: none;
|
|
||||||
cursor: inherit;
|
cursor: inherit;
|
||||||
|
margin: 0px 5px;
|
||||||
|
padding: 3px 5px;
|
||||||
|
font-size: 14px;
|
||||||
|
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 1px;
|
||||||
|
border-radius: 4px;
|
||||||
|
border-color: var(--icons);
|
||||||
|
background-color: var(--theme-popup-bg);
|
||||||
|
transition: 100ms;
|
||||||
|
transition-property: color,border-color,background-color;
|
||||||
|
color: var(--icons);
|
||||||
}
|
}
|
||||||
|
@media (pointer: coarse) {
|
||||||
|
pre > .buttons button {
|
||||||
|
/* On mobile, make it easier to tap buttons. */
|
||||||
|
padding: 0.3rem 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
code {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: ACE editors overlap their buttons because ACE does absolute
|
||||||
|
positioning within the code block which breaks padding. The only solution I
|
||||||
|
can think of is to move the padding to the outer pre tag (or insert a div
|
||||||
|
wrapper), but that would require fixing a whole bunch of CSS rules.
|
||||||
|
*/
|
||||||
|
.hljs.ace_editor {
|
||||||
|
padding: 0rem 0rem;
|
||||||
|
}
|
||||||
|
|
||||||
pre > .result {
|
pre > .result {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,8 +90,7 @@ h6:target::before {
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding: 0 15px;
|
padding: 0 5px 50px 5px;
|
||||||
padding-bottom: 50px;
|
|
||||||
}
|
}
|
||||||
.content main {
|
.content main {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
|
|
|
@ -61,7 +61,6 @@
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
background: #f6f7f6;
|
background: #f6f7f6;
|
||||||
color: #000;
|
color: #000;
|
||||||
padding: 0.5em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.hljs-emphasis {
|
.hljs-emphasis {
|
||||||
|
|
|
@ -81,8 +81,6 @@
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
background: #1d1f21;
|
background: #1d1f21;
|
||||||
color: #c5c8c6;
|
color: #c5c8c6;
|
||||||
padding: 0.5em;
|
|
||||||
-webkit-text-size-adjust: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.coffeescript .javascript,
|
.coffeescript .javascript,
|
||||||
|
|
Loading…
Reference in New Issue