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

Store: Clean up header on smaller screens #22541

Merged
merged 16 commits into from
Mar 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions client/extensions/woocommerce/app/dashboard/style.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
.dashboard__manage-has-orders,
.dashboard__manage-no-orders,
.dashboard__placeholder,
.setup__wrapper {
@include breakpoint( ">660px" ) {
margin-top: 58px;
}
}

.dashboard__placeholder .card {
@include placeholder();
}
Expand Down
36 changes: 18 additions & 18 deletions client/extensions/woocommerce/app/order/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Gridicon from 'gridicons';
import { isEmpty } from 'lodash';
import { localize } from 'i18n-calypso';
import PropTypes from 'prop-types';
import React, { Component, Fragment } from 'react';
import React, { Component } from 'react';

/**
* Internal dependencies
Expand Down Expand Up @@ -153,22 +153,20 @@ class OrderActionHeader extends Component {

renderEditingButtons = () => {
const { hasOrderEdits, isSaving, translate } = this.props;
return (
<Fragment>
<Button key="cancel" onClick={ this.cancelEditing }>
{ translate( 'Cancel' ) }
</Button>
<Button
key="save"
primary
onClick={ this.saveOrder }
busy={ isSaving }
disabled={ ! hasOrderEdits || isSaving }
>
{ translate( 'Update' ) }
</Button>
</Fragment>
);
return [
<Button key="cancel" onClick={ this.cancelEditing }>
{ translate( 'Cancel' ) }
</Button>,
<Button
key="save"
primary
onClick={ this.saveOrder }
busy={ isSaving }
disabled={ ! hasOrderEdits || isSaving }
>
{ translate( 'Update' ) }
</Button>,
];
};

render() {
Expand All @@ -181,8 +179,10 @@ class OrderActionHeader extends Component {
</span>,
];

const primaryLabel = isEditing ? translate( 'Update' ) : translate( 'Edit Order' );

return (
<ActionHeader breadcrumbs={ breadcrumbs }>
<ActionHeader breadcrumbs={ breadcrumbs } primaryLabel={ primaryLabel }>
{ isEditing ? this.renderEditingButtons() : this.renderViewButtons() }
</ActionHeader>
);
Expand Down
4 changes: 0 additions & 4 deletions client/extensions/woocommerce/app/order/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
box-sizing: border-box;
}

@include breakpoint( '>660px' ) {
margin-top: 58px;
}

@include breakpoint( '>960px' ) {
display: flex;
flex-wrap: wrap;
Expand Down
4 changes: 0 additions & 4 deletions client/extensions/woocommerce/app/orders/style.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
.orders__container {
@include breakpoint( ">660px" ) {
margin-top: 58px;
}

thead {
.table-row {
&:hover {
Expand Down
19 changes: 8 additions & 11 deletions client/extensions/woocommerce/app/product-categories/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,21 @@ import ActionHeader from 'woocommerce/components/action-header';
import Button from 'components/button';
import { getLink } from 'woocommerce/lib/nav-utils';

function renderDeleteButton( onDelete, category, translate ) {
function renderDeleteButton( onDelete, label ) {
return (
onDelete && (
<Button borderless scary onClick={ onDelete ? onDelete : undefined }>
<Gridicon icon="trash" />
<span>{ translate( 'Delete' ) } </span>
<span>{ label } </span>
</Button>
)
);
}

function renderSaveButton( onSave, isBusy, category, translate ) {
function renderSaveButton( onSave, isBusy, label ) {
const saveExists = 'undefined' !== typeof onSave;
const saveDisabled = false === onSave;

const saveLabel =
category && ! isObject( category.id ) ? translate( 'Update' ) : translate( 'Save' );

return (
saveExists && (
<Button
Expand All @@ -43,17 +40,17 @@ function renderSaveButton( onSave, isBusy, category, translate ) {
disabled={ saveDisabled }
busy={ isBusy }
>
{ saveLabel }
{ label }
</Button>
)
);
}

const ProductCategoryHeader = ( { onDelete, onSave, translate, site, category, isBusy } ) => {
const existing = category && ! isObject( category.id );

const deleteButton = renderDeleteButton( onDelete, category, translate );
const saveButton = renderSaveButton( onSave, isBusy, category, translate );
const deleteButton = renderDeleteButton( onDelete, translate( 'Delete' ) );
const saveLabel = existing ? translate( 'Update' ) : translate( 'Save' );
const saveButton = renderSaveButton( onSave, isBusy, saveLabel );

const currentCrumb =
category && existing ? (
Expand All @@ -72,7 +69,7 @@ const ProductCategoryHeader = ( { onDelete, onSave, translate, site, category, i
];

return (
<ActionHeader breadcrumbs={ breadcrumbs }>
<ActionHeader breadcrumbs={ breadcrumbs } primaryLabel={ saveLabel }>
{ deleteButton }
{ saveButton }
</ActionHeader>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@
}

.product-categories__form {
@include breakpoint( ">660px" ) {
margin-top: 58px;
}

&.is-placeholder div {
@include placeholder();
background: $white;
Expand Down Expand Up @@ -198,4 +194,3 @@
}
}
}

2 changes: 0 additions & 2 deletions client/extensions/woocommerce/app/products/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import NavTabs from 'components/section-nav/tabs';
import NavItem from 'components/section-nav/item';
import ProductsList from './products-list';
import ProductsListSearchResults from './products-list-search-results';
import SidebarNavigation from 'my-sites/sidebar-navigation';
import SectionNav from 'components/section-nav';
import Search from 'components/search';

Expand Down Expand Up @@ -124,7 +123,6 @@ class Products extends Component {

return (
<Main className={ classes } wideLayout>
<SidebarNavigation />
<ActionHeader breadcrumbs={ <span>{ translate( 'Products' ) }</span> }>
<Button primary href={ getLink( '/store/product/:site/', site ) }>
{ translate( 'Add a product' ) }
Expand Down
4 changes: 0 additions & 4 deletions client/extensions/woocommerce/app/products/product-form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
*/

