Skip to content

Commit fea7bb0

Browse files
committed
recipe shortcode: add copy indicator
resolves ScottPlot/ScottPlot#4725
1 parent 1948db3 commit fea7bb0

4 files changed

Lines changed: 16 additions & 4 deletions

File tree

layouts/_default/baseof.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
3535

3636
<script src="/js/anchor.js"></script>
37-
<script src="/js/recipe.js?20250112"></script>
37+
<script src="/js/recipe.js?20250123"></script>
3838

3939
<link rel="stylesheet" href="/css/accordian.css?20231209">
4040
<link rel="stylesheet" href="/css/stats.css?20231209">
@@ -44,7 +44,7 @@
4444

4545
<link rel="stylesheet" href="/css/highlightjs/vs2015.css?20241101">
4646
<script src="/js/highlight.min.js"></script>
47-
<link rel="stylesheet" href="/css/recipe.css?20250112">
47+
<link rel="stylesheet" href="/css/recipe.css?20250123">
4848

4949
</head>
5050

layouts/shortcodes/recipe-sp5.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@
3333

3434
<div class="w-100 text-end pe-2">
3535
<button type="button" onclick="copy_button_clicked(this)" class="code-copy-button" title="Copy to Clipboard">
36+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clipboard2-check code-copied-button-hidden" viewBox="0 0 16 16">
37+
<path d="M9.5 0a.5.5 0 0 1 .5.5.5.5 0 0 0 .5.5.5.5 0 0 1 .5.5V2a.5.5 0 0 1-.5.5h-5A.5.5 0 0 1 5 2v-.5a.5.5 0 0 1 .5-.5.5.5 0 0 0 .5-.5.5.5 0 0 1 .5-.5z"/>
38+
<path d="M3 2.5a.5.5 0 0 1 .5-.5H4a.5.5 0 0 0 0-1h-.5A1.5 1.5 0 0 0 2 2.5v12A1.5 1.5 0 0 0 3.5 16h9a1.5 1.5 0 0 0 1.5-1.5v-12A1.5 1.5 0 0 0 12.5 1H12a.5.5 0 0 0 0 1h.5a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5z"/>
39+
<path d="M10.854 7.854a.5.5 0 0 0-.708-.708L7.5 9.793 6.354 8.646a.5.5 0 1 0-.708.708l1.5 1.5a.5.5 0 0 0 .708 0z"/>
40+
</svg>
3641
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
3742
class="bi bi-copy" viewBox="0 0 16 16">
38-
<path fill-rule="evenodd"
39-
d="M4 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2zm2-1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1zM2 5a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-1h1v1a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h1v1z" />
43+
<path fill-rule="evenodd" d="M4 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2zm2-1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1zM2 5a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-1h1v1a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h1v1z" />
4044
</svg>
4145
</button>
4246
</div>

static/css/recipe.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,9 @@
6969
.code-copy-button:active {
7070
background-color: #FFFFFF11 !important;
7171
opacity: 1;
72+
}
73+
74+
.code-copied-button-hidden {
75+
opacity: 0;
76+
transition: opacity 1s;
7277
}

static/js/recipe.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,7 @@ function copy_button_clicked(button) {
9999
}
100100

101101
navigator.clipboard.writeText(code);
102+
103+
button.children[0].classList.remove("code-copied-button-hidden");
104+
setTimeout(() => button.children[0].classList.add("code-copied-button-hidden"), 100);
102105
}

0 commit comments

Comments
 (0)