mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
filter some menu items based on Web3 status
This commit is contained in:
parent
d42453a93e
commit
9b9cbfaff3
@ -1,12 +1,28 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { NavLink } from 'react-router-dom'
|
import { NavLink } from 'react-router-dom'
|
||||||
import { ReactComponent as Logo } from '@oceanprotocol/art/logo/logo.svg'
|
import { ReactComponent as Logo } from '@oceanprotocol/art/logo/logo.svg'
|
||||||
|
import { User } from '../../context/User'
|
||||||
import AccountStatus from '../molecules/AccountStatus'
|
import AccountStatus from '../molecules/AccountStatus'
|
||||||
import styles from './Header.module.scss'
|
import styles from './Header.module.scss'
|
||||||
|
|
||||||
import menu from '../../data/menu.json'
|
import menu from '../../data/menu.json'
|
||||||
import meta from '../../data/meta.json'
|
import meta from '../../data/meta.json'
|
||||||
|
|
||||||
|
const MenuItem = ({ item, isWeb3 }: { item: any; isWeb3: boolean }) => {
|
||||||
|
if (item.web3 && !isWeb3) return null
|
||||||
|
|
||||||
|
return (
|
||||||
|
<NavLink
|
||||||
|
to={item.link}
|
||||||
|
className={styles.link}
|
||||||
|
activeClassName={styles.linkActive}
|
||||||
|
exact
|
||||||
|
>
|
||||||
|
{item.title}
|
||||||
|
</NavLink>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const Header = () => (
|
const Header = () => (
|
||||||
<header className={styles.header}>
|
<header className={styles.header}>
|
||||||
<div className={styles.headerContent}>
|
<div className={styles.headerContent}>
|
||||||
@ -16,17 +32,17 @@ const Header = () => (
|
|||||||
</NavLink>
|
</NavLink>
|
||||||
|
|
||||||
<nav className={styles.headerMenu}>
|
<nav className={styles.headerMenu}>
|
||||||
{menu.map(item => (
|
<User.Consumer>
|
||||||
<NavLink
|
{states =>
|
||||||
key={item.title}
|
menu.map(item => (
|
||||||
to={item.link}
|
<MenuItem
|
||||||
className={styles.link}
|
key={item.title}
|
||||||
activeClassName={styles.linkActive}
|
item={item}
|
||||||
exact
|
isWeb3={states.isWeb3}
|
||||||
>
|
/>
|
||||||
{item.title}
|
))
|
||||||
</NavLink>
|
}
|
||||||
))}
|
</User.Consumer>
|
||||||
</nav>
|
</nav>
|
||||||
<AccountStatus className={styles.accountStatus} />
|
<AccountStatus className={styles.accountStatus} />
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"title": "Publish",
|
"title": "Publish",
|
||||||
"link": "/publish"
|
"link": "/publish",
|
||||||
|
"web3": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "History",
|
"title": "History",
|
||||||
"link": "/history"
|
"link": "/history",
|
||||||
|
"web3": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Faucet",
|
"title": "Faucet",
|
||||||
"link": "/faucet"
|
"link": "/faucet",
|
||||||
|
"web3": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "About",
|
"title": "About",
|
||||||
|
Loading…
Reference in New Issue
Block a user