├── .gitignore ├── README.md ├── bin └── examples.js ├── examples ├── .gitkeep └── simple │ ├── App.vue │ └── index.js ├── index.js ├── package-lock.json ├── package.json └── src ├── Stack.vue └── StackItem.vue /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-stack-grid 2 | 3 | Vue components for stack grid/waterfall/Pinterest type layouts. Inspired by [react-stack-grid](https://github.com/tsuyoshiwada/react-stack-grid). 4 | 5 | ## Demo 6 | 7 | Coming soon. Please see [react-stack-grid](https://github.com/tsuyoshiwada/react-stack-grid) for an indication of the features. 8 | 9 | ## Installation 10 | 11 | NPM: 12 | 13 | ``` 14 | npm install --save vue-stack-grid 15 | ``` 16 | 17 | ## Usage 18 | 19 | ### Basic 20 | 21 | ```vue 22 | 31 | 32 | 39 | 40 | ``` 41 | 42 | ### With animation 43 | 44 | For animation, simply add `style="transition: transform 300ms"` to the `stack-item`s. 45 | 46 | ### With images 47 | 48 | If images appear anywhere in the stack items, apply the `monitor-images-loaded` prop to the `stack` component. 49 | 50 | ## Props 51 | 52 | ### Stack 53 | 54 | | Name | Type | Required | Default | Description | 55 | | --- | --- | --- | --- | --- | 56 | | `column-min-width` | Number | Yes | | The minimum width of columns. If the columns do not fit into the container anymore, the number of columns is reduced. | 57 | | `gutter-width` | Number | No | `0` | The space between columns in pixels. | 58 | | `gutter-height` | Number | No | `0` | The space between items in the same column. | 59 | | `monitor-images-loaded` | Boolean | No | `false` | If true, reflow once all images are loaded using [vue-images-loaded](https://github.com/David-Desmaisons/Vue.ImagesLoaded). This is recommended if any of the stack items contain images, as the images might not be loaded yet when the initial positions and sizes are computed. | 60 | 61 | Note that `gutter-width` and `gutter-height` can also be replaced by adding margin/padding to the stack items. 62 | 63 | ## Examples 64 | Clone the repository and run: `npm run examples` 65 | 66 | ## Future plans 67 | 68 | - Handle adding/removing items. 69 | - Add build system. 70 | - Add demo. 71 | - **Please make feature requests if you have any!** 72 | -------------------------------------------------------------------------------- /bin/examples.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { lstatSync, readdirSync } = require('fs') 4 | const { join, resolve } = require('path') 5 | const { execSync } = require('child_process') 6 | const inquirer = require('inquirer') 7 | 8 | const EX_DIR = resolve('examples') 9 | const IS_WIN = /^win/.test(process.platform) 10 | 11 | const dirs = readdirSync(EX_DIR).map(fn => join(EX_DIR, fn)).filter(f => ( 12 | lstatSync(f).isDirectory() 13 | )) 14 | 15 | inquirer.prompt([{ 16 | type: 'list', 17 | name: 'ex', 18 | message: 'Which example would you like to run?', 19 | choices: dirs.map(dir => dir.replace(`${EX_DIR}/`, '')) 20 | }]) 21 | .then(r => {execSync(IS_WIN ? `poi ${r.ex}` : `poi ${join(EX_DIR, r.ex)}`, { stdio: [0, 1, 2] }) }) 22 | // swallow child exit exceptions 23 | .catch(() => process.exit(0)) 24 | -------------------------------------------------------------------------------- /examples/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WouterFlorijn/vue-stack-grid/ec17f08347bfd61dcc504832293de23f9593687d/examples/.gitkeep -------------------------------------------------------------------------------- /examples/simple/App.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 63 | 64 | 97 | -------------------------------------------------------------------------------- /examples/simple/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | 4 | new Vue({ 5 | el: '#app', 6 | render: h => h(App) 7 | }) 8 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import Stack from './src/Stack.vue' 2 | import StackItem from './src/StackItem.vue' 3 | 4 | export { Stack, StackItem } 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-stack-grid", 3 | "version": "1.2.2", 4 | "description": "Vue components for stack grid/waterfall/Pinterest type layouts. Lightweight, reactive and responsive.", 5 | "main": "index.js", 6 | "scripts": { 7 | "build": "npm install && webpack", 8 | "watch": "webpack --watch", 9 | "examples": "node bin/examples" 10 | }, 11 | "author": { 12 | "name": "Wouter Florijn", 13 | "email": "woutermflorijn@gmail.com" 14 | }, 15 | "license": "ISC", 16 | "homepage": "https://github.com/WouterFlorijn/vue-stack-grid", 17 | "repository": "WouterFlorijn/vue-stack-grid", 18 | "keywords": [ 19 | "vue", 20 | "grid", 21 | "pinterest", 22 | "stack", 23 | "waterfall" 24 | ], 25 | "dependencies": { 26 | "vue-images-loaded": "^1.1.2" 27 | }, 28 | "devDependencies": { 29 | "inquirer": "^7.1.0", 30 | "poi": "^12.8.0", 31 | "vue": "^2.6.11", 32 | "vue-template-compiler": "^2.6.11" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Stack.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 124 | 125 | 132 | -------------------------------------------------------------------------------- /src/StackItem.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 14 | --------------------------------------------------------------------------------