diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 79afc75..543469f 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -1,6 +1,7 @@ import React from 'react' import { NavLink } from 'react-router-dom' import { ReactComponent as Logo } from '@oceanprotocol/art/logo/logo.svg' +import AccountStatus from './molecules/AccountStatus' import styles from './Header.module.scss' import menu from '../data/menu.json' @@ -27,6 +28,7 @@ const Header = () => ( ))} + ) diff --git a/src/components/Web3message.module.scss b/src/components/Web3message.module.scss index 759ebb8..5f78d8c 100644 --- a/src/components/Web3message.module.scss +++ b/src/components/Web3message.module.scss @@ -11,36 +11,6 @@ padding-bottom: $spacer / 2; } -// default: red square -.indicator { - display: inline-block; - width: $font-size-small; - height: $font-size-small; - background: $red; - margin-right: $spacer / 8; - position: absolute; - left: 0; - top: ($spacer / 2) + .3rem; -} - -// yellow triangle -.indicatorCloseEnough { - composes: indicator; - background: none; - width: 0; - height: 0; - border-left: $font-size-small / 1.75 solid transparent; - border-right: $font-size-small / 1.75 solid transparent; - border-bottom: $font-size-small solid $yellow; -} - -// green circle -.indicatorActive { - composes: indicator; - border-radius: 50%; - background: $green; -} - .account { display: inline-block; margin-left: $spacer / 8; diff --git a/src/components/Web3message.tsx b/src/components/Web3message.tsx index b0996aa..919da5f 100644 --- a/src/components/Web3message.tsx +++ b/src/components/Web3message.tsx @@ -1,33 +1,31 @@ import React, { PureComponent } from 'react' import Button from '../components/atoms/Button' +import AccountStatus from './molecules/AccountStatus' import styles from './Web3message.module.scss' import { User } from '../context/User' export default class Web3message extends PureComponent { public render() { return ( - <> - - {states => - !states.isWeb3 - ? this.noWeb3() - : !states.isLogged - ? this.unlockAccount(states) - : states.isLogged - ? this.haveAccount(states.account) - : null - } - - + + {states => + !states.isWeb3 + ? this.noWeb3() + : !states.isLogged + ? this.unlockAccount(states) + : states.isLogged + ? this.haveAccount(states.account) + : null + } + ) } public noWeb3() { return (
- No Web3 Browser. For - publishing an asset you need to use a Web3-capable plugin or - browser, like{' '} + No Web3 Browser. For publishing an asset you + need to use a Web3-capable plugin or browser, like{' '} MetaMask @@ -39,8 +37,8 @@ export default class Web3message extends PureComponent { public unlockAccount(states: any) { return (
- Account locked. - For publishing an asset you need to unlock your Web3 account. + Account locked. For publishing an asset you + need to unlock your Web3 account. @@ -51,8 +49,7 @@ export default class Web3message extends PureComponent { public haveAccount(account: string) { return (
- Connected with - account + Connected with account {`${account && account.substring(0, 20)}...`} diff --git a/src/components/molecules/AccountStatus.module.scss b/src/components/molecules/AccountStatus.module.scss new file mode 100644 index 0000000..ccbdc9b --- /dev/null +++ b/src/components/molecules/AccountStatus.module.scss @@ -0,0 +1,106 @@ +@import '../../styles/variables'; + +.status { + display: inline-block; + position: relative; +} + +// default: red square +.statusIndicator { + width: $font-size-small; + height: $font-size-small; + display: block; + background: $red; + margin-bottom: -.1rem; +} + +// yellow triangle +.statusIndicatorCloseEnough { + composes: statusIndicator; + background: none; + width: 0; + height: 0; + border-left: $font-size-small / 1.7 solid transparent; + border-right: $font-size-small / 1.7 solid transparent; + border-bottom: $font-size-small solid $yellow; +} + +// green circle +.statusIndicatorActive { + composes: statusIndicator; + border-radius: 50%; + background: $green; +} + +$popoverWidth: 18rem; + +.popover { + position: absolute; + top: 1.5rem; + right: -($spacer / 3); + width: $popoverWidth; + padding: $spacer / 2; + background: $brand-black; + border-radius: .1rem; + border: .1rem solid $brand-grey-light; + box-shadow: 0 6px 16px 0 rgba($brand-black, .3); + color: $brand-grey-light; + font-size: $font-size-small; + + &:after { + bottom: 100%; + right: 2%; + border: solid transparent; + content: ''; + height: 0; + width: 0; + position: absolute; + pointer-events: none; + border-color: transparent; + border-bottom-color: $brand-grey-light; + border-width: 10px; + margin-left: -10px; + } +} + +.popoverInfoline { + border-bottom: .05rem solid $brand-grey; + padding: $spacer / 3 0; + display: flex; + flex-wrap: wrap; + align-items: center; + + &:first-child { + padding-top: 0; + } + + &:last-child { + padding-bottom: 0; + border-bottom: 0; + } + + button { + font-size: $font-size-small; + } +} + +.accountName { + composes: popoverInfoline; + flex-wrap: nowrap; + + // blockies avatar + canvas { + display: inline-block; + border-radius: 50%; + overflow: hidden; + flex: 0 0 20px; + margin-right: $spacer / 4; + } +} + +.address { + width: 15rem; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} diff --git a/src/components/molecules/AccountStatus.tsx b/src/components/molecules/AccountStatus.tsx new file mode 100644 index 0000000..09d9356 --- /dev/null +++ b/src/components/molecules/AccountStatus.tsx @@ -0,0 +1,88 @@ +import React, { PureComponent } from 'react' +// import Blockies from 'react-blockies' +import Button from '../atoms/Button' +import { User } from '../../context/User' +import styles from './AccountStatus.module.scss' + +interface AccountStatusState { + popoverOpen: boolean +} + +export default class AccountStatus extends PureComponent< + {}, + AccountStatusState +> { + public state = { + popoverOpen: false + } + + private togglePopover() { + this.setState(prevState => ({ + popoverOpen: !prevState.popoverOpen + })) + } + + public render() { + return ( +
this.togglePopover()} + onMouseLeave={() => this.togglePopover()} + onTouchStart={() => this.togglePopover()} + > + + {states => + !states.isWeb3 ? ( + + ) : !states.isLogged ? ( + + ) : states.isLogged ? ( + + ) : null + } + + + {this.state.popoverOpen && } +
+ ) + } +} + +const AccountPopover = () => ( +
+
+ + {states => + states.account ? ( + <> + {/* */} + + {states.account} + + + ) : ( + 'No account selected' + ) + } + +
+
+ Network:  {''} +
+
+ +
+
+)