From 1fb5235f2b5fd5e535fd18a50adf79b78397a02c Mon Sep 17 00:00:00 2001 From: Joel Therrien Date: Mon, 7 Aug 2023 22:56:12 -0700 Subject: [PATCH] Build in basic drag & drop for tiles --- ui/src/elements.tsx | 48 ++++++++++++++++++++++++++++++++++++++++----- ui/src/style.less | 9 ++++++++- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/ui/src/elements.tsx b/ui/src/elements.tsx index 54be1c2..8405994 100644 --- a/ui/src/elements.tsx +++ b/ui/src/elements.tsx @@ -1,7 +1,7 @@ import * as React from "react"; import {GameWasm, Letter as LetterData, Tray} from "word_grid"; import {createRoot} from "react-dom/client"; -import {useReducer, useState} from "react"; +import {Children, useReducer, useState} from "react"; export enum LocationType { GRID, @@ -29,6 +29,8 @@ function matchCoordinate(playerLetters: PlayableLetterData[], coords: Coordinate } +type TileDispatch = React.Dispatch<{start: CoordinateData, end: CoordinateData}>; + function movePlayableLetters(playerLetters: PlayableLetterData[], update: {start: CoordinateData, end: CoordinateData}) { let startIndex = matchCoordinate(playerLetters, update.start); @@ -66,7 +68,7 @@ export function Game(props: {wasm: GameWasm}) { return <> - +