Vue
by khamer
HTML
<div id="app" :style="style">
<input type="number" v-model.number="numColumns" class="columns">
<input type="number" v-model.number="numRows" class="rows">
<input type="number" v-model.number="rowHeight" class="rowHeight">
<div v-for="(c,i) in columns" class="row" :style="c.style"></div>
</div>
CSS
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
border-radius: 4px;
padding: .5em;
position: relative;
transition: all 0.2s;
margin-left: 7em;
background-color: #fff;
}
li {
margin: 8px 0;
}
h2 {
font-weight: bold;
margin-bottom: 15px;
}
del {
color: rgba(0, 0, 0, 0.3);
}
input {
box-sizing: border-box;
height: 15px;
padding: 0;
margin: 0;
font-size: 15px;
position: absolute;
width: 3em;
text-align: center;
}
input.columns {
left: -7.5em;
}
input.rows {
left: -3.5em;
}
.row {
margin-top: 1em;
height: 2em;
}
.rowHeight {
left: -7.5em;
top: 2.5em;
}
Vue
new Vue({
el: "#app",
data: {
numColumns: 18,
numRows: 30,
rowHeight: 1,
},
computed: {
columns() {
let columns = [];
for (let w = 2; w < this.numColumns / 2; w++) {
for (let g = 0; g < w; g++) {
if ( (this.numColumns+g) % (w+g) === 0) {
columns.push({style: `
background-image: linear-gradient(to right, #8ac 1px, transparent 0), \
linear-gradient(to right, #acf ${w}em, transparent 0);
height: ${this.rowHeight}em;
background-size: ${w+g}em;
`});
columns.push
}
}
}
return columns;
},
style() {
return `
font-size: 15px;
background-image: radial-gradient(#000 1px, transparent 0);
width: ${this.numColumns}em;
height: ${this.numRows}em;
background-position: 0 0;
background-size: 1em 1em;
`
}
}
})