Skip to content

Commit f8e5b77

Browse files
committed
feat: add vueuse
1 parent d7ad2e4 commit f8e5b77

File tree

6 files changed

+200
-14
lines changed

6 files changed

+200
-14
lines changed

components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ declare module '@vue/runtime-core' {
77
export interface GlobalComponents {
88
AppButton: typeof import('./src/components/AppButton.vue')['default']
99
AppImage: typeof import('./src/components/AppImage.vue')['default']
10+
AppImageDropzone: typeof import('./src/components/AppImageDropzone.vue')['default']
1011
BoardCard: typeof import('./src/components/BoardCard.vue')['default']
1112
RouterLink: typeof import('vue-router')['RouterLink']
1213
RouterView: typeof import('vue-router')['RouterView']

package-lock.json

Lines changed: 125 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515
"dependencies": {
1616
"@vue/apollo-composable": "^4.0.0-alpha.18",
17+
"@vueuse/core": "^8.9.2",
1718
"graphql-tag": "^2.12.6",
1819
"lodash-es": "^4.17.21",
1920
"unplugin-vue-components": "^0.20.1",
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<script setup lang="ts">
2+
import { useBase64, useDropZone } from "@vueuse/core";
3+
import { ref } from "vue";
4+
5+
const dropzoneEl = ref<HTMLElement | null>(null);
6+
const file = ref();
7+
const { base64: url } = useBase64(file);
8+
const { isOverDropZone } = useDropZone(dropzoneEl, (files) => {
9+
if (!files) return;
10+
file.value = files[0];
11+
console.log(file.value);
12+
});
13+
14+
function onFileChange(e: any) {
15+
file.value = e.target.files[0];
16+
console.log(file.value);
17+
}
18+
19+
function reset() {
20+
file.value = null;
21+
}
22+
</script>
23+
24+
<template>
25+
<div
26+
ref="dropzoneEl"
27+
class="flex m-4"
28+
:class="{
29+
border: isOverDropZone,
30+
'bg-orange-100': isOverDropZone,
31+
'border-orange-400': isOverDropZone,
32+
}"
33+
style="width: 300px; height: 200px; background: #3332; position: relative"
34+
>
35+
<div class="m-auto opacity-50">Drop a image over or select</div>
36+
<div v-if="url" class="absolute left-0 top-0 bottom-0 right-0 object-cover">
37+
<img :src="url" class="h-full" />
38+
</div>
39+
<input
40+
class="absolute z-1 left-0 top-0 bottom-0 right-0 opacity-0"
41+
type="file"
42+
accept="image/*"
43+
@input="onFileChange"
44+
/>
45+
</div>
46+
<button @click="reset">Reset</button>
47+
</template>

src/components/TheDrawer.vue

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<script setup lang="ts">
2-
32
import { Drawer, DrawerContent } from "@progress/kendo-vue-layout";
4-
3+
import { useLocalStorage } from "@vueuse/core";
54
import { useRouter } from "vue-router";
65
76
import { computed, ref } from "vue";
87
9-
// const router = useRouter();
8+
// const router = useRouter();
109
const selectedId = ref(0);
1110
12-
const expanded = ref(false);
11+
const expanded = useLocalStorage("vue-forge-drawer-expanded", true);
1312
const expandedIcon = computed(() =>
1413
expanded.value ? "k-i-arrow-chevron-left" : "k-i-arrow-chevron-right"
1514
);
@@ -50,16 +49,22 @@ function onSelect({ itemIndex }: { itemIndex: number }) {
5049
if (item.data.path) router.push(item.data.path);
5150
if (typeof item.data.action === "function") item.data.action();
5251
}
53-
5452
</script>
5553

5654
<template>
57-
<Drawer class="h-[90vh]" :expanded="expanded" position="start" mode="push" :mini="true" :items="items"
58-
@select="onSelect">
59-
<DrawerContent>
60-
<div class="px-5">
61-
<router-view />
62-
</div>
63-
</DrawerContent>
64-
</Drawer>
65-
</template>
55+
<Drawer
56+
class="h-[90vh]"
57+
:expanded="expanded"
58+
position="start"
59+
mode="push"
60+
:mini="true"
61+
:items="items"
62+
@select="onSelect"
63+
>
64+
<DrawerContent>
65+
<div class="px-5">
66+
<router-view />
67+
</div>
68+
</DrawerContent>
69+
</Drawer>
70+
</template>

src/pages/boards/[id].vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script setup lang="ts">
2+
import AppImageDropzone from "../../components/AppImageDropzone.vue";
3+
</script>
4+
5+
<template>
6+
<AppImageDropzone />
7+
</template>

0 commit comments

Comments
 (0)