mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-19 13:52:12 +00:00
handle props variations in NavBarButton
This commit is contained in:
parent
4e85b21b73
commit
613cfe8710
2 changed files with 18 additions and 4 deletions
|
|
@ -8,10 +8,10 @@ const routesRegexp = require('../../routesRegexp');
|
|||
const useLocationHash = require('../../useLocationHash');
|
||||
const styles = require('./styles');
|
||||
|
||||
const NavBarButton = ({ className, icon, label, href, onClick }) => {
|
||||
const NavBarButton = ({ className, icon = '', label = '', href = '', onClick }) => {
|
||||
const locationHash = useLocationHash();
|
||||
const routeRegexp = React.useMemo(() => {
|
||||
if (typeof href === 'string') {
|
||||
if (typeof href === 'string' && href.length > 0) {
|
||||
for (const { regexp } of Object.values(routesRegexp)) {
|
||||
if (regexp.exec(href.slice(1))) {
|
||||
return regexp;
|
||||
|
|
@ -31,8 +31,18 @@ const NavBarButton = ({ className, icon, label, href, onClick }) => {
|
|||
}, [routeRegexp, locationHash]);
|
||||
return (
|
||||
<Button className={classnames(className, styles['nav-bar-button-container'], { 'active': active })} title={label} tabIndex={-1} href={href} onClick={onClick}>
|
||||
<Icon className={styles['icon']} icon={icon} />
|
||||
<div className={styles['label']}>{label}</div>
|
||||
{
|
||||
typeof icon === 'string' && icon.length > 0 ?
|
||||
<Icon className={styles['icon']} icon={icon} />
|
||||
:
|
||||
null
|
||||
}
|
||||
{
|
||||
typeof label === 'string' && label.length > 0 ?
|
||||
<div className={styles['label']}>{label}</div>
|
||||
:
|
||||
null
|
||||
}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@
|
|||
height: 1.2rem;
|
||||
margin-right: 0.6rem;
|
||||
fill: var(--color-surfacelighter);
|
||||
|
||||
&:only-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.label {
|
||||
|
|
|
|||
Loading…
Reference in a new issue