Skip to content

Commit

Permalink
doc: refactor copy to clipboard button (#2894)
Browse files Browse the repository at this point in the history
* doc: remove copy button background colour

the motivation for this commit is that I often get a feeling of having
marked the COPY buttons, but when I check, it turns out I haven't

that happens because the COPY buttons have a background colour that is
basically the same as when you mark text

* doc: use emoji for copy button

kind seems to be fond of emojis, it can maybe work here as well?

* doc: copy kubernetes.io code blocks design

as per feedback in PR

* doc: comply with copycode.svg license

* Revert "doc: comply with copycode.svg license"

This reverts commit c018fda.
  • Loading branch information
aude authored Oct 26, 2022
1 parent 17d2276 commit 1545581
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
33 changes: 14 additions & 19 deletions site/assets/css/inline.css
Original file line number Diff line number Diff line change
Expand Up @@ -261,38 +261,33 @@ table.includecode {
max-width: 100%;
width: 100%;
table-layout: fixed;
background: #f3f4f4;
border: .15em solid black;
border: 1px solid rgba(0,0,0,.125);
border-spacing: 0;
}

table.includecode thead {
background: #333;
color: white;
}

table.includecode thead th a {
color: white;
}

table.includecode thead th {
border-bottom: .1em solid black;
border-bottom: 1px solid rgba(0,0,0,.125);
font-weight: normal;
font-size: .9em;
font-size: 85%;
}

table.includecode thead th {
text-align: right;
}

table.includecode thead th a {
font-family: monospace;
}

table.includecode thead th button {
background: #326be5;
border: .25em solid white;
color: white;
font-weight: bold;
margin: .25em;
vertical-align: middle;
background: transparent;
border: 0;
cursor: pointer;
padding: .1em .5em;
}

table.includecode tbody {
background: #f3f4f4;
}

table.includecode pre {
Expand Down
10 changes: 7 additions & 3 deletions site/layouts/shortcodes/codeFromFile.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
<table class="includecode" id="code-{{ $virtualPath }}">
<thead>
<tr>
<th><a href="/{{ $virtualPath }}">{{ $virtualPath }}</a> <button
onclick='copyText("code-{{ $virtualPath }}-hidden-copy-text");'>COPY</button></th>
<th>
<a href="/{{ $virtualPath }}">{{ $virtualPath }}</a>
<button onclick='copyText("code-{{ $virtualPath }}-hidden-copy-text");' title="Copy to clipboard">
<img src="{{ "copycode.svg" | relURL }}" alt="Copy">
</button>
</th>
</tr>
</thead>
<tbody>
Expand All @@ -19,4 +23,4 @@
</tr>
</tbody>
<textarea class="hidden-copy-text" id="code-{{ $virtualPath }}-hidden-copy-text">{{ ($file | readFile) }}</textarea>
</table>
</table>
7 changes: 5 additions & 2 deletions site/layouts/shortcodes/codeFromInline.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
<table class="includecode" id="inline-code-{{ $hash }}">
<thead>
<tr>
<th> <button
onclick='copyText("inline-code-{{ $hash }}-hidden-copy-text");'>COPY</button></th>
<th>
<button onclick='copyText("inline-code-{{ $hash }}-hidden-copy-text");' title="Copy to clipboard">
<img src="{{ "copycode.svg" | relURL }}" alt="Copy">
</button>
</th>
</tr>
</thead>
<tbody>
Expand Down
3 changes: 3 additions & 0 deletions site/static/copycode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1545581

Please sign in to comment.