Skip to content

Commit 0c5dd82

Browse files
committed
Support SVG icons added & fix bugs
1 parent 39c620c commit 0c5dd82

File tree

14 files changed

+1692
-2074
lines changed

14 files changed

+1692
-2074
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
- Zero-config required
2121
- Auto-import Ionic components, composables and icons
22+
- Support SVG Icons
2223
- Ionic Router integration
2324
- Pre-render routes
2425
- Mobile meta tags

docs/content/0.index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Batteries-included [Ionic](https://ionicframework.com/) integration for Nuxt.
2525
::list
2626
- Zero-config required
2727
- Auto-import Ionic components, composables and icons
28+
- Support SVG Icons
2829
- Ionic Router integration
2930
- Pre-render routes
3031
- Mobile meta tags

docs/content/1.get-started/1.introduction.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ This module attempts to get you going with Nuxt + Ionic quickly, providing sane
3535
::list{type=success}
3636
- **Ionic router integration:** continue defining routes based on the structure of your `~/pages` directory and using page-level utilities such as `definePageMeta()`.
3737
- **Auto-imports**: Ionic components, composables and icons are all [auto-imported](https://nuxt.com/docs/guide/concepts/auto-imports) for ease of use.
38+
- **Support SVG Icons**: custom icons in the assets/ionic-icons path
3839
- **Helpful components and utilities**: This module provides components and utilities to accomplish common tasks more easily.
3940
- **PWA support**: out-of-the-box support for progressive web apps, using `nuxt-pwa-module`.
4041
- **Pre-render routes**

docs/content/1.get-started/3.configuration.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,29 @@ Integrations control which other modules this module should enable and setup fro
5050

5151
- **icons**
5252

53+
- **ionicons**
54+
5355
Default: `true`
54-
Disable to stop icons from being auto-imported.
56+
Disable to stop ionic-icons from being auto-imported.
57+
58+
- **svg**
59+
60+
Custom SVG icons and automatic detection with nested folders and icon size optimization in assets/ionic-icons path.
61+
::alert{type="warning"}
62+
⚠️ Note: Please put all the necessary SVG files in the assets/ionic-icons folder before you run your project. Because when a file is added/deleted in this path, your project will be rerendered again.
63+
::
64+
65+
- **enable**
66+
67+
Default: `true`
68+
69+
Disable to stop svg from being auto-imported.
70+
71+
- **directoryAsNamespace**
72+
73+
Default: `true`
74+
75+
Disable to stop svg from being auto-imported.
5576

5677
#### `css`
5778

docs/content/2.overview/5.icons.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,59 @@ navigation.icon: uil:illustration
66

77
Icons are auto-imported from [`ionicons/icons`](https://github.com/ionic-team/ionicons) by default, following the pattern of camel case naming with `ionicons` in front of the original icon name, that you can find on the [official ionicons website](https://ionic.io/ionicons).
88

9+
::alert{type="info"}
10+
ℹ️ Note: Please put all the necessary SVG files in the assets/ionic-icons folder before you run your project. Because when a file is added/deleted in this path, your project will be rerendered again.
11+
::
12+
13+
::alert{type="warning"}
14+
⚠️ Note: When you use #import , change the name of the icon using "as" and the desired name. Because it doesn't interfere with auto-import.
15+
::
16+
917
::code-group
1018

1119
```vue [Auto-imported icons]
1220
<template>
1321
<ion-icon :icon="ioniconsImage"></ion-icon>
1422
<ion-icon :md="ioniconsSquareSharp" :ios="ioniconsTriangleOutline"></ion-icon>
23+
<!-- ##### svg icon ##### -->
24+
<!-- without directoryAsNamespace -->
25+
<ion-icon :icon="ionicIconSvg`YourSvgFile`"></ion-icon>
26+
<!-- example -->
27+
<ion-icon :icon="ionicIconSvgHome"></ion-icon>
28+
<!-- with directoryAsNamespace -->
29+
<ion-icon :icon="ionicIconSvg`Subdirectories``YourSvgFile`"></ion-icon>
30+
<!-- example -->
31+
<ion-icon :icon="ionicIconSvgTabImage"></ion-icon>
1532
</template>
1633
```
1734

1835
```vue [Manual imports]
1936
<script setup lang="ts">
2037
import { image, squareSharp, triangleOutline } from 'ionicons/icons'
38+
import { ionicIconSvgHome as home, ionicIconSvgTabImage as tabImage } from "#imports";
2139
</script>
2240
2341
<template>
2442
<ion-icon :icon="image"></ion-icon>
2543
<ion-icon :md="squareSharp" :ios="triangleOutline"></ion-icon>
44+
<!-- ##### svg icon ##### -->
45+
<ion-icon :icon="home"></ion-icon>
46+
<ion-icon :icon="tabImage"></ion-icon>
47+
<ion-icon :md="home" :ios="tabImage"></ion-icon>
2648
</template>
2749
```
2850

2951
::
3052

31-
You can opt-out of auto-importing icons by setting the `integrations.icons` module options in your `nuxt.config.ts` to `false`.
53+
You can opt-out of auto-importing icons by setting the `integrations.icons.ionicons` module options in your `nuxt.config.ts` to `false`.
3254

3355
```js
3456
export default defineNuxtConfig({
3557
ionic: {
3658
integrations: {
37-
icons: false,
59+
icons: {
60+
ionicons: false
61+
},
3862
},
3963
},
4064
})

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"devDependencies": {
1212
"@nuxt-themes/docus": "1.15.0",
1313
"@nuxtjs/plausible": "0.2.4",
14-
"nuxt": "3.9.1"
14+
"nuxt": "3.9.3"
1515
}
1616
}

package.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,41 +57,42 @@
5757
"@capacitor/cli": "^5.6.0",
5858
"@capacitor/core": "^5.6.0",
5959
"@ionic/cli": "^7.2.0",
60-
"@ionic/vue": "^7.6.3",
61-
"@ionic/vue-router": "^7.6.3",
60+
"@ionic/vue": "^7.6.5",
61+
"@ionic/vue-router": "^7.6.5",
6262
"@kevinmarrec/nuxt-pwa": "^0.17.0",
63-
"@nuxt/kit": "^3.9.1",
63+
"@nuxt/kit": "^3.9.3",
6464
"ionicons": "^7.2.2",
65-
"pathe": "^1.1.1",
65+
"pathe": "^1.1.2",
6666
"pkg-types": "^1.0.3",
6767
"ufo": "^1.3.2",
6868
"unimport": "^3.7.1"
6969
},
7070
"devDependencies": {
7171
"@nuxt/eslint-config": "0.2.0",
7272
"@nuxt/module-builder": "0.5.5",
73-
"@nuxt/schema": "3.9.1",
73+
"@nuxt/schema": "3.9.3",
7474
"@nuxt/test-utils": "3.9.0",
7575
"@types/node": "20.10.7",
76-
"@vitest/coverage-v8": "1.1.3",
76+
"@vitest/coverage-v8": "1.2.1",
7777
"bumpp": "9.2.1",
7878
"eslint": "8.56.0",
7979
"eslint-config-prettier": "9.1.0",
8080
"eslint-plugin-prettier": "5.1.2",
8181
"expect-type": "0.17.3",
8282
"husky": "8.0.3",
8383
"lint-staged": "15.2.0",
84-
"nuxt": "3.9.1",
84+
"nuxt": "3.9.3",
8585
"pinst": "3.0.0",
86-
"playwright": "1.40.1",
86+
"playwright": "1.41.1",
8787
"prettier": "3.1.1",
88+
"svgo": "^3.2.0",
8889
"typescript": "5.3.3",
89-
"vitest": "1.1.3",
90+
"vitest": "1.2.1",
9091
"vue": "3.4.7"
9192
},
9293
"resolutions": {
93-
"@nuxt/kit": "3.9.1",
94-
"@nuxt/schema": "3.9.1",
94+
"@nuxt/kit": "3.9.3",
95+
"@nuxt/schema": "3.9.3",
9596
"@nuxtjs/ionic": "link:.",
9697
"consola": "^3.2.3"
9798
},

playground/composables/usePhotoGallery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Camera, CameraSource, CameraResultType, Photo } from '@capacitor/camera
33
import { Filesystem, Directory } from '@capacitor/filesystem'
44
import { Preferences } from '@capacitor/preferences'
55

6-
export function usePhotoGallery() {
6+
export const usePhotoGallery = () => {
77
const photos = ref<UserPhoto[]>([])
88
const PHOTO_STORAGE = 'photos'
99

playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
"@capacitor/filesystem": "5.2.0",
1313
"@capacitor/preferences": "5.0.6",
1414
"@nuxtjs/ionic": "latest",
15-
"nuxt": "3.9.1"
15+
"nuxt": "3.9.3"
1616
}
1717
}

0 commit comments

Comments
 (0)