diff --git a/css/main.css b/css/main.css index 3811df1..f6573f8 100644 --- a/css/main.css +++ b/css/main.css @@ -11,14 +11,31 @@ body { align-items: center; } -section { +section.markers { + display: grid; + grid-template-columns: repeat(7, 10vmin); + grid-gap: 1vmin; + margin-bottom: 1vmin; +} + +section.markers div { + border-top: 5vmin solid lightgrey; + border-left: 5vmin solid transparent; + border-right: 5vmin solid transparent; +} + +section.markers div:hover { + border-top-color: grey; +} + +section.board { display: grid; grid-template-columns: repeat(7, 10vmin); grid-template-rows: repeat(6, 10vmin); grid-gap: 1vmin; } -section div { +section.board div { border-radius: 50%; border: 1px solid grey; } \ No newline at end of file diff --git a/index.html b/index.html index 7511d45..2d29b4c 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,16 @@

CONNECT FOUR

-
+
+
+
+
+
+
+
+
+
+
diff --git a/js/main.js b/js/main.js index 52db426..0b45cd3 100644 --- a/js/main.js +++ b/js/main.js @@ -12,9 +12,11 @@ let board, turn, winner; /*----- event listeners -----*/ - +document.querySelector('section.markers') + .addEventListener('click', handleClick); /*----- functions -----*/ +init(); function init() { board = [ @@ -28,4 +30,22 @@ function init() { ]; turn = 1; winner = null; // 1, -1, null (no winner), 'T' (tie) + render(); +} + +function render() { + // Render the board + board.forEach(function(colArr, colIdx) { + colArr.forEach(function(cell, rowIdx) { + let div = document.getElementById(`c${colIdx}r${rowIdx}`); + div.style.backgroundColor = COLORS[cell]; + }); + }); +} + +function handleClick(evt) { + let idx = parseInt(evt.target.id.replace('col', '')); + if (isNaN(idx) || winner) return; + + } \ No newline at end of file