.products__form {
@include breakpoint( ">660px" ) {
margin-top: 58px;
}

&.is-placeholder div {
@include placeholder();
background: $white;
Expand Down
25 changes: 11 additions & 14 deletions client/extensions/woocommerce/app/products/product-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import ActionHeader from 'woocommerce/components/action-header';
import Button from 'components/button';
import { getLink } from 'woocommerce/lib/nav-utils';

function renderViewButton( product, translate ) {
function renderViewButton( product, label ) {
const url = product && product.permalink;
return (
// TODO: Do more to validate this URL?
Expand All @@ -29,29 +29,26 @@ function renderViewButton( product, translate ) {
rel="noopener noreferrer"
>
<Gridicon icon="visible" />
<span>{ translate( 'View' ) }</span>
<span>{ label }</span>
</Button>
);
}

function renderTrashButton( onTrash, product, isBusy, translate ) {
function renderTrashButton( onTrash, isBusy, label ) {
return (
onTrash && (
<Button borderless scary onClick={ onTrash ? onTrash : undefined }>
<Gridicon icon="trash" />
<span>{ translate( 'Delete' ) } </span>
<span>{ label } </span>
</Button>
)
);
}

function renderSaveButton( onSave, product, isBusy, translate ) {
function renderSaveButton( onSave, isBusy, label ) {
const saveExists = 'undefined' !== typeof onSave;
const saveDisabled = false === onSave;

const saveLabel =
product && ! isObject( product.id ) ? translate( 'Update' ) : translate( 'Save & Publish' );

return (
saveExists && (
<Button
Expand All @@ -60,18 +57,18 @@ function renderSaveButton( onSave, product, isBusy, translate ) {
disabled={ saveDisabled }
busy={ isBusy }
>
{ saveLabel }
{ label }
</Button>
)
);
}

const ProductHeader = ( { viewEnabled, onTrash, onSave, isBusy, translate, site, product } ) => {
const existing = product && ! isObject( product.id );

const viewButton = viewEnabled && renderViewButton( product, translate );
const trashButton = renderTrashButton( onTrash, product, isBusy, translate );
const saveButton = renderSaveButton( onSave, product, isBusy, translate );
const viewButton = viewEnabled && renderViewButton( product, translate( 'View' ) );
const trashButton = renderTrashButton( onTrash, isBusy, translate( 'Delete' ) );
const saveLabel = existing ? translate( 'Update' ) : translate( 'Save & Publish' );
const saveButton = renderSaveButton( onSave, isBusy, saveLabel );

const currentCrumb =
product && existing ? (
Expand All @@ -86,7 +83,7 @@ const ProductHeader = ( { viewEnabled, onTrash, onSave, isBusy, translate, site,
];

return (
<ActionHeader breadcrumbs={ breadcrumbs }>
<ActionHeader breadcrumbs={ breadcrumbs } primaryLabel={ saveLabel }>
{ trashButton }
{ viewButton }
{ saveButton }
Expand Down
2 changes: 0 additions & 2 deletions client/extensions/woocommerce/app/products/product-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { localize } from 'i18n-calypso';
import Main from 'components/main';
import accept from 'lib/accept';
import { ProtectFormGuard } from 'lib/protect-form';
import SidebarNavigation from 'my-sites/sidebar-navigation';
import { getLink } from 'woocommerce/lib/nav-utils';
import { successNotice, errorNotice } from 'state/notices/actions';
import { getActionList } from 'woocommerce/state/action-list/selectors';
Expand Down Expand Up @@ -207,7 +206,6 @@ class ProductUpdate extends React.Component {

return (
<Main className={ className } wideLayout>
<SidebarNavigation />
<ProductHeader
site={ site }
product={ product }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
margin-top: 16px;
}

.search-card {
@include breakpoint( ">660px" ) {
margin-top: 58px;
}
}

.products__list-placeholder {
@include placeholder();
background: $white;
Expand All @@ -45,7 +39,7 @@
.is-requesting td div {
@include placeholder();
background: transparent;

.image-thumb::after {
display: none;
}
Expand Down
2 changes: 0 additions & 2 deletions client/extensions/woocommerce/app/promotions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { getLink } from 'woocommerce/lib/nav-utils';
import { setPromotionSearch } from 'woocommerce/state/ui/promotions/actions';
import { getSelectedSiteWithFallback } from 'woocommerce/state/sites/selectors';
import Main from 'components/main';
import SidebarNavigation from 'my-sites/sidebar-navigation';
import PromotionsList from './promotions-list';
import SearchCard from 'components/search-card';

Expand Down Expand Up @@ -106,7 +105,6 @@ class Promotions extends Component {

return (
<Main className={ classes } wideLayout>
<SidebarNavigation />
<ActionHeader breadcrumbs={ <span>{ translate( 'Promotions' ) }</span> }>
<Button primary href={ getLink( '/store/promotion/:site/', site ) }>
{ translate( 'Add promotion' ) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@

.promotions__form {
@include breakpoint( ">660px" ) {
margin-top: 58px;
}

&.is-placeholder div {
@include placeholder();
background: $white;
Expand Down
26 changes: 10 additions & 16 deletions client/extensions/woocommerce/app/promotions/promotion-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,50 +14,45 @@ import ActionHeader from 'woocommerce/components/action-header';
import Button from 'components/button';
import { getLink } from 'woocommerce/lib/nav-utils';

function renderTrashButton( onTrash, promotion, isBusy, translate ) {
function renderTrashButton( onTrash, isBusy, label ) {
return onTrash && (
<Button borderless scary onClick={ onTrash }>
<Gridicon icon="trash" />
<span>{ translate( 'Delete' ) }</span>
<span>{ label }</span>
</Button>
);
}

function renderSaveButton( onSave, promotion, isBusy, translate ) {
function renderSaveButton( onSave, isBusy, label ) {
if ( 'undefined' === typeof onSave ) {
// 'Save' not allowed here.
return null;
}

const saveDisabled = false === onSave;

const saveLabel = ( promotion && ! isObject( promotion.id )
? translate( 'Update' )
: translate( 'Save & Publish' )
);

return (
<Button primary onClick={ onSave || noop } disabled={ saveDisabled } busy={ isBusy }>
{ saveLabel }
{ label }
</Button>
);
}

const PromotionHeader = ( { promotion, onSave, onTrash, isBusy, translate, site } ) => {
const trashButton = renderTrashButton( onTrash, promotion, isBusy, translate );
const saveButton = renderSaveButton( onSave, promotion, isBusy, translate );
const existing = ( promotion && ! isObject( promotion.id ) );
const trashButton = renderTrashButton( onTrash, isBusy, translate( 'Delete' ) );
const saveLabel = existing ? translate( 'Update' ) : translate( 'Save & Publish' );
const saveButton = renderSaveButton( onSave, isBusy, saveLabel );

const currentCrumb = promotion && ! isObject( promotion.id )
? ( <span>{ translate( 'Edit Promotion' ) }</span> )
: ( <span>{ translate( 'Add Promotion' ) }</span> );
const currentCrumb = existing ? ( <span>{ translate( 'Edit Promotion' ) }</span> ) : ( <span>{ translate( 'Add Promotion' ) }</span> );

const breadcrumbs = [
( <a href={ getLink( '/store/promotions/:site/', site ) }>{ translate( 'Promotions' ) }</a> ),
currentCrumb,
];

return (
<ActionHeader breadcrumbs={ breadcrumbs }>
<ActionHeader breadcrumbs={ breadcrumbs } primaryLabel={ saveLabel }>
{ trashButton }
{ saveButton }
</ActionHeader>
Expand All @@ -82,4 +77,3 @@ PromotionHeader.propTypes = {
};

export default localize( PromotionHeader );

Loading