Created
December 23, 2020 23:50
-
-
Save donrestarone/908b37a14e7010abda420b8a920ce63e to your computer and use it in GitHub Desktop.
a function for dynamically generating dummy data for react-grid-layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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