Skip to content
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.idea
node_modules/
node_modules/
bun.lock
package-lock.json
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ Create Svelte components from Iconify SVG icons with type-safe support. A simple

- 🎯 **Iconify Integration**: Access and download icons from the Iconify collection.
- ⚡ **Fast Conversion**: Quickly convert SVG icons to Svelte components.
- 📦 **TypeScript Support**: Generate fully typed components with interfaces for Svelte TypeScript projects.
- 📦 **TypeScript Support**: Generate fully typed components with types for Svelte TypeScript projects.
- 🎨 **Customizable Icons**: Control icon size, display behavior, and spacing.
- 🛠️ **CLI Tool**: Easy-to-use command-line interface for Svelte icon generation.
- 🔄 **Flexible Output**: Generate JavaScript or TypeScript Svelte components.
- 📂 **Configurable Output Directory**: The Svelte component output folder can be configured with `SVELICON_ICON_PATH`.

> Svelicon streamlines the process of using Iconify icons in your Svelte projects, offering TypeScript support and flexible customization.

Expand Down Expand Up @@ -37,7 +38,7 @@ src/icons/FluentPersonPasskey28Filled.svelte
npx svelicon [options] [collection]/[icon]

Options:
-o, --output <dir> Output directory (default: "src/icons")
-o, --output <dir> Output directory (default: environment variable SVELICON_ICON_PATH or "src/icons")
--withts Generate TypeScript version (default: true)
--withjs Generate JavaScript version
-h, --help Display help for command
Expand All @@ -48,12 +49,21 @@ Options:
npx svelicon --withjs fluent/person-passkey-28-filled
```

### Output Directory Configuration

To set a custom output directory for your Svelte components, set the `SVELICON_ICON_PATH` environment variable to your desired path.

**Linux (Bash/Zsh):**
```bash
export SVELICON_ICON_PATH = "src/components/icons"
```

## Component Props 🎛️

All generated components accept these props:

```typescript
interface IconProps {
type IconProps = {
size?: number; // Icon size in em units
class?: string; // Add custom CSS classes to the SVG element
}
Expand Down Expand Up @@ -92,7 +102,7 @@ Generated components include:

```svelte
<script lang="ts" module>
export interface FluentPersonPasskey28FilledProps {
export type FluentPersonPasskey28FilledProps = {
size?: number;
class?: string;
}
Expand Down
5 changes: 4 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
import {program} from 'commander';
import {downloadIcon} from './index.js';

const iconPathFromEnvironmentVariable = process.env['SVELICON_ICON_PATH'];
const iconPath = iconPathFromEnvironmentVariable || "src/icons";

program
.name('iconify-svelte')
.description('Download Iconify icons as Svelte components')
.argument('<icon>', 'icon collection (e.g., mdi)')
.option('-o, --output <dir>', 'output directory', 'src/icons')
.option('-o, --output <dir>', 'output directory', iconPath)
.option('--withts', 'generate TypeScript version', true)
.option('--withjs', 'generate JavaScript version', false)
.action(async (icon, options) => {
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ${generateSvgTemplate(pathData, width, height, size)}`;

function generateComponent(pathData, height, width, componentName, isTypescript) {
const scriptContent = isTypescript ? `<script lang="ts" module>
export interface ${componentName}Props {
export type ${componentName}Props = {
size?: number;
class?: string;
}
Expand Down
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
"version": "1.0.5",
"description": "✨ Svelte Icon Library - Iconify icons, raw SVG and converts them to Svelte components",
"keywords": [
"svelte", "svelte5",
"svelte icon", "icons", "svg",
"iconify", "font awesome", "fluent"
"svelte",
"svelte5",
"svelte icon",
"icons",
"svg",
"iconify",
"font awesome",
"fluent"
],
"repository": {
"type": "git",
Expand All @@ -19,7 +24,7 @@
"dependencies": {
"@iconify/utils": "^2.1.5",
"axios": "^1.6.2",
"commander": "^11.1.0",
"commander": "^13.1.0",
"mkdirp": "^3.0.1"
}
}
19 changes: 0 additions & 19 deletions src/icons/FluentSearch12Regular.svelte

This file was deleted.