2018-05-18 17:31:08 +00:00
|
|
|
/** @format */
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2018-06-26 14:49:42 +00:00
|
|
|
import { Component, Fragment } from '@wordpress/element';
|
2018-06-26 14:59:35 +00:00
|
|
|
import { Router, Route, Switch } from 'react-router-dom';
|
2018-05-18 17:31:08 +00:00
|
|
|
import { Slot } from 'react-slot-fill';
|
2018-06-26 14:49:42 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2018-05-18 17:31:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import './style.scss';
|
2018-06-28 13:52:45 +00:00
|
|
|
import Header from 'layout/header';
|
2018-05-18 17:31:08 +00:00
|
|
|
import { Controller, getPages } from './controller';
|
2018-06-26 14:59:35 +00:00
|
|
|
import history from 'lib/history';
|
2018-05-18 17:31:08 +00:00
|
|
|
import Notices from './notices';
|
|
|
|
|
|
|
|
class Layout extends Component {
|
|
|
|
render() {
|
2018-06-26 14:49:42 +00:00
|
|
|
const { isEmbeded, ...restProps } = this.props;
|
2018-05-18 17:31:08 +00:00
|
|
|
return (
|
2018-06-28 13:52:45 +00:00
|
|
|
<div className="woocommerce-layout">
|
|
|
|
<Slot name="header" />
|
|
|
|
|
2018-06-04 14:25:41 +00:00
|
|
|
<div className="woocommerce-layout__primary" id="woocommerce-layout__primary">
|
2018-05-18 17:31:08 +00:00
|
|
|
<Notices />
|
2018-06-26 14:49:42 +00:00
|
|
|
{ ! isEmbeded && (
|
|
|
|
<div className="woocommerce-layout__main">
|
|
|
|
<Controller { ...restProps } />
|
|
|
|
</div>
|
|
|
|
) }
|
2018-05-18 17:31:08 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-26 14:49:42 +00:00
|
|
|
Layout.propTypes = {
|
|
|
|
isEmbededLayout: PropTypes.bool,
|
|
|
|
};
|
|
|
|
|
|
|
|
export class PageLayout extends Component {
|
2018-05-18 17:31:08 +00:00
|
|
|
render() {
|
|
|
|
return (
|
2018-06-26 14:59:35 +00:00
|
|
|
<Router history={ history }>
|
2018-05-18 17:31:08 +00:00
|
|
|
<Switch>
|
|
|
|
{ getPages().map( page => {
|
|
|
|
return <Route key={ page.path } path={ page.path } exact component={ Layout } />;
|
|
|
|
} ) }
|
|
|
|
<Route component={ Layout } />
|
|
|
|
</Switch>
|
|
|
|
</Router>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2018-06-26 14:49:42 +00:00
|
|
|
|
|
|
|
export class EmbedLayout extends Component {
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
<Header sections={ wcSettings.embedBreadcrumbs } isEmbedded />
|
|
|
|
<Layout isEmbeded />
|
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|