@wyxos/vibe 1.6.7 → 1.6.9
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 +45 -6
- package/lib/index.js +557 -492
- package/package.json +1 -1
- package/src/components/MasonryItem.vue +174 -57
- package/src/views/Home.vue +1 -1
package/README.md
CHANGED
|
@@ -56,6 +56,7 @@ By default, VIBE uses the built-in `MasonryItem` component, which handles image
|
|
|
56
56
|
const response = await fetch(`/api/items?page=${page}`)
|
|
57
57
|
const data = await response.json()
|
|
58
58
|
// Items must have a 'src' property for the default MasonryItem
|
|
59
|
+
// Optional: include 'type' ('image' or 'video') and 'notFound' (boolean)
|
|
59
60
|
return {
|
|
60
61
|
items: data.items,
|
|
61
62
|
nextPage: page + 1
|
|
@@ -104,6 +105,36 @@ You can fully customize the item rendering using the `#item` slot. You can also
|
|
|
104
105
|
</template>
|
|
105
106
|
```
|
|
106
107
|
|
|
108
|
+
### Item Data Structure
|
|
109
|
+
|
|
110
|
+
Items can include the following properties:
|
|
111
|
+
|
|
112
|
+
```javascript
|
|
113
|
+
{
|
|
114
|
+
id: 'unique-id', // Required: unique identifier
|
|
115
|
+
width: 300, // Required: original width
|
|
116
|
+
height: 200, // Required: original height
|
|
117
|
+
src: 'https://...', // Required: media source URL
|
|
118
|
+
type: 'image' | 'video', // Optional: media type (defaults to 'image')
|
|
119
|
+
notFound: false, // Optional: show "Not Found" state
|
|
120
|
+
// ... any other custom properties
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Slot Props
|
|
125
|
+
|
|
126
|
+
The `MasonryItem` component exposes the following props to its default slot:
|
|
127
|
+
|
|
128
|
+
- `item`: The item object
|
|
129
|
+
- `remove`: The remove callback function
|
|
130
|
+
- `imageLoaded`: Boolean indicating if image has loaded
|
|
131
|
+
- `imageError`: Boolean indicating if image failed to load
|
|
132
|
+
- `videoLoaded`: Boolean indicating if video has loaded
|
|
133
|
+
- `videoError`: Boolean indicating if video failed to load
|
|
134
|
+
- `showNotFound`: Boolean indicating if item is in "not found" state
|
|
135
|
+
- `isLoading`: Boolean indicating if media is currently loading
|
|
136
|
+
- `mediaType`: String indicating the media type ('image' or 'video')
|
|
137
|
+
|
|
107
138
|
---
|
|
108
139
|
|
|
109
140
|
## Props
|
|
@@ -138,19 +169,27 @@ You can fully customize the item rendering using the `#item` slot. You can also
|
|
|
138
169
|
|
|
139
170
|
## MasonryItem Component
|
|
140
171
|
|
|
141
|
-
The built-in `MasonryItem` component is available for use within the `#item` slot or as a standalone component.
|
|
172
|
+
The built-in `MasonryItem` component is available for use within the `#item` slot or as a standalone component. It provides intelligent lazy loading, media type detection, and comprehensive error handling.
|
|
142
173
|
|
|
143
174
|
### Props
|
|
144
175
|
|
|
145
176
|
| Prop | Type | Description |
|
|
146
177
|
|------|------|-------------|
|
|
147
|
-
| `item` | `Object` | The item object. Must contain `src` for
|
|
148
|
-
| `remove` | `Function` | Optional callback to remove the item. If provided, a remove button is shown. |
|
|
178
|
+
| `item` | `Object` | The item object. Must contain `src` for media loading. Can include `type` (`'image'` or `'video'`), `notFound` (boolean), and other custom properties. |
|
|
179
|
+
| `remove` | `Function` | Optional callback to remove the item. If provided, a remove button is shown on hover. |
|
|
180
|
+
| `type` | `'image' \| 'video'` | Optional. Overrides `item.type`. Defaults to `'image'`. |
|
|
181
|
+
| `notFound` | `Boolean` | Optional. Overrides `item.notFound`. When `true`, displays a "Not Found" state instead of loading media. |
|
|
149
182
|
|
|
150
183
|
### Features
|
|
151
|
-
|
|
152
|
-
- **
|
|
153
|
-
- **
|
|
184
|
+
|
|
185
|
+
- **Lazy Loading with Intersection Observer**: Only starts preloading media when the item comes into view (50%+ visible), significantly improving initial page load performance.
|
|
186
|
+
- **Image & Video Support**: Automatically handles both images and videos with appropriate loading strategies.
|
|
187
|
+
- **Media Type Indicator**: Shows a badge icon (image/video) on hover to indicate the media type.
|
|
188
|
+
- **Smart Spinner**: Displays a loading spinner underneath the media (not covering it) during preload.
|
|
189
|
+
- **Error Handling**: Displays user-friendly error states if media fails to load.
|
|
190
|
+
- **Not Found State**: Special visual state for items that cannot be located.
|
|
191
|
+
- **Hover Effects**: Includes subtle zoom, overlay gradient, and smooth transitions.
|
|
192
|
+
- **Performance Optimized**: Properly cleans up Intersection Observers to prevent memory leaks.
|
|
154
193
|
|
|
155
194
|
---
|
|
156
195
|
|