-
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #41 from skedwards88/custom-puzzles
Allow custom puzzles
- Loading branch information
Showing
29 changed files
with
1,741 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from "react"; | ||
import Pool from "./Pool"; | ||
import Board from "./Board"; | ||
import DragGroup from "./DragGroup"; | ||
|
||
function CustomCreation({dispatchCustomState, customState, validityOpacity}) { | ||
// dragCount ensures a different key each time, so a fresh DragGroup is mounted even if there's | ||
// no render between one drag ending and the next one starting. | ||
const dragGroup = customState.dragState ? ( | ||
<DragGroup | ||
key={customState.dragCount} | ||
dispatchGameState={dispatchCustomState} | ||
gameState={customState} | ||
/> | ||
) : null; | ||
|
||
return ( | ||
<div | ||
id="custom" | ||
style={{ | ||
"--grid-rows": customState.gridSize, | ||
"--grid-columns": customState.gridSize, | ||
"--validity-opacity": validityOpacity, | ||
}} | ||
> | ||
<Board | ||
pieces={customState.pieces} | ||
gameIsSolved={false} | ||
dispatchGameState={dispatchCustomState} | ||
indicateValidity={validityOpacity > 0} | ||
dragPieceIDs={customState.dragState?.pieceIDs} | ||
dragDestination={customState.dragState?.destination} | ||
gridSize={customState.gridSize} | ||
customCreation={true} | ||
></Board> | ||
<Pool | ||
// don't pass drag destination so that won't render drag shadow on pool | ||
pieces={customState.pieces} | ||
dispatchGameState={dispatchCustomState} | ||
></Pool> | ||
{dragGroup} | ||
</div> | ||
); | ||
} | ||
|
||
export default CustomCreation; |
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,40 @@ | ||
import React from "react"; | ||
|
||
export default function CustomShare({ | ||
representativeString, | ||
dispatchCustomState, | ||
setDisplay, | ||
}) { | ||
const link = `https://crossjig.com?id=custom-${representativeString}`; | ||
|
||
return ( | ||
<div className="App customMessage"> | ||
<div>{`Share your custom puzzle with this link!`}</div> | ||
<a href={link}>{link}</a> | ||
<div id="custom-message-buttons"> | ||
<button | ||
onClick={() => { | ||
try { | ||
navigator.clipboard.writeText(link); | ||
} catch (error) { | ||
console.log("Error copying", error); | ||
} | ||
}} | ||
> | ||
Copy | ||
</button> | ||
<button | ||
onClick={() => { | ||
dispatchCustomState({ | ||
action: "updateRepresentativeString", | ||
representativeString: "", | ||
}); | ||
setDisplay("custom"); | ||
}} | ||
> | ||
Ok | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.