Skip to content

Commit fa4c126

Browse files
Add a button to create a custom link from last guess
1 parent 135c0a8 commit fa4c126

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

src/Game.tsx

+27-2
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,14 @@ function Game(props: GameProps) {
128128
setGameNumber((x) => x + 1);
129129
};
130130

131-
async function share(copiedHint: string, text?: string) {
131+
async function share(
132+
copiedHint: string,
133+
text?: string,
134+
customTarget?: string
135+
) {
132136
const url = seed
133137
? window.location.origin + window.location.pathname + currentSeedParams()
134-
: getChallengeUrl(target);
138+
: getChallengeUrl(customTarget ? customTarget : target);
135139
const body = url + (text ? "\n\n" + text : "");
136140
if (
137141
/android|iphone|ipad|ipod|webos/i.test(navigator.userAgent) &&
@@ -355,6 +359,27 @@ function Game(props: GameProps) {
355359
</button>
356360
)}
357361
</p>
362+
<p>
363+
<button
364+
onClick={() => {
365+
if (currentGuess.length >= minLength) {
366+
if (dictionary.includes(currentGuess)) {
367+
share(
368+
`Link for word "${currentGuess.toUpperCase()}" copied to clipboard!`,
369+
"I created this challenge for you!",
370+
currentGuess
371+
);
372+
} else {
373+
setHint("Not a valid word");
374+
}
375+
} else {
376+
setHint("Please make a guess first");
377+
}
378+
}}
379+
>
380+
Create a custom game from last guess
381+
</button>
382+
</p>
358383
</div>
359384
);
360385
}

0 commit comments

Comments
 (0)