Blaze Dashboard App
Blaze Dashboard is built as a standalone application to be used inside Jetpack, and in the future, into WooCommerce. The Jetpack counterpart of the project is in here.
Hiarachy
.
βββ src/
βββ components/ β blaze dashboard app only components. For now there is only a layout component.
βββ page-middleware/ β page.js integration with React and everything
βββ app.js β entry point
βββ routes.js β page.js routes
Routing
It utilizes the hashbang (#!) in page.js, however it doesn't work out of the box, because we are using hardcoded paths in Calypso, so some tricks are done in Jetpack to intercept the anchor clicks and convert them to hashbangs.
$("#wpcom").on('click', 'a', function (e) {
const link = e && e.currentTarget && e.currentTarget.attributes && e.currentTarget.attributes.href && e.currentTarget.attributes.href.value;
if( link && ! link.startsWith( 'http' ) ) {
location.hash = `#!${link}`;
return false;
}
});
Gridicon
The Gridicon in @automattic/components leverages <use> to load SVG sprites and has issues when loading from CDN (i.e. other than the main domain). So we had to replace with one that doesn't load the SVG sprite file - packages/components/src/gridicon/no-asset.tsx - and then in Jetpack, we load it separately:
$.get("https://widgets.wp.com/blaze-dashboard/common/gridicons-506499ddac13811fee8e.svg", function(data) {
var div = document.createElement("div");
div.innerHTML = new XMLSerializer().serializeToString(data.documentElement);
div.style = 'display: none';
document.body.insertBefore(div, document.body.childNodes[0]);
});
Building
Production
cd apps/blaze-dashboard
yarn build
Development with local Jetpack
- Ensure you have a working local Jetpack installation
- Run
BLAZE_DASHBOARD_PACKAGE_PATH=/path/to/jetpack/projects/packages/blaze yarn dev
Development with sandbox
- Ensure you have a working sandbox and the its hostname is
wpcom-sandbox - Run
yarn dev --syncto build and sync files as you change them.
Uploading to CDN
The path is widgets.wp.com/blaze-dashboard.