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 0
/
haxcms-dev-theme.html
148 lines (145 loc) · 4.78 KB
/
haxcms-dev-theme.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../haxcms-elements/haxcms-theme-behavior.html">
<link rel="import" href="../schema-behaviors/schema-behaviors.html">
<link rel="import" href="../simple-colors/simple-colors.html">
<link rel="import" href="../paper-card/paper-card.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../iron-icons/iron-icons.html">
<!--
`haxcms-dev-theme`
A theme intended as the starting point to fork from and build new themes for HAXCMS
which allows you to build things that just work using JSON Outline Schema as it's "backend"
and then IF hax is around it'll show up :)
@demo demo/index.html
-->
<dom-module id="haxcms-dev-theme">
<template>
<style is="custom-style" include="simple-colors">
:host {
display: block;
/* theme color which is dictated by the manifest */
background-color: var(--haxcms-color, black);
}
iron-list {
padding: 16px;
margin: 0 auto;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
paper-card {
width: 200px;
color: black;
background-color: white;
padding: 8px;
font-size: 10px;
}
/**
* Hide the slotted content during edit mode. This must be here to work.
*/
:host[edit-mode] #slot {
display: none;
}
.manifest,.activeitem {
width: 48%;
margin: 0;
padding: 0;
display:inline-block;
vertical-align: text-top;
}
</style>
<h1 style="margin:0;">HAXCMS DEVELOPMENT THEME</h1>
<iron-list id="list" items="[[manifest.items]]" grid>
<template>
<div style="padding:16px;">
<paper-card heading="[[item.title]]" image="[[item.metadata.image]]" elevation="1" animated-shadow="false">
<div class="card-content">
<div>description: [[item.description]]</div>
<div>location: [[item.location]]</div>
<div>changed: [[item.metadata.updated]]</div>
</div>
<div class="card-actions">
<paper-button data-id$="[[item.id]]">Click to set activeItem</paper-button>
</div>
</paper-card>
</div>
</template>
</iron-list>
<div class="manifest">
<h2>title: [[manifest.title]]</h2>
<div>description: [[manifest.description]]</div>
<div>icon: <iron-icon icon="[[manifest.metadata.icon]]"></iron-icon></div>
<div>image: <img src$="[[manifest.metadata.image]]" height="200px" width="200px" /></div>
</div>
<div class="activeitem">
<paper-button id="unset">Unset activeItem</paper-button>
<h2>ACTIVE ITEM</h2>
<div>[[activeItem.title]]</div>
<div id="contentcontainer">
<div id="slot">
<slot></slot>
</div>
</div>
</div>
</template>
<script>
Polymer({
is: 'haxcms-dev-theme',
listeners: {
'list.tap': '_itemTapped',
'unset.tap': '_unsetTapped',
},
behaviors: [
SchemaBehaviors.Schema,
window.simpleColorsBehaviors,
HAXCMSBehaviors.Theme,
],
properties: {
// The behavior gives you editMode, activeItem and manifest
// You can add whatever else you need here
},
/**
* Ready life cycle
*/
ready: function () {
// required so that HAX is injected when available
this.setupHAXTheme();
},
/**
* Detatched life cycle
*/
detached: function () {
// this helps with cleaning things up if the theme is changed
this.setupHAXTheme(false);
},
/**
* Item tapped, let's set it as active by searching the manifest array
* Your theme is in charge of ensuring that when activeItem needs changed
* that it ensures that happens
*/
_itemTapped: function (e) {
var normalizedEvent = Polymer.dom(e);
var local = normalizedEvent.localTarget;
var activeId = local.getAttribute('data-id');
if (local.tagName === 'PAPER-BUTTON' && typeof activeId !== typeof undefined) {
const item = this.manifest.items.filter((d, i) => {
if (activeId === d.id) {
return d;
}
}).pop();
this.fire('json-outline-schema-active-item-changed', item);
// console log these so you can debug easily as you build out
console.log(this.manifest);
console.log(item);
}
},
/**
* Settings activeItem to nothing will ensure that state goes back to nothing active
* and then other options appear
*/
_unsetTapped: function (e) {
this.fire('json-outline-schema-active-item-changed', {});
},
});
</script>
</dom-module>