-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
webui: Add Sidebar buttons that link to docs and support.
- Loading branch information
1 parent
64fa68b
commit 63c06e5
Showing
5 changed files
with
110 additions
and
121 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
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,61 @@ | ||
import {NavLink} from "react-router-dom"; | ||
|
||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"; | ||
|
||
|
||
/** | ||
* Component for rendering a sidebar link. | ||
* | ||
* @param {object} props | ||
* @param {import("@fortawesome/react-fontawesome").IconProp} props.icon | ||
* @param {string} props.label | ||
* @param {string} [props.link] | ||
* @param {Function} [props.onClick] | ||
* @return {React.ReactElement} | ||
*/ | ||
const SidebarButton = ({ | ||
icon, | ||
label, | ||
link, | ||
onClick, | ||
}) => { | ||
const children = ( | ||
<> | ||
<div className={"sidebar-item-icon"}> | ||
<FontAwesomeIcon | ||
fixedWidth={true} | ||
icon={icon} | ||
size={"sm"}/> | ||
</div> | ||
<span className={"sidebar-item-text"}> | ||
{label} | ||
</span> | ||
</> | ||
); | ||
|
||
const isNavLink = ("undefined" !== typeof link) && link.startsWith("/"); | ||
if (isNavLink) { | ||
return ( | ||
<NavLink | ||
activeClassName={"active"} | ||
to={link} | ||
onClick={onClick} | ||
> | ||
{children} | ||
</NavLink> | ||
); | ||
} | ||
|
||
return ( | ||
<a | ||
href={link} | ||
rel={"noreferrer"} | ||
target={"_blank"} | ||
onClick={onClick} | ||
> | ||
{children} | ||
</a> | ||
); | ||
}; | ||
|
||
export default SidebarButton; |
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