@wyxos/vibe 1.6.3 → 1.6.5

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 CHANGED
@@ -1,139 +1,188 @@
1
- # VIBE — Vue Infinite Block Engine
2
-
3
- [![npm](https://img.shields.io/npm/v/@wyxos/vibe?color=%2300c58e&label=npm)](https://www.npmjs.com/package/@wyxos/vibe)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
- [![Demo](https://img.shields.io/badge/Demo-Live%20Preview-blue?logo=githubpages)](https://wyxos.github.io/vibe/)
6
-
7
- A high-performance, responsive masonry layout engine for Vue 3 with built-in infinite scrolling and virtualization.
8
-
9
- VIBE (Vue Infinite Block Engine) is designed for applications that need to display large datasets in a masonry grid without compromising performance. Unlike other masonry libraries, VIBE leverages virtualization to render only what is visible on the screen, ensuring smooth scrolling even with thousands of items.
10
-
11
- ---
12
-
13
- ## Features
14
-
15
- - **High Performance Virtualization**: Efficiently renders thousands of items by only mounting elements currently in the viewport.
16
- - **Responsive Masonry Layout**: Automatically adjusts column counts and layout based on screen width and breakpoints.
17
- - **Infinite Scrolling**: Seamlessly loads more content as the user scrolls, with built-in support for async data fetching.
18
- - **Dynamic Updates**: Supports adding, removing, and reflowing items with smooth FLIP animations.
19
- - **Scroll Position Maintenance**: Keeps the user's scroll position stable when new items are loaded or the layout changes.
20
- - **Customizable Rendering**: Full control over item markup via scoped slots.
21
-
22
- ---
23
-
24
- ## Installation
25
-
26
- ```bash
27
- npm install @wyxos/vibe
28
- ```
29
-
30
- ---
31
-
32
- ## Usage
33
-
34
- ```vue
35
- <script setup>
36
- import { ref } from 'vue'
37
- import { Masonry } from '@wyxos/vibe'
38
-
39
- const items = ref([])
40
-
41
- const layout = {
42
- gutterX: 12,
43
- gutterY: 12,
44
- sizes: { base: 1, sm: 2, md: 3, lg: 4 }
45
- }
46
-
47
- async function getNextPage(page) {
48
- const response = await fetch(`/api/items?page=${page}`)
49
- const data = await response.json()
50
- return {
51
- items: data.items,
52
- nextPage: page + 1
53
- }
54
- }
55
- </script>
56
-
57
- <template>
58
- <Masonry
59
- v-model:items="items"
60
- :get-next-page="getNextPage"
61
- :layout="layout"
62
- >
63
- <template #item="{ item, onRemove }">
64
- <div class="relative">
65
- <img :src="item.src" class="w-full" alt="Masonry item" />
66
- <button
67
- class="absolute bottom-2 right-2 bg-red-600 text-white text-xs p-1 rounded"
68
- @click="onRemove(item)"
69
- >
70
- Remove
71
- </button>
72
- </div>
73
- </template>
74
- </Masonry>
75
- </template>
76
- ```
77
-
78
- ---
79
-
80
- ## Props
81
-
82
- | Prop | Type | Required | Description |
83
- |------|------|----------|-------------|
84
- | `items` | `Array` | Yes | Two-way bound item array. Each item must include `width`, `height`, and `id`. |
85
- | `getNextPage` | `Function(page: Number)` | Yes | Async function to load the next page. Must return `{ items, nextPage }`. |
86
- | `layout` | `Object` | No | Configuration object for layout, including sizes and gutters. |
87
- | `loadAtPage` | `Number` | No | The starting page number (default: `1`). |
88
-
89
- ### Layout Configuration Example
90
-
91
- ```js
92
- {
93
- gutterX: 10,
94
- gutterY: 10,
95
- sizes: {
96
- base: 1,
97
- sm: 2,
98
- md: 3,
99
- lg: 4,
100
- xl: 5,
101
- '2xl': 6
102
- }
103
- }
104
- ```
105
-
106
- ---
107
-
108
- ## Slots
109
-
110
- | Slot Name | Props | Description |
111
- |-----------|-------|-------------|
112
- | `item` | `{ item, onRemove }` | Scoped slot for custom rendering of each masonry block. |
113
-
114
- ---
115
-
116
- ## Run Locally
117
-
118
- To run the demo project locally:
119
-
120
- ```bash
121
- git clone https://github.com/wyxos/vibe
122
- cd vibe
123
- npm install
124
- npm run dev
125
- ```
126
-
127
- Visit `http://localhost:5173` to view the demo.
128
-
129
- ---
130
-
131
- ## Live Demo
132
-
133
- [View Live Demo on GitHub Pages](https://wyxos.github.io/vibe/)
134
-
135
- ---
136
-
137
- ## License
138
-
139
- MIT © [@wyxos](https://github.com/wyxos)
1
+ # VIBE — Vue Infinite Block Engine
2
+
3
+ [![npm](https://img.shields.io/npm/v/@wyxos/vibe?color=%2300c58e&label=npm)](https://www.npmjs.com/package/@wyxos/vibe)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Demo](https://img.shields.io/badge/Demo-Live%20Preview-blue?logo=githubpages)](https://wyxos.github.io/vibe/)
6
+
7
+ A high-performance, responsive masonry layout engine for Vue 3 with built-in infinite scrolling and virtualization.
8
+
9
+ VIBE (Vue Infinite Block Engine) is designed for applications that need to display large datasets in a masonry grid without compromising performance. Unlike other masonry libraries, VIBE leverages virtualization to render only what is visible on the screen, ensuring smooth scrolling even with thousands of items.
10
+
11
+ ![VIBE Demo](https://raw.githubusercontent.com/wyxos/vibe/main/public/demo.webp)
12
+
13
+ ---
14
+
15
+ ## Features
16
+
17
+ - **High Performance Virtualization**: Efficiently renders thousands of items by only mounting elements currently in the viewport.
18
+ - **Responsive Masonry Layout**: Automatically adjusts column counts and layout based on screen width and breakpoints.
19
+ - **Infinite Scrolling**: Seamlessly loads more content as the user scrolls, with built-in support for async data fetching.
20
+ - **Dynamic Updates**: Supports adding, removing, and reflowing items with smooth FLIP animations.
21
+ - **Scroll Position Maintenance**: Keeps the user's scroll position stable when new items are loaded or the layout changes.
22
+ - **Built-in Item Component**: Includes a production-ready `MasonryItem` with image preloading, error handling, and hover effects.
23
+ - **Customizable Rendering**: Full control over item markup via scoped slots.
24
+
25
+ ---
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ npm install @wyxos/vibe
31
+ ```
32
+
33
+ ---
34
+
35
+ ## Usage
36
+
37
+ ### Basic Usage (Default Item)
38
+
39
+ By default, VIBE uses the built-in `MasonryItem` component, which handles image loading and provides a clean UI.
40
+
41
+ ```vue
42
+ <script setup>
43
+ import { ref } from 'vue'
44
+ import { Masonry } from '@wyxos/vibe'
45
+
46
+ const items = ref([])
47
+
48
+ // Layout configuration
49
+ const layout = {
50
+ gutterX: 12,
51
+ gutterY: 12,
52
+ sizes: { base: 1, sm: 2, md: 3, lg: 4 }
53
+ }
54
+
55
+ async function getNextPage(page) {
56
+ const response = await fetch(`/api/items?page=${page}`)
57
+ const data = await response.json()
58
+ // Items must have a 'src' property for the default MasonryItem
59
+ return {
60
+ items: data.items,
61
+ nextPage: page + 1
62
+ }
63
+ }
64
+ </script>
65
+
66
+ <template>
67
+ <Masonry
68
+ v-model:items="items"
69
+ :get-next-page="getNextPage"
70
+ :layout="layout"
71
+ />
72
+ </template>
73
+ ```
74
+
75
+ ### Custom Item Rendering
76
+
77
+ You can fully customize the item rendering using the `#item` slot. You can also import and use `MasonryItem` inside the slot if you want to wrap it or extend it.
78
+
79
+ ```vue
80
+ <script setup>
81
+ import { Masonry, MasonryItem } from '@wyxos/vibe'
82
+ // ... setup code ...
83
+ </script>
84
+
85
+ <template>
86
+ <Masonry
87
+ v-model:items="items"
88
+ :get-next-page="getNextPage"
89
+ :layout="layout"
90
+ >
91
+ <template #item="{ item, remove }">
92
+ <!-- Custom container -->
93
+ <div class="custom-card">
94
+ <!-- You can use the built-in item or your own -->
95
+ <MasonryItem :item="item" :remove="remove">
96
+ <!-- Optional: MasonryItem also has a default slot for overlays -->
97
+ <div class="absolute bottom-0 p-2 text-white">
98
+ {{ item.title }}
99
+ </div>
100
+ </MasonryItem>
101
+ </div>
102
+ </template>
103
+ </Masonry>
104
+ </template>
105
+ ```
106
+
107
+ ---
108
+
109
+ ## Props
110
+
111
+ | Prop | Type | Required | Description |
112
+ |------|------|----------|-------------|
113
+ | `items` | `Array` | Yes | Two-way bound item array. Each item must include `width`, `height`, and `id`. |
114
+ | `getNextPage` | `Function(page: Number)` | Yes | Async function to load the next page. Must return `{ items, nextPage }`. |
115
+ | `layout` | `Object` | No | Configuration object for layout, including sizes and gutters. |
116
+ | `loadAtPage` | `Number` | No | The starting page number (default: `1`). |
117
+ | `paginationType` | `String` | No | `'page'` or `'cursor'` (default: `'page'`). |
118
+ | `pageSize` | `Number` | No | Number of items per page, used for backfilling (default: `40`). |
119
+
120
+ ### Layout Configuration Example
121
+
122
+ ```js
123
+ {
124
+ gutterX: 10,
125
+ gutterY: 10,
126
+ sizes: {
127
+ base: 1,
128
+ sm: 2,
129
+ md: 3,
130
+ lg: 4,
131
+ xl: 5,
132
+ '2xl': 6
133
+ }
134
+ }
135
+ ```
136
+
137
+ ---
138
+
139
+ ## MasonryItem Component
140
+
141
+ The built-in `MasonryItem` component is available for use within the `#item` slot or as a standalone component.
142
+
143
+ ### Props
144
+
145
+ | Prop | Type | Description |
146
+ |------|------|-------------|
147
+ | `item` | `Object` | The item object. Must contain `src` for image loading. |
148
+ | `remove` | `Function` | Optional callback to remove the item. If provided, a remove button is shown. |
149
+
150
+ ### Features
151
+ - **Image Preloading**: Shows a spinner while the image loads.
152
+ - **Error Handling**: Displays an error state if the image fails to load.
153
+ - **Hover Effects**: Includes a subtle zoom and overlay on hover.
154
+
155
+ ---
156
+
157
+ ## Slots
158
+
159
+ | Slot Name | Props | Description |
160
+ |-----------|-------|-------------|
161
+ | `item` | `{ item, remove }` | Scoped slot for custom rendering of each masonry block. |
162
+
163
+ ---
164
+
165
+ ## Run Locally
166
+
167
+ To run the demo project locally:
168
+
169
+ ```bash
170
+ git clone https://github.com/wyxos/vibe
171
+ cd vibe
172
+ npm install
173
+ npm run dev
174
+ ```
175
+
176
+ Visit `http://localhost:5173` to view the demo.
177
+
178
+ ---
179
+
180
+ ## Live Demo
181
+
182
+ [View Live Demo on GitHub Pages](https://wyxos.github.io/vibe/)
183
+
184
+ ---
185
+
186
+ ## License
187
+
188
+ MIT © [@wyxos](https://github.com/wyxos)
package/lib/demo.webp ADDED
Binary file