Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enum of the sprite and its contents #297

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,17 @@ Module create a page that list all of icons for you, by default you can see this
Module default options:


| Option | Default | Description |
| ------ | ------- | ----------- |
| input | `~/assets/sprite/svg` | Directory of original svg files |
| output | `~/assets/sprite/gen` | Directory to store generated sprites |
| defaultSprite | `icons` | Name of default sprite (default sprite consist of all svgs that place directly inside `input` directory) |
| elementClass | `icon` | global class of all `<svg-icon>` instances |
| spriteClassPrefix | `sprite-` | Prefix of sprite specific classes |
| publicPath | `null` | Specifies a custom public path for the sprites |
| iconsPath | `_icons` | Custom path for icons list page (In order to disable this page, pass `false` or `null` to this option) |
| svgoConfig | `null` | Custom config object for SVGO, [How to customize SVGO config](/docs/svgo-config.md) |
| Option | Default | Description |
|-------------------|-----------------------|----------------------------------------------------------------------------------------------------------|
| input | `~/assets/sprite/svg` | Directory of original svg files |
| output | `~/assets/sprite/gen` | Directory to store generated sprites |
| defaultSprite | `icons` | Name of default sprite (default sprite consist of all svgs that place directly inside `input` directory) |
| elementClass | `icon` | global class of all `<svg-icon>` instances |
| spriteClassPrefix | `sprite-` | Prefix of sprite specific classes |
| publicPath | `null` | Specifies a custom public path for the sprites |
| iconsPath | `_icons` | Custom path for icons list page (In order to disable this page) |
| pageIcons | `_false` | Showing a page with all the icons |
| svgoConfig | `null` | Custom config object for SVGO, [How to customize SVGO config](/docs/svgo-config.md) |

You can update them with the `svgSprite` option in `nuxt.config`:

Expand Down
18 changes: 15 additions & 3 deletions docs/content/1.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,22 @@ export default defineNuxtConfig({

::code-group

```html [Usage]
```vue [Usage]
<script setup>
import { Love } from '#sprite'
</script>

<template>
<div>
<h2>Default sprite(top level icons)</h2>
<SvgIcon name="nuxt" />

<h2>Named Sprite</h2>
<SvgIcon name="love/love" />
<SvgIcon name="love/bee-mine" />

<h2>Enum Sprite</h2>
<SvgIcon :name="Love.HugsAndKisses" />
<SvgIcon :name="Love.BeeMine" />
</div>
</template>
```
Expand All @@ -83,6 +90,10 @@ export default defineNuxtConfig({
## Named Sprite

:SvgIcon{name="love/love"}

## Enum Sprite

:SvgIcon{name="love/hugs-and-kisses"}
:SvgIcon{name="love/bee-mine"}
::
::
Expand All @@ -104,6 +115,7 @@ export default defineNuxtConfig({
spriteClassPrefix: 'sprite-',
publicPath: null,
iconsPath: '_icons',
pageIcons: true,
svgoConfig: null
}
})
Expand All @@ -125,4 +137,4 @@ Or locally:

[MIT License](https://github.com/nuxt-community/svg-sprite-module/blob/master/LICENSE)

Copyright (c) Nuxt Community
Copyright (c) Nuxt Community
6 changes: 3 additions & 3 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"preview": "nuxi preview"
},
"dependencies": {
"@nuxt-themes/docus": "^1.10.1",
"@nuxthq/studio": "^0.10.0",
"nuxt": "^3.3.2"
"@nuxt-themes/docus": "^1.15.0",
"@nuxthq/studio": "^1.0.2",
"nuxt": "^3.8.0"
},
"packageManager": "[email protected]",
"pnpm": {
Expand Down
Loading