vuetify-masonry 0.3.3 → 0.4.1
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,49 +1,51 @@
|
|
|
1
1
|
# vuetify-masonry
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/vuetify-masonry)
|
|
4
|
+
[](https://www.npmjs.com/package/vuetify-masonry)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://vuejs.org/)
|
|
7
|
+
[](https://vuetifyjs.com/)
|
|
8
|
+
[](https://github.com/semantic-release/semantic-release)
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
Lightweight Vue 3 component for responsive masonry-style grids built on Vuetify 3 primitives.
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
## ✨ Features
|
|
8
13
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
- 📱 **Fully responsive** - Automatic column adjustment across all breakpoints
|
|
15
|
+
- ⚡ **Lightweight** - Built on Vuetify's native layout components
|
|
16
|
+
- 🎯 **Flexible** - Customizable column count per breakpoint
|
|
17
|
+
- 🔧 **TypeScript** - Full type support included
|
|
18
|
+
- 🎨 **Slot-based** - Complete control over item rendering
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
## 🚀 Demo
|
|
16
21
|
|
|
17
|
-
|
|
22
|
+
[](https://stackblitz.com/edit/vuetify-masonry-demo?file=src%2FApp.vue)
|
|
18
23
|
|
|
19
|
-
|
|
24
|
+
## 📦 Installation
|
|
20
25
|
|
|
21
|
-
```
|
|
22
|
-
|
|
26
|
+
```bash
|
|
27
|
+
npm install vuetify-masonry
|
|
23
28
|
```
|
|
24
29
|
|
|
25
|
-
|
|
30
|
+
**Peer dependencies:** Vue 3 and Vuetify 3
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
- `col` (1 | 2 | 3 | 4 | 6 | 12 or string): default number of columns fallback.
|
|
29
|
-
- `xs`, `sm`, `md`, `lg`, `xl`, `xxl` (same as `col`): responsive column count overrides for each breakpoint.
|
|
32
|
+
## 📖 Usage
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
Import `VMasonry` and simply use it in template.
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
- `item`: the item value from the `items` array
|
|
38
|
-
- `index`: the index of the item within its column
|
|
39
|
-
- `columnIndex`: the index of the column the item was placed into
|
|
36
|
+
```js
|
|
37
|
+
<script setup>
|
|
38
|
+
import { VMasonry } from 'vuetify-masonry'
|
|
40
39
|
|
|
41
|
-
|
|
40
|
+
const cards = [
|
|
41
|
+
{ title: 'Card 1', description: 'Short' },
|
|
42
|
+
{ title: 'Card 2', description: 'Longer content to show varying heights' }
|
|
43
|
+
]
|
|
44
|
+
</script>
|
|
42
45
|
|
|
43
|
-
```vue
|
|
44
46
|
<template>
|
|
45
|
-
<v-masonry :items="cards" col="3">
|
|
46
|
-
<template #
|
|
47
|
+
<v-masonry :items="cards" col="2" sm="3">
|
|
48
|
+
<template #default="{ item }">
|
|
47
49
|
<v-card>
|
|
48
50
|
<v-card-title>{{ item.title }}</v-card-title>
|
|
49
51
|
<v-card-text>{{ item.description }}</v-card-text>
|
|
@@ -51,34 +53,34 @@ Example:
|
|
|
51
53
|
</template>
|
|
52
54
|
</v-masonry>
|
|
53
55
|
</template>
|
|
54
|
-
|
|
55
|
-
<script setup>
|
|
56
|
-
const cards = [
|
|
57
|
-
{ title: 'One', description: 'Short' },
|
|
58
|
-
{
|
|
59
|
-
title: 'Two',
|
|
60
|
-
description: 'Longer content to demonstrate varying heights',
|
|
61
|
-
},
|
|
62
|
-
// ...
|
|
63
|
-
]
|
|
64
|
-
</script>
|
|
65
56
|
```
|
|
66
57
|
|
|
67
|
-
##
|
|
58
|
+
## ⚙️ API
|
|
68
59
|
|
|
69
|
-
|
|
70
|
-
- Column distribution places items round-robin into columns: `columns[index % nbColumns]`.
|
|
71
|
-
- This package targets Vue 3 + Vuetify 3 (see `peerDependencies` in `package.json`).
|
|
60
|
+
### Props
|
|
72
61
|
|
|
73
|
-
|
|
62
|
+
- **items** (`Array<T>`): List of items to render
|
|
63
|
+
- **col, xs, sm, md, lg, xl, xxl** (`1 | 2 | 3 | 4 | 6 | 12`): Column count per breakpoint (mobile-first)
|
|
74
64
|
|
|
75
|
-
|
|
65
|
+
### Slot
|
|
76
66
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
67
|
+
**Default slot** - Renders each item in the masonry grid
|
|
68
|
+
|
|
69
|
+
Slot props:
|
|
70
|
+
|
|
71
|
+
- `item` - The item value from the `items` array
|
|
72
|
+
- `index` - The index of the item within its column
|
|
73
|
+
- `columnIndex` - The index of the column where the item is placed
|
|
74
|
+
|
|
75
|
+
## 🏗️ How It Works
|
|
76
|
+
|
|
77
|
+
The component distributes items across columns using a round-robin algorithm (`columns[index % nbColumns]`), ensuring balanced column heights. It leverages Vuetify's `VRow` and `VCol` components for responsive grid behavior.
|
|
78
|
+
|
|
79
|
+
## 🌟 Showcase
|
|
80
|
+
|
|
81
|
+
[](https://benimpenceremebru.com/)
|
|
82
|
+
|
|
83
|
+
_Using vuetify-masonry in your project? [Open a PR](https://github.com/senerh/vuetify-masonry/edit/main/README.md) to add it here!_
|
|
82
84
|
|
|
83
85
|
## License
|
|
84
86
|
|
package/dist/vuetify-masonry.mjs
CHANGED
|
@@ -58,17 +58,17 @@ const y = /* @__PURE__ */ B({
|
|
|
58
58
|
key: m,
|
|
59
59
|
class: E({ "mb-6": m !== l.length - 1 })
|
|
60
60
|
}, [
|
|
61
|
-
M(t.$slots, "
|
|
61
|
+
M(t.$slots, "default", {
|
|
62
62
|
item: s,
|
|
63
63
|
index: m,
|
|
64
64
|
columnIndex: n
|
|
65
65
|
}, () => [
|
|
66
|
-
r[0] || (r[0] = g(" Please
|
|
66
|
+
r[0] || (r[0] = g(" Please ", -1)),
|
|
67
67
|
r[1] || (r[1] = N("a", {
|
|
68
|
-
href: "https://github.com/senerh/vuetify-masonry?tab=readme-ov-file
|
|
68
|
+
href: "https://github.com/senerh/vuetify-masonry?tab=readme-ov-file#-usage",
|
|
69
69
|
target: "_blank",
|
|
70
70
|
rel: "noopener"
|
|
71
|
-
}, "
|
|
71
|
+
}, "provide a slot", -1)),
|
|
72
72
|
r[2] || (r[2] = g(". ", -1))
|
|
73
73
|
])
|
|
74
74
|
], 2))), 128))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(r,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vuetify"),require("vuetify/components")):typeof define=="function"&&define.amd?define(["exports","vue","vuetify","vuetify/components"],e):(r=typeof globalThis<"u"?globalThis:r||self,e(r.VuetifyMasonry={},r.Vue,r.Vuetify,r.Vuetify))})(this,(function(r,e,m,d){"use strict";const u=e.defineComponent({__name:"VMasonry",props:{col:{},items:{default:()=>[]},xs:{},sm:{},md:{},lg:{},xl:{},xxl:{}},setup(c){const t=c,{xs:x,smAndUp:y,mdAndUp:k,lgAndUp:
|
|
1
|
+
(function(r,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vuetify"),require("vuetify/components")):typeof define=="function"&&define.amd?define(["exports","vue","vuetify","vuetify/components"],e):(r=typeof globalThis<"u"?globalThis:r||self,e(r.VuetifyMasonry={},r.Vue,r.Vuetify,r.Vuetify))})(this,(function(r,e,m,d){"use strict";const u=e.defineComponent({__name:"VMasonry",props:{col:{},items:{default:()=>[]},xs:{},sm:{},md:{},lg:{},xl:{},xxl:{}},setup(c){const t=c,{xs:x,smAndUp:y,mdAndUp:k,lgAndUp:g,xlAndUp:V,xxl:B}=m.useDisplay(),f=e.computed(()=>{const l=o=>{if(o!==void 0)return typeof o=="string"?Number(o):o},n=(...o)=>{for(const s of o){const i=l(s);if(i!==void 0)return i}return 1};return B.value?n(t.xxl,t.xl,t.lg,t.md,t.sm,t.xs,t.col):V.value?n(t.xl,t.lg,t.md,t.sm,t.xs,t.col):g.value?n(t.lg,t.md,t.sm,t.xs,t.col):k.value?n(t.md,t.sm,t.xs,t.col):y.value?n(t.sm,t.xs,t.col):x.value?n(t.xs,t.col):n(t.col)}),h=e.computed(()=>{const l=Array.from({length:f.value},()=>[]);return t.items.forEach((n,o)=>{l[o%f.value].push(n)}),l});return(l,n)=>(e.openBlock(),e.createBlock(e.unref(d.VRow),null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,(o,s)=>(e.openBlock(),e.createBlock(e.unref(d.VCol),{key:s,cols:12/f.value},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o,(i,a)=>(e.openBlock(),e.createElementBlock("div",{key:a,class:e.normalizeClass({"mb-6":a!==o.length-1})},[e.renderSlot(l.$slots,"default",{item:i,index:a,columnIndex:s},()=>[n[0]||(n[0]=e.createTextVNode(" Please ",-1)),n[1]||(n[1]=e.createElementVNode("a",{href:"https://github.com/senerh/vuetify-masonry?tab=readme-ov-file#-usage",target:"_blank",rel:"noopener"},"provide a slot",-1)),n[2]||(n[2]=e.createTextVNode(". ",-1))])],2))),128))]),_:2},1032,["cols"]))),128))]),_:3}))}}),p={...u,install(c){c.component("VMasonry",u)}};r.VMasonry=u,r.default=p,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|