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 00000000..68b6ad91 Binary files /dev/null and b/frontend/src/resources/avatar.png differ diff --git a/frontend/src/state/actions.js b/frontend/src/state/actions.js index c421a45a..d02d2495 100644 --- a/frontend/src/state/actions.js +++ b/frontend/src/state/actions.js @@ -9,5 +9,6 @@ const APP = constantCase(process.env['APP_NAME']); module.exports = { ...require('@state/thunks'), - updateRouter: createAction(`${APP}/APP/UPDATE_ROUTER`) + updateRouter: createAction(`${APP}/APP/UPDATE_ROUTER`), + handleToggleAction: createAction(`${APP}/APP/HANDLE_TOGGLE`, bool => 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,