This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhax-stax-browser.html
111 lines (105 loc) · 3.11 KB
/
hax-stax-browser.html
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-list/iron-list.html">
<link rel="import" href="hax-stax-browser-item.html">
<!--
`hax-stax-browser`
Select a stack / template to insert
@demo demo/index.html
@microcopy - the mental model for this element
- stax - silly name for the general public when talking about custom elements and what it provides in the end.
-->
<dom-module id="hax-stax-browser">
<template>
<style>
:host {
display: block;
}
hax-stax-browser-item {
margin: 10px;
-webkit-transition: .3s all linear;
transition: .3s all linear;
}
#ironlist {
min-height: 50vh;
}
</style>
<iron-list id="ironlist" items="[[__staxList]]" as="stax" grid>
<template>
<div class="stax-container">
<hax-stax-browser-item
index="[[stax.index]]"
title="[[stax.details.title]]"
tag="[[stax.details.tag]]"
image="[[stax.details.image]]"
author="[[stax.details.author]]"
teaser="[[stax.details.teaser]]"
description="[[stax.details.description]]"
examples="[[stax.details.examples]]"
status="[[stax.details.status]]"
stax="[[stax.stax]]"></hax-stax-browser-item>
</div>
</template>
</iron-list>
</template>
<script>
Polymer({
is: 'hax-stax-browser',
properties: {
/**
* The list of stax
*/
staxList: {
type: Array,
observer: '_staxListChanged',
}
},
/**
* Ready life cycle
*/
ready: function() {
document.body.addEventListener('hax-store-property-updated', this._haxStorePropertyUpdated.bind(this));
},
/**
* Detached life cycle
*/
detached: function () {
document.body.removeEventListener('hax-store-property-updated', this._haxStorePropertyUpdated.bind(this));
},
/**
* Attached
*/
attached: function() {
this.resetBrowser();
},
/**
* Store updated, sync.
*/
_haxStorePropertyUpdated: function(e) {
if (e.detail && typeof e.detail.value !== typeof undefined && e.detail.property) {
// make sure we set array's empty first to force a repaint of paths
if (typeof this[e.detail.property] !== typeof undefined && this[e.detail.property] != null && typeof this[e.detail.property].length !== typeof undefined) {
this.set(e.detail.property, []);
}
this.set(e.detail.property, e.detail.value);
}
},
/**
* Notice staxList changing.
*/
_staxListChanged: function(newValue, oldValue) {
if (typeof newValue !== typeof undefined) {
this.set('__staxList', newValue);
}
},
/**
* Reset this browser.
*/
resetBrowser: function() {
setTimeout( () => {
this.$.ironlist.fire('iron-resize');
window.dispatchEvent(new Event('resize'));
}, 100);
},
});
</script>
</dom-module>