Skip to content

Commit f0f0f6d

Browse files
committed
add share button
1 parent c58b056 commit f0f0f6d

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

src/TempoLite.vue

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@
237237
</div>
238238
</v-card>
239239
</v-menu>
240-
240+
<div id="location-and-sharing">
241241
<location-search
242242
v-model="searchOpen"
243243
small
@@ -252,6 +252,26 @@
252252
}"
253253
@error="(error: string) => searchErrorMessage = error"
254254
></location-search>
255+
<use-clipboard v-slot="{ copy, copied }" :source="currentUrl">
256+
<v-tooltip :text="copied ? 'Link Copied' : 'Copy Link to Share'">
257+
<template v-slot:activator="{ props }">
258+
<v-btn
259+
class="share-button"
260+
icon
261+
@click="copy()"
262+
@keyup.enter="copy()"
263+
v-bind="props"
264+
color="#ffffff66"
265+
elevation="0"
266+
size="small"
267+
rounded="1"
268+
>
269+
<v-icon color="#333">mdi-share-variant</v-icon>
270+
</v-btn>
271+
</template>
272+
</v-tooltip>
273+
</use-clipboard>
274+
</div>
255275
</div>
256276
<colorbar
257277
v-if="$vuetify.display.width > 750"
@@ -856,6 +876,7 @@ export default defineComponent({
856876
}),
857877
cloudTimestamps,
858878
showClouds: false,
879+
currentUrl: window.location.href,
859880
};
860881
},
861882
@@ -1146,6 +1167,7 @@ export default defineComponent({
11461167
const url = new URL(location.origin);
11471168
const searchParams = new URLSearchParams(state);
11481169
url.search = searchParams.toString();
1170+
this.currentUrl = url.toString();
11491171
window.history.replaceState(null,'',url);
11501172
}
11511173
},
@@ -1866,12 +1888,17 @@ a {
18661888
flex-shrink: 1;
18671889
}
18681890
1869-
.forward-geocoding-container {
1891+
#location-and-sharing {
18701892
position: absolute;
18711893
bottom: 0;
1872-
left: 0;
1873-
18741894
z-index: 1000;
1895+
display: flex;
1896+
flex-direction: row;
1897+
align-items: center;
1898+
gap: 0.5rem;
1899+
width:fit-content;
1900+
}
1901+
.forward-geocoding-container {
18751902
width: 250px;
18761903
border: 2px solid black;
18771904
}
@@ -2286,4 +2313,13 @@ button:focus-visible,
22862313
image-rendering: pixelated; /* CSS4 Proposed */
22872314
-ms-interpolation-mode: nearest-neighbor; /* IE8+ */
22882315
}
2316+
2317+
.share-button {
2318+
z-index: 1000;
2319+
background-color: rgb(255 255 255);
2320+
border: 1px solid black;
2321+
backdrop-filter: blur(5px);
2322+
padding-inline: 5px;
2323+
border-radius: 10px;
2324+
}
22892325
</style>

src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424

2525
import VueDatePicker from "@vuepic/vue-datepicker";
2626
import '@vuepic/vue-datepicker/dist/main.css';
27+
import { UseClipboard } from "@vueuse/components";
2728

2829
library.add(faBookOpen);
2930
library.add(faPlay);
@@ -71,6 +72,7 @@ createApp(TempoLite, {})
7172
.component('info-button', InfoButton)
7273
.component('colorbar-horizontal', ColorBarHorizontal)
7374
.component('date-picker', VueDatePicker)
75+
.component('use-clipboard', UseClipboard as Vue.Component)
7476

7577
// Mount
7678
.mount("#app");

0 commit comments

Comments
 (0)