Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion web/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
}
}

.card {
.dualColumns {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logo-spin is hyphen case but this is camel, should be one or the other, I vote hyphen case for css

padding: 2em;
display: flex;
align-items: center;
}
19 changes: 0 additions & 19 deletions web/src/IncrementButton.tsx

This file was deleted.

13 changes: 13 additions & 0 deletions web/src/components/IncrementButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Dispatch } from 'react';

function IncrementButton(props: { countIncrease: Dispatch<number>, incrementBy: number}) {
return (
<div>
<button onClick={() => props.countIncrease(props.incrementBy)}>
This button increments by {props.incrementBy}
</button>
</div>
);
}

export default IncrementButton;
34 changes: 23 additions & 11 deletions web/src/components/SnakeScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import IncrementButton from '../IncrementButton';
import IncrementButton from './IncrementButton';
import CanvasBoard from './CanvasBoard';
import { useState } from 'react';

function SnakeScreen() {
return (
<div className='App'>
<div className='logo snake'>🐍</div>
<h1>GDSC Snake</h1>
<div className="card">
<IncrementButton incrementBy={1} />
<IncrementButton incrementBy={2} />
<CanvasBoard height={200} width={400}/>
</div>
const [count, setCount] = useState(0);

function increaseCount(incrementNum: number) {
setCount(count + incrementNum);
}

return (
<div className='App'>
<div className='logo snake'>🐍</div>
<h1>GDSC Snake</h1>
<div className='dualColumns'>
<div>
<CanvasBoard height={200} width={400}/>
</div>
<div>
<h2>Current score: {count}</h2>
<IncrementButton countIncrease={increaseCount} incrementBy={1} />
<IncrementButton countIncrease={increaseCount} incrementBy={2} />
</div>
);
</div>
</div>
);
}

export default SnakeScreen;