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
- Lightweight Vue 3 component that provides a responsive masonry-style grid built on Vuetify 3 layout primitives (`VRow`, `VCol`). Use it to render lists of variable-height items in evenly balanced columns.
3
+ [![npm version](https://img.shields.io/npm/v/vuetify-masonry.svg)](https://www.npmjs.com/package/vuetify-masonry)
4
+ [![npm downloads](https://img.shields.io/npm/dm/vuetify-masonry.svg)](https://www.npmjs.com/package/vuetify-masonry)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Vue 3](https://img.shields.io/badge/Vue-3-42b883?logo=vue.js)](https://vuejs.org/)
7
+ [![Vuetify 3](https://img.shields.io/badge/Vuetify-3-1867C0?logo=vuetify)](https://vuetifyjs.com/)
8
+ [![semantic-release: conventionalcommits](https://img.shields.io/badge/semantic--release-conventionalcommits-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
4
9
 
5
- ## Installation
10
+ Lightweight Vue 3 component for responsive masonry-style grids built on Vuetify 3 primitives.
6
11
 
7
- Install the package and ensure peer dependencies are present:
12
+ ## Features
8
13
 
9
- ```bash
10
- npm install vuetify-masonry
11
- # or
12
- # yarn add vuetify-masonry
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
- Peer dependencies: Vue 3 and Vuetify 3 (see `package.json`).
20
+ ## 🚀 Demo
16
21
 
17
- ## Usage
22
+ [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/vuetify-masonry-demo?file=src%2FApp.vue)
18
23
 
19
- Import the component locally when you need it:
24
+ ## 📦 Installation
20
25
 
21
- ```js
22
- import { VMasonry } from 'vuetify-masonry'
26
+ ```bash
27
+ npm install vuetify-masonry
23
28
  ```
24
29
 
25
- ## Props
30
+ **Peer dependencies:** Vue 3 and Vuetify 3
26
31
 
27
- - `items` (Array<T>, default `[]`): the list of items to render into the masonry columns.
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
- The component uses Vuetify's `useDisplay` breakpoints to pick the appropriate column count.
34
+ Import `VMasonry` and simply use it in template.
32
35
 
33
- ## Slot API
34
-
35
- Provide a named slot `item` to render each item. The slot receives these props:
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
- Example:
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 #item="{ item }">
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
- ## Notes
58
+ ## ⚙️ API
68
59
 
69
- - The component implementation lives in `src/components/VMasonry.vue` and relies on Vuetify's `VRow` and `VCol` for layout.
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
- ## Development
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
- Run the dev server or build for publishing:
65
+ ### Slot
76
66
 
77
- ```bash
78
- npm install
79
- npm run dev # start example / dev server
80
- npm run build # produce files in dist/
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
+ [![Benim Pencerem Ebru](https://img.shields.io/badge/🌐-benimpenceremebru.com-blue)](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
 
@@ -14,7 +14,7 @@ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>
14
14
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
15
15
  attrs: any;
16
16
  slots: {
17
- item?(_: {
17
+ default?(_: {
18
18
  item: T;
19
19
  index: number;
20
20
  columnIndex: number;
@@ -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, "item", {
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 provide an ", -1)),
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#slot-api",
68
+ href: "https://github.com/senerh/vuetify-masonry?tab=readme-ov-file#-usage",
69
69
  target: "_blank",
70
70
  rel: "noopener"
71
- }, "item slot", -1)),
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:V,xlAndUp:g,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):g.value?n(t.xl,t.lg,t.md,t.sm,t.xs,t.col):V.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,"item",{item:i,index:a,columnIndex:s},()=>[n[0]||(n[0]=e.createTextVNode(" Please provide an ",-1)),n[1]||(n[1]=e.createElementVNode("a",{href:"https://github.com/senerh/vuetify-masonry?tab=readme-ov-file#slot-api",target:"_blank",rel:"noopener"},"item 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"}})}));
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"}})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vuetify-masonry",
3
- "version": "0.3.3",
3
+ "version": "0.4.1",
4
4
  "description": "A simple Vuetify-compatible masonry grid Vue 3 component",
5
5
  "main": "dist/vuetify-masonry.umd.js",
6
6
  "module": "dist/vuetify-masonry.mjs",