File size: 2,345 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# 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](https://github.com/Automattic/jetpack/tree/trunk/projects/packages/blaze).
## 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](https://github.com/visionmedia/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
```bash
cd apps/blaze-dashboard
yarn build
```
### Development with local Jetpack
1. Ensure you have a working local Jetpack installation
2. Run `BLAZE_DASHBOARD_PACKAGE_PATH=/path/to/jetpack/projects/packages/blaze yarn dev`
## Development with sandbox
1. Ensure you have a working sandbox and the its hostname is `wpcom-sandbox`
2. Run `yarn dev --sync` to build and sync files as you change them.
## Uploading to CDN
The path is `widgets.wp.com/blaze-dashboard`.
|