• Stars
    star
    210
  • Rank 187,585 (Top 4 %)
  • Language Vue
  • License
    MIT License
  • Created almost 5 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A pure vue responsive masonry layout without direct dom manipulation and ssr support.

vue-masonry-wall

A pure vue responsive masonry implementation without direct dom manipulation, ssr friendly with lazy appending. I created this because other libraries has no SSR support, and I needed a pure vue implementation.

vue-masonry-wall screenshot

Installation

npm i vue-masonry-wall
# or yarn
yarn add vue-masonry-wall

Features

  • No Direct DOM Manipulation
  • SSR friendly, able to load and re hydrate later
  • 1 dependency only, no legacy dependencies
  • Auto lazy appending, scroll to auto load more
  • Auto item placement, will find best column
  • Responsive design

Usage

<vue-masonry-wall :items="items" :options="options" @append="append"/>
const items = []
const options = {
  width: 300,
  padding: {
    default: 12,
    1: 6,
    2: 8
  }
}

const append = () => {
  // API call and add items
  this.items.push(...[])
}

Basic

<template>
  <div id="app">
    <h2>Masonry: append endlessly</h2>

    <vue-masonry-wall :items="items" :options="{width: 300, padding: 12}" @append="append">
      <template v-slot:default="{item}">
        <div class="item">
          <h5>{{item.title}}</h5>
          <p>{{item.content}}</p>
        </div>
      </template>
    </vue-masonry-wall>
  </div>
</template>

<script>
  import VueMasonryWall from "vue-masonry-wall";

  export default {
    name: 'app',
    components: {VueMasonryWall},
    data() {
      return {
        items: [
          {title: 'Item 0', content: 'Content'},
          {title: 'Item 1', content: 'Content'},
        ]
      }
    },
    methods: {
      /**
       * I am mocking a API call that load 20 objects at a time.
       */
      append() {
        for (let i = 0; i < 20; i++) {
          this.items.push({title: `Item ${this.items.length}`, content: 'Content'})
        }
      }
    }
  }
</script>

Nuxt SSR

Add :ssr="{columns: 2}" to masonry so that during SSR, it will be load in 2 columns.

SSR has no clue what is the size of your height of your element or width of the browser. You can however guess based on user-agent: https://github.com/nuxt-community/device-module This param allow you to preload a config for SSR rendering, it will distribute your items into all columns evenly.

<vue-masonry-wall :items="items" :options="{width: 300, padding: 12}" :ssr="{columns: 2}" @append="append">
  <template v-slot:default="{item}">
    <div class="item">
      <h5>{{item.title}}</h5>
      <p>{{item.content}}</p>
    </div>
  </template>
</vue-masonry-wall>

Dependencies

Contributing

For any question or feature request please feel free to create an issue or pull request.

TODO

These were features from my original project that I removed for brevity of this package.

Vue Horizontal

I also maintain another project called Vue Horizontal.

At its core, Vue Horizontal is an ultra simple pure vue horizontal layout for modern responsive web with zero dependencies. Vue Horizontal is also an ultra complex code snippet dossier with over 100 SPA/SSR/SSG friendly recipes for your design needs. Do check it out, might be useful for you!

More Repositories

1

vue-horizontal

An ultra simple pure vue horizontal layout for modern responsive web with zero dependencies. (SPA/SSG/SSR)
Vue
220
star
2

vue-horizontal-list

A pure vue native horizontal list implementation for mobile/touch and responsive web.
Vue
179
star
3

contented

Contented is a Markdown-based authoring workflow & processor that encourage developer authoring within its contextual Git repository.
TypeScript
52
star
4

multi-labeler

Multi labeler for title, body, comments, commit messages, branch, author or files with automated status checks.
TypeScript
32
star
5

airtable

A lightweight Java 8 Airtable API client for https://airtable.com/api with all features implemented.
Java
19
star
6

nuxt-app

Nuxt app template project with my customisation.
Vue
18
star
7

oracles.dfc.fuxing.dev

Open-source web app that is developed by the community of developers and researchers to understand the oracle network built on DeFiChain Native network.
TypeScript
3
star
8

Internal-External-Storage-Synchronization

Internal storage: sqlite, External storage: cloud like azure, with this library you can sync data. with internet or not
Java
3
star
9

terraform-aws-vpc-peering

Terraform AWS peering module to peer all VPC together forming a mesh network.
HCL
2
star
10

aws-es-proxy

aws-es-proxy is a small web server application sitting between your HTTP client (browser, curl, etc...) and Amazon Elasticsearch service.
2
star
11

hibernate-validator-enum

So, null & unknown value handling for enum has always been an issue for me, saw the implementation on Amazon Java SDK packages and created @ValidEnum constraints to support using Hibernate Validator library.
Java
2
star
12

crypto-frontmatter

A collection of frontmatter for crypto projects.
TypeScript
2
star
13

solana-container

TypeScript
2
star
14

turbo-plan

Plan turbo run tasks in a separate action to run them parallel in a matrix job.
2
star
15

hibernate-utils

Hibernate utils for JPA entity manager, run transaction in lambda.
Java
1
star
16

dfi-rawtx-bitcoinjs

Creating a RawTx using generic bitcoinjs libraries
TypeScript
1
star
17

defi-txn-composer

Vue
1
star
18

oss-governance-example

1
star
19

dusd.dfc.fuxing.dev

TypeScript
1
star
20

turbo-repo-filter-dependencies-bug

1
star
21

jellyfishsdk-docs

@birthdayresearch/contented example
1
star
22

hibernate-postgres-jsonb

Using Hibernate with Postgres JSONB
Java
1
star
23

css-horizontal-collapse-demo

Chrome Fixed It. - This used to be "A demo of how CSS horizontal collapse can cause oddities in components rendered in the horizontal space."
Vue
1
star
24

background-image.fuxing.dev

A micro-site about background image for the web and how to do them properly.
Vue
1
star
25

oxtu

OXTU (UTXO in reverse) is a space-efficient UTXO set for Bitcoin (and bitcoin-like) blockchains.
Rust
1
star
26

karfia

Karfia is an open-source framework to define, test, deploy, and scale blockchain nodes on container-orchestration platforms.
TypeScript
1
star
27

hardhat-container

TypeScript
1
star