Skip to content

Commit

Permalink
Header Cake (component): removed unnecessary corner div
Browse files Browse the repository at this point in the history
Removes continaer corner div, using just back link instead. Also removed back text if window is below 300px.
  • Loading branch information
adambbecker committed Jan 4, 2016
1 parent 92e15e2 commit bca16eb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
23 changes: 14 additions & 9 deletions client/components/header-cake/back.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import React, { PropTypes } from 'react';
import classNames from 'classnames';

/**
* Internal dependencies
Expand All @@ -26,25 +27,29 @@ export default React.createClass( {
propTypes: {
onClick: PropTypes.func,
href: PropTypes.string,
text: PropTypes.string
text: PropTypes.string,
spacer: PropTypes.bool
},

getDefaultProps() {
return {
text: 'Back'
}
spacer: false
};
},

render() {
const { text, href, onClick } = this.props;
const hideText = window.innerWidth <= HIDE_BACK_CRITERIA.windowWidth && text.length >= HIDE_BACK_CRITERIA.characterLength;
const { text = this.translate( 'Back' ), href, onClick, spacer } = this.props;
const windowWidth = window.innerWidth;
const hideText = windowWidth <= HIDE_BACK_CRITERIA.windowWidth && text.length >= HIDE_BACK_CRITERIA.characterLength || windowWidth <= 300;
const linkClasses = classNames( {
'header-cake__back': true,
'is-spacer': spacer
} );

return (
<a className="header-cake__back" href={ href } onClick={ onClick }>
<a className={ linkClasses } href={ href } onClick={ onClick }>
<Gridicon icon="chevron-left" size={ 18 } />
{ hideText ?
null
: <span className="header-cake__back-text">{ text }</span> }
{ ! hideText && <span className="header-cake__back-text">{ text }</span> }
</a>
);
},
Expand Down
10 changes: 3 additions & 7 deletions client/components/header-cake/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default React.createClass( {
},

render() {
const backText = this.props.backText || this.translate( 'Back' );
const { backText } = this.props;
const classes = classNames(
'header-cake',
this.props.className,
Expand All @@ -38,15 +38,11 @@ export default React.createClass( {

return (
<Card className={ classes }>
<div className="header-cake__corner">
<HeaderCakeBack text={ backText } onClick={ this.props.onClick } />
</div>
<HeaderCakeBack text={ backText } onClick={ this.props.onClick } />
<div className="header-cake__title" onClick={ this.props.onTitleClick }>
{ this.props.children }
</div>
<div className="header-cake__corner is-spacer">
<HeaderCakeBack text={ backText } />
</div>
<HeaderCakeBack text={ backText } spacer />
</Card>
);
}
Expand Down
17 changes: 7 additions & 10 deletions client/components/header-cake/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,19 @@
line-height: 18px;
padding: 0;

&::after {
display: none;
}

@include breakpoint( "<660px" ) {
margin-top: 10px;
}
}

.header-cake__corner {
.header-cake__back {
flex: none;
display: block;
max-width: 33.333%;

&.is-spacer {
opacity: 0;
}
}

.header-cake__back {
display: block;
padding: 16px;
color: darken( $gray, 20% );
white-space: nowrap;
Expand All @@ -42,7 +38,8 @@
opacity: 0.6;
}

.header-cake__corner.is-spacer & {
&.is-spacer {
opacity: 0;
cursor: default;
}
}
Expand Down

0 comments on commit bca16eb

Please sign in to comment.