feat(navigation): add user dropdown

This commit is contained in:
Sara Vieira 2018-03-28 14:26:25 +01:00 committed by Sérgio Ramos
parent 495af5702d
commit cac551beaf
8 changed files with 79 additions and 16 deletions

View File

@ -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",

View File

@ -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};

View File

@ -4,11 +4,7 @@ import remcalc from 'remcalc';
const Img = emotion('img')`
width: ${remcalc(24)};
border-radius: 50%;
`;
export default props => (
<Img
{...props}
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAACXBIWXMAAAsSAAALEgHS3X78AAALZElEQVR4nN2dfWwbZx3HP/dmO2kaZ0lbm74lXdauY23SUmnaVrZl0GloINWFSf0L1lYgxJhEiCbgP4LE/kCC0moaQ0hoKYOpQ5S52ipWwVi2AW1hG0nXvWhd1mRdW2dKsrqkjd/Oxx93dmzf+XznnN0kX6nq5bnn7fe95/d7fs+rBU3TuJ6I93X2AFuAFqDHCN4CBC2ijwGjxvOg8TwU3D8yVMMq2kKoN4Hxvs4tQASdrHs8zPooOqnR4P6RUQ/ztUVdCIz3dXYAvejEtde8QBgGBoCB4P6Ry7UsqKYEGurZj7ctzS0OAQdqpeY1IXCeEFeKV4A9Xqu3pwQaqjrA/CKuFIeAXq9UW/QiE4B4X2c/cI75TR7AQ8BovK8z4kVmc26BRq86AHR7UaE64yi6WlfdGufUAuN9nXvQXYeFSB7ATmDIaARVoWoCDZV9CmuHdyGhHRg0GoNrVKXC8b7OAXRbstiwN7h/ZMBNAtctcBGTB/CU25bomEA1Gm6Z+c3aF1m85OkQ+FXqmVUPO43upgUO+Fak7vfdlDlfRbUWBg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G8RF2ugjcuaajnVfBHgahbn64a1P3HCAw76fWPEYyhT7sNohNX0/vzC1F3AkthLGJ1GP9yP4sBZnILfwpjCH1j6CAwWiv1dIL/A+EDttkCSrnHAAAAAElFTkSuQmCC"
/>
);
export default props => <Img {...props} />;

View File

@ -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';

View File

@ -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;
}
`;

View File

@ -0,0 +1,11 @@
import React from 'react';
import { Anchor, Popover } from '../components';
const Account = ({ expanded }) =>
expanded ? (
<Popover>
<Anchor href="/navigation/signout">Log Out</Anchor>
</Popover>
) : null;
export default Account;

View File

@ -1,2 +1,3 @@
export { default as Services } from './services';
export { default as Datacenter } from './datacenter';
export { default as Account } from './account';

View File

@ -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 = ({
</HeaderItem>
) : null}
{datacenter ? <HeaderDividerItem /> : null}
{account.login ? (
<HeaderItem>
{user.login ? (
<HeaderItem
onClick={() => toggleSectionOpen('account')}
active={isOpen && activePanel === 'account'}
>
<HeaderItemContent>
<HeaderItemSubContent>Account:</HeaderItemSubContent>
<HeaderSpace />
{`${account.login}`}
{`${user.login}`}
</HeaderItemContent>
<HeaderItemIcon>
<Avatar />
<Avatar src={user.image} />
</HeaderItemIcon>
</HeaderItem>
) : 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, {