-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearchkit-manager.html
86 lines (79 loc) · 2.64 KB
/
searchkit-manager.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
<link rel="import" href="../polymer/polymer-element.html">
<script src="https://unpkg.com/react@16.0.0/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@16.0.0/umd/react-dom.production.min.js"></script>
<script src="./bower_components/searchkit/release/bundle.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
<dom-module id="searchkit-manager">
<link rel="import" type="css" href="./bower_components/searchkit/release/theme.css">
<template>
<style>
:host {
display: block;
}
</style>
<slot name="script-babel"></slot>
</template>
<script>
/**
* `searchkit-manager`
* Searchkit Manager
*
* @customElement
* @polymer
* @demo demo/index.html
*/
const {
SearchBox,
Hits,
HitsStats,
RefinementListFilter,
ResetFilters,
SelectedFilters,
HierarchicalMenuFilter,
NumericRefinementListFilter,
SearchkitComponent,
SearchkitProvider,
SearchkitManager,
NoHits,
RangeFilter,
ItemHistogramList,
TagCloud,
Layout, LayoutBody, LayoutResults,
SideBar, TopBar,
ActionBar, ActionBarRow
} = window.Searchkit;
class SearchkitManagerElement extends Polymer.Element {
static get is() { return 'searchkit-manager'; }
static get properties() {
return {
config: {
type: String,
value: 'searchkit-manager'
}
};
}
constructor() {
super();
}
connectedCallback() {
if (super.connectedCallback) {
super.connectedCallback();
}
window.SearckitManagerContainer = this.shadowRoot;
/* ... */
let code = this.getBabelScript();
var output = Babel.transform(code, {presets: ['react', 'es2015'],plugins: ["transform-eval"]}).code;
eval(output);
var style = document.createElement('style');
style.innerHTML = '@import "../bower_components/searchkit/release/theme.css";@import "./bower_components/searchkit/release/theme.css";.sk-layout__top-bar {position: relative;}';
this.shadowRoot.appendChild(style);
}
getBabelScript() {
let nodes = Polymer.FlattenedNodesObserver.getFlattenedNodes(this.shadowRoot.querySelector('slot'));
let template = [].filter.call(nodes, (node) => node.nodeType === Node.ELEMENT_NODE)[0];
return template.innerHTML;
}
}
window.customElements.define(SearchkitManagerElement.is, SearchkitManagerElement);
</script>
</dom-module>