Skip to content

Commit 4a694cb

Browse files
author
pemrouz
committed
wip
1 parent 5253c4d commit 4a694cb

24 files changed

Lines changed: 16803 additions & 661 deletions

‎hackernews/dist/pages/index.html‎

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,3 @@
1-
<!-- <script src="https://rawgit.com/web-animations/web-animations-js/master/web-animations.min.js"></script> -->
2-
<script src="/ripple.js" transports="websocket,polling" ></script>
3-
<app-hn data="stories"></app-hn>
4-
<script type="text/javascript">
5-
// if ('serviceWorker' in navigator) {
6-
// window.addEventListener('load', function() {
7-
// navigator.serviceWorker.register('/sw.js').then(function(registration) {
8-
// // Registration was successful
9-
// console.log('ServiceWorker registration successful with scope: ', registration.scope)
10-
// }).catch(function(err) {
11-
// // registration failed :(
12-
// console.log('ServiceWorker registration failed: ', err)
13-
// })
14-
// })
15-
// }
16-
17-
// if (!!window.SharedWorker) {
18-
// var myWorker = new SharedWorker("ripple.sync.worker.js")
19-
20-
// // myWorker.addEventListener('error', function(e){ console.log("e", e)}, false)
21-
// myWorker.onerror = function(e){
22-
// console.log("error", e)
23-
// }
24-
25-
// myWorker.port.postMessage(['something', { a: 1 }])
26-
// console.log('Message posted to worker', myWorker)
27-
28-
// myWorker.port.onmessage = function(e) {
29-
// console.log('Message received from worker', e.data)
30-
// // result1.textContent = e.data
31-
// }
32-
// }
33-
</script>
1+
<script src="https://rawgit.com/web-animations/web-animations-js/master/web-animations.min.js"></script>
2+
<script src="/ripple.js" transports="websocket,polling"></script>
3+
<app-hn data="stories"></app-hn>

‎hackernews/dist/pages/ripple.sync.worker.js‎

Lines changed: 0 additions & 47 deletions
This file was deleted.

‎hackernews/dist/pages/shared.js‎

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎hackernews/dist/pages/sw.js‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎hackernews/dist/resources/app-hn/app-hn.css‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
:host {
22
display: block;
3-
width: 85%;
43
margin: 100px auto;
5-
position: relative;
4+
position: absolute;
5+
/*overflow: hidden;*/
6+
left: 10%;
7+
right: 10%;
68
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;
79
background-color: rgb(246, 246, 239); }
810

‎hackernews/dist/resources/app-hn/app-hn.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ exports.default = function (node, _ref) {
2121

2222
o('h1', 1).text('Realtime HN');
2323

24-
o('hn-story[sync="true"]', items, function (d) {
24+
o('hn-story', items, function (d) {
2525
return d.id;
2626
}).classed('score-changed', function (d) {
2727
return d.id in scoresChanged;
2828
}).classed('comments-changed', function (d) {
2929
return d.id in commentsChanged;
3030
}).each(function (el, d, i) {
31-
return el.animate({ top: [el.currentPos || '-52px', el.currentPos = STORY_HEIGHT * i + 'px'] }, { duration: 500, fill: 'forwards' });
31+
return el.animate({ transform: ['translateY(' + (is.def(el.currentPos) ? el.currentPos : -52) + 'px)', 'translateY(' + (el.currentPos = STORY_HEIGHT * i) + 'px)'] }, { duration: 500, fill: 'forwards', easing: 'ease-in' });
3232
});
3333
};

‎hackernews/dist/resources/data/stories.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ exports.default = {
8383
name: 'stories',
8484
body: {},
8585
headers: { loaded: loaded }
86-
};
8786

88-
// setInterval(d => update('a', 'a')(ripple('stories')), 2000)
87+
// setInterval(d => update('a', 'a')(ripple('stories')), 2000)
8988

89+
};
9090
var latest = 0;
91-
var MAX_CACHE_SIZE = 30,
91+
var MAX_CACHE_SIZE = 20,
9292
log = require('utilise/log')('[hn]');

‎hackernews/dist/resources/hn-story/hn-story.css‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
:host {
2-
contain: strict;
2+
left: 0;
3+
right: 0;
34
box-sizing: border-box;
45
display: block;
56
padding: 14px;
67
height: 52px;
7-
position: relative;
8+
position: absolute;
89
width: 100%;
910
overflow: hidden;
1011
line-height: 24px; }

‎hackernews/dist/resources/hn-story/hn-story.js‎

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,28 @@
33
Object.defineProperty(exports, "__esModule", {
44
value: true
55
});
6+
exports.default = {
7+
name: 'hn-story',
8+
body: body,
9+
headers: { sync: true, needs: '[css]' }
10+
};
611

7-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
812

9-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13+
function body(node, _ref) {
14+
var id = _ref.id,
15+
_ref$title = _ref.title,
16+
title = _ref$title === undefined ? '' : _ref$title,
17+
_ref$descendants = _ref.descendants,
18+
descendants = _ref$descendants === undefined ? 0 : _ref$descendants,
19+
_ref$score = _ref.score,
20+
score = _ref$score === undefined ? 0 : _ref$score,
21+
url = _ref.url;
1022

11-
var _class = function () {
12-
function _class() {
13-
_classCallCheck(this, _class);
14-
}
23+
var o = once(node);
1524

16-
_createClass(_class, [{
17-
key: 'render',
18-
value: function render(node, _ref) {
19-
var id = _ref.id,
20-
_ref$title = _ref.title,
21-
title = _ref$title === undefined ? '' : _ref$title,
22-
_ref$descendants = _ref.descendants,
23-
descendants = _ref$descendants === undefined ? 0 : _ref$descendants,
24-
_ref$score = _ref.score,
25-
score = _ref$score === undefined ? 0 : _ref$score,
26-
url = _ref.url;
25+
o('a.title', 1).attr('href', url).text(title);
2726

28-
var o = once(node);
27+
o('a.comments', 1).attr('href', 'https://news.ycombinator.com/item?id=' + id).text(descendants);
2928

30-
o('a.title', 1).attr('href', url).text(title);
31-
32-
o('a.comments', 1).attr('href', 'https://news.ycombinator.com/item?id=' + id).text(descendants);
33-
34-
o('span.score', 1).text(score);
35-
}
36-
}], [{
37-
key: 'async',
38-
get: function get() {
39-
return true;
40-
}
41-
}]);
42-
43-
return _class;
44-
}();
45-
46-
exports.default = _class;
29+
o('span.score', 1).text(score);
30+
}

0 commit comments

Comments
 (0)