|
1 | 1 | <script setup lang="ts"> |
| 2 | +import { ref, onMounted, onUnmounted } from "vue"; |
2 | 3 | import { useResponsive } from "../../composables/useResponsive"; |
3 | 4 | import { URLS } from "../../constants/urls"; |
4 | 5 |
|
5 | 6 | defineProps<{ |
6 | 7 | copyStatus: "idle" | "copied"; |
7 | 8 | shareStatus: "idle" | "copied"; |
| 9 | + oneLinerStatus: "idle" | "copied"; |
8 | 10 | files: string[]; |
9 | 11 | activeFile: string; |
10 | 12 | }>(); |
11 | 13 |
|
12 | 14 | const emit = defineEmits<{ |
13 | 15 | (e: "copy"): void; |
14 | 16 | (e: "share"): void; |
| 17 | + (e: "one-liner"): void; |
15 | 18 | (e: "download"): void; |
16 | 19 | (e: "reset"): void; |
17 | 20 | (e: "update:activeFile", file: string): void; |
18 | 21 | }>(); |
19 | 22 |
|
20 | 23 | const { isMobile } = useResponsive(); |
| 24 | +const showCopyMenu = ref(false); |
| 25 | +
|
| 26 | +function handleClickOutside(e: MouseEvent) { |
| 27 | + const target = e.target as HTMLElement; |
| 28 | + if (showCopyMenu.value && !target.closest(".copy-dropdown-container")) { |
| 29 | + showCopyMenu.value = false; |
| 30 | + } |
| 31 | +} |
| 32 | +
|
| 33 | +onMounted(() => { |
| 34 | + window.addEventListener("click", handleClickOutside); |
| 35 | +}); |
| 36 | +
|
| 37 | +onUnmounted(() => { |
| 38 | + window.removeEventListener("click", handleClickOutside); |
| 39 | +}); |
21 | 40 | </script> |
22 | 41 |
|
23 | 42 | <template> |
@@ -89,46 +108,145 @@ const { isMobile } = useResponsive(); |
89 | 108 | </div> |
90 | 109 | </div> |
91 | 110 |
|
92 | | - <div class="flex items-center gap-1 sm:gap-2 px-2 sm:px-4"> |
93 | | - <button |
94 | | - @click="$emit('copy')" |
95 | | - class="flex items-center gap-1.5 px-2 py-1.5 rounded hover:bg-ide-accent/10 transition-colors text-ide-text-muted hover:text-ide-text-bright group" |
96 | | - :title="copyStatus === 'copied' ? 'Copied' : 'Copy JSON'" |
97 | | - > |
98 | | - <svg |
99 | | - v-if="copyStatus === 'idle'" |
100 | | - class="w-4 h-4 lg:w-3.5 lg:h-3.5" |
101 | | - fill="none" |
102 | | - viewBox="0 0 24 24" |
103 | | - stroke="currentColor" |
| 111 | + <div class="flex items-center gap-1 sm:gap-2 px-2 sm:px-4 relative"> |
| 112 | + <!-- Copy Dropdown --> |
| 113 | + <div class="relative copy-dropdown-container"> |
| 114 | + <button |
| 115 | + @click="showCopyMenu = !showCopyMenu" |
| 116 | + class="flex items-center gap-1.5 px-2 py-1.5 rounded hover:bg-ide-accent/10 transition-colors text-ide-text-muted hover:text-ide-text-bright group" |
| 117 | + :class="{ 'bg-ide-accent/10 text-ide-text-bright': showCopyMenu }" |
| 118 | + title="Copy Options" |
104 | 119 | > |
105 | | - <path |
106 | | - stroke-linecap="round" |
107 | | - stroke-linejoin="round" |
108 | | - stroke-width="2" |
109 | | - d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m-3 8h3m-3 4h3" |
110 | | - /> |
111 | | - </svg> |
112 | | - <svg |
113 | | - v-else |
114 | | - class="w-4 h-4 lg:w-3.5 lg:h-3.5 text-ide-green" |
115 | | - fill="none" |
116 | | - viewBox="0 0 24 24" |
117 | | - stroke="currentColor" |
118 | | - > |
119 | | - <path |
120 | | - stroke-linecap="round" |
121 | | - stroke-linejoin="round" |
122 | | - stroke-width="3" |
123 | | - d="M5 13l4 4L19 7" |
124 | | - /> |
125 | | - </svg> |
126 | | - <span |
127 | | - v-if="!isMobile" |
128 | | - class="text-[10px] font-bold uppercase tracking-widest" |
129 | | - >{{ copyStatus === "copied" ? "Copied" : "Copy" }}</span |
| 120 | + <svg |
| 121 | + class="w-4 h-4 lg:w-3.5 lg:h-3.5" |
| 122 | + fill="none" |
| 123 | + viewBox="0 0 24 24" |
| 124 | + stroke="currentColor" |
| 125 | + > |
| 126 | + <path |
| 127 | + stroke-linecap="round" |
| 128 | + stroke-linejoin="round" |
| 129 | + stroke-width="2" |
| 130 | + d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m-3 8h3m-3 4h3" |
| 131 | + /> |
| 132 | + </svg> |
| 133 | + <span |
| 134 | + v-if="!isMobile" |
| 135 | + class="text-[10px] font-bold uppercase tracking-widest" |
| 136 | + >Copy</span |
| 137 | + > |
| 138 | + <svg |
| 139 | + class="w-2.5 h-2.5 opacity-50 transition-transform duration-200" |
| 140 | + :class="{ 'rotate-180': showCopyMenu }" |
| 141 | + fill="none" |
| 142 | + viewBox="0 0 24 24" |
| 143 | + stroke="currentColor" |
| 144 | + > |
| 145 | + <path |
| 146 | + stroke-linecap="round" |
| 147 | + stroke-linejoin="round" |
| 148 | + stroke-width="3" |
| 149 | + d="M19 9l-7 7-7-7" |
| 150 | + /> |
| 151 | + </svg> |
| 152 | + </button> |
| 153 | + |
| 154 | + <!-- Dropdown Menu --> |
| 155 | + <div |
| 156 | + v-if="showCopyMenu" |
| 157 | + class="absolute top-full right-0 mt-2 w-48 bg-ide-sidebar border border-ide-border rounded-lg shadow-2xl z-50 overflow-hidden py-1 animate-in fade-in slide-in-from-top-1 duration-200" |
130 | 158 | > |
131 | | - </button> |
| 159 | + <button |
| 160 | + @click="$emit('copy')" |
| 161 | + class="w-full flex items-center relative px-3 py-2 hover:bg-ide-accent/10 transition-colors group text-left" |
| 162 | + > |
| 163 | + <div class="flex items-center gap-2 flex-1 min-w-0 pr-6"> |
| 164 | + <svg |
| 165 | + class="w-3.5 h-3.5 text-ide-text-muted group-hover:text-ide-accent transition-colors shrink-0" |
| 166 | + fill="none" |
| 167 | + viewBox="0 0 24 24" |
| 168 | + stroke="currentColor" |
| 169 | + > |
| 170 | + <path |
| 171 | + stroke-linecap="round" |
| 172 | + stroke-linejoin="round" |
| 173 | + stroke-width="2" |
| 174 | + d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" |
| 175 | + /> |
| 176 | + </svg> |
| 177 | + <div class="flex flex-col min-w-0"> |
| 178 | + <span |
| 179 | + class="text-[10px] font-bold uppercase tracking-tight text-ide-text-bright truncate" |
| 180 | + >Copy to Clipboard</span |
| 181 | + > |
| 182 | + <span class="text-[9px] text-ide-text-muted truncate" |
| 183 | + >Clipboard active file</span |
| 184 | + > |
| 185 | + </div> |
| 186 | + </div> |
| 187 | + <svg |
| 188 | + v-if="copyStatus === 'copied'" |
| 189 | + class="w-3.5 h-3.5 text-ide-green absolute right-3" |
| 190 | + fill="none" |
| 191 | + viewBox="0 0 24 24" |
| 192 | + stroke="currentColor" |
| 193 | + > |
| 194 | + <path |
| 195 | + stroke-linecap="round" |
| 196 | + stroke-linejoin="round" |
| 197 | + stroke-width="3" |
| 198 | + d="M5 13l4 4L19 7" |
| 199 | + /> |
| 200 | + </svg> |
| 201 | + </button> |
| 202 | + |
| 203 | + <div class="h-px bg-ide-border mx-2 my-1"></div> |
| 204 | + |
| 205 | + <button |
| 206 | + @click="$emit('one-liner')" |
| 207 | + class="w-full flex items-center relative px-3 py-2 hover:bg-ide-accent/10 transition-colors group text-left" |
| 208 | + > |
| 209 | + <div class="flex items-center gap-2 flex-1 min-w-0 pr-6"> |
| 210 | + <svg |
| 211 | + class="w-3.5 h-3.5 text-ide-text-muted group-hover:text-ide-accent transition-colors shrink-0" |
| 212 | + fill="none" |
| 213 | + viewBox="0 0 24 24" |
| 214 | + stroke="currentColor" |
| 215 | + > |
| 216 | + <path |
| 217 | + stroke-linecap="round" |
| 218 | + stroke-linejoin="round" |
| 219 | + stroke-width="2" |
| 220 | + d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" |
| 221 | + /> |
| 222 | + </svg> |
| 223 | + <div class="flex flex-col min-w-0"> |
| 224 | + <span |
| 225 | + class="text-[10px] font-bold uppercase tracking-tight text-ide-text-bright truncate" |
| 226 | + >Copy Scaffolding</span |
| 227 | + > |
| 228 | + <span class="text-[9px] text-ide-text-muted truncate" |
| 229 | + >Bash one-liner command</span |
| 230 | + > |
| 231 | + </div> |
| 232 | + </div> |
| 233 | + <svg |
| 234 | + v-if="oneLinerStatus === 'copied'" |
| 235 | + class="w-3.5 h-3.5 text-ide-green absolute right-3" |
| 236 | + fill="none" |
| 237 | + viewBox="0 0 24 24" |
| 238 | + stroke="currentColor" |
| 239 | + > |
| 240 | + <path |
| 241 | + stroke-linecap="round" |
| 242 | + stroke-linejoin="round" |
| 243 | + stroke-width="3" |
| 244 | + d="M5 13l4 4L19 7" |
| 245 | + /> |
| 246 | + </svg> |
| 247 | + </button> |
| 248 | + </div> |
| 249 | + </div> |
132 | 250 |
|
133 | 251 | <button |
134 | 252 | @click="$emit('share')" |
|
0 commit comments