-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: move items from side menu to header (#540)
Co-authored-by: Noam Gaash <noam.gaash@gmail.com>
- Loading branch information
1 parent
04518e6
commit d8b1a55
Showing
6 changed files
with
77 additions
and
35 deletions.
There are no files selected for viewing
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
8 changes: 7 additions & 1 deletion
8
src/layout/header/GitHubLink/GitHubLink.scss → ...ayout/header/HeaderLinks/HeaderLinks.scss
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,54 @@ | ||
import { FC } from 'react' | ||
import { useNavigate } from 'react-router-dom' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import './HeaderLinks.scss' | ||
import { HEADER_LINKS } from 'src/routes' | ||
|
||
type LinkType = Omit<(typeof HEADER_LINKS)[number], 'element'> | ||
|
||
const HeaderLinks: FC = () => { | ||
return ( | ||
<div className="header-links"> | ||
{HEADER_LINKS.map((item) => { | ||
if (item.element === null) { | ||
return ( | ||
<ExternalLink key={item.label} label={item.label} icon={item.icon} path={item.path} /> | ||
) | ||
} else { | ||
return ( | ||
<InternalLink key={item.label} label={item.label} icon={item.icon} path={item.path} /> | ||
) | ||
} | ||
})} | ||
</div> | ||
) | ||
} | ||
|
||
const ExternalLink = ({ label, path, icon }: LinkType) => { | ||
const { t } = useTranslation() | ||
function handleClick() { | ||
window.open(path, '_blank') | ||
} | ||
return ( | ||
<div className="header-link" aria-label={t(label)} title={t(label)} onClick={handleClick}> | ||
{icon} | ||
</div> | ||
) | ||
} | ||
|
||
const InternalLink = ({ label, path, icon }: LinkType) => { | ||
const navigate = useNavigate() | ||
const { t } = useTranslation() | ||
return ( | ||
<div | ||
aria-label={t(label)} | ||
title={t(label)} | ||
className="header-link" | ||
onClick={() => navigate(path)}> | ||
{icon} | ||
</div> | ||
) | ||
} | ||
|
||
export default HeaderLinks |
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