Skip to content

Commit

Permalink
Merge pull request #724 from Automattic/add/sidebar-section-toggle
Browse files Browse the repository at this point in the history
Reader sidebar: toggle visibility of lists and tags
  • Loading branch information
bluefuton committed Feb 2, 2016
2 parents 5d9d0fd + 53f1d3b commit d8d55b7
Show file tree
Hide file tree
Showing 24 changed files with 1,080 additions and 386 deletions.
4 changes: 2 additions & 2 deletions client/layout/sidebar/heading.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*/
import React from 'react';

const SidebarHeading = ( { children } ) => (
<h2 className="sidebar__heading">{ children }</h2>
const SidebarHeading = ( { children, onClick } ) => (
<h2 className="sidebar__heading" onClick={ onClick }>{ children }</h2>
);

export default SidebarHeading;
5 changes: 3 additions & 2 deletions client/layout/sidebar/menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
* External dependencies
*/
import React from 'react';
import classNames from 'classnames';

const SidebarMenu = ( { children } ) => (
<li className="sidebar__menu">{ children }</li>
const SidebarMenu = ( { children, className } ) => (
<li className={ classNames( 'sidebar__menu', className ) }>{ children }</li>
);

export default SidebarMenu;
11 changes: 7 additions & 4 deletions client/reader/controller.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
/**
* External Dependencies
*/
var ReactDom = require( 'react-dom' ),
const ReactDom = require( 'react-dom' ),
React = require( 'react' ),
page = require( 'page' ),
debug = require( 'debug' )( 'calypso:reader:controller' ),
trim = require( 'lodash/string/trim' ),
startsWith = require( 'lodash/string/startsWith' ),
moment = require( 'moment' );
moment = require( 'moment' ),
ReduxProvider = require( 'react-redux' ).Provider;

/**
* Internal Dependencies
*/
var i18n = require( 'lib/mixins/i18n' ),
const i18n = require( 'lib/mixins/i18n' ),
route = require( 'lib/route' ),
pageNotifier = require( 'lib/route/page-notifier' ),
analytics = require( 'analytics' ),
Expand Down Expand Up @@ -130,7 +131,9 @@ module.exports = {
context.store.dispatch( setSection( 'reader' ) );

ReactDom.render(
React.createElement( ReaderSidebarComponent, { path: context.path } ),
React.createElement( ReduxProvider, { store: context.store },
React.createElement( ReaderSidebarComponent, { path: context.path } )
),
document.getElementById( 'secondary' )
);

Expand Down
202 changes: 170 additions & 32 deletions client/reader/sidebar/_style.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
// Reader Sidebar
.is-section-reader .sidebar {

overflow-x: hidden;

.sidebar__menu {
margin-bottom: 8px;

.selected {
.menu-link-icon,
.sidebar-dynamic-menu__action-icon {
.sidebar__menu-action .gridicon,
.sidebar-dynamic-menu-action-icon {
fill: $white;
}

Expand All @@ -20,7 +25,7 @@
fill: darken( $gray, 20% );
}

.menu-link-text {
.sidebar__menu-item-label, .menu-link-text {
color: $gray-dark;
}

Expand All @@ -31,55 +36,194 @@
}
}

.sidebar-streams {
}
.is-togglable {

.sidebar-dynamic-menu__list,
.sidebar-dynamic-menu__tag,
.sidebar-dynamic-menu__explore {
a:first-child {
padding: 8px 16px 8px 24px;
@include breakpoint( "<660px" ) {
margin-top: 0;
}

a.add-new {
margin-top: 5px;
.sidebar__heading {
margin: 0;
padding: 10px 16px 10px 55px;
cursor: pointer;
position: relative;
transition: background-color 0.15s ease-in-out,
box-shadow 0.15s ease-in-out;

.gridicon {
top: 10px;
left: 20px;
height: 16px; // Smaller than recommended for gridicon, but works here
transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.count {
margin-left: 8px;
}

&:hover {
color: $blue-medium;
background-color: $gray-light;

.gridicon {
fill: $blue-medium;
}
}
}

@include breakpoint( "<660px" ) {
a:first-child {
padding: 18px 16px 18px 24px;
.sidebar__menu-list,
.sidebar__menu-empty {
height: 0;
overflow: hidden;
}

.sidebar__menu-item {
transition: transform 0.15s cubic-bezier(0.230, 1.000, 0.320, 1.000),
opacity 0.15s ease-in-out;
transition-delay: 0.05s;
opacity: 0;
transform: translateY( -100px );
}

&.is-toggle-open {
.sidebar__heading {
background-color: $gray-light;
box-shadow: 0 1px 0 lighten( $gray, 20 ),
0 -1px 0 lighten( $gray, 20 );

.gridicon {
transform: rotate( 180deg );
}
}

.sidebar__menu-add-button {
opacity: 1;
pointer-events: auto;
transform: translateX( 0 );
}

.sidebar__menu-list,
.sidebar__menu-empty {
height: auto;
padding-top: 8px;
padding-bottom: 8px;
}

a.add-new {
.sidebar__menu-item {
opacity: 1;
transform: translateY( 0 );
}
}

.is-add-open {
.sidebar__menu-add {
opacity: 1;
pointer-events: auto;
transform: translateX( 0 );
}
}
}

.sidebar__menu-empty,
.sidebar__menu-empty:hover {
padding-right: 32px;
padding-left: 55px;
font-size: 13px;
color: $gray-dark;
background-color: transparent !important; // needs to be more specific
}

.sidebar__menu-item {
a.add-new {
margin-top: 5px;

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

.sidebar-dynamic-menu__add {
padding: 8px;
.sidebar__menu-item-label {
padding: 8px 16px 8px 55px;

@include breakpoint( "<660px" ) {
padding: 18px 16px 18px 24px;
}
}

.sidebar__menu-add-button {
position: absolute;
top: 7px;
right: 8px;
border-width: 1px;
border-color: lighten( $gray, 20% );
padding: 6px 7px;
border-radius: 3px;
text-transform: none;

// Disabled by default
opacity: 0;
transform: translateX( -20px );
pointer-events: none;
transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
transition-delay: 0.05s;
}

.sidebar__menu-add {
opacity: 0;
//transform: translateX( 100px );
transition: all 0.15s ease-in;
pointer-events: none;
padding: 0;
position: absolute;
top: -1px;
left: -1px;
right: -1px;

input {
font-size: 13px;
padding: 10px 24px 9px;
}

.gridicon {
top: 14px;
cursor: pointer;
position: absolute;
top: 0;
right: 0;
left: auto;
padding: 8px 13px;
}
}

.sidebar-dynamic-menu__add-input {
font-size: 13px;
padding-left: 16px;
.selected {
.sidebar__menu-action {
.gridicon {
fill: #fff !important;
}
}
}

.sidebar-dynamic-menu__action {
.sidebar__menu-action {
position: absolute;
top: 3px;
right: 8px;
line-height: 15px;
line-height: 15px;
padding: 3px 4px 2px 4px;

.gridicon {
position: relative;
top: 0;
left: auto;
fill: $gray !important; // this needs to be more specific
}


&:hover {
cursor: pointer;

.gridicon {
fill: $alert-red !important; // this needs to be more specific
}
}

@include breakpoint( "<660px" ) {
Expand All @@ -91,14 +235,8 @@
}
}

.sidebar-dynamic-menu__action-label {
.sidebar__menu-action-label,
.sidebar-dynamic-menu-action_label {
display: none;
}

// Sidebar Activity Items
// My Comments
.sidebar-activity__comments {}

// My Likes
.sidebar-activity__likes {}
}
}
80 changes: 80 additions & 0 deletions client/reader/sidebar/expandable-add-form.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* External Dependencies
*/
import React from 'react';
import classNames from 'classnames';
import noop from 'lodash/utility/noop';

/**
* Internal Dependencies
*/
import Gridicon from 'components/gridicon';
import Button from 'components/button';

const ExpandableSidebarAddForm = React.createClass( {

propTypes: {
addPlaceholder: React.PropTypes.string,
onAddSubmit: React.PropTypes.func,
onAddClick: React.PropTypes.func
},

getInitialState() {
return {
isAdding: false
};
},

getDefaultProps() {
return {
onAddSubmit: noop,
onAddClick: noop
}
},

toggleAdd() {
if ( ! this.state.isAdding ) {
this.refs.menuAddInput.focus();
this.props.onAddClick();
}
this.setState( { isAdding: ! this.state.isAdding } );
},

handleAddKeyDown( event ) {
const inputValue = this.refs.menuAddInput.value;
if ( event.keyCode === 13 && inputValue.length > 0 ) {
event.preventDefault();
this.props.onAddSubmit( inputValue );
this.refs.menuAddInput.value = '';
this.toggleAdd();
}
},

render() {
const classes = classNames(
'sidebar__menu-add-item',
{
'is-add-open': this.state.isAdding
}
);

return(
<div className={ classes }>
<Button compact className="sidebar__menu-add-button" onClick={ this.toggleAdd }>{ this.translate( 'Add' ) }</Button>

<div className="sidebar__menu-add">
<input
className="sidebar__menu-add-input"
type="text"
placeholder={ this.props.addPlaceholder }
ref="menuAddInput"
onKeyDown={ this.handleAddKeyDown }
/>
<Gridicon icon="cross-small" onClick={ this.toggleAdd } />
</div>
</div>
);
}
} );

export default ExpandableSidebarAddForm;
Loading

0 comments on commit d8d55b7

Please sign in to comment.