@pikacss/plugin-icons 0.0.39 → 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/README.md +0 -315
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikacss/plugin-icons",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.41",
|
|
5
5
|
"author": "DevilTea <ch19980814@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"dist"
|
|
43
43
|
],
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@pikacss/core": "0.0.
|
|
45
|
+
"@pikacss/core": "0.0.41"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@iconify/utils": "^3.1.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"ofetch": "^1.5.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@pikacss/core": "0.0.
|
|
53
|
+
"@pikacss/core": "0.0.41"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "tsdown && pnpm exec publint",
|
package/README.md
DELETED
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
# @pikacss/plugin-icons
|
|
2
|
-
|
|
3
|
-
Use thousands of icons from popular icon sets in PikaCSS.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
pnpm add @pikacss/plugin-icons
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Quick Start
|
|
12
|
-
|
|
13
|
-
**pika.config.ts**:
|
|
14
|
-
```typescript
|
|
15
|
-
/// <reference path="./src/pika.gen.ts" />
|
|
16
|
-
|
|
17
|
-
import { defineEngineConfig } from '@pikacss/core'
|
|
18
|
-
import { icons } from '@pikacss/plugin-icons'
|
|
19
|
-
|
|
20
|
-
export default defineEngineConfig({
|
|
21
|
-
plugins: [
|
|
22
|
-
icons()
|
|
23
|
-
],
|
|
24
|
-
icons: {
|
|
25
|
-
// Configure icons plugin here
|
|
26
|
-
prefix: 'i-',
|
|
27
|
-
scale: 1,
|
|
28
|
-
mode: 'auto',
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**Your code**:
|
|
34
|
-
```typescript
|
|
35
|
-
// Method 1: Direct shortcut string
|
|
36
|
-
const iconClass = pika('i-mdi:home')
|
|
37
|
-
|
|
38
|
-
// Method 2: With additional styles (shortcut as first argument)
|
|
39
|
-
const styledIcon = pika('i-mdi:home', {
|
|
40
|
-
fontSize: '24px',
|
|
41
|
-
color: 'blue'
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
// Method 3: Using __shortcut property in style object
|
|
45
|
-
const iconWithStyles = pika({
|
|
46
|
-
__shortcut: 'i-mdi:home',
|
|
47
|
-
fontSize: '24px'
|
|
48
|
-
})
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Features
|
|
52
|
-
|
|
53
|
-
- 🎨 Access to 100,000+ icons from popular icon sets
|
|
54
|
-
- 🔍 Auto-installs icon collections on demand
|
|
55
|
-
- 📦 Tree-shakeable - only icons you use are included
|
|
56
|
-
- 🎯 Simple shortcut syntax with customizable prefix
|
|
57
|
-
- 🔧 Customizable icon collections
|
|
58
|
-
- ⚡ Built on top of Iconify
|
|
59
|
-
- 🎭 Supports both mask mode (for currentColor) and background mode
|
|
60
|
-
|
|
61
|
-
## Usage
|
|
62
|
-
|
|
63
|
-
### Basic Icon Usage
|
|
64
|
-
|
|
65
|
-
Icons are provided as shortcuts (default prefix is `i-`):
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
// Direct shortcut string
|
|
69
|
-
const iconClass = pika('i-mdi:home')
|
|
70
|
-
|
|
71
|
-
// Combine shortcut with styles (recommended)
|
|
72
|
-
const styledIcon = pika('i-mdi:home', {
|
|
73
|
-
fontSize: '24px',
|
|
74
|
-
color: 'blue'
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
// Or use __shortcut property
|
|
78
|
-
const iconWithStyles = pika({
|
|
79
|
-
__shortcut: 'i-mdi:home',
|
|
80
|
-
display: 'inline-block'
|
|
81
|
-
})
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### Supported Icon Collections
|
|
85
|
-
|
|
86
|
-
All Iconify icon collections are supported. Some popular ones:
|
|
87
|
-
|
|
88
|
-
- **Material Design Icons**: `mdi:*`
|
|
89
|
-
- **Heroicons**: `heroicons:*`
|
|
90
|
-
- **Bootstrap Icons**: `bi:*`
|
|
91
|
-
- **Font Awesome**: `fa:*`, `fa-solid:*`, `fa-brands:*`
|
|
92
|
-
- **Tabler Icons**: `tabler:*`
|
|
93
|
-
- **Carbon**: `carbon:*`
|
|
94
|
-
- **Phosphor**: `ph:*`
|
|
95
|
-
- **Lucide**: `lucide:*`
|
|
96
|
-
|
|
97
|
-
Browse all collections at: [Iconify Icon Sets](https://icon-sets.iconify.design/)
|
|
98
|
-
|
|
99
|
-
### Usage Examples
|
|
100
|
-
|
|
101
|
-
```typescript
|
|
102
|
-
// Simple icon
|
|
103
|
-
const homeIcon = pika('i-mdi:home')
|
|
104
|
-
|
|
105
|
-
// Icon with size and color
|
|
106
|
-
const largeIcon = pika('i-mdi:account', {
|
|
107
|
-
fontSize: '48px',
|
|
108
|
-
color: '#3b82f6'
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
// Icon with hover effect
|
|
112
|
-
const hoverIcon = pika('i-mdi:heart', {
|
|
113
|
-
fontSize: '24px',
|
|
114
|
-
color: 'red',
|
|
115
|
-
cursor: 'pointer',
|
|
116
|
-
'$:hover': {
|
|
117
|
-
transform: 'scale(1.2)'
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
// Combining multiple shortcuts
|
|
122
|
-
const buttonWithIcon = pika('btn', 'i-mdi:send', {
|
|
123
|
-
display: 'inline-flex',
|
|
124
|
-
alignItems: 'center',
|
|
125
|
-
gap: '0.5rem'
|
|
126
|
-
})
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Icon Syntax
|
|
130
|
-
|
|
131
|
-
Icons follow the pattern: `{prefix}{collection}:{icon-name}` (default prefix is `i-`)
|
|
132
|
-
|
|
133
|
-
```typescript
|
|
134
|
-
pika('i-mdi:home') // Material Design home icon
|
|
135
|
-
pika('i-heroicons:user') // Heroicons user icon
|
|
136
|
-
pika('i-carbon:cloud-upload') // Carbon cloud upload icon
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### Icon Rendering Modes
|
|
140
|
-
|
|
141
|
-
Append `?mask`, `?bg`, or `?auto` to specify the rendering mode:
|
|
142
|
-
|
|
143
|
-
```typescript
|
|
144
|
-
pika('i-mdi:home?mask') // Mask mode (uses currentColor)
|
|
145
|
-
pika('i-mdi:home?bg') // Background mode
|
|
146
|
-
pika('i-mdi:home?auto') // Auto-detect (default)
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
- **auto**: Automatically selects mask or bg based on whether icon contains `currentColor`
|
|
150
|
-
- **mask**: Icon inherits the current text color (good for monochrome icons)
|
|
151
|
-
- **bg**: Uses background-image (good for multi-colored icons)
|
|
152
|
-
|
|
153
|
-
### Customizing Icon Size and Color
|
|
154
|
-
|
|
155
|
-
Icons inherit text properties:
|
|
156
|
-
|
|
157
|
-
```typescript
|
|
158
|
-
// Using shortcut with styles
|
|
159
|
-
pika('i-mdi:home', {
|
|
160
|
-
fontSize: '32px',
|
|
161
|
-
color: '#3b82f6' // Works with mask mode
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
// Using __shortcut property
|
|
165
|
-
pika({
|
|
166
|
-
__shortcut: 'i-mdi:home',
|
|
167
|
-
fontSize: '32px',
|
|
168
|
-
color: '#3b82f6'
|
|
169
|
-
})
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
## Configuration
|
|
173
|
-
|
|
174
|
-
Configure the icons plugin using the standard plugin pattern:
|
|
175
|
-
|
|
176
|
-
```typescript
|
|
177
|
-
/// <reference path="./src/pika.gen.ts" />
|
|
178
|
-
|
|
179
|
-
import { defineEngineConfig } from '@pikacss/core'
|
|
180
|
-
import { icons } from '@pikacss/plugin-icons'
|
|
181
|
-
|
|
182
|
-
export default defineEngineConfig({
|
|
183
|
-
// 1. Register plugin in plugins array
|
|
184
|
-
plugins: [
|
|
185
|
-
icons() // Note: Call the function!
|
|
186
|
-
],
|
|
187
|
-
|
|
188
|
-
// 2. Configure at root level
|
|
189
|
-
icons: {
|
|
190
|
-
prefix: 'i-', // Shortcut prefix
|
|
191
|
-
scale: 1, // Icon scale multiplier
|
|
192
|
-
mode: 'auto', // 'auto' | 'mask' | 'bg'
|
|
193
|
-
cdn: 'https://esm.sh/', // CDN for icon collections
|
|
194
|
-
autoInstall: false, // Auto-install icon packages
|
|
195
|
-
// ... other options
|
|
196
|
-
}
|
|
197
|
-
})
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
::: tip Common Mistake
|
|
201
|
-
Always call the plugin function: `plugins: [icons()]` not `plugins: [icons]`
|
|
202
|
-
:::
|
|
203
|
-
|
|
204
|
-
### Available Options
|
|
205
|
-
|
|
206
|
-
```typescript
|
|
207
|
-
interface IconsConfig {
|
|
208
|
-
/**
|
|
209
|
-
* Icon shortcut prefix.
|
|
210
|
-
* @default 'i-'
|
|
211
|
-
*/
|
|
212
|
-
prefix?: string | string[]
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Scale factor for icons.
|
|
216
|
-
* @default 1
|
|
217
|
-
*/
|
|
218
|
-
scale?: number
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Icon rendering mode.
|
|
222
|
-
* - 'auto': Auto-detect based on currentColor
|
|
223
|
-
* - 'mask': Use mask with currentColor
|
|
224
|
-
* - 'bg': Use background image
|
|
225
|
-
* @default 'auto'
|
|
226
|
-
*/
|
|
227
|
-
mode?: 'auto' | 'mask' | 'bg'
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* CDN base URL for loading icon collections.
|
|
231
|
-
*/
|
|
232
|
-
cdn?: string
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Custom icon collections.
|
|
236
|
-
*/
|
|
237
|
-
collections?: Record<string, any>
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Auto-install icon collections from npm.
|
|
241
|
-
* @default false
|
|
242
|
-
*/
|
|
243
|
-
autoInstall?: boolean
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Unit for icon size (when specified).
|
|
247
|
-
*/
|
|
248
|
-
unit?: string
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Extra CSS properties to apply to all icons.
|
|
252
|
-
*/
|
|
253
|
-
extraProperties?: Record<string, string>
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Custom processor for icon styles.
|
|
257
|
-
*/
|
|
258
|
-
processor?: (styleItem: StyleItem, meta: IconMeta) => void
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Icons for auto-completion.
|
|
262
|
-
*/
|
|
263
|
-
autocomplete?: string[]
|
|
264
|
-
}
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
### Custom Icon Prefix
|
|
268
|
-
|
|
269
|
-
Change the shortcut prefix:
|
|
270
|
-
|
|
271
|
-
```typescript
|
|
272
|
-
export default defineEngineConfig({
|
|
273
|
-
plugins: [icons()],
|
|
274
|
-
icons: {
|
|
275
|
-
prefix: 'icon-' // Now use icon-mdi:home
|
|
276
|
-
}
|
|
277
|
-
})
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### Custom Icon Scale
|
|
281
|
-
|
|
282
|
-
Adjust the default scale of all icons:
|
|
283
|
-
|
|
284
|
-
```typescript
|
|
285
|
-
export default defineEngineConfig({
|
|
286
|
-
plugins: [icons()],
|
|
287
|
-
icons: {
|
|
288
|
-
scale: 1.2 // Make all icons 20% larger
|
|
289
|
-
}
|
|
290
|
-
})
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
## How It Works
|
|
294
|
-
|
|
295
|
-
The plugin automatically:
|
|
296
|
-
|
|
297
|
-
1. Detects icon usage in your code
|
|
298
|
-
2. Downloads the required icon collections from Iconify
|
|
299
|
-
3. Generates optimized SVG background images
|
|
300
|
-
4. Applies them using CSS custom properties
|
|
301
|
-
|
|
302
|
-
## Performance
|
|
303
|
-
|
|
304
|
-
- **On-demand loading**: Only downloads icon sets you actually use
|
|
305
|
-
- **Tree-shaking**: Only icons you reference are included in the build
|
|
306
|
-
- **Cached**: Downloaded icon collections are cached locally
|
|
307
|
-
- **Optimized SVG**: Icons are optimized for minimal file size
|
|
308
|
-
|
|
309
|
-
## Documentation
|
|
310
|
-
|
|
311
|
-
For complete documentation, visit: [PikaCSS Documentation](https://pikacss.github.io/pikacss/)
|
|
312
|
-
|
|
313
|
-
## License
|
|
314
|
-
|
|
315
|
-
MIT © DevilTea
|