flightkit 1.0.1-alpha.0 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -310
- package/dist/flightkit.js +171 -437
- package/dist/flightkit.js.map +1 -1
- package/package.json +36 -32
- package/gulpfile.js +0 -64
- package/rollup.config.js +0 -27
- package/src/components/card-buttonlink.js +0 -229
- package/src/components/card-textlink.js +0 -290
- package/src/components/localized-bgimg.js +0 -29
- package/src/components/localized-text.js +0 -28
- package/src/core/APIStrategy.js +0 -49
- package/src/core/deferred.js +0 -44
- package/src/core/flybits-core.js +0 -143
- package/src/core/flybits-layout.js +0 -94
- package/src/core/flybits-slot.js +0 -52
- package/src/core/flybits-viewable.js +0 -34
- package/src/layouts/flybits-list.js +0 -71
- package/src/styles/card-base.js +0 -17
- package/src/utils/actions.js +0 -33
- package/src/utils/content.js +0 -49
- package/src/utils/element.js +0 -22
- package/test.html +0 -65
- package/vendor/models/deferred.js +0 -44
- package/vendor/models/file.js +0 -29
- package/vendor/utils/file.js +0 -28
- package/vendor/utils/string.js +0 -26
package/README.md
CHANGED
|
@@ -1,310 +1,48 @@
|
|
|
1
|
-
 protocol/workflow is required, JavaScript is already typically required thus in order set IdP details a little JavaScript is required to be performed on the Core element
