Skip to content

Commit 340dedf

Browse files
committed
- Modify code block style and remove copy button in favor of a code click
1 parent 38409f0 commit 340dedf

8 files changed

Lines changed: 38 additions & 79 deletions

File tree

app/public/css/main.css

Lines changed: 12 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/public/css/main.css.map

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/public/js/clipboard.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
$(function() {
2-
new ClipboardJS('.clipboard-button', {
2+
new ClipboardJS('.sourceCode', {
33
target: function(trigger) {
44
return trigger.parentElement;
55
}
66
});
7-
8-
html = '<a href="#" onclick="return false" class="icon clipboard-button" data-clipboard-target="code"><i class="icon-copy"></i></a>';
9-
10-
$('pre code').prepend(html);
117
})

app/styles/_code.scss

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,17 @@ code {
88
}
99

1010
pre {
11-
overflow-x: auto;
1211
position: relative;
13-
border-radius: 3px;
12+
13+
border: 1px solid var(--code-border-color);
14+
border-radius: 5px;
15+
overflow-x: auto;
16+
padding: 10px;
1417

1518
code {
1619
background-color: transparent;
1720
display: block;
18-
font-size: inherit;
19-
20-
// padding: 0 20px;
2121
line-height: 1.2;
22-
23-
.clipboard-button {
24-
background: var(--clipboard-button-bg-color);
25-
border: 1px solid var(--clipboard-button-border-color);
26-
position: absolute;
27-
left: 7px;
28-
bottom: 7px;
29-
font-size: 1.25em;
30-
border-radius: 5px;
31-
opacity: 0;
32-
transition: opacity 0.3s;
33-
display: inline-block;
34-
padding: 7px;
35-
}
36-
37-
&:hover .clipboard-button {
38-
opacity: 0.7;
39-
transition: opacity 0.3s;
40-
41-
&:hover {
42-
opacity: 1.0;
43-
transition: opacity 0.3s;
44-
}
45-
}
22+
position: relative;
4623
}
4724
}

app/styles/_pandoc_code.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pre > code.sourceCode { white-space: pre; position: relative; }
22
pre > code.sourceCode > span { line-height: 1.25; }
33
pre > code.sourceCode > span:empty { height: 1.2em; }
4-
.sourceCode { overflow: visible; }
4+
// .sourceCode { overflow: visible; }
55
code.sourceCode > span { color: inherit; text-decoration: inherit; }
66
div.sourceCode { margin: 1em 0; }
77
pre.sourceCode { margin: 0; }
@@ -10,7 +10,7 @@ div.sourceCode { overflow: auto; }
1010
}
1111
@media print {
1212
pre > code.sourceCode { white-space: pre-wrap; }
13-
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
13+
pre > code.sourceCode > span { display: inline-block; text-indent: -5em; padding-left: 5em; }
1414
}
1515
pre.numberSource code
1616
{ counter-reset: source-line 0; }

app/styles/_typography.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ body {
22
-ms-text-size-adjust: 100%;
33
-webkit-text-size-adjust: 100%;
44
color: var(--font-color);
5-
// font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
6-
font-family: "Segoe UI", "Helvetica Neue", Helvetica,Arial, freesans, sans-serif;
5+
font-family: var(--font-family);
76
font-size: 16px;
87
line-height: 1.6;
98
word-wrap: break-word;
@@ -59,5 +58,6 @@ h6 {
5958
}
6059

6160
code, pre, kbd {
62-
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
61+
font-family: var(--font-family-monospace);
6362
}
63+

app/styles/_variables.scss

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
:root {
2-
32
--background-color: #fff;
43
--blockquote-border-color: #ddd;
54
--blockquote-color: #777;
65
--breadcrumbs-border-color: #ccc;
7-
--clipboard-button-bg-color: white;
8-
--clipboard-button-border-color: #ccc;
6+
--code-border-color: #ddd;
97
--font-color: #333;
8+
--font-family: "Segoe UI", "Helvetica Neue", Helvetica,Arial, freesans, sans-serif;
9+
--font-family-monospace: Consolas, "Liberation Mono", Menlo, Courier, monospace;
1010
--footnotes-color: #666;
1111
--h1-border-color: #eee;
1212
--h1-color: #333;
@@ -36,5 +36,4 @@
3636
--table-border-color: #ddd;
3737
--table-header-bg-color: transparent;
3838
--table-row-bg-color: transparent;
39-
40-
}
39+
}

tasks/css.runfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,9 @@ action :pandoc do
3232
File.write 'tmp/pandoc-dummy.md', sample
3333

3434
puts 'Saving app/styles/_pandoc_code.scss'
35-
system 'pandoc tmp/pandoc-dummy.md --metadata title=dummy --highlight-style=pygments --template=tmp/pandoc-style.css > app/styles/_pandoc_code.scss'
35+
system 'pandoc tmp/pandoc-dummy.md --metadata title=dummy --highlight-style=pygments --template=tmp/pandoc-style.css > tmp/pandoc.scss'
36+
37+
css = File.read 'tmp/pandoc.scss'
38+
patched_css = css.gsub(/^(.sourceCode { overflow: visible; })/, '// \1')
39+
File.write 'app/styles/_pandoc_code.scss', patched_css
3640
end

0 commit comments

Comments
 (0)