generated from the-collab-lab/smart-shopping-list
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#14.3) create IconButton component and render in Layout.jsx. Use…
… Layout.jsx css.
- Loading branch information
1 parent
8040f53
commit 919d09c
Showing
4 changed files
with
37 additions
and
3 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 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,21 @@ | ||
import { useState } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import '../views/Layout.css'; | ||
|
||
export function IconButton({ icon, label, link }) { | ||
const navigate = useNavigate(); | ||
const [clicked, setClicked] = useState(false); | ||
|
||
const handleClick = () => { | ||
// e.preventDefault(); | ||
navigate(link); | ||
setClicked(true); | ||
}; | ||
|
||
return ( | ||
<button onClick={handleClick} className={clicked ? 'clicked-link' : ''}> | ||
{icon && <i className={icon}></i>} <br /> | ||
{label && <span>{label}</span>} | ||
</button> | ||
); | ||
} |
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