From 66dd2cee92e3ef6c3c5d93723ac4470c2dc5e27d Mon Sep 17 00:00:00 2001 From: meriadec Date: Thu, 8 Oct 2015 12:59:20 +0200 Subject: [PATCH] refactor(header): hover style for logout --- components/ProfileBox.js | 82 ++++++++++++++++------------------------ styles/Header.scss | 72 ++++++----------------------------- 2 files changed, 44 insertions(+), 110 deletions(-) diff --git a/components/ProfileBox.js b/components/ProfileBox.js index e8d8bd4..ac3e720 100644 --- a/components/ProfileBox.js +++ b/components/ProfileBox.js @@ -6,27 +6,19 @@ import { NavLink } from 'fluxible-router'; import { logout } from '../actions/auth'; -class ProfileDrop extends React.Component { - - componentDidMount () { - const first = React.findDOMNode(this).querySelector('.item'); - first.focus(); - } +class LogoutButton extends React.Component { componentWillEnter (done) { - const els = React.findDOMNode(this).querySelectorAll('.item'); + const el = React.findDOMNode(this); new TimelineMax() - .staggerFrom(els, 0.15, { - opacity: 0, - y: -10 - }, 0.1) + .from(el, 0.25, { opacity: 0, x: 20, ease: 'Back.easeOut' }) .addCallback(done); } componentWillLeave (done) { - const els = React.findDOMNode(this).querySelectorAll('.item'); + const el = React.findDOMNode(this); new TimelineMax() - .staggerTo(els, 0.15, { opacity: 0, y: -10 }, -0.1) + .to(el, 0.2, { opacity: 0, x: 20, ease: 'Back.easeIn' }) .addCallback(done); } @@ -36,20 +28,12 @@ class ProfileDrop extends React.Component { render () { return ( -
- - - {'Profile'} - - -
+ ); } @@ -65,9 +49,15 @@ export default class ProfileBox extends React.Component { }; } - toggle () { + toggleOn () { + this.setState({ + open: true + }); + } + + toggleOff () { this.setState({ - open: !this.state.open + open: false }); } @@ -76,32 +66,26 @@ export default class ProfileBox extends React.Component { const { user } = this.props; const { open } = this.state; - const toggleClassName = [ - 'Profile-toggle', - open ? 'open' : '' - ].join(' '); - return ( -
- +
{open && ( - )} + +
+
); } diff --git a/styles/Header.scss b/styles/Header.scss index 794f405..9d4d2d4 100644 --- a/styles/Header.scss +++ b/styles/Header.scss @@ -27,72 +27,22 @@ .ProfileBox { position: relative; - .Profile-toggle { - display: flex; - align-items: center; - padding: 1px 0.5rem; - cursor: pointer; - border: none; - background: $cdark; - outline: none; - border: 2px solid transparent; - border-radius: 3px; - color: rgba($clight, 0.5); - position: relative; - z-index: 2; - - &:active, &.open { background: $cdarken1 !important; } - &:focus { border-color: rgba($cdarken, 0.3); } + display: flex; + align-items: center; - &:hover { - background: $cdarken2; + .logout { + padding: 0.5rem; + margin-right: 1rem; + i { + margin-right: 0.5rem; } } .ProfilePic { - width: 40px; - height: 40px; + padding: 3px; + border: 2px solid $cdarken2; + width: 45px; + height: 45px; background-size: 100%; } - - .ProfileName { - margin-right: 0.5rem; - } - - .ProfileBox-drop { - display: flex; - flex-direction: column; - width: 100%; - position: absolute; - z-index: 1; - right: 0; - top: 100%; - margin-top: 0.25rem; - min-width: 250px; - - .item { - font-weight: normal; - color: rgba($clight, 0.5); - background: rgba($cdarken2, 0.3); - border: 2px solid transparent; - cursor: pointer; - display: flex; - display: flex; - justify-content: center; - padding: 1rem; - outline: none; - - &:hover { - background: rgba($cdarken2, 0.7); - } - &:active, &:focus { - background: $cdarken2; - border-color: $cdarken1; - } - - i { - margin-right: 0.5rem; - } - } - } }