diff --git a/packages/my-joy-navigation/package.json b/packages/my-joy-navigation/package.json index 4d3263b0..51d2a4b0 100644 --- a/packages/my-joy-navigation/package.json +++ b/packages/my-joy-navigation/package.json @@ -1,6 +1,6 @@ { "name": "my-joy-navigation", - "version": "2.5.1", + "version": "2.6.0", "private": true, "license": "MPL-2.0", "main": "lib/index.js", diff --git a/packages/my-joy-navigation/src/components/anchor.js b/packages/my-joy-navigation/src/components/anchor.js index a4e2f9ba..8ec842d0 100644 --- a/packages/my-joy-navigation/src/components/anchor.js +++ b/packages/my-joy-navigation/src/components/anchor.js @@ -1,9 +1,10 @@ import emotion from 'preact-emotion'; +import remcalc from 'remcalc'; export default emotion('a')` font-weight: 600; - line-height: 24px; - font-size: 15px; + line-height: ${remcalc(24)}; + font-size: ${remcalc(15)}; text-decoration: none; color: ${props => props.theme.text}; diff --git a/packages/my-joy-navigation/src/components/avatar.js b/packages/my-joy-navigation/src/components/avatar.js index 9a5c6acf..af2c1f38 100644 --- a/packages/my-joy-navigation/src/components/avatar.js +++ b/packages/my-joy-navigation/src/components/avatar.js @@ -4,11 +4,7 @@ import remcalc from 'remcalc'; const Img = emotion('img')` width: ${remcalc(24)}; + border-radius: 50%; `; -export default props => ( - -); +export default props => ; diff --git a/packages/my-joy-navigation/src/components/index.js b/packages/my-joy-navigation/src/components/index.js index c859c8eb..422de1b8 100644 --- a/packages/my-joy-navigation/src/components/index.js +++ b/packages/my-joy-navigation/src/components/index.js @@ -33,4 +33,5 @@ export { export { default as Overlay } from './overlay'; export { default as Anchor } from './anchor'; +export { default as Popover } from './popover'; export { default as Sup } from './sup'; diff --git a/packages/my-joy-navigation/src/components/popover.js b/packages/my-joy-navigation/src/components/popover.js new file mode 100644 index 00000000..3ee29806 --- /dev/null +++ b/packages/my-joy-navigation/src/components/popover.js @@ -0,0 +1,44 @@ +import emotion from 'preact-emotion'; +import remcalc from 'remcalc'; + +export default emotion('div')` + min-width: ${remcalc(180)}; + right: ${remcalc(12)}; + top: ${remcalc(46)}; + display: flex; + justify-content: start; + position: absolute; + padding: ${remcalc(12)}; + z-index: 20; + border-radius: ${remcalc(4)}; + background: ${props => props.theme.white}; + border: ${remcalc(1)} solid ${props => props.theme.grey}; + box-sizing: border-box; + box-shadow: 0 ${remcalc(2)} ${remcalc(4)} rgba(0, 0, 0, 0.05); + + &:after { + position: absolute; + content: ''; + top: ${remcalc(-6)}; + right: ${remcalc(12)}; + width: 0; + height: 0; + border-style: solid; + border-width: 0 ${remcalc(4.5)} ${remcalc(6)} ${remcalc(4.5)}; + border-color: transparent transparent ${props => + props.theme.white} transparent; + } + + &:before { + position: absolute; + content: ''; + top: ${remcalc(-7)}; + right: ${remcalc(11)}; + width: 0; + height: 0; + border-style: solid; + border-width: 0 ${remcalc(5.5)} ${remcalc(7)} ${remcalc(5.5)}; + border-color: transparent transparent ${props => + props.theme.grey} transparent; + } +`; diff --git a/packages/my-joy-navigation/src/containers/account.js b/packages/my-joy-navigation/src/containers/account.js new file mode 100644 index 00000000..32c11285 --- /dev/null +++ b/packages/my-joy-navigation/src/containers/account.js @@ -0,0 +1,11 @@ +import React from 'react'; +import { Anchor, Popover } from '../components'; + +const Account = ({ expanded }) => + expanded ? ( + + Log Out + + ) : null; + +export default Account; diff --git a/packages/my-joy-navigation/src/containers/index.js b/packages/my-joy-navigation/src/containers/index.js index ca096e86..63a6ba99 100644 --- a/packages/my-joy-navigation/src/containers/index.js +++ b/packages/my-joy-navigation/src/containers/index.js @@ -1,2 +1,3 @@ export { default as Services } from './services'; export { default as Datacenter } from './datacenter'; +export { default as Account } from './account'; diff --git a/packages/my-joy-navigation/src/header.js b/packages/my-joy-navigation/src/header.js index 886e5412..274fb4f6 100644 --- a/packages/my-joy-navigation/src/header.js +++ b/packages/my-joy-navigation/src/header.js @@ -40,13 +40,14 @@ const GetAccount = gql` } account { login + emailHash } } `; const Navigation = ({ - account = {}, - datacenter = true, + user = {}, + datacenter, toggleSectionOpen, isOpen, activePanel @@ -85,15 +86,18 @@ const Navigation = ({ ) : null} {datacenter ? : null} - {account.login ? ( - + {user.login ? ( + toggleSectionOpen('account')} + active={isOpen && activePanel === 'account'} + > Account: - {`${account.login}`} + {`${user.login}`} - + ) : null} @@ -121,7 +125,12 @@ export default compose( const { name } = datacenter; - return { account, datacenter: name, loading, error }; + const user = { + ...account, + image: `https://www.gravatar.com/avatar/${account.emailHash}` + }; + + return { user, datacenter: name, loading, error }; } }), graphql(GetHeader, {