You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code of your component lives inside `/src/index.svelte`, this is the main point for either Storybook and the building process. It's important that this file has it's own style tag with content in it, otherwise we cannot inject the styles of your app inside the shadow DOM of the custom element. ([read the build script](./scripts/build.js))
28
+
Start making your own modifications watching changes in Storybook.
25
29
26
-
The global styles for your Svelte component lives inside `/src/styles.svelte`, this file is important because we get the compiled CSS from this and inject it in Storybook so you can have global styles in all your stories without the need to duplicate this styles.
30
+
### How to integrate the component in your project?
31
+
32
+
1. Build the component using `yarn build`
33
+
2. (Optional) Create a `public` folder
34
+
3. (Optional) Create an `public/index.html` file
35
+
4. Copy the built component inside a `vendor` folder (accesible from `index.html`)
36
+
5. Import the component from the HTML using the `defer` attribute
6. Open the `index.html` and enjoy the web component
27
41
28
42
## Why?
29
43
Building custom elements with Svelte is really easy but have a lot of limitations, is this template I'm trying to show the way I solve most of these limitations.
@@ -35,6 +49,12 @@ Svelte current limitations:
35
49
*[Transitions in custom Elements](https://github.com/sveltejs/svelte/issues/1825)
36
50
*[Context API doesn't work for custom elements](https://github.com/sveltejs/svelte/issues/3422)
37
51
52
+
## How does this template work?
53
+
54
+
The code of your component lives inside `/src/index.svelte`, this is the main point for either Storybook and the building process. It's important that this file has it's own style tag with content in it, otherwise we cannot inject the styles of your app inside the shadow DOM of the custom element. ([read the build script](./scripts/build.js))
55
+
56
+
The global styles for your Svelte component lives inside `/src/styles.svelte`, this file is important because we get the compiled CSS from this and inject it in Storybook so you can have global styles in all your stories without the need to duplicate this styles.
57
+
38
58
## Available scripts
39
59
40
60
*`start`: runs the storybook, this is used when develop because of the live reloading
0 commit comments