Skip to content

Commit 48489f8

Browse files
psellechadoh
authored andcommitted
Add submit button to component
1 parent db55e71 commit 48489f8

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

src/components/GuessTheNumber.tsx

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { useState } from "react";
2-
import { Code, Input, Text } from "@stellar/design-system";
2+
import { Button, Code, Input, Text } from "@stellar/design-system";
33
import { useWallet } from "../hooks/useWallet";
44
import game from "../contracts/guess_the_number";
5+
import { Box } from "../components/layout/Box";
56

67
export const GuessTheNumber = () => {
78
const [guessedIt, setGuessedIt] = useState<boolean>();
@@ -40,16 +41,27 @@ export const GuessTheNumber = () => {
4041
</Text>
4142
</>
4243
) : (
43-
<Input
44-
label="Guess a number from 1 to 10!"
45-
id="guess"
46-
fieldSize="lg"
47-
error={guessedIt === false && "Wrong! Guess again."}
48-
onChange={(e) => {
49-
setGuessedIt(undefined);
50-
setTheGuess(Number(e.target.value));
51-
}}
52-
/>
44+
<Box gap="sm" direction="row" align="end" justify="end" wrap="wrap">
45+
<Input
46+
label="Guess a number from 1 to 10!"
47+
id="guess"
48+
fieldSize="lg"
49+
error={guessedIt === false && "Wrong! Guess again."}
50+
onChange={(e) => {
51+
setGuessedIt(undefined);
52+
setTheGuess(Number(e.target.value));
53+
}}
54+
/>
55+
<Button
56+
type="submit"
57+
disabled={!theGuess}
58+
style={{ marginTop: 8 }}
59+
variant="primary"
60+
size="md"
61+
>
62+
Submit Guess
63+
</Button>
64+
</Box>
5365
)}
5466
<Text as="p" size="lg">
5567
&nbsp; {/* Not sure the SDS way to add consistent spacing at the end */}

0 commit comments

Comments
 (0)