Skip to content

Commit 02afe5f

Browse files
TommertomTommertom
Tommertom
authored and
Tommertom
committed
Readme update
1 parent df4b3db commit 02afe5f

File tree

5 files changed

+40
-30
lines changed

5 files changed

+40
-30
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Change Log Ionic-Svelte-NPM
22
All notable changes to this project will be documented in this file.
33

4-
## 0.62/63/64/65
4+
## 0.62/63/64/65/66/67
55
- removed typescript in *.svelte components as Vite does not process them (but does process *.ts)
66
- removed IonTabsLegacy.svelte - can still be found here https://github.com/Tommertom/svelte-ionic-app/blob/main/src/IonTabsLegacy.svelte for manual inclusion
77

README.md

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ adapter: adapter({
6868

6969
Integration of Ionic
7070

71-
- `npm i @ionic/core ionic-svelte` - (ionic svelte has typings until 6.4.2)
71+
- `npm i @ionic/core ionic-svelte`
7272
- create a theme folder/file that contains the colours for Ionic (see starterfiles/theme). Example: - create a theme folder/file that contains the colours for Ionic (see starterfiles/theme). Example: https://raw.githubusercontent.com/Tommertom/svelte-ionic-app/main/starterfiles/theme/variables.css
7373
- the top-route layout file `+layout.svelte` (Kit) or top root module (others) needs to run `setupIonicSvelte()` and import the theme stylesheet before anything else - also see starterfiles/+layout.svelte. Example:
7474

@@ -83,7 +83,7 @@ Integration of Ionic
8383
import 'ionic-svelte/components/all';
8484
8585
/* run base configuration code from ionic/core */
86-
setupIonicSvelte();
86+
setupIonicBase();
8787
</script>
8888
8989
<ion-app>
@@ -107,6 +107,28 @@ Code for this library - https://github.com/Tommertom/svelte-ionic-app
107107

108108
Ionic-svelte on NPMjs- https://www.npmjs.com/package/ionic-svelte
109109

110+
111+
## Code Splitting to reduce bundle size
112+
In order to reduce bundle size or limit the size of individual chunks, you can replace the import in main layout file. Example: if you replace the line `import 'ionic-svelte/components/all';` with imports like below. This can reduce the bundle for that chunk drastically. The import of `all` will result to at least an 800kb chunk (80 components), so it is worth it to change this.
113+
114+
Next you can choose to load specific components only where you use them.
115+
116+
Please note, you only need to import a component only once, as the import registers the webcomponent globally. So this saves you lots of imports, reducing the bundle as well (compared to tree-shaking).
117+
118+
And never forget to at least `import 'ionic-svelte/components/ion-app';` - as this one is in the main layout.
119+
120+
```
121+
import 'ionic-svelte/components/ion-app';
122+
import 'ionic-svelte/components/ion-card';
123+
import 'ionic-svelte/components/ion-card-title';
124+
import 'ionic-svelte/components/ion-card-subtitle';
125+
import 'ionic-svelte/components/ion-card-header';
126+
import 'ionic-svelte/components/ion-card-content';
127+
import 'ionic-svelte/components/ion-chip';
128+
import 'ionic-svelte/components/ion-button';
129+
```
130+
131+
110132
## How to use components
111133
Ionic components are webcomponents, so appear in your template just like other dom elements. They don't need ECMA imports like `import {IonCard} from '...`.
112134

@@ -115,8 +137,8 @@ Ionic components are webcomponents, so appear in your template just like other d
115137
Here content
116138
</ion-card>
117139
```
140+
So you can also apply css classes to them, also when wanting to tweak UI via the shadow dom/web-parts.
118141

119-
`setupIonicBase` - will register all these Ionic components as webcomponents so you can use them easily. But, there is a trade-off - no tree shaking (unless you change `setupIonicBase` a bit).
120142

121143
## Special components
122144
Due to router issues and overlays, there are three special compontents included that override/replace the ionic standard webcomponents:
@@ -168,25 +190,6 @@ Sample `tsconfig.json`:
168190
}
169191
```
170192

171-
## Code Splitting to reduce bundle size
172-
In order to reduce bundle size or limit the size of individual chunks, you can replace the
173-
Example: if you replace the line `import 'ionic-svelte/components/all';` with imports like below. This can reduce the bundle for that chunk drastically. The import of `all` will result to at least an 800kb chunk (80 components), so it is worth it to change this.
174-
175-
Please note, you only need to import a component only once, as the import registers the webcomponent globally. So this saves you lots of imports, reducing the bundle as well (compared to tree-shaking).
176-
177-
And never forget to at least `import 'ionic-svelte/components/ion-app';`.
178-
179-
```
180-
import 'ionic-svelte/components/ion-app';
181-
import 'ionic-svelte/components/ion-card';
182-
import 'ionic-svelte/components/ion-card-title';
183-
import 'ionic-svelte/components/ion-card-subtitle';
184-
import 'ionic-svelte/components/ion-card-header';
185-
import 'ionic-svelte/components/ion-card-content';
186-
import 'ionic-svelte/components/ion-chip';
187-
import 'ionic-svelte/components/ion-button';
188-
```
189-
190193
## How to contribute?
191194
Would you like to contribute to this project? Great!
192195

@@ -213,13 +216,15 @@ When you do a PR, make sure you explain what you did and why!
213216

214217
- bind:value does not seem to work on input and other form elements, so a click handler is needed - which is cumbersome - https://github.com/sveltejs/svelte/issues/892 - so probably not solvable without support by Ionic or Svelte - or we need to create wrappers for all elements - which is quite some work and you will be required to manually import all elements you use per page (like with Vue and React) - which seems a drag to me?
215218

219+
SvelteKit form actions make the usage of bind:value even obsolete. So that is the go-to way route anyway - https://kit.svelte.dev/docs/form-actions
220+
216221
Please note - if you use a library such as https://svelte-forms-lib-sapper-docs.vercel.app/introduction together with Yup schemas https://github.com/jquense/yup, the bind:value-issue actually becomes less relevant as you will have the library handle the events and you will use the observables to manage validation and final values to use for further processing. See https://blog.logrocket.com/form-validation-in-svelte/ for nice examples.
217222

218-
- Some styles are unused - related to md and ios options for webcomponents? Or need to be discarded. Probably issue with webcomponents and the nature of Ionic being sensitive to md or ios style (as part of its config)
223+
- Some styles are reported as unused - related to md and ios options for webcomponents? Or need to be discarded. Probably issue with webcomponents and the nature of Ionic being sensitive to md or ios style (as part of its config). Or the way Svelte/vite checks for unused css.
219224

220225
- Add IonPage, IonTabs and IonBackButton are not part of the default export - these are svelte components, so index.ts cannot handle these (?)
221226

222-
- Ion Icons implementation will not support md and ios specific icons etc (yet) - name prop does not function - also happening in Vue/React.Similar icon issues arise with other component that can digest custom icons (to check) - solution could be to make a svelte IonIcon component, but that will likely import all icons in a non-tree-shakable way?
227+
- Ion Icons implementation only uses icon-property syntax. Name/md/ios will not function
223228

224229
- In some cases IonPage clips the content enclosed - then you need to remove main tags in IonPage
225230

@@ -231,7 +236,9 @@ Please note - if you use a library such as https://svelte-forms-lib-sapper-docs.
231236

232237
- ItemSliding sometimes does not catch the gesture - known issue - needs fix in @ionic/core
233238

234-
- Many "File not found errors" on css.map files. I frankly don't really mind these. Maybe it is easy to get rid of these, but for now, I leave it.
239+
- Many "File not found errors" on css.map files in the demo app. I frankly don't really mind these. Maybe it is easy to get rid of these, but for now, I leave it.
240+
241+
Check https://github.com/Tommertom/svelte-ionic-app/issues for most recent overview of issues.
235242

236243

237244
## Things not being implemented

demo-app/src/lib/components/Menu.svelte

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,15 @@
7878
menuItems = [...menuItems];
7979
8080
const closeAndNavigate = async (url: string) => {
81-
//@ts-ignore
82-
window.gtag('event', url);
81+
// take the google tag from the main thread
82+
setTimeout(() => {
83+
//@ts-ignore
84+
if (!dev) window.gtag('event', url);
85+
}, 100);
8386
8487
console.log('Navigate url', url);
85-
goto(url);
8688
89+
goto(url);
8790
menuController.close('mainmenu');
8891
};
8992

experimental_index.d.ts

Whitespace-only changes.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ionic-svelte",
3-
"version": "0.5.66",
3+
"version": "0.5.67",
44
"private": false,
55
"homepage": "https://ionicsvelte.firebaseapp.com",
66
"repository": {

0 commit comments

Comments
 (0)