File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
packages/sfc-playground/src Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
2
import { onMounted , ref } from ' vue'
3
+ import Copy from ' ./icons/Copy.vue'
3
4
4
5
const expanded = ref (false )
5
6
const versions = ref <string []>()
@@ -53,6 +54,12 @@ function setVersion(v: string) {
53
54
expanded .value = false
54
55
}
55
56
57
+ function copyVersion(v : string ) {
58
+ window .navigator .clipboard .writeText (v ).then (() => {
59
+ alert (' Vue version has been copied to clipboard.' )
60
+ })
61
+ }
62
+
56
63
onMounted (() => {
57
64
window .addEventListener (' click' , () => {
58
65
expanded .value = false
@@ -76,11 +83,19 @@ onMounted(() => {
76
83
<li v-if =" !versions" ><a >loading versions...</a ></li >
77
84
<li
78
85
v-for =" (ver, index) of versions"
86
+ class =" versions-item"
79
87
:class =" {
80
88
active: ver === version || (version === 'latest' && index === 0),
81
89
}"
82
90
>
83
91
<a @click =" setVersion(ver)" >v{{ ver }}</a >
92
+ <button
93
+ title =" Copy Version"
94
+ class =" version-copy"
95
+ @click =" copyVersion(`v${ver}`)"
96
+ >
97
+ <Copy />
98
+ </button >
84
99
</li >
85
100
<div @click =" expanded = false" >
86
101
<slot />
@@ -120,4 +135,17 @@ onMounted(() => {
120
135
.versions .active a {
121
136
color : var (--green );
122
137
}
138
+
139
+ .versions .versions-item {
140
+ display : flex ;
141
+ justify-content : space-between ;
142
+ }
143
+
144
+ .versions .versions-item .version-copy {
145
+ display : none ;
146
+ }
147
+
148
+ .versions .versions-item :hover .version-copy {
149
+ display : block ;
150
+ }
123
151
</style >
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <svg
3
+ xmlns =" http://www.w3.org/2000/svg"
4
+ width =" 1.3em"
5
+ height =" 1.3em"
6
+ viewBox =" 0 0 24 24"
7
+ >
8
+ <path fill =" currentColor" d =" M8 7h11v14H8z" opacity =" .3" />
9
+ <path
10
+ fill =" currentColor"
11
+ d =" M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m0 16H8V7h11z"
12
+ />
13
+ </svg >
14
+ </template >
You can’t perform that action at this time.
0 commit comments