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

Removing Polymer for nav+thumb #354

Merged
merged 8 commits into from
Jun 14, 2017
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
16 changes: 16 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
## dev

## 0.10.0 (unreleased)

Breaking changes

* Polymer element `the-graph-thumb` has been removed.
Should instead use the JavaScript API `TheGraph.thumb.render()`,
as shown in `examples/demo-thumbnail.html`.
* Polymer element `the-graph-nav` has been removed.
Should instead use the new React component `TheGraph.nav.Component`,
as shown in `examples/demo-full.html`

Internal changes

* All dependencies except Polymer (deprecated) are installed via NPM
* Some more modules have been converted to proper CommonJS

## 0.9.0 (2017 May 6)

New features
Expand Down
44 changes: 30 additions & 14 deletions examples/demo-full.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<!-- Custom elements -->
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../the-graph-editor/the-graph-editor.html">
<link rel="import" href="../the-graph-nav/the-graph-nav.html">

<!-- Fonts -->
<link rel="stylesheet" href="../node_modules/font-awesome/css/font-awesome.min.css">
Expand Down Expand Up @@ -76,7 +75,7 @@
theme="dark">
</the-graph-editor>

<the-graph-nav id="nav" width="216" height="162"></the-graph-nav>
<div id="nav"></div>

<div id="testing">
<button id="autolayout">autolayout</button>
Expand Down Expand Up @@ -113,22 +112,40 @@
// Remove loading message
var loading = document.getElementById("loading");
loading.parentNode.removeChild(loading);

renderNav();
});

// Attach nav
var nav = document.getElementById('nav');
editor.addEventListener('viewchanged', function(e) {
nav.view = e.detail;
});
nav.addEventListener('panto', function(e) {
var pan = e.detail;
function fitGraphInView() {
editor.triggerFit();
}
function panEditorTo(pan) {
editor.pan[0] = pan.x;
editor.pan[1] = pan.y;
});
nav.addEventListener('tap', function() {
editor.triggerFit();
});

}
function renderNav() {
var props = {
height: 162,
width: 216,
graph: editor.graph,
onTap: fitGraphInView,
onPanTo: panEditorTo,
viewrectangle: [
-editor.pan[0],
-editor.pan[1],
editor.width,
editor.height
],
viewscale: editor.scale,
};

var element = React.createElement(TheGraph.nav.Component, props);
ReactDOM.render(element, document.getElementById('nav'));
}
editor.graph.on('endTransaction', renderNav); // graph changed
editor.addEventListener('viewchanged', renderNav); // editor viewport changed

// Simulate a library update
setTimeout(function () {
var originalComponent = editor.getComponent('core/Split');
Expand Down Expand Up @@ -206,7 +223,6 @@
document.getElementById("theme").addEventListener("click", function () {
theme = (theme==="dark" ? "light" : "dark");
editor.theme = theme;
nav.theme = theme;
});

// Focus a node
Expand Down
34 changes: 19 additions & 15 deletions examples/demo-thumbnail.html
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
<!DOCTYPE html>
<html>
<head>
<title>the-graph-thumb documentation</title>
<title>the-graph-thumb example</title>
<meta charset="utf-8">

<!-- Deps -->
<script src="../node_modules/webcomponents.js/webcomponents.js"></script>
<script src="../node_modules/react/dist/react.js"></script>
<script src="../node_modules/react-dom/dist/react-dom.js"></script>
<script src="../dist/the-graph.js"></script>

<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../the-graph-thumb/the-graph-thumb.html">

</head>
<body style="background-color:gray; color:white;">

<the-graph-thumb id="thumb" width="400" height="300"></the-graph-thumb>
<canvas id="thumb" width="400" height="300" style='background-color:black; border:1px solid; border-color: white' ></canvas>

<script type="text/javascript">
(function(){
"use strict";
var TheGraph = window.TheGraph;
var fbpGraph = window.TheGraph.fbpGraph;

Polymer.veiledElements = ["the-graph-thumb"];
window.addEventListener('polymer-ready', function() {

window.loadGraph = function (json) {
// Load graph
var graphData = json.data.files['noflo.json'].content;
var thumb = document.getElementById('thumb');
window.fbpGraph.graph.loadJSON(graphData, function(err, graph) {
thumb.graph = graph;
fbpGraph.graph.loadJSON(graphData, function(err, graph) {
if (err) {
throw err;
}

// Render the numbnail
var thumb = document.getElementById('thumb');
var properties = TheGraph.thumb.styleFromTheme('dark');
properties.width = thumb.width;
properties.height = thumb.height;
properties.nodeSize = 60;
properties.lineWidth = 1;
var context = thumb.getContext("2d");
var info = TheGraph.thumb.render(context, graph, properties);
});

};
Expand All @@ -46,9 +52,7 @@
// Edge algo test
// script.src = 'https://api.github.com/gists/6890344?callback=loadGraph';
body.appendChild(script);
});

})();
})();
</script>
</body>
</html>
2 changes: 0 additions & 2 deletions spec/runner.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
theme="dark">
</the-graph-editor>

<the-graph-nav id="nav" width="216" height="162"></the-graph-nav>

<script src="basics.js"></script>
<script src="editing.js"></script>
<script src="graphchanges.js"></script>
Expand Down
161 changes: 0 additions & 161 deletions the-graph-nav/the-graph-nav.html

This file was deleted.

Loading