weg-shared-layout 0.0.2 → 0.0.3
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/package.json +7 -3
- package/readme.md +35 -141
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weg-shared-layout",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "Shared layout Web Components built with Stencil",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"types": "dist/components/index.d.ts",
|
|
@@ -29,8 +29,12 @@
|
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|
|
32
|
-
"url": "https://github.com/
|
|
32
|
+
"url": "git+https://github.com/jobsac/weg-shared-layout.git"
|
|
33
33
|
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/jobsac/weg-shared-layout/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/jobsac/weg-shared-layout#readme",
|
|
34
38
|
"files": [
|
|
35
39
|
"dist/",
|
|
36
40
|
"loader/"
|
package/readme.md
CHANGED
|
@@ -1,115 +1,61 @@
|
|
|
1
1
|
[](https://stenciljs.com)
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# weg-shared-layout
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> Shared layout Web Components (Stencil).
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Stencil combines the best concepts of the most popular frontend frameworks into a compile-time rather than runtime tool. Stencil takes TypeScript, JSX, a tiny virtual DOM layer, efficient one-way data binding, an asynchronous rendering pipeline (similar to React Fiber), and lazy-loading out of the box, and generates 100% standards-based Web Components that run in any browser supporting the Custom Elements specification.
|
|
10
|
-
|
|
11
|
-
Stencil components are just Web Components, so they work in any major framework or with no framework at all.
|
|
12
|
-
|
|
13
|
-
## Getting Started
|
|
14
|
-
|
|
15
|
-
To start building a new web component using Stencil, clone this repo to a new directory:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
git clone https://github.com/stenciljs/component-starter.git my-component
|
|
19
|
-
cd my-component
|
|
20
|
-
git remote rm origin
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
and run:
|
|
7
|
+
Install:
|
|
24
8
|
|
|
25
9
|
```bash
|
|
26
|
-
npm
|
|
27
|
-
npm start
|
|
10
|
+
npm i weg-shared-layout
|
|
28
11
|
```
|
|
29
12
|
|
|
30
|
-
|
|
13
|
+
## Using in Angular
|
|
31
14
|
|
|
32
|
-
|
|
33
|
-
npm run build
|
|
34
|
-
```
|
|
15
|
+
Register custom elements (recommended in `main.ts`):
|
|
35
16
|
|
|
36
|
-
|
|
17
|
+
```ts
|
|
18
|
+
import { defineCustomElements } from 'weg-shared-layout/loader';
|
|
37
19
|
|
|
38
|
-
|
|
39
|
-
npm test
|
|
20
|
+
defineCustomElements();
|
|
40
21
|
```
|
|
41
22
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
## Naming Components
|
|
45
|
-
|
|
46
|
-
When creating new component tags, we recommend _not_ using `stencil` in the component name (ex: `<stencil-datepicker>`). This is because the generated component has little to nothing to do with Stencil; it's just a web component!
|
|
47
|
-
|
|
48
|
-
Instead, use a prefix that fits your company or any name for a group of related components. For example, all of the [Ionic-generated](https://ionicframework.com/) web components use the prefix `ion`.
|
|
49
|
-
|
|
50
|
-
## Using this component
|
|
51
|
-
|
|
52
|
-
There are two strategies we recommend for using web components built with Stencil.
|
|
53
|
-
|
|
54
|
-
The first step for all two of these strategies is to [publish to NPM](https://docs.npmjs.com/getting-started/publishing-npm-packages).
|
|
55
|
-
|
|
56
|
-
You can read more about these different approaches in the [Stencil docs](https://stenciljs.com/docs/publishing).
|
|
57
|
-
|
|
58
|
-
### Lazy Loading
|
|
59
|
-
|
|
60
|
-
If your Stencil project is built with the [`dist`](https://stenciljs.com/docs/distribution) output target, you can import a small bootstrap script that registers all components and allows you to load individual component scripts lazily.
|
|
23
|
+
Allow custom elements in the module that uses them:
|
|
61
24
|
|
|
62
|
-
|
|
25
|
+
```ts
|
|
26
|
+
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
|
63
27
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
-->
|
|
70
|
-
<my-component first="Stencil" middle="'Don't call me a framework'" last="JS"></my-component>
|
|
28
|
+
@NgModule({
|
|
29
|
+
// ...
|
|
30
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
31
|
+
})
|
|
32
|
+
export class AppModule {}
|
|
71
33
|
```
|
|
72
34
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
You can also import the script as part of your `node_modules` in your applications entry file:
|
|
35
|
+
Use in a template (standard):
|
|
76
36
|
|
|
77
|
-
```
|
|
78
|
-
|
|
37
|
+
```html
|
|
38
|
+
<weg-footer
|
|
39
|
+
variant="standard"
|
|
40
|
+
company-name="WEG"
|
|
41
|
+
company-number="12345678"
|
|
42
|
+
social-links-src="/assets/footer-social-links.json"
|
|
43
|
+
standard-links-src="/assets/footer-standard-links.json"
|
|
44
|
+
></weg-footer>
|
|
79
45
|
```
|
|
80
46
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
### Standalone
|
|
84
|
-
|
|
85
|
-
If you are using a Stencil component library with `dist-custom-elements`, we recommend importing Stencil components individually in those files where they are needed.
|
|
86
|
-
|
|
87
|
-
To export Stencil components as standalone components make sure you have the [`dist-custom-elements`](https://stenciljs.com/docs/custom-elements) output target defined in your `stencil.config.ts`.
|
|
88
|
-
|
|
89
|
-
For example, given you'd like to use `<my-component />` as part of a React component, you can import the component directly via:
|
|
90
|
-
|
|
91
|
-
```tsx
|
|
92
|
-
import 'foobar-design-system/my-component';
|
|
93
|
-
|
|
94
|
-
function App() {
|
|
95
|
-
return (
|
|
96
|
-
<>
|
|
97
|
-
<div>
|
|
98
|
-
<my-component
|
|
99
|
-
first="Stencil"
|
|
100
|
-
middle="'Don't call me a framework'"
|
|
101
|
-
last="JS"
|
|
102
|
-
></my-component>
|
|
103
|
-
</div>
|
|
104
|
-
</>
|
|
105
|
-
);
|
|
106
|
-
}
|
|
47
|
+
Use in a template (additional):
|
|
107
48
|
|
|
108
|
-
|
|
49
|
+
```html
|
|
50
|
+
<weg-footer
|
|
51
|
+
variant="additional"
|
|
52
|
+
company-name="WEG"
|
|
53
|
+
company-number="12345678"
|
|
54
|
+
social-links-src="/assets/footer-social-links.json"
|
|
55
|
+
additional-groups-src="/assets/footer-additional-groups.json"
|
|
56
|
+
></weg-footer>
|
|
109
57
|
```
|
|
110
58
|
|
|
111
|
-
Check out this [Live Demo](https://stackblitz.com/edit/vitejs-vite-b6zuds?file=src%2FApp.tsx).
|
|
112
|
-
|
|
113
59
|
## Using in React
|
|
114
60
|
|
|
115
61
|
Install:
|
|
@@ -205,58 +151,6 @@ Stencil generates `components.d.ts` in this repo, but React does not automatical
|
|
|
205
151
|
|
|
206
152
|
If your app still complains about JSX intrinsic elements, you can also augment `JSX.IntrinsicElements` in that same file (varies by React/TS setup).
|
|
207
153
|
|
|
208
|
-
## Using in Angular
|
|
209
|
-
|
|
210
|
-
Install:
|
|
211
|
-
|
|
212
|
-
```bash
|
|
213
|
-
npm i weg-shared-layout
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
Register custom elements (recommended in `main.ts`):
|
|
217
|
-
|
|
218
|
-
```ts
|
|
219
|
-
import { defineCustomElements } from 'weg-shared-layout/loader';
|
|
220
|
-
|
|
221
|
-
defineCustomElements();
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
Allow custom elements in the module that uses them:
|
|
225
|
-
|
|
226
|
-
```ts
|
|
227
|
-
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
|
228
|
-
|
|
229
|
-
@NgModule({
|
|
230
|
-
// ...
|
|
231
|
-
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
232
|
-
})
|
|
233
|
-
export class AppModule {}
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
Use in a template (standard):
|
|
237
|
-
|
|
238
|
-
```html
|
|
239
|
-
<weg-footer
|
|
240
|
-
variant="standard"
|
|
241
|
-
company-name="WEG"
|
|
242
|
-
company-number="12345678"
|
|
243
|
-
social-links-src="/assets/footer-social-links.json"
|
|
244
|
-
standard-links-src="/assets/footer-standard-links.json"
|
|
245
|
-
></weg-footer>
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
Use in a template (additional):
|
|
249
|
-
|
|
250
|
-
```html
|
|
251
|
-
<weg-footer
|
|
252
|
-
variant="additional"
|
|
253
|
-
company-name="WEG"
|
|
254
|
-
company-number="12345678"
|
|
255
|
-
social-links-src="/assets/footer-social-links.json"
|
|
256
|
-
additional-groups-src="/assets/footer-additional-groups.json"
|
|
257
|
-
></weg-footer>
|
|
258
|
-
```
|
|
259
|
-
|
|
260
154
|
### Note on `*-src` JSON URLs
|
|
261
155
|
|
|
262
156
|
`social-links-src`, `standard-links-src`, and `additional-groups-src` are fetched by the component at runtime, so the JSON files must be **served by the host app** (e.g. Angular’s `src/assets/`), or be a full `https://...` URL.
|