From 36f14ba3a20356067eb6aec4a2476621eb43cbd0 Mon Sep 17 00:00:00 2001 From: Alex Windett Date: Wed, 21 Dec 2016 14:05:16 +0000 Subject: [PATCH] implimenting header and porfile tooltip toggle --- frontend/src/components/article/index.js | 10 +- frontend/src/components/header/index.js | 135 +++++++++++++++++++++-- frontend/src/mock-state.json | 6 +- frontend/src/resources/avatar.png | Bin 0 -> 3212 bytes frontend/src/state/actions.js | 3 +- frontend/src/state/reducers/account.js | 16 ++- frontend/src/state/selectors.js | 2 + 7 files changed, 152 insertions(+), 20 deletions(-) create mode 100644 frontend/src/resources/avatar.png diff --git a/frontend/src/components/article/index.js b/frontend/src/components/article/index.js index 229e5525..09210628 100644 --- a/frontend/src/components/article/index.js +++ b/frontend/src/components/article/index.js @@ -1,14 +1,14 @@ const Styled = require('styled-components'); -const fns = require('@ui/shared/functions'); +// const fns = require('@ui/shared/functions'); const { default: styled } = Styled; -const { - remcalc -} = fns; +// const { +// remcalc +// } = fns; +// Main Contonent Wrapper Styles module.exports = styled.article` - margin-top: ${remcalc(78)}; `; diff --git a/frontend/src/components/header/index.js b/frontend/src/components/header/index.js index c2435c1c..050ebf28 100644 --- a/frontend/src/components/header/index.js +++ b/frontend/src/components/header/index.js @@ -1,12 +1,19 @@ const React = require('react'); +const ReactRedux = require('react-redux'); const ReactRouter = require('react-router'); const Styled = require('styled-components'); +const selectors = require('@state/selectors'); +const actions = require('@state/actions'); + const Column = require('@ui/components/column'); const Container = require('@ui/components/container'); +const Avatar = require('@ui/components/avatar'); const fns = require('@ui/shared/functions'); const logo = require('@resources/logo.png'); const Row = require('@ui/components/row'); +const Tooltip = require('@ui/components/tooltip'); +const composers = require('@ui/shared/composers'); const { Link @@ -20,34 +27,138 @@ const { remcalc } = fns; -const StyledHeader = styled.header` - height: ${remcalc(78)}; - background-color: #ffffff; - position: absolute; - width: 100%; - top: 0; - left: 0 -`; +const { + connect +} = ReactRedux; -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-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 ( - + + + + + + + {account.name} + + + + + { accountUI.profile_tooltip ? ( + + +
  • My Account
  • +
  • Settings
  • +
  • About
  • +
    +
    + ) : null } + +
    +
    ); }; -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); diff --git a/frontend/src/mock-state.json b/frontend/src/mock-state.json index 1c01eb60..04a0c729 100644 --- a/frontend/src/mock-state.json +++ b/frontend/src/mock-state.json @@ -4,7 +4,11 @@ "uuid": "b94033c1-3665-4c36-afab-d9c3d0b51c01", "id": "nicola", "name": "Nicola", - "email": "nicola@biztech.com" + "email": "nicola@biztech.com", + "avatar": "./resources/avatar.png" + }, + "ui": { + "profile_tooltip": false } }, "datacenters": { diff --git a/frontend/src/resources/avatar.png b/frontend/src/resources/avatar.png new file mode 100644 index 0000000000000000000000000000000000000000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=LM`KWXf&jpTsy9sE|CN`n_E9$?E_3Hf znO6R?u;ZaMxkD|=7>X5%=V{Lb8o)6ClV%{XR&lYuRo(0sNE$`RkF02LRVffP8b&G+ zB%_hEph9hwF`5uSm10i4dhOe%)~n!v1}(N^E&)Z@1x9n8X6e{dhWx~MCMy|5lL|B{ zBWNn2(lI$JuGrY@k8($(5LlEF)(F@iPr@WIToMo?kk+J#cY7H+!9iAi;|DKvQgE$E y0fKWNjuZ;8Q3TF9TNY)dQRhWKMTHKvnEwZB%TgVYtRJiZ0000 bool) }; diff --git a/frontend/src/state/reducers/account.js b/frontend/src/state/reducers/account.js index 7fec06fb..365e2e98 100644 --- a/frontend/src/state/reducers/account.js +++ b/frontend/src/state/reducers/account.js @@ -1,9 +1,23 @@ const ReduxActions = require('redux-actions'); +const actions = require('@state/actions'); + const { handleActions } = ReduxActions; +const { + handleToggleAction +} = actions; + 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 + } + }; + } }, {}); diff --git a/frontend/src/state/selectors.js b/frontend/src/state/selectors.js index 62419e73..f504a7ea 100644 --- a/frontend/src/state/selectors.js +++ b/frontend/src/state/selectors.js @@ -8,6 +8,7 @@ const { } = reselect; const account = (state) => get(state, 'account.data', {}); +const accountUi = (state) => get(state, 'account.ui', {}); const orgUiSections = (state) => get(state, 'orgs.ui.sections', []); const projectUiSections = (state) => get(state, 'projects.ui.sections', []); const orgs = (state) => get(state, 'orgs.data', []); @@ -37,6 +38,7 @@ const orgSections = (orgId) => createSelector( module.exports = { accountSelector: account, + accountUISelector: accountUi, orgByIdSelector: orgById, orgsSelector: orgs, orgSectionsSelector: orgSections,