mirror of
https://github.com/yldio/copilot.git
synced 2024-11-11 05:40:11 +02:00
implimenting header and porfile tooltip toggle
This commit is contained in:
parent
172cc3d447
commit
36f14ba3a2
@ -1,14 +1,14 @@
|
|||||||
const Styled = require('styled-components');
|
const Styled = require('styled-components');
|
||||||
const fns = require('@ui/shared/functions');
|
// const fns = require('@ui/shared/functions');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
default: styled
|
default: styled
|
||||||
} = Styled;
|
} = Styled;
|
||||||
|
|
||||||
const {
|
// const {
|
||||||
remcalc
|
// remcalc
|
||||||
} = fns;
|
// } = fns;
|
||||||
|
|
||||||
|
// Main Contonent Wrapper Styles
|
||||||
module.exports = styled.article`
|
module.exports = styled.article`
|
||||||
margin-top: ${remcalc(78)};
|
|
||||||
`;
|
`;
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
|
const ReactRedux = require('react-redux');
|
||||||
const ReactRouter = require('react-router');
|
const ReactRouter = require('react-router');
|
||||||
const Styled = require('styled-components');
|
const Styled = require('styled-components');
|
||||||
|
|
||||||
|
const selectors = require('@state/selectors');
|
||||||
|
const actions = require('@state/actions');
|
||||||
|
|
||||||
const Column = require('@ui/components/column');
|
const Column = require('@ui/components/column');
|
||||||
const Container = require('@ui/components/container');
|
const Container = require('@ui/components/container');
|
||||||
|
const Avatar = require('@ui/components/avatar');
|
||||||
const fns = require('@ui/shared/functions');
|
const fns = require('@ui/shared/functions');
|
||||||
const logo = require('@resources/logo.png');
|
const logo = require('@resources/logo.png');
|
||||||
const Row = require('@ui/components/row');
|
const Row = require('@ui/components/row');
|
||||||
|
const Tooltip = require('@ui/components/tooltip');
|
||||||
|
const composers = require('@ui/shared/composers');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
Link
|
Link
|
||||||
@ -20,34 +27,138 @@ const {
|
|||||||
remcalc
|
remcalc
|
||||||
} = fns;
|
} = fns;
|
||||||
|
|
||||||
const StyledHeader = styled.header`
|
const {
|
||||||
height: ${remcalc(78)};
|
connect
|
||||||
background-color: #ffffff;
|
} = ReactRedux;
|
||||||
position: absolute;
|
|
||||||
width: 100%;
|
|
||||||
top: 0;
|
|
||||||
left: 0
|
|
||||||
`;
|
|
||||||
|
|
||||||
const StyledLogo = styled.img`
|
const {
|
||||||
|
accountSelector,
|
||||||
|
accountUISelector
|
||||||
|
} = selectors;
|
||||||
|
|
||||||
|
const {
|
||||||
|
pseudoEl
|
||||||
|
} = composers;
|
||||||
|
|
||||||
|
const {
|
||||||
|
handleToggleAction
|
||||||
|
} = actions;
|
||||||
|
|
||||||
|
const StyledHeader = styled.header`
|
||||||
|
background-color: #ffffff;
|
||||||
padding-top: ${remcalc(21)};
|
padding-top: ${remcalc(21)};
|
||||||
padding-bottom: ${remcalc(21)};
|
padding-bottom: ${remcalc(21)};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Header = () => {
|
const StyledLogo = styled.img`
|
||||||
|
padding-top: ${remcalc(10)}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledProfileWrapper = styled.div`
|
||||||
|
position: relative;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledAvatarWrapper = styled.div`
|
||||||
|
&:after {
|
||||||
|
border-left: 5px solid transparent;
|
||||||
|
border-right: 5px solid transparent;
|
||||||
|
border-top: 5px solid black;
|
||||||
|
|
||||||
|
${pseudoEl({
|
||||||
|
top: '50%',
|
||||||
|
right: '10px'
|
||||||
|
})}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledTooltipWrapper = styled.div`
|
||||||
|
position: absolute;
|
||||||
|
left: -40px;
|
||||||
|
bottom: -180px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const arrowPosition = {
|
||||||
|
bottom: '100%',
|
||||||
|
right: '10%'
|
||||||
|
};
|
||||||
|
|
||||||
|
const Header = ({
|
||||||
|
account = {},
|
||||||
|
accountUI = {},
|
||||||
|
dispatch
|
||||||
|
}) => {
|
||||||
|
const handleToggle = (ev) => {
|
||||||
|
ev.preventDefault();
|
||||||
|
dispatch(handleToggleAction(accountUI.profile_tooltip));
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledHeader>
|
<StyledHeader>
|
||||||
<Container fluid>
|
<Container fluid>
|
||||||
<Row>
|
<Row>
|
||||||
<Column xs={2}>
|
<Column xs={2}>
|
||||||
<Link to='/'>
|
<Link to='/'>
|
||||||
<StyledLogo src={logo} />
|
<StyledLogo
|
||||||
|
alt="Joyent"
|
||||||
|
src={logo}
|
||||||
|
/>
|
||||||
</Link>
|
</Link>
|
||||||
</Column>
|
</Column>
|
||||||
|
<Column
|
||||||
|
smOffset={8.5}
|
||||||
|
xs={1.5}
|
||||||
|
>
|
||||||
|
<StyledProfileWrapper>
|
||||||
|
|
||||||
|
<StyledAvatarWrapper>
|
||||||
|
<Link
|
||||||
|
onClick={handleToggle}
|
||||||
|
to='/'
|
||||||
|
>
|
||||||
|
<span>{account.name}</span>
|
||||||
|
<Avatar
|
||||||
|
alt={account.name}
|
||||||
|
name={account.name}
|
||||||
|
src={account.avatar}
|
||||||
|
/>
|
||||||
|
</Link>
|
||||||
|
</StyledAvatarWrapper>
|
||||||
|
|
||||||
|
{ accountUI.profile_tooltip ? (
|
||||||
|
<StyledTooltipWrapper>
|
||||||
|
<Tooltip arrowPosition={arrowPosition}>
|
||||||
|
<li><Link to={'/'}>My Account</Link></li>
|
||||||
|
<li><Link to={'/'}>Settings</Link></li>
|
||||||
|
<li><Link to={'/'}>About</Link></li>
|
||||||
|
</Tooltip>
|
||||||
|
</StyledTooltipWrapper>
|
||||||
|
) : null }
|
||||||
|
|
||||||
|
</StyledProfileWrapper>
|
||||||
|
</Column>
|
||||||
</Row>
|
</Row>
|
||||||
</Container>
|
</Container>
|
||||||
</StyledHeader>
|
</StyledHeader>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Header;
|
Header.propTypes = {
|
||||||
|
account: React.PropTypes.shape({
|
||||||
|
uuid: React.PropTypes.string,
|
||||||
|
id: React.PropTypes.string,
|
||||||
|
name: React.PropTypes.string,
|
||||||
|
}),
|
||||||
|
accountUI: React.PropTypes.shape({
|
||||||
|
profile_tooltip: React.PropTypes.boolean
|
||||||
|
}),
|
||||||
|
dispatch: React.PropTypes.func
|
||||||
|
};
|
||||||
|
|
||||||
|
const mapStateToProps = (state, ownProps) => ({
|
||||||
|
account: accountSelector(state),
|
||||||
|
accountUI: accountUISelector(state)
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = connect(
|
||||||
|
mapStateToProps
|
||||||
|
)(Header);
|
||||||
|
@ -4,7 +4,11 @@
|
|||||||
"uuid": "b94033c1-3665-4c36-afab-d9c3d0b51c01",
|
"uuid": "b94033c1-3665-4c36-afab-d9c3d0b51c01",
|
||||||
"id": "nicola",
|
"id": "nicola",
|
||||||
"name": "Nicola",
|
"name": "Nicola",
|
||||||
"email": "nicola@biztech.com"
|
"email": "nicola@biztech.com",
|
||||||
|
"avatar": "./resources/avatar.png"
|
||||||
|
},
|
||||||
|
"ui": {
|
||||||
|
"profile_tooltip": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"datacenters": {
|
"datacenters": {
|
||||||
|
BIN
frontend/src/resources/avatar.png
Normal file
BIN
frontend/src/resources/avatar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
@ -9,5 +9,6 @@ const APP = constantCase(process.env['APP_NAME']);
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
...require('@state/thunks'),
|
...require('@state/thunks'),
|
||||||
updateRouter: createAction(`${APP}/APP/UPDATE_ROUTER`)
|
updateRouter: createAction(`${APP}/APP/UPDATE_ROUTER`),
|
||||||
|
handleToggleAction: createAction(`${APP}/APP/HANDLE_TOGGLE`, bool => bool)
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,23 @@
|
|||||||
const ReduxActions = require('redux-actions');
|
const ReduxActions = require('redux-actions');
|
||||||
|
|
||||||
|
const actions = require('@state/actions');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
handleActions
|
handleActions
|
||||||
} = ReduxActions;
|
} = ReduxActions;
|
||||||
|
|
||||||
|
const {
|
||||||
|
handleToggleAction
|
||||||
|
} = actions;
|
||||||
|
|
||||||
module.exports = handleActions({
|
module.exports = handleActions({
|
||||||
'x': (state) => state // somehow handleActions needs at least one reducer
|
[handleToggleAction.toString()]: (state, action) => {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
ui: {
|
||||||
|
...state.ui,
|
||||||
|
'profile_tooltip': !action.payload
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}, {});
|
}, {});
|
||||||
|
@ -8,6 +8,7 @@ const {
|
|||||||
} = reselect;
|
} = reselect;
|
||||||
|
|
||||||
const account = (state) => get(state, 'account.data', {});
|
const account = (state) => get(state, 'account.data', {});
|
||||||
|
const accountUi = (state) => get(state, 'account.ui', {});
|
||||||
const orgUiSections = (state) => get(state, 'orgs.ui.sections', []);
|
const orgUiSections = (state) => get(state, 'orgs.ui.sections', []);
|
||||||
const projectUiSections = (state) => get(state, 'projects.ui.sections', []);
|
const projectUiSections = (state) => get(state, 'projects.ui.sections', []);
|
||||||
const orgs = (state) => get(state, 'orgs.data', []);
|
const orgs = (state) => get(state, 'orgs.data', []);
|
||||||
@ -37,6 +38,7 @@ const orgSections = (orgId) => createSelector(
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
accountSelector: account,
|
accountSelector: account,
|
||||||
|
accountUISelector: accountUi,
|
||||||
orgByIdSelector: orgById,
|
orgByIdSelector: orgById,
|
||||||
orgsSelector: orgs,
|
orgsSelector: orgs,
|
||||||
orgSectionsSelector: orgSections,
|
orgSectionsSelector: orgSections,
|
||||||
|
Loading…
Reference in New Issue
Block a user