|
|
93
|
-
|
|
94
|
-
```html
|
|
95
|
-
<flybits-core>
|
|
96
|
-
<flybits-list>
|
|
97
|
-
<flybits-slot></flybits-slot>
|
|
98
|
-
</flybits-list>
|
|
99
|
-
</flybits-core>
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
```javascript
|
|
103
|
-
var flbCore = document.querySelector('flybits-core');
|
|
104
|
-
flbCore.init({
|
|
105
|
-
idp: new Flybits.idp.ApiKeyIDP({
|
|
106
|
-
projectID: '12345678-D5B0-4602-83B4-2EDC10A65838',
|
|
107
|
-
email: 'bob1234',
|
|
108
|
-
apiKey: 'EAD37756-58B6-4EF7-B5BD-E468D497611A'
|
|
109
|
-
})
|
|
110
|
-
});
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
## Component Hierarchy
|
|
114
|
-
|
|
115
|
-
### FlybitsCore `<flybits-core>`
|
|
116
|
-
|
|
117
|
-
This component is meant to be the root governing element of your Flybits embedded content. It is responsible for content API querying and will propagate child native html events outward (including deep linking and data change events). Think of this element as the brains and data store of anything meant to be rendered as children.
|
|
118
|
-
|
|
119
|
-
```html
|
|
120
|
-
<flybits-core>
|
|
121
|
-
...
|
|
122
|
-
</flybits-core>
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### FlybitsLayout `<flybits-layout>`
|
|
126
|
-
|
|
127
|
-
This is a foundational component meant to be extended/sub-classed. This type of component must live within a **FlybitsCore** element and is meant to layout the resultant content from the Core. It has the opportunity to add other structural elements around the main content layout such as headers, tabs, etc. FlybitsLayout components come with default support for rendering out of the box content types known as Viewables but also support the override and addition of new Viewables. More info can be found in [Extensible Content Types](#extensible-content-types).
|
|
128
|
-
|
|
129
|
-
Currently supported out of the box layouts include:
|
|
130
|
-
- FlybitsList `<flybits-list>`
|
|
131
|
-
|
|
132
|
-
Because layouts can/will have other structural and extension capabiltiies one must use a **FlybitsSlot** to specify where the actual content will be rendered within the layout.
|
|
133
|
-
|
|
134
|
-
```html
|
|
135
|
-
<flybits-core>
|
|
136
|
-
<flybits-list>
|
|
137
|
-
<div class="btn settings" slot="header">Settings</div>
|
|
138
|
-
<flybits-slot></flybits-slot>
|
|
139
|
-
</flybits-list>
|
|
140
|
-
</flybits-core>
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### FlybitsSlot `<flybits-slot>`
|
|
144
|
-
|
|
145
|
-
This is a common utility component used to filter/map incoming content instances and their types to available UI component types (Viewables).
|
|
146
|
-
|
|
147
|
-
### FlybitsViewable `<flybits-viewable>`
|
|
148
|
-
|
|
149
|
-
This is a foundational component meant to be extended/sub-classed. It is meant to represent the output of particular content types. FlybitsViewables are simple components only responsible for rendering JSON data that it has been passed.
|
|
150
|
-
|
|
151
|
-
Currently supported out of the box Viewables include:
|
|
152
|
-
- CardButtonLink `<card-buttonlink>`
|
|
153
|
-
- CardTextLink `<card-textlink>`
|
|
154
|
-
|
|
155
|
-
This class of component is not needed to be explicitly used. As long as they are registered as discussed in [Extensible Content Types](#extensible-content-types), the `<flybits-slot>` will map and render it accordingly.
|
|
156
|
-
|
|
157
|
-
## A Note About Styling
|
|
158
|
-
|
|
159
|
-
It has been a conscious design choice to render all rendered children of `<flybits-slot>` outside of the shadow DOM. This allows for full CSS customization of any child elements instead of a select amount of CSS variables inside the shadow DOM.
|
|
160
|
-
|
|
161
|
-
## Extensible Content Types
|
|
162
|
-
|
|
163
|
-
All **FlybitsViewable** components must have a constant known as `TEMPLATETYPE` which is used to map the Viewable to Flybits Content Template types.
|
|
164
|
-
|
|
165
|
-
This mapping can be updated by inserting Viewable components into the `<flybits-layout>` `viewables` slot component.
|
|
166
|
-
|
|
167
|
-
For example the out of the box `<card-buttonlink>` component has a `TEMPLATETYPE = "concierge-card-buttons"`. If you would like to override this mapping with a new component, like `<unicorn-card>`, first you must ensure that `<unicron-card>` has the same `TEMPLATETYPE = "concierge-card-buttons"`. Next you can insert the FlybitsViewable subclass into the `viewables` slot of the layout parent.
|
|
168
|
-
|
|
169
|
-
```html
|
|
170
|
-
<flybits-list>
|
|
171
|
-
<unicorn-card slot="viewables"></unicorn-card>
|
|
172
|
-
<flybits-slot></flybits-slot>
|
|
173
|
-
</flybits-list>
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
Now you can add new content rendering capabilities to your layouts and optionally override the out of the box.
|
|
177
|
-
|
|
178
|
-
### Building Your Own Viewable
|
|
179
|
-
|
|
180
|
-
#### 1. Extend Base Class
|
|
181
|
-
|
|
182
|
-
First you must extend the **FlybitsViewable** base class.
|
|
183
|
-
|
|
184
|
-
If you are using modules:
|
|
185
|
-
|
|
186
|
-
```javascript
|
|
187
|
-
import {FlybitsViewable} from 'flightkit'
|
|
188
|
-
|
|
189
|
-
class CustomComponent extends FlybitsViewable
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
if you are not using modules **flightkit** is accessible through the `window` namespace.
|
|
193
|
-
|
|
194
|
-
```javascript
|
|
195
|
-
class CustomComponent extends flightkit.FlybitsViewable
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
#### 2. Declare reactive properties
|
|
199
|
-
|
|
200
|
-
Next you must delcare properties that this viewable will need to be reactive.
|
|
201
|
-
|
|
202
|
-
```javascript
|
|
203
|
-
class CustomComponent extends FlybitsViewable{
|
|
204
|
-
static properties = {
|
|
205
|
-
content: {},
|
|
206
|
-
TEMPLATETYPE: {
|
|
207
|
-
type: String
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
...
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
#### 3. Initialize and Set Template Type
|
|
214
|
-
|
|
215
|
-
```javascript
|
|
216
|
-
class CustomComponent extends FlybitsViewable{
|
|
217
|
-
static properties = {
|
|
218
|
-
content: {},
|
|
219
|
-
TEMPLATETYPE: {
|
|
220
|
-
type: String
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
constructor(){
|
|
224
|
-
super();
|
|
225
|
-
this.TEMPLATETYPE = 'template-type-id';
|
|
226
|
-
}
|
|
227
|
-
...
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
#### 4. Transform Content Data (optional)
|
|
231
|
-
|
|
232
|
-
```javascript
|
|
233
|
-
class CustomComponent extends FlybitsViewable{
|
|
234
|
-
static properties = {
|
|
235
|
-
content: {},
|
|
236
|
-
TEMPLATETYPE: {
|
|
237
|
-
type: String
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
constructor(){
|
|
241
|
-
super();
|
|
242
|
-
this.TEMPLATETYPE = 'template-type-id';
|
|
243
|
-
}
|
|
244
|
-
getData(){
|
|
245
|
-
// get root content data payload
|
|
246
|
-
var rootObj = super.getData();
|
|
247
|
-
if(!rootObj){
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// perform necessary transformations
|
|
252
|
-
|
|
253
|
-
return retObj;
|
|
254
|
-
}
|
|
255
|
-
...
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
#### 5. Implement Render Function
|
|
259
|
-
|
|
260
|
-
```javascript
|
|
261
|
-
import {html} from 'flightkit';
|
|
262
|
-
|
|
263
|
-
class CustomComponent extends FlybitsViewable{
|
|
264
|
-
static properties = {
|
|
265
|
-
content: {},
|
|
266
|
-
TEMPLATETYPE: {
|
|
267
|
-
type: String
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
constructor(){
|
|
271
|
-
super();
|
|
272
|
-
this.TEMPLATETYPE = 'template-type-id';
|
|
273
|
-
}
|
|
274
|
-
// optional
|
|
275
|
-
getData(){
|
|
276
|
-
// get root content data payload
|
|
277
|
-
var rootObj = super.getData();
|
|
278
|
-
if(!rootObj){
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// perform necessary transformations
|
|
283
|
-
|
|
284
|
-
return retObj;
|
|
285
|
-
}
|
|
286
|
-
render(){
|
|
287
|
-
// get data object
|
|
288
|
-
var root = this.getData();
|
|
289
|
-
if(!root){
|
|
290
|
-
return '';
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
return html`
|
|
294
|
-
<!-- custom HTML rendering -->
|
|
295
|
-
`;
|
|
296
|
-
}
|
|
297
|
-
// optionally prevent rendering in shadow DOM
|
|
298
|
-
createRenderRoot(){
|
|
299
|
-
return this;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
#### 6. Register Custom Element
|
|
305
|
-
|
|
306
|
-
Here you can define and register your custome HTML element tag. You can declare any dasherized string as your HTML element tag and assign your subclassed **FlybitsViewable**.
|
|
307
|
-
|
|
308
|
-
```javascript
|
|
309
|
-
customElements.define('custom-component', CustomComponent);
|
|
310
|
-
```
|
|
1
|
+

|
|
2
|
+
# Flightkit
|
|
3
|
+
|
|
4
|
+
v2.0.0-beta.0
|
|
5
|
+
|
|
6
|
+
Flybits Flightkit is a fully contained, framework agnostic solution for personalized UI and Content within your web applications. Composed of [native web components](https://www.webcomponents.org/introduction) you can simply drop pure HTML tags into your application and view curated experiences from the [Flybits](https://flybits.com) platform.
|
|
7
|
+
|
|
8
|
+
## Quickstart
|
|
9
|
+
|
|
10
|
+
Here is the bare minimum code required to quickly embed a Flybits powered UI container within your existing application. For more flexible and robust options, read more in the following sections starting with Installation.
|
|
11
|
+
|
|
12
|
+
1. **Import**
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
<!-- Import the Flybits.js core SDK -->
|
|
16
|
+
<script src="<!-- coming soon -->"></script>
|
|
17
|
+
<!-- Import the Flightkit library -->
|
|
18
|
+
<script type="module" src="<!-- coming soon -->"></script>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
> Note: NPM and CDN deployments will be available once full release is made.
|
|
22
|
+
|
|
23
|
+
2. **Declare**
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
<flybits-slot ref-id="homepage-carousel"></flybits-slot>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
3. **Authenticate**
|
|
30
|
+
|
|
31
|
+
```javascript
|
|
32
|
+
<script>
|
|
33
|
+
// Use existing Flybits.js authentication strategies
|
|
34
|
+
Flybits.init({
|
|
35
|
+
HOST: 'https://api.demo.flybits.com'
|
|
36
|
+
}).then(function(){
|
|
37
|
+
return Flybits.Session.connect(new Flybits.idp.AnonymousIDP({
|
|
38
|
+
projectID: '1230D8CA-2173-2226-B70A-96A092348C68'
|
|
39
|
+
}))
|
|
40
|
+
})
|
|
41
|
+
</script>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
4. **Enjoy Contextual Personalized Content**
|
|
45
|
+
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
> Note: Layouts & content must be configured within the Flybits Experience Studio for them to appear within a FlybitsSlot.
|