-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
102 additions
and
87 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 was deleted.
Oops, something went wrong.
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,79 @@ | ||
import { type FC, useRef } from "react"; | ||
import kaplayLogo from "../assets/kaplay.png"; | ||
import runIcon from "../assets/run.png"; | ||
import AboutButton from "./About/AboutButton"; | ||
import ProjectMenu from "./Projects/ProjectMenu"; | ||
import ThemeToggler from "./ThemeToggler"; | ||
|
||
type Props = { | ||
run: () => void; | ||
onShare?: () => void; | ||
onThemeChange?: (theme: string) => void; | ||
}; | ||
|
||
const Toolbar: FC<Props> = ({ run, onThemeChange, onShare }) => { | ||
const shareButton = useRef<HTMLButtonElement>(null); | ||
|
||
const handleRun = () => { | ||
run(); | ||
}; | ||
|
||
const handleShare = () => { | ||
onShare?.(); | ||
|
||
if (shareButton.current) { | ||
const shareText = shareButton.current.querySelector(".share-text"); | ||
|
||
if (shareText) { | ||
shareText.textContent = "Copied!"; | ||
setTimeout(() => { | ||
shareText.textContent = "Share"; | ||
}, 1000); | ||
} | ||
} | ||
}; | ||
|
||
return ( | ||
<nav className="flex flex-1 py-2 justify-between items-center bg-base-300 px-4"> | ||
<a className="btn btn-xs btn-ghost text-lg"> | ||
<img alt="Logo" src={kaplayLogo.src} className="h-6" /> | ||
<h1 className="sr-only">KAPLAY</h1> | ||
</a> | ||
|
||
<ul className="flex flex-row items-center gap-2"> | ||
<li> | ||
<button | ||
className="btn btn-xs btn-primary" | ||
onClick={handleRun} | ||
> | ||
Run | ||
<img src={runIcon.src} alt="Run" className="w-4" /> | ||
</button> | ||
</li> | ||
<li> | ||
<button | ||
className="btn btn-xs btn-primary" | ||
onClick={handleShare} | ||
ref={shareButton} | ||
> | ||
<span className="share-text">Share</span> | ||
<img src={runIcon.src} alt="Run" className="w-4" /> | ||
</button> | ||
</li> | ||
<li> | ||
<ThemeToggler | ||
onThemeChange={onThemeChange} | ||
/> | ||
</li> | ||
<li> | ||
<ProjectMenu /> | ||
</li> | ||
<li> | ||
<AboutButton /> | ||
</li> | ||
</ul> | ||
</nav> | ||
); | ||
}; | ||
|
||
export default Toolbar; |