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">
  
  <div class="cells">
    <div v-for="i in cells" class="cell" v-text="i"></div>
  </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;
}

.cell {
  width: 3em;
  height: 2em;
  background: blue;
  margin-right: 1em;
  margin-bottom: 1em;
}

.cells {
  display: flex;
  flex-flow: row wrap;
  justify-content: flex-start;
  align-items: flex-start;
}

Vue

new Vue({
  el: "#app",
  data: {
  	numColumns: 30,
    numRows: 18,
    rowHeight: 1,
  },
  computed: {
  	cells() {
    	return Array(42);
    },
  	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;
      `
    }
  }
})