Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
counter model: Rewrite view in d3
Browse files Browse the repository at this point in the history
Towards #1: "Remove all React and JSX"

May affect #7: "counter model broken on Firefox"
  • Loading branch information
ongardie committed Jun 8, 2016
1 parent 25c6442 commit cee5da3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 45 deletions.
34 changes: 34 additions & 0 deletions dist/models/counter/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2015-2016, Salesforce.com, Inc.
* All rights reserved.
* Licensed under the MIT license.
* For full license text, see LICENSE.md file in the repo root or
* https://opensource.org/licenses/MIT
*/

'use strict';

let d3 = require('d3');
let View = function(controller, svg, module) {
let model = module.env;
svg = d3.select(svg)
.classed('counter', true)
.append('g');
let text = svg.append('text')
.attr('x', 10)
.attr('y', 20);

return {
name: 'CounterView',
update: function(changes) {
let output = '';
let counterVar = model.vars.get('counter');
if (counterVar !== undefined) {
output = counterVar.toString();
}
text.text(output);
},
};
}; // View

module.exports = View;
44 changes: 0 additions & 44 deletions dist/models/counter/counter.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion dist/models/counter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"main": {
"name": "Counter",
"spec": "counter.model",
"view": "counter.jsx"
"view": "counter.js"
}
}
}

0 comments on commit cee5da3

Please sign in to comment.