-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #264 from anderbellstudios/dx/typescript
Add TypeScript
- Loading branch information
Showing
69 changed files
with
980 additions
and
545 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { ComponentChildren, Ref, h } from 'preact' | ||
import { forwardRef } from 'preact/compat' | ||
import { performMove } from './appState/game/actions' | ||
import { useAppState } from './useAppState' | ||
import { GridCell } from './GridCell' | ||
import { Move } from '../../common/types' | ||
|
||
export interface GridProps { | ||
disabled: boolean | ||
children: ComponentChildren | ||
} | ||
|
||
export const Grid = forwardRef( | ||
({ disabled, children }: GridProps, ref: Ref<HTMLDivElement>) => { | ||
const boardState = useAppState('app.game.board') | ||
const currentTurn = useAppState('app.game.currentTurn') | ||
|
||
return ( | ||
<div | ||
ref={ref} | ||
class="relative grid grid-cols-4 gap-1 rounded-lg bg-slate-100 p-1 dark:bg-slate-800 sm:gap-2 sm:p-2" | ||
> | ||
{Array.from({ length: 16 }).map((_, i) => ( | ||
<GridCell | ||
key={i} | ||
shape={boardState[i]} | ||
nextShape={currentTurn} | ||
onClick={() => performMove(i as Move)} | ||
disabled={disabled} | ||
/> | ||
))} | ||
|
||
{children} | ||
</div> | ||
) | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.