Skip to content

Instantly share code, notes, and snippets.

@donrestarone
Created December 23, 2020 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donrestarone/908b37a14e7010abda420b8a920ce63e to your computer and use it in GitHub Desktop.
Save donrestarone/908b37a14e7010abda420b8a920ce63e to your computer and use it in GitHub Desktop.
a function for dynamically generating dummy data for react-grid-layout
let faker = require('faker');
export const todoList = () => {
let columnCount = 12
let maxBlocksPerColumn = 12
let layout = []
let i = 0
const cardWidth = 3
const cardHeight = 8
const inlineYaxis = 1
while (i < columnCount) {
let rng = Math.floor(Math.random() * Math.floor(maxBlocksPerColumn))
let maxBlockCount = rng > 0 ? rng : 1
let n = 0
while (n < maxBlockCount) {
layout.push({
i: `${i}${n}`,
x: n*3,
y: inlineYaxis,
w: cardWidth,
h: cardHeight,
body: faker.lorem.paragraph(),
bg: `#${Math.floor(Math.random()*16777215).toString(16)}`
})
n ++
}
i ++
}
return layout
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment