-
Notifications
You must be signed in to change notification settings - Fork 10
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 #40 from codeWhizperer/feat/modal
feat: add modal implementation
- Loading branch information
Showing
6 changed files
with
11,664 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,68 @@ | ||
import Dapp from './example/Dapp' | ||
import Dapp from "./example/Dapp"; // import the Dapp component | ||
import { useState } from "react"; | ||
import { TokenBoundModal } from "../src/connector/index"; | ||
import { TokenboundConnector } from "../src/connector/index"; | ||
import { ConnectedStarknetWindowObject } from "get-starknet-core"; | ||
|
||
function App() { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const [value, setValue] = useState<string>(""); | ||
const [selectedOption, setSelectedOption] = useState<string>(""); | ||
|
||
const handleChange = (event: any) => { | ||
setSelectedOption(event.target.value); | ||
}; | ||
|
||
const handleChangeInput = (event: any) => { | ||
setValue(event.target.value); | ||
}; | ||
const closeModal = () => { | ||
setIsOpen(!isOpen); | ||
}; | ||
|
||
const [connection, setConnection] = useState<ConnectedStarknetWindowObject>(); | ||
|
||
const tokenbound = new TokenboundConnector({ | ||
tokenboundAddress: value, | ||
parentAccountId: selectedOption, | ||
}); | ||
|
||
const connectTBA = async () => { | ||
const result = await tokenbound.connect(); | ||
console.log(result); | ||
console.log("connected:", await result.isConnected); | ||
|
||
if (result && (await result).isConnected) { | ||
setConnection(connection); | ||
closeModal(); | ||
} | ||
}; | ||
|
||
return ( | ||
<Dapp /> | ||
) | ||
<> | ||
<div className="App"> | ||
<Dapp /> | ||
<button | ||
className="text-white bg-[#0C0C4F] text-center border-gray-500 outline-none p-2" | ||
onClick={closeModal} | ||
> | ||
Open Modal | ||
</button> | ||
{isOpen && ( | ||
<TokenBoundModal | ||
isOpen={isOpen} | ||
closeModal={closeModal} | ||
value={value} | ||
selectedOption={selectedOption} | ||
handleChange={handleChange} | ||
handleChangeInput={handleChangeInput} | ||
onConnect={connectTBA} | ||
/> | ||
)} | ||
</div> | ||
</> | ||
|
||
); | ||
} | ||
|
||
export default App | ||
export default App; |
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
Oops, something went wrong.