yapp 5.0.16 → 5.0.19
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 +10 -4
- package/example.js +47 -1
- package/lib/index.js +8 -1
- package/lib/utilities/element.js +33 -0
- package/package.json +1 -1
- package/src/index.js +2 -0
- package/src/utilities/element.js +23 -0
package/README.md
CHANGED
|
@@ -75,22 +75,26 @@ The following will mount an instance of Yapp and render the necessary styles:
|
|
|
75
75
|
|
|
76
76
|
import Yapp from "yapp";
|
|
77
77
|
|
|
78
|
-
import { renderYappStyles } from "yapp";
|
|
78
|
+
import { mountYapp, unmountYapp, renderYappStyles } from "yapp";
|
|
79
|
+
|
|
80
|
+
const { } = elementMixins;
|
|
79
81
|
|
|
80
82
|
const body = document.querySelector("body"),
|
|
81
83
|
yapp = Yapp.fromContentAndConfiguration(` ... `, {});
|
|
82
84
|
|
|
83
85
|
renderYappStyles();
|
|
84
86
|
|
|
85
|
-
|
|
87
|
+
mountYapp(yapp, body);
|
|
86
88
|
|
|
87
|
-
yapp
|
|
89
|
+
unmountYapp(yapp); // At some later time.
|
|
88
90
|
```
|
|
89
|
-
|
|
91
|
+
|
|
92
|
+
Note that if you take this approach then you must call the `mountYapp()` function with the Yapp instance as an argument. Similarly if you remove an instance of Yapp from the DOM then you must call the `unmountYapp()` function.
|
|
90
93
|
|
|
91
94
|
### Make use of an Easy element
|
|
92
95
|
|
|
93
96
|
A slightly less cumbersome approach is to make use of an [Easy](https://github.com/djalbat/easy) element:
|
|
97
|
+
|
|
94
98
|
```
|
|
95
99
|
"use strict";
|
|
96
100
|
|
|
@@ -106,6 +110,7 @@ renderYappStyles();
|
|
|
106
110
|
|
|
107
111
|
body.mount(yapp);
|
|
108
112
|
```
|
|
113
|
+
|
|
109
114
|
Note that there is now no need to call the `didMount()` method.
|
|
110
115
|
|
|
111
116
|
### Use JSX by way of Juxtapose
|
|
@@ -136,6 +141,7 @@ body.mount(
|
|
|
136
141
|
|
|
137
142
|
);
|
|
138
143
|
```
|
|
144
|
+
|
|
139
145
|
Unless you plan to use Juxtapose to build your site, however, this may not be ideal.
|
|
140
146
|
|
|
141
147
|
Note that in all of the three use cases above you must call the `renderYappStyles()` function *before* mounting any instance of Yapp.
|