Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framework: Allow for a sans-sidebar layout and adjust accordingly #302

Merged
merged 9 commits into from
Nov 27, 2015
29 changes: 18 additions & 11 deletions assets/stylesheets/layout/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -237,35 +237,42 @@ html.iframed {

/* =General Layout
----------------------------------------------- */
$sidebar-width-max: 272px;
$sidebar-width-min: 228px;

.wp-content {
@include clear-fix;
position: relative;
width: 100%;
margin: 47px auto 0;
margin: 47px 0 0 0;
padding: 32px 32px 32px ( $sidebar-width-max + 32px );
box-sizing: border-box;
overflow: hidden;
}

.wp-primary {
padding: 32px;
margin-left: 272px;
.has-no-sidebar & {
padding-left: 32px;
}
}

// Tablets
@include breakpoint( "<960px" ) {
.wp-primary {
margin-left: 224px;
.wp-content {
padding: 24px;
padding-left: ( $sidebar-width-min + 24px );

.has-no-sidebar & {
padding-left: 24px;
}
}
}

// Mobile (Full Width)
@include breakpoint( "<660px" ) {
.wp-primary {
.wp-content {
margin-left: 0;
padding: 8px;

.focus-sidebar & {
transform: translateX( 100vw );
.has-no-sidebar & {
padding-left: 8px;
}

.focus-sidebar.is-section-post & {
Expand Down
6 changes: 3 additions & 3 deletions assets/stylesheets/layout/_sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
position: fixed;
top: 47px;
bottom: 0;
left: 0;

@include breakpoint( "<960px" ) {
border-right: 1px solid lighten( $gray, 25% );
width: 224px;
width: $sidebar-width-min;
}

@include breakpoint( ">960px" ) {
border-right: 1px solid lighten( $gray, 25% );
left: 0;
width: 272px;
width: $sidebar-width-max;
}

@include breakpoint( "<660px" ) {
Expand Down
2 changes: 1 addition & 1 deletion client/auth/login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ module.exports = React.createClass( {
const { requires2fa, inProgress, errorMessage, errorLevel } = this.state;

return (
<Main className="auth is-full">
<Main className="auth">
<WordPressLogo />
<form className="auth__form" onSubmit={ this.submitForm }>
<FormFieldset>
Expand Down
22 changes: 2 additions & 20 deletions client/components/main/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,9 @@
max-width: 720px;
z-index: 20;

// Some screens (like /sites) don't have a sidebar.
// @todo: This kinda sucks. I think the full-width class
// should be moved to .wp-primary, and we can just remove
// the margin, instead of overriding it here. -shaun
&.is-full {
margin-left: -272px;
max-width: calc( 100% + 272px );

// Tablets
@include breakpoint( "<960px" ) {
margin-left: -224px;
}

@include breakpoint( "<660px" ) {
margin-left: 0;
max-width: 100%;
}
}

// Themes is a great example of using all this new space ;)
&.themes {
&.themes,
&.sites {
max-width: 100%;
}

Expand Down
5 changes: 4 additions & 1 deletion client/devdocs/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ var devdocs = {
false );
}

context.layout.setState( { section: 'devdocs' } );
context.layout.setState( {
section: 'devdocs',
noSidebar: true
} );

React.render(
React.createElement( DocsComponent, {
Expand Down
7 changes: 6 additions & 1 deletion client/layout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ module.exports = React.createClass( {
getInitialState: function() {
return {
section: false,
isLoading: false
isLoading: false,
noSidebar: false
};
},

Expand Down Expand Up @@ -93,6 +94,10 @@ module.exports = React.createClass( {
'is-active': this.state.isLoading
} );

if ( this.state.noSidebar ) {
sectionClass += ' has-no-sidebar';
}

return (
<div className={ sectionClass }>
{ config.isEnabled( 'keyboard-shortcuts' ) ? <KeyboardShortcutsMenu /> : null }
Expand Down
6 changes: 6 additions & 0 deletions client/mailing-lists/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import MainComponent from './main';

export default {
unsubscribe( context ) {
// We don't need the sidebar here.
context.layout.setState( {
section: 'me',
noSidebar: true }
);

React.render(
React.createElement( MainComponent, {
email: context.query.email,
Expand Down
1 change: 1 addition & 0 deletions client/me/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ export default {

if ( isWelcome ) {
React.unmountComponentAtNode( document.getElementById( 'secondary' ) );
context.layout.setState( { noSidebar: true } );
}

analytics.tracks.recordEvent( 'calypso_me_next_view', { is_welcome: isWelcome } );
Expand Down
20 changes: 3 additions & 17 deletions client/me/next-steps/next-steps.scss
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
.next-steps.is-single-page {
box-sizing: border-box;
margin: 0 0 0 -227px;
max-width: inherit;

.next-steps__intro,
.next-steps__steps,
.next-steps__outro {
max-width: 640px;
margin-left: auto;
margin-right: auto;
}

@include breakpoint( "<660px" ) {
margin-left: 0;
}
.has-no-sidebar .next-steps {
max-width: 640px;
}

.next-steps__title {
Expand All @@ -28,4 +14,4 @@

.next-steps__outro {
clear: both;
}
}
5 changes: 4 additions & 1 deletion client/my-sites/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ module.exports = {
* Sites is rendered on #primary but it doesn't expect a sidebar to exist
* so section needs to be set explicitly and #secondary cleaned up
*/
context.layout.setState( { section: 'sites' } );
context.layout.setState( {
section: 'sites',
noSidebar: true
} );
React.unmountComponentAtNode( document.getElementById( 'secondary' ) );
layoutFocus.set( 'content' );

Expand Down
2 changes: 1 addition & 1 deletion client/my-sites/sites/sites.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ module.exports = React.createClass( {
}

return (
<div className="main main-column sites is-full" role="main">
<div className="main main-column sites" role="main">
<h2 className="sites__select-heading">{ siteSelectionHeaderText }</h2>
{ this.getSiteCount() > 1 ?
<SearchCard onSearch={ this.doSearch } analyticsGroup="Sites" />
Expand Down
2 changes: 1 addition & 1 deletion client/my-sites/upgrades/checkout/thank-you.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ var CheckoutThankYou = React.createClass( {
}

return (
<Main className="checkout-thank-you is-full">
<Main className="checkout-thank-you">
<Card>
<div className="thank-you-message">
<span className="receipt-icon"></span>
Expand Down
1 change: 1 addition & 0 deletions client/my-sites/upgrades/controller.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ module.exports = {
basePath = route.sectionify( context.path );

analytics.pageView.record( basePath, 'Checkout Thank You' );
context.layout.setState( { noSidebar: true } );

if ( ! lastTransaction ) {
page.redirect( '/plans' );
Expand Down
38 changes: 15 additions & 23 deletions client/notices/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
.notice__text {
flex-grow: 1;
flex-basis: 100px;
max-width: 680px; // For line-length sanity

padding: 11px 24px;

& > span,
& > div {
max-width: 680px;
}

@include breakpoint( ">660px" ) {
padding: 13px 48px;
}
Expand Down Expand Up @@ -78,14 +81,7 @@
// Email Verification Notice
&.is-email-verification {
background: $white;
margin-left: 273px;
margin-bottom: 0;
box-shadow: 0 0 0 1px lighten( $gray, 20 );

// The signup screens don't have the sidebar
.is-section-signup & {
margin-left: 0;
}
}
}

Expand Down Expand Up @@ -232,29 +228,25 @@
}

.notices-list {
@include breakpoint( ">660px" ) {
margin-left: 273px;
}

.notice {
margin-bottom: 0;
}
overflow: hidden;

&.is-pinned {
width: 100%;
min-width: 320px;
max-width: 960px;
width: calc( 100% - 272px - 32px - 32px );
z-index: 180;
position: fixed;
top: 47px;
top: 47px + 32px;

.notice {
z-index: 180;
}

@include breakpoint( "<480px" ) {
top: 0;
left: 0;
@include breakpoint( "<960px" ) {
width: calc( 100% - 228px - 24px - 24px );
}

@include breakpoint( "<660px" ) {
top: 16px;
width: calc( 100% - 16px );
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion client/post-editor/style.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
.is-section-post .wp-primary {
.is-section-post .wp-content {
// We don't need the space for a sidebar
margin-left: 0;
padding-bottom: 0;
padding-left: 0;
padding-right: 0;

// Lets go full width on smaller screens
@include breakpoint( "<660px" ) {
Expand Down
5 changes: 4 additions & 1 deletion client/signup/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ export default {

titleActions.setTitle( i18n.translate( 'Create an account' ) );

context.layout.setState( { section: 'signup' } );
context.layout.setState( {
section: 'signup',
noSidebar: true
} );

React.render(
React.createElement( SignupComponent, {
Expand Down
5 changes: 0 additions & 5 deletions client/signup/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
margin: 0 auto;
}

// We don't need the space for a sidebar
.is-section-signup .wp-primary {
margin-left: 0;
}

.signup__step {
margin: 0 24px;
position: absolute;
Expand Down