Designing the board
This commit is contained in:
@@ -26,7 +26,7 @@
|
|||||||
1,
|
1,
|
||||||
"multiline"
|
"multiline"
|
||||||
],
|
],
|
||||||
"react/jsx-closing-bracket-location": 1,
|
"react/jsx-closing-bracket-location": 0,
|
||||||
"react/jsx-curly-spacing": 1,
|
"react/jsx-curly-spacing": 1,
|
||||||
"react/jsx-indent-props": [
|
"react/jsx-indent-props": [
|
||||||
2,
|
2,
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import { Canvas } from 'components';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return <div className="App">hello world!</div>;
|
return (
|
||||||
|
<div className="app">
|
||||||
|
<Canvas />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
|||||||
5
src/assets/scss/_variables.scss
Normal file
5
src/assets/scss/_variables.scss
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
$gray-light: #f6f6f6;
|
||||||
|
$gray-mid: #e3e3e3;
|
||||||
|
$gray-dark: #333;
|
||||||
|
$gray: #d1d1d1;
|
||||||
|
$red: #ec433c;
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
@import 'reset';
|
@import 'reset';
|
||||||
|
@import 'variables';
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
background-color: #f6f6f6;
|
background-color: $gray-light;
|
||||||
}
|
}
|
||||||
|
|||||||
7
src/components/Board/Board.js
Normal file
7
src/components/Board/Board.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
const Board = () => {
|
||||||
|
return <div className="board">Board here</div>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Board;
|
||||||
1
src/components/Board/index.js
Normal file
1
src/components/Board/index.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { default } from './Board';
|
||||||
13
src/components/Canvas/Canvas.js
Normal file
13
src/components/Canvas/Canvas.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Header } from 'components';
|
||||||
|
import './styles.scss';
|
||||||
|
|
||||||
|
const Canvas = () => {
|
||||||
|
return (
|
||||||
|
<div className="canvas">
|
||||||
|
<Header />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Canvas;
|
||||||
1
src/components/Canvas/index.js
Normal file
1
src/components/Canvas/index.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { default } from './Canvas';
|
||||||
26
src/components/Canvas/styles.scss
Normal file
26
src/components/Canvas/styles.scss
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
@import '../../assets/scss/variables';
|
||||||
|
|
||||||
|
.canvas {
|
||||||
|
max-width: 1000px;
|
||||||
|
width: 100%;
|
||||||
|
min-width: 500px;
|
||||||
|
background-color: $gray-mid;
|
||||||
|
margin: 0 auto;
|
||||||
|
border-radius: 3px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box {
|
||||||
|
border-radius: 0;
|
||||||
|
border-width: 3px;
|
||||||
|
border-style: solid;
|
||||||
|
background-color: $gray;
|
||||||
|
border-color: lighten($gray, 20%) darken($gray, 20%) darken($gray, 20%)
|
||||||
|
lighten($gray, 20%);
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:focus {
|
||||||
|
background-color: lighten($gray, 10%);
|
||||||
|
}
|
||||||
|
}
|
||||||
95
src/components/Header/Header.js
Normal file
95
src/components/Header/Header.js
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import './styles.scss';
|
||||||
|
|
||||||
|
const difficulty = {
|
||||||
|
custom: {
|
||||||
|
rows: 10,
|
||||||
|
cols: 10,
|
||||||
|
mines: 5,
|
||||||
|
flags: 5
|
||||||
|
},
|
||||||
|
beginner: {
|
||||||
|
rows: 20,
|
||||||
|
cols: 20,
|
||||||
|
mines: 5,
|
||||||
|
flags: 5
|
||||||
|
},
|
||||||
|
intermediate: {
|
||||||
|
rows: 50,
|
||||||
|
cols: 50,
|
||||||
|
mines: 15,
|
||||||
|
flags: 15
|
||||||
|
},
|
||||||
|
expert: {
|
||||||
|
rows: 100,
|
||||||
|
cols: 100,
|
||||||
|
mines: 50,
|
||||||
|
flags: 50
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const Header = () => {
|
||||||
|
const [selectedDifficulty, setSelectedDifficulty] = useState('beginner');
|
||||||
|
const [rows, setRows] = useState(difficulty.beginner.rows);
|
||||||
|
const [cols, setCols] = useState(difficulty.beginner.cols);
|
||||||
|
const [mines, setMines] = useState(difficulty.beginner.mines);
|
||||||
|
const [flags, setFlags] = useState(5);
|
||||||
|
const [resetContent] = useState('🙂');
|
||||||
|
|
||||||
|
const handleSetDifficulty = event => {
|
||||||
|
setSelectedDifficulty(event.target.value);
|
||||||
|
setRows(difficulty[event.target.value].rows);
|
||||||
|
setCols(difficulty[event.target.value].cols);
|
||||||
|
setMines(difficulty[event.target.value].mines);
|
||||||
|
setFlags(difficulty[event.target.value].flags);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSetMines = event => {
|
||||||
|
setMines(parseInt(event.target.value));
|
||||||
|
setFlags(parseInt(event.target.value));
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="header">
|
||||||
|
<div className="flags led-panel box">{flags}</div>
|
||||||
|
<div className="settings">
|
||||||
|
{selectedDifficulty === 'custom' && (
|
||||||
|
<div className="custom">
|
||||||
|
<input
|
||||||
|
className="box"
|
||||||
|
onChange={event => setRows(parseInt(event.target.value))}
|
||||||
|
type="number"
|
||||||
|
value={rows}
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
className="box"
|
||||||
|
onChange={event => setCols(parseInt(event.target.value))}
|
||||||
|
type="number"
|
||||||
|
value={cols}
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
className="box"
|
||||||
|
onChange={event => handleSetMines(event)}
|
||||||
|
type="number"
|
||||||
|
value={mines}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<select
|
||||||
|
className="box"
|
||||||
|
onChange={event => handleSetDifficulty(event)}
|
||||||
|
value={selectedDifficulty}>
|
||||||
|
<option value="custom">Custom</option>
|
||||||
|
<option value="beginner">Beginner</option>
|
||||||
|
<option value="intermediate">Intermediate</option>
|
||||||
|
<option value="expert">Expert</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="reset box">{resetContent}</div>
|
||||||
|
<div className="timer led-panel box">000</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Header;
|
||||||
1
src/components/Header/index.js
Normal file
1
src/components/Header/index.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { default } from './Header';
|
||||||
43
src/components/Header/styles.scss
Normal file
43
src/components/Header/styles.scss
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
@import '../../assets/scss/variables';
|
||||||
|
|
||||||
|
.header {
|
||||||
|
max-width: 500px;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 5px;
|
||||||
|
|
||||||
|
.led-panel {
|
||||||
|
font-family: 'Space Mono', monospace;
|
||||||
|
background: $gray-dark;
|
||||||
|
color: $red;
|
||||||
|
text-shadow: 0 0 2px rgba($red, 1);
|
||||||
|
line-height: 30px;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
text-align: center;
|
||||||
|
width: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings {
|
||||||
|
max-width: 221px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
.custom {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
input {
|
||||||
|
width: 30px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.reset {
|
||||||
|
width: 30px;
|
||||||
|
line-height: 30px;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
3
src/components/index.js
Normal file
3
src/components/index.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export { default as Canvas } from './Canvas';
|
||||||
|
export { default as Header } from './Header';
|
||||||
|
export { default as Board } from './Board';
|
||||||
Reference in New Issue
Block a user