@wyxos/vibe 1.2.2 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -25
- package/index.js +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,36 +32,42 @@ npm install @wyxos/vibe
|
|
|
32
32
|
|
|
33
33
|
```vue
|
|
34
34
|
<script setup>
|
|
35
|
-
import
|
|
36
|
-
import {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const items = ref([])
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
})
|
|
50
|
-
}
|
|
35
|
+
import { ref } from 'vue'
|
|
36
|
+
import { Masonry } from '@wyxos/vibe' // named export
|
|
37
|
+
// or if globally registered via `app.use()`, you can skip this import
|
|
38
|
+
|
|
39
|
+
const items = ref([])
|
|
40
|
+
|
|
41
|
+
async function getNextPage(page) {
|
|
42
|
+
const response = await fetch(`/api/items?page=${page}`)
|
|
43
|
+
const data = await response.json()
|
|
44
|
+
return {
|
|
45
|
+
items: data.items,
|
|
46
|
+
nextPage: page + 1
|
|
47
|
+
}
|
|
48
|
+
}
|
|
51
49
|
</script>
|
|
52
50
|
|
|
53
51
|
<template>
|
|
54
|
-
<
|
|
52
|
+
<WyxosMasonry
|
|
53
|
+
v-model:items="items"
|
|
54
|
+
:get-next-page="getNextPage"
|
|
55
|
+
:gutter-x="12"
|
|
56
|
+
:gutter-y="12"
|
|
57
|
+
:sizes="{ base: 1, sm: 2, md: 3, lg: 4 }"
|
|
58
|
+
>
|
|
55
59
|
<template #item="{ item, onRemove }">
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
<div class="relative">
|
|
61
|
+
<img :src="item.src" class="w-full" />
|
|
62
|
+
<button
|
|
63
|
+
class="absolute bottom-2 right-2 bg-red-600 text-white text-xs p-1 rounded"
|
|
64
|
+
@click="onRemove(item)"
|
|
65
|
+
>
|
|
66
|
+
Remove
|
|
67
|
+
</button>
|
|
68
|
+
</div>
|
|
63
69
|
</template>
|
|
64
|
-
</
|
|
70
|
+
</WyxosMasonry>
|
|
65
71
|
</template>
|
|
66
72
|
```
|
|
67
73
|
|
package/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Masonry from './src/Masonry.vue';
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
install(app) {
|
|
5
|
-
app.component('
|
|
5
|
+
app.component('WyxosMasonry', Masonry);
|
|
6
|
+
app.component('WMasonry', Masonry);
|
|
6
7
|
}
|
|
7
8
|
};
|
|
8
9
|
|
|
9
|
-
export {
|
|
10
|
+
export { Masonry };
|