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 CHANGED
@@ -1,310 +1,48 @@
1
- ![flightkit-200](https://user-images.githubusercontent.com/5612789/155478647-ad0f1ce8-0ce6-4396-b8e6-8287897896e5.png)
2
- # Flightkit
3
-
4
- Flightkit is a UI kit for rapidly creating [Flybits](https://flybits.com) enabled web applications. Composed of [native web components](https://www.webcomponents.org/introduction) you can simply drop pure HTML tags into your application and immediately view curated experiences through the Flybits platform.
5
-
6
- ## Table of Contents
7
- 1. [Compatibility](#compatibility)
8
- 2. [Dependencies](#dependencies)
9
- 3. [Getting Started](#getting-started)
10
- 4. [Authentication Strategies](#authentication-strategies)
11
- 5. [Component Hierarchy](#component-hierarchy)
12
- 6. [Extensible Content Types](#extensible-content-types)
13
- 6.1. [Building Your Own Viewable](#building-your-own-viewable)
14
-
15
- ## Compatibility
16
-
17
- All modern browsers are supported however if you would like to support Internet Explorer 11 (not recommended) you must include the polyfill below.
18
-
19
- * Webcomponentsjs Polyfill: [webcomponents/webcomponentsjs](https://github.com/WebComponents/webcomponentsjs)
20
-
21
- 1. Fetch the package
22
-
23
- ```shell
24
- $ npm install @webcomponents/webcomponentsjs --save
25
- ```
26
-
27
- 2. Include the package in your page
28
-
29
- ```html
30
- <script src="node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js" type="text/javascript"></script>
31
- ```
32
-
33
- ## Dependencies
34
-
35
- This UI kit requires the core Flybits.js SDK to be present in the global `window` namespace.
36
- * [Flybits.js](https://www.npmjs.com/package/flybits)
37
-
38
- 1. Fetch the package
39
-
40
- ```shell
41
- $ npm install flybits --save
42
- ```
43
-
44
- 2. Include the library in your page
45
-
46
- ```html
47
- <script src="node_modules/flybits/dist/flybits.js" type="text/javascript"></script>
48
- ```
49
-
50
- Alternatively you can simply include the library using a cdn link:
51
-
52
- ```html
53
- <script src="https://cdn.jsdelivr.net/npm/flybits@2.6.0/dist/flybits.min.js"></script>
54
- ```
55
-
56
- ## Getting Started
57
-
58
- 1. Fetch the package
59
-
60
- ```shell
61
- $ npm install flightkit --save
62
- ```
63
-
64
- 2. Include the library in your page
65
-
66
- ```html
67
- <script src="node_modules/flightkit/dist/flightkit.js" type="text/javascript"></script>
68
- ```
69
-
70
- 3. Start using Flybits html components
71
-
72
- ```html
73
- <flybits-core projectID="12345678-D5B0-4602-83B4-2EDC10A65838">
74
- <flybits-list>
75
- <flybits-slot></flybits-slot>
76
- </flybits-list>
77
- </flybits-core>
78
- ```
79
-
80
- ## Authentication Strategies
81
-
82
- By default if only specifying project ID as an attribute on the Core element the Flightkit will facilitate anonymous login to the Flybits platform.
83
-
84
- ```html
85
- <flybits-core projectID="12345678-D5B0-4602-83B4-2EDC10A65838">
86
- <flybits-list>
87
- <flybits-slot></flybits-slot>
88
- </flybits-list>
89
- </flybits-core>
90
- ```
91
-
92
- If another identity provider (IdP) 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
+ ![flightkit-200](https://js.flybits.app/images/Flybits-Header-flightkit-thin.png)
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
+ ![Carousel of curated content](https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1furhUrHM7k3yZOnffSu%2Fuploads%2FFmJd3OrB6TWt97pumBDt%2FScreenshot%202024-02-12%20024159.png?alt=media&token=4e0ede9e-0c3c-42ac-a322-4323b37c3bb0)
47
+
48
+ > Note: Layouts & content must be configured within the Flybits Experience Studio for them to appear within a FlybitsSlot.