chore: setup codesandbox ci (#183)

This commit is contained in:
Miralem Drek
2019-11-19 13:07:13 +01:00
committed by GitHub
parent 2ea2613d3a
commit 588dfc6f0e
9 changed files with 129 additions and 1 deletions

6
.codesandbox/ci.json Normal file
View File

@@ -0,0 +1,6 @@
{
"buildCommand": "build:codesandbox",
"packages": ["apis/nucleus"],
"sandboxes": ["/.codesandbox/mekko"],
"silent": true
}

16
.codesandbox/mekko/index.html Executable file
View File

@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>Nebula mashup</title>
<meta charset="UTF-8" />
</head>
<body>
<div id="app">
<div id="selections"></div>
<div id="object"></div>
</div>
<script src="src/index.js"></script>
</body>
</html>

19
.codesandbox/mekko/package.json Executable file
View File

@@ -0,0 +1,19 @@
{
"name": "parcel-sandbox",
"version": "1.0.0",
"description": "Simple Parcel Sandbox",
"main": "index.html",
"scripts": {
"start": "parcel index.html --open",
"build": "parcel build index.html"
},
"dependencies": {
"@nebula.js/nucleus": "0.1.0-alpha.25",
"@nebula.js/sn-mekko-chart": "1.0.0",
"enigma.js": "2.4.0"
},
"devDependencies": {
"@babel/core": "7.2.0",
"parcel-bundler": "^1.6.1"
}
}

View File

@@ -0,0 +1,3 @@
{
"hardReloadOnChange": true
}

View File

@@ -0,0 +1,8 @@
import "./styles.css";
import init from "./init";
init({
appId: "doc/01775889-c700-413f-9b0e-6ba1837c52b0",
fields: ["Country", "Product Category", "=count(Customer)"]
});

55
.codesandbox/mekko/src/init.js Executable file
View File

@@ -0,0 +1,55 @@
import enigma from 'enigma.js';
import qixSchema from 'enigma.js/schemas/12.34.11.json';
import nucleus from '@nebula.js/nucleus';
import mekko from '@nebula.js/sn-mekko-chart';
const openApp = id =>
enigma
.create({
schema: qixSchema,
url: `wss://apps.core.qlik.com/app/${id}`,
})
.open()
.then(global => global.getActiveDoc());
const appCache = (window.appCache = window.appCache || {});
export default function init({ appId, fields, objectId }) {
if (!appCache[appId]) {
appCache[appId] = openApp(appId);
}
appCache[appId].then(app => {
const nebbie = nucleus(app, {
load: (type, config) => config.Promise.resolve(mekko),
});
nebbie.selections().mount(document.getElementById('selections'));
nebbie.types.clearFromCache('dummy');
const params = {
context: {
permissions: ['passive', 'interact', 'select', 'fetch'],
},
element: document.getElementById('object'),
};
if (objectId) {
nebbie.get(
{
type: 'dummy',
id: objectId,
},
params
);
} else {
nebbie.create(
{
type: 'dummy',
fields,
},
params
);
}
});
}

View File

@@ -0,0 +1,20 @@
body {
font-family: Arial;
color: #404040;
background: #eee;
margin: 12px;
}
#selections, #object {
background: #fff;
border-radius: 2px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
#object {
position: absolute;
top: 64px;
left: 12px;
bottom: 12px;
right: 12px;
}

View File

@@ -3,6 +3,7 @@
"description": "",
"scripts": {
"build": "cross-env NODE_ENV=production FORCE_COLOR=1 lerna run build --stream",
"build:codesandbox": "cross-env NODE_ENV=production CODESANDBOX=1 FORCE_COLOR=1 lerna run build --stream --scope \"@nebula.js/{nucleus,supernova,theme}\"",
"build:watch": "FORCE_COLOR=1 lerna run build:watch --stream --concurrency 99 --no-sort",
"lint": "eslint packages apis commands --ext .js,.jsx",
"lint:check": "eslint --print-config ./aw.config.js | eslint-config-prettier-check",

View File

@@ -90,7 +90,7 @@ const config = isEsm => {
format: isEsm ? 'esm' : 'umd',
exports: 'default',
name: umdName,
sourcemap: true,
sourcemap: process.env.CODESANDBOX ? 'inline' : true,
banner,
globals,
},