-
Notifications
You must be signed in to change notification settings - Fork 15
feat: add starknet kit package #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,70 +1,84 @@ | ||
|
|
||
| "use client"; | ||
|
|
||
| import React from "react"; | ||
| import { Bell, Menu, User, PanelLeftClose, LogOut } from "lucide-react"; | ||
| import React, { useEffect, useState } from "react"; | ||
| import { | ||
| Bell, | ||
| Menu, | ||
| User, | ||
| PanelLeftClose, | ||
| LogOut, | ||
| } from "lucide-react"; | ||
| import { ThemeToggle } from "@/components/theme-toggle"; | ||
| import { useAccount } from "@starknet-react/core"; | ||
| import { useStarknetWallet } from "@/components/context/StarknetWalletContext"; | ||
| import WalletDisconnectModal from "../../../components/blockchain/Wallet-disconnect-modal"; | ||
| import { useAccount, useDisconnect } from "@starknet-react/core"; | ||
| import { useRouter } from "next/navigation"; | ||
|
|
||
| const Header = () => { | ||
| const [isCollapsed, setIsCollapsed] = useState(false); | ||
| const [isModalOpen, setIsModalOpen] = useState(false); | ||
| const [waitingForReconnect, setWaitingForReconnect] = useState(false); | ||
|
|
||
| const { disconnect } = useDisconnect(); | ||
| const { address } = useAccount(); | ||
| const router = useRouter(); | ||
|
|
||
| const toggleSidebar = () => setIsCollapsed(!isCollapsed); | ||
|
|
||
| interface HeaderProps { | ||
| onMenuClick: () => void; | ||
| isCollapsed: boolean; | ||
| onToggleCollapse: () => void; | ||
| } | ||
| const handleDisconnect = () => { | ||
| disconnect(); | ||
| setIsModalOpen(false); | ||
| setWaitingForReconnect(true); | ||
| }; | ||
|
|
||
| // ✅ When the user reconnects after disconnecting, navigate to dashboard | ||
| useEffect(() => { | ||
| if (waitingForReconnect && address) { | ||
| router.push("/dashboard"); | ||
| } | ||
| }, [waitingForReconnect, address, router]); | ||
|
|
||
| const Header: React.FC<HeaderProps> = ({ | ||
| onMenuClick, | ||
| isCollapsed, | ||
| onToggleCollapse, | ||
| }) => { | ||
| const { truncatedAddress, disconnectWallet, address } = useStarknetWallet(); | ||
| return ( | ||
| <header className="h-16 bg-slate-200/95 dark:bg-slate-950/95 border-b border-border flex items-center justify-between px-4 lg:px-6 sticky top-0 z-50"> | ||
| <div className="flex items-center space-x-4"> | ||
| <button | ||
| className="lg:hidden text-foreground hover:text-muted-foreground" | ||
| onClick={onMenuClick} | ||
| > | ||
| <Menu className="w-6 h-6" /> | ||
| </button> | ||
| <header className="flex items-center justify-between px-4 py-2 border-b bg-background"> | ||
| <div className="flex items-center gap-4"> | ||
| <button | ||
| className="hidden lg:block text-foreground hover:text-muted-foreground" | ||
| onClick={onToggleCollapse} | ||
| onClick={toggleSidebar} | ||
| className="flex items-center justify-center w-8 h-8 bg-muted rounded-full hover:bg-accent transition-colors" | ||
| > | ||
| <PanelLeftClose className="w-6 h-6" /> | ||
| {isCollapsed ? ( | ||
| <Menu className="w-4 h-4 text-muted-foreground" /> | ||
| ) : ( | ||
| <PanelLeftClose className="w-4 h-4 text-muted-foreground" /> | ||
| )} | ||
| </button> | ||
| <div className="flex items-center space-x-2 bg-green-50 dark:bg-green-900/20 px-3 py-1 rounded-full"> | ||
| <div className="w-2 h-2 bg-green-500 rounded-full"></div> | ||
| <span className="text-xs font-medium text-green-700 dark:text-green-400"> | ||
| Connected to StarkNet Mainnet | ||
| </span> | ||
| </div> | ||
| <span className="text-lg font-semibold">Dashboard</span> | ||
| </div> | ||
| <div className="flex items-center space-x-4"> | ||
| {address && ( | ||
| <div className="text-sm text-muted-foreground"> | ||
| {" "} | ||
| {truncatedAddress}{" "} | ||
| </div> | ||
| )} | ||
| <button className="relative p-2 text-muted-foreground hover:text-foreground rounded-lg hover:bg-accent transition-colors"> | ||
| <Bell className="w-5 h-5" /> | ||
| <span className="absolute top-1 right-1 w-2 h-2 bg-red-500 rounded-full"></span> | ||
| </button> | ||
|
|
||
| <div className="flex items-center gap-3"> | ||
| <ThemeToggle /> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The theme toggle function is broken, please fix! |
||
|
|
||
| <button className="flex items-center justify-center w-8 h-8 bg-muted rounded-full hover:bg-accent transition-colors"> | ||
| <Bell className="w-4 h-4 text-muted-foreground" /> | ||
| </button> | ||
|
|
||
| <button className="flex items-center justify-center w-8 h-8 bg-muted rounded-full hover:bg-accent transition-colors"> | ||
| <User className="w-4 h-4 text-muted-foreground" /> | ||
| </button> | ||
|
|
||
| <button | ||
| onClick={disconnectWallet} | ||
| className="flex items-center justify-center w-8 h-8 bg-muted rounded-full hover:bg-accent transition-colors" | ||
| onClick={() => setIsModalOpen(true)} | ||
| className="flex items-center justify-center w-8 h-8 bg-muted rounded-full hover:bg-accent transition-colors cursor-pointer" | ||
| > | ||
| <LogOut className="w-4 h-4 text-muted-foreground" /> | ||
| </button> | ||
| </div> | ||
|
|
||
| {/* Disconnect confirmation modal */} | ||
| <WalletDisconnectModal | ||
| isOpen={isModalOpen} | ||
| onClose={() => setIsModalOpen(false)} | ||
| onDisconnect={handleDisconnect} | ||
| /> | ||
| </header> | ||
| ); | ||
| }; | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sidebar toggle is broken please fix!