Skip to content

Commit

Permalink
[wip] load up to 5 cells rows
Browse files Browse the repository at this point in the history
  • Loading branch information
SivanMehta committed Apr 30, 2022
1 parent 383b68d commit 90bef24
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
15 changes: 11 additions & 4 deletions dist/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -7683,6 +7683,11 @@
}) {
return ready ? children : message;
}
const params = new Proxy(new URLSearchParams(window.location.search), {
get: (searchParams, prop) => searchParams.get(prop)
});
root.style.setProperty('--row-size', Math.min(window.innerWidth, 800) / 5 + "px");
const CELL_COUNT = params.cells || 4;

function pick(array) {
const idx = Math.floor(Math.random() * array.length);
Expand All @@ -7700,10 +7705,8 @@
array[m] = array[i];
array[i] = t;
}
}
} // just a CELLS x CELLS table

root.style.setProperty('--row-size', Math.min(window.innerWidth, 800) / 4 + "px");
const CELL_COUNT = 4; // just a CELLS x CELLS table

function Board() {
shuffle(dice);
Expand All @@ -7728,6 +7731,10 @@
return /*#__PURE__*/react.createElement("table", null, /*#__PURE__*/react.createElement("tbody", null, rows));
}

function Difficulty() {
return 'very hard';
}

function App() {
const [ready, setReady] = react.useState(false);

Expand All @@ -7740,7 +7747,7 @@
});
return /*#__PURE__*/react.createElement(Loading, {
ready: ready
}, /*#__PURE__*/react.createElement(Board, null));
}, /*#__PURE__*/react.createElement(Board, null), /*#__PURE__*/react.createElement(Difficulty, null));
}

reactDom.render( /*#__PURE__*/react.createElement(App, null), document.querySelector('#root'));
Expand Down
2 changes: 1 addition & 1 deletion dist/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ td {
width: calc(var(--row-size));
text-align: center;
vertical-align: middle;
font-size: 17vh;
font-size: 15vh;
border: 1px solid black;
}

Expand Down
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState, useEffect } from 'react';
import { Loading } from './utils';
import Board from './Board';
import Difficulty from './Difficulty';

function App() {
const [ready, setReady] = useState(false);
Expand All @@ -16,6 +17,7 @@ function App() {
return (
<Loading ready={ ready }>
<Board />
<Difficulty />
</Loading>
);
}
Expand Down
5 changes: 1 addition & 4 deletions src/Board.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { dice } from './utils';
import { dice, CELL_COUNT } from './utils';

// randomly pick an element out of an array
function pick(array) {
Expand All @@ -17,9 +17,6 @@ function shuffle(array) {
}
}

root.style.setProperty('--row-size', Math.min(window.innerWidth, 800) / 4 + "px");
const CELL_COUNT = 4;

// just a CELLS x CELLS table
export default function Board() {
shuffle(dice);
Expand Down
3 changes: 3 additions & 0 deletions src/Difficulty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Difficulty() {
return 'very hard'
}
8 changes: 8 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ export const dice = [
export function Loading({ children, ready, message='' }) {
return ready ? children : (message);
}

const params = new Proxy(new URLSearchParams(window.location.search), {
get: (searchParams, prop) => searchParams.get(prop),
});

root.style.setProperty('--row-size', Math.min(window.innerWidth, 800) / 5 + "px");

export const CELL_COUNT = params.cells || 4;

0 comments on commit 90bef24

Please sign in to comment.