Skip to content

Commit 2682428

Browse files
committed
add code snippet copied tooltip
1 parent 5b88d28 commit 2682428

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

assets/_custom.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,18 @@ a .r-icon {
9797
background-color: rgba(255, 221, 102, .1);
9898
}
9999

100+
.copied-tooltip {
101+
visibility: hidden;
102+
width: 95px;
103+
background-color: #93f19c;
104+
color: #333;
105+
text-align: center;
106+
border-radius: 4px;
107+
padding: 5px;
108+
position: absolute;
109+
z-index: 100;
110+
left: 48%;
111+
top:1%;
112+
opacity: 0;
113+
transition: opacity 0.3s;
114+
}

content/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type: docs
3131

3232
<div id="resty-go-mod" class="resty-go-mod">
3333
<pre>
34-
require resty.dev/v3 {{% param Resty.V3.Version %}}
34+
<code>require resty.dev/v3 {{% param Resty.V3.Version %}}</code>
3535
</pre>
3636
</div>
3737

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<div class="copied-tooltip" id="copied-tooltip">Copied!</div>
2+
<script>
3+
(function() {
4+
document.querySelectorAll("pre code").forEach(t => {
5+
t.addEventListener("click", function() {
6+
let toolTip = document.getElementById("copied-tooltip");
7+
toolTip.style.visibility = "visible";
8+
toolTip.style.opacity = 1;
9+
setTimeout(function() {
10+
toolTip.style.visibility = "hidden";
11+
toolTip.style.opacity = 0;
12+
}, 1000);
13+
})
14+
})
15+
})()
16+
</script>

0 commit comments

Comments
 (0)