JSFiddle - React, Tailwind, and code Playground

by dumptyd

HTML

<script src="https://unpkg.com/vue"></script>
<div id="app">
  <div v-for="row in hexagons" class="h-container">
    <div class="hexagon" v-for="col in row"></div>
  </div>
  {{hexagons}}
</div>

CSS

.h-container:nth-child(even) {
  margin-left: -30px;
}
.h-container:not(:nth-child(1)) {
  margin-top: -10px;
}
.h-container {
  white-space: nowrap;
}

.hexagon {
  position: relative;
  width: 50px; 
  height: 28.87px;
  background-color: #fff;
  margin: 14.43px 0;
  display: inline-block;
  margin-left: 10px;
  transition: 1s transform ease;
  animation: spin 3s linear infinite;
}

.hexagon:before,
.hexagon:after {
  content: "";
  position: absolute;
  width: 0;
  border-left: 25px solid transparent;
  border-right: 25px solid transparent;
}

.hexagon:before {
  bottom: 100%;
  border-bottom: 14.43px solid #fff;
}

.hexagon:after {
  top: 100%;
  width: 0;
  border-top: 14.43px solid #fff;
}

#app {
  height: 400px;
  width: 600px;
  background-color: #000;
  margin: 25px auto;
  overflow: hidden;
  border: 1px solid;
}

@keyframes spin {
  0% {
    transform: rotate(180deg);
  }
  50% {
    transform: rotate(0deg);
  }
}

JavaScript

var height = 400, width = 600, hexagon = 50;
new Vue({
	el: '#app',
  data: {
  	height: 400,
    width: 600,
    size: 50,
    hPad: 10
  },
  computed: {
  	hexagons: function() {
    	var colLength = (this.width / this.size);
      console.log(colLength);
      colLength = Math.ceil(colLength - ((colLength * 10) / this.size));
      colLength = 15;
      var rowLength = this.height / this.size;
      return Array(rowLength).fill(Array(colLength).fill(true));
    }
  }
});