Skip to content

Commit 261a97e

Browse files
skal nkunne vise tre-på-rad brettet
1 parent 991e1fb commit 261a97e

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

src/App.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { useState } from 'react'
22
import logo from './logo.svg'
33
import './App.css'
4+
import * as React from 'react';
5+
import Board from "./frontend/board/Board";
46

5-
function App() {
7+
const App: React.FC = () => {
68
const [count, setCount] = useState(0)
79

810
return (
@@ -38,6 +40,7 @@ function App() {
3840
</a>
3941
</p>
4042
</header>
43+
<Board size={3} />
4144
</div>
4245
)
4346
}

src/frontend/board/Board.tsx

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import * as React from 'react';
2+
import styled from "styled-components";
3+
4+
const BoardContainer = styled.div`
5+
margin: auto;
6+
width: 30%;
7+
display: flex;
8+
justify-content: center;
9+
flex-wrap: wrap;
10+
margin-top: 2rem;
11+
margin-bottom: 2rem;
12+
`;
13+
14+
const Box = styled.div`
15+
background-color: #C86752;
16+
height: 10rem;
17+
width: 10rem;
18+
border: 2px solid black;
19+
`;
20+
21+
interface Props {
22+
size: number;
23+
}
24+
25+
const Board: React.FC<Props> = ({size}) => {
26+
27+
const handleClick = () => {
28+
console.log('click');
29+
}
30+
31+
return (
32+
<BoardContainer>
33+
{Array.from({length: size*size}, (v, i) => i).map((num, index) => {
34+
return <Box onClick={handleClick} key={index}/>
35+
})}
36+
</BoardContainer>
37+
)
38+
}
39+
40+
export default Board

src/index.css

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
body {
22
margin: 0;
3+
background-color: #282c34;
34
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
45
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
56
sans-serif;

0 commit comments

Comments
 (0)