@nice2dev/icons 1.0.0 → 1.0.2
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/CHANGELOG.md +169 -7
- package/README.md +247 -2
- package/bin/ntd-icons.mjs +732 -0
- package/dist/cjs/NtdIconBadge.js +375 -0
- package/dist/cjs/NtdIconBadge.js.map +1 -0
- package/dist/cjs/NtdIconMorph.js +386 -0
- package/dist/cjs/NtdIconMorph.js.map +1 -0
- package/dist/cjs/NtdStateMorph.js +177 -0
- package/dist/cjs/NtdStateMorph.js.map +1 -0
- package/dist/cjs/createIcon.js +51 -4
- package/dist/cjs/createIcon.js.map +1 -1
- package/dist/cjs/figmaSync.js +308 -0
- package/dist/cjs/figmaSync.js.map +1 -0
- package/dist/cjs/iconAnalytics.js +189 -0
- package/dist/cjs/iconAnalytics.js.map +1 -0
- package/dist/cjs/iconMetadata.js +523 -0
- package/dist/cjs/iconMetadata.js.map +1 -0
- package/dist/cjs/iconStyles.js +597 -0
- package/dist/cjs/iconStyles.js.map +1 -0
- package/dist/cjs/icons/accessibility.js +168 -0
- package/dist/cjs/icons/accessibility.js.map +1 -0
- package/dist/cjs/icons/ai.js +191 -0
- package/dist/cjs/icons/ai.js.map +1 -0
- package/dist/cjs/icons/brand.js +70 -0
- package/dist/cjs/icons/brand.js.map +1 -1
- package/dist/cjs/icons/education.js +212 -0
- package/dist/cjs/icons/education.js.map +1 -0
- package/dist/cjs/icons/food.js +198 -0
- package/dist/cjs/icons/food.js.map +1 -0
- package/dist/cjs/icons/gaming.js +191 -0
- package/dist/cjs/icons/gaming.js.map +1 -0
- package/dist/cjs/icons/index.js +520 -0
- package/dist/cjs/icons/index.js.map +1 -0
- package/dist/cjs/icons/legal.js +168 -0
- package/dist/cjs/icons/legal.js.map +1 -0
- package/dist/cjs/icons/realestate.js +212 -0
- package/dist/cjs/icons/realestate.js.map +1 -0
- package/dist/cjs/icons/science.js +201 -0
- package/dist/cjs/icons/science.js.map +1 -0
- package/dist/cjs/icons/sports.js +176 -0
- package/dist/cjs/icons/sports.js.map +1 -0
- package/dist/cjs/icons/sustainability.js +193 -0
- package/dist/cjs/icons/sustainability.js.map +1 -0
- package/dist/cjs/icons/travel.js +184 -0
- package/dist/cjs/icons/travel.js.map +1 -0
- package/dist/cjs/index.js +265 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lottieIntegration.js +286 -0
- package/dist/cjs/lottieIntegration.js.map +1 -0
- package/dist/cjs/nicetodev-icons.css +1 -1
- package/dist/cjs/particleEffects.js +259 -0
- package/dist/cjs/particleEffects.js.map +1 -0
- package/dist/cjs/resolver.js +224 -0
- package/dist/cjs/resolver.js.map +1 -0
- package/dist/cjs/tailwind-plugin.js +340 -0
- package/dist/cjs/tailwind-plugin.js.map +1 -0
- package/dist/cjs/types.js +38 -0
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/variantProps.js +78 -0
- package/dist/cjs/variantProps.js.map +1 -0
- package/dist/esm/NtdIconBadge.js +370 -0
- package/dist/esm/NtdIconBadge.js.map +1 -0
- package/dist/esm/NtdIconMorph.js +381 -0
- package/dist/esm/NtdIconMorph.js.map +1 -0
- package/dist/esm/NtdStateMorph.js +174 -0
- package/dist/esm/NtdStateMorph.js.map +1 -0
- package/dist/esm/createIcon.js +53 -6
- package/dist/esm/createIcon.js.map +1 -1
- package/dist/esm/figmaSync.js +304 -0
- package/dist/esm/figmaSync.js.map +1 -0
- package/dist/esm/iconAnalytics.js +185 -0
- package/dist/esm/iconAnalytics.js.map +1 -0
- package/dist/esm/iconMetadata.js +510 -0
- package/dist/esm/iconMetadata.js.map +1 -0
- package/dist/esm/iconStyles.js +585 -0
- package/dist/esm/iconStyles.js.map +1 -0
- package/dist/esm/icons/accessibility.js +153 -0
- package/dist/esm/icons/accessibility.js.map +1 -0
- package/dist/esm/icons/ai.js +174 -0
- package/dist/esm/icons/ai.js.map +1 -0
- package/dist/esm/icons/brand.js +67 -1
- package/dist/esm/icons/brand.js.map +1 -1
- package/dist/esm/icons/education.js +193 -0
- package/dist/esm/icons/education.js.map +1 -0
- package/dist/esm/icons/food.js +180 -0
- package/dist/esm/icons/food.js.map +1 -0
- package/dist/esm/icons/gaming.js +174 -0
- package/dist/esm/icons/gaming.js.map +1 -0
- package/dist/esm/icons/index.js +31 -0
- package/dist/esm/icons/index.js.map +1 -0
- package/dist/esm/icons/legal.js +153 -0
- package/dist/esm/icons/legal.js.map +1 -0
- package/dist/esm/icons/realestate.js +193 -0
- package/dist/esm/icons/realestate.js.map +1 -0
- package/dist/esm/icons/science.js +183 -0
- package/dist/esm/icons/science.js.map +1 -0
- package/dist/esm/icons/sports.js +160 -0
- package/dist/esm/icons/sports.js.map +1 -0
- package/dist/esm/icons/sustainability.js +176 -0
- package/dist/esm/icons/sustainability.js.map +1 -0
- package/dist/esm/icons/travel.js +167 -0
- package/dist/esm/icons/travel.js.map +1 -0
- package/dist/esm/index.js +27 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lottieIntegration.js +282 -0
- package/dist/esm/lottieIntegration.js.map +1 -0
- package/dist/esm/nicetodev-icons.css +1 -1
- package/dist/esm/particleEffects.js +257 -0
- package/dist/esm/particleEffects.js.map +1 -0
- package/dist/esm/resolver.js +221 -0
- package/dist/esm/resolver.js.map +1 -0
- package/dist/esm/tailwind-plugin.js +337 -0
- package/dist/esm/tailwind-plugin.js.map +1 -0
- package/dist/esm/types.js +37 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/variantProps.js +68 -0
- package/dist/esm/variantProps.js.map +1 -0
- package/dist/types/NtdIconBadge.d.ts +209 -0
- package/dist/types/NtdIconMorph.d.ts +183 -0
- package/dist/types/NtdStateMorph.d.ts +100 -0
- package/dist/types/client.d.ts +27 -0
- package/dist/types/design-tokens.d.ts +281 -0
- package/dist/types/figmaSync.d.ts +135 -0
- package/dist/types/headless-ui.d.ts +462 -0
- package/dist/types/iconAnalytics.d.ts +131 -0
- package/dist/types/iconMetadata.d.ts +123 -0
- package/dist/types/iconStyles.d.ts +104 -0
- package/dist/types/icons/accessibility.d.ts +39 -0
- package/dist/types/icons/ai.d.ts +43 -0
- package/dist/types/icons/brand.d.ts +4 -0
- package/dist/types/icons/education.d.ts +47 -0
- package/dist/types/icons/food.d.ts +45 -0
- package/dist/types/icons/gaming.d.ts +42 -0
- package/dist/types/icons/index.d.ts +12 -1
- package/dist/types/icons/legal.d.ts +39 -0
- package/dist/types/icons/realestate.d.ts +47 -0
- package/dist/types/icons/science.d.ts +45 -0
- package/dist/types/icons/sports.d.ts +41 -0
- package/dist/types/icons/sustainability.d.ts +43 -0
- package/dist/types/icons/travel.d.ts +43 -0
- package/dist/types/index.d.ts +28 -6
- package/dist/types/lottieIntegration.d.ts +173 -0
- package/dist/types/micro-interactions.d.ts +146 -0
- package/dist/types/microInteractions.d.ts +174 -0
- package/dist/types/particleEffects.d.ts +69 -0
- package/dist/types/resolver.d.ts +58 -0
- package/dist/types/rsc.d.ts +159 -0
- package/dist/types/tailwind-plugin.d.ts +100 -0
- package/dist/types/types.d.ts +100 -0
- package/dist/types/utilities.d.ts +221 -0
- package/dist/types/variantProps.d.ts +122 -0
- package/package.json +58 -5
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file microInteractions.tsx
|
|
3
|
+
* @description Micro-interactions library for icons
|
|
4
|
+
*
|
|
5
|
+
* Provides hover, click, and focus effects for icons with 20+ presets.
|
|
6
|
+
*
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
* @since 2026-03
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import type { NtdIconProps } from './types';
|
|
13
|
+
/** Hover effect presets */
|
|
14
|
+
export type HoverEffect = 'lift' | 'grow' | 'shrink' | 'rotate' | 'spin' | 'wobble' | 'pulse' | 'bounce' | 'shake' | 'flip' | 'tilt-left' | 'tilt-right' | 'glow' | 'shadow' | 'color-shift' | 'invert' | 'blur-in' | 'none';
|
|
15
|
+
/** Click effect presets */
|
|
16
|
+
export type ClickEffect = 'ripple' | 'pop' | 'push' | 'rubber' | 'jello' | 'heartbeat' | 'flash' | 'tada' | 'squeeze' | 'none';
|
|
17
|
+
/** Focus effect presets */
|
|
18
|
+
export type FocusEffect = 'glow' | 'ring' | 'outline' | 'pulse' | 'highlight' | 'none';
|
|
19
|
+
/** Props for NtdInteractiveIcon */
|
|
20
|
+
export interface NtdInteractiveIconProps extends Omit<NtdIconProps, 'ref'> {
|
|
21
|
+
/** The icon component to render */
|
|
22
|
+
icon: React.ComponentType<NtdIconProps>;
|
|
23
|
+
/** Effect on hover */
|
|
24
|
+
hoverEffect?: HoverEffect;
|
|
25
|
+
/** Effect on click */
|
|
26
|
+
clickEffect?: ClickEffect;
|
|
27
|
+
/** Effect on focus */
|
|
28
|
+
focusEffect?: FocusEffect;
|
|
29
|
+
/** Duration of hover effect in ms */
|
|
30
|
+
hoverDuration?: number;
|
|
31
|
+
/** Duration of click effect in ms */
|
|
32
|
+
clickDuration?: number;
|
|
33
|
+
/** Custom hover styles */
|
|
34
|
+
hoverStyle?: React.CSSProperties;
|
|
35
|
+
/** Custom click styles */
|
|
36
|
+
clickStyle?: React.CSSProperties;
|
|
37
|
+
/** Easing function */
|
|
38
|
+
easing?: string;
|
|
39
|
+
/** Callback on hover start */
|
|
40
|
+
onHoverStart?: () => void;
|
|
41
|
+
/** Callback on hover end */
|
|
42
|
+
onHoverEnd?: () => void;
|
|
43
|
+
/** Callback on click animation complete */
|
|
44
|
+
onClickComplete?: () => void;
|
|
45
|
+
/** Disable all interactions */
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
/** Tabindex for focus */
|
|
48
|
+
tabIndex?: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* NtdInteractiveIcon - Icon with micro-interactions
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```tsx
|
|
55
|
+
* <NtdInteractiveIcon
|
|
56
|
+
* icon={NtdHeart}
|
|
57
|
+
* hoverEffect="lift"
|
|
58
|
+
* clickEffect="pop"
|
|
59
|
+
* focusEffect="glow"
|
|
60
|
+
* />
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare const NtdInteractiveIcon: React.ForwardRefExoticComponent<NtdInteractiveIconProps & React.RefAttributes<HTMLSpanElement>>;
|
|
64
|
+
/** Preset interaction configurations */
|
|
65
|
+
export declare const interactionPresets: {
|
|
66
|
+
/** Subtle lift on hover */
|
|
67
|
+
subtle: {
|
|
68
|
+
hoverEffect: HoverEffect;
|
|
69
|
+
clickEffect: ClickEffect;
|
|
70
|
+
focusEffect: FocusEffect;
|
|
71
|
+
};
|
|
72
|
+
/** Playful bouncy interactions */
|
|
73
|
+
playful: {
|
|
74
|
+
hoverEffect: HoverEffect;
|
|
75
|
+
clickEffect: ClickEffect;
|
|
76
|
+
focusEffect: FocusEffect;
|
|
77
|
+
};
|
|
78
|
+
/** Professional, minimal */
|
|
79
|
+
professional: {
|
|
80
|
+
hoverEffect: HoverEffect;
|
|
81
|
+
clickEffect: ClickEffect;
|
|
82
|
+
focusEffect: FocusEffect;
|
|
83
|
+
};
|
|
84
|
+
/** Fun, energetic */
|
|
85
|
+
energetic: {
|
|
86
|
+
hoverEffect: HoverEffect;
|
|
87
|
+
clickEffect: ClickEffect;
|
|
88
|
+
focusEffect: FocusEffect;
|
|
89
|
+
};
|
|
90
|
+
/** Material Design style */
|
|
91
|
+
material: {
|
|
92
|
+
hoverEffect: HoverEffect;
|
|
93
|
+
clickEffect: ClickEffect;
|
|
94
|
+
focusEffect: FocusEffect;
|
|
95
|
+
};
|
|
96
|
+
/** Elastic, rubbery feel */
|
|
97
|
+
elastic: {
|
|
98
|
+
hoverEffect: HoverEffect;
|
|
99
|
+
clickEffect: ClickEffect;
|
|
100
|
+
focusEffect: FocusEffect;
|
|
101
|
+
};
|
|
102
|
+
/** Attention-grabbing */
|
|
103
|
+
attention: {
|
|
104
|
+
hoverEffect: HoverEffect;
|
|
105
|
+
clickEffect: ClickEffect;
|
|
106
|
+
focusEffect: FocusEffect;
|
|
107
|
+
};
|
|
108
|
+
/** Notification/alert style */
|
|
109
|
+
alert: {
|
|
110
|
+
hoverEffect: HoverEffect;
|
|
111
|
+
clickEffect: ClickEffect;
|
|
112
|
+
focusEffect: FocusEffect;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
export interface UseMicroInteractionOptions {
|
|
116
|
+
hoverEffect?: HoverEffect;
|
|
117
|
+
clickEffect?: ClickEffect;
|
|
118
|
+
focusEffect?: FocusEffect;
|
|
119
|
+
hoverDuration?: number;
|
|
120
|
+
clickDuration?: number;
|
|
121
|
+
disabled?: boolean;
|
|
122
|
+
}
|
|
123
|
+
export interface UseMicroInteractionReturn {
|
|
124
|
+
isHovered: boolean;
|
|
125
|
+
isClicking: boolean;
|
|
126
|
+
isFocused: boolean;
|
|
127
|
+
handlers: {
|
|
128
|
+
onMouseEnter: () => void;
|
|
129
|
+
onMouseLeave: () => void;
|
|
130
|
+
onClick: () => void;
|
|
131
|
+
onFocus: () => void;
|
|
132
|
+
onBlur: () => void;
|
|
133
|
+
};
|
|
134
|
+
style: React.CSSProperties;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Hook for adding micro-interactions to any element
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```tsx
|
|
141
|
+
* const { handlers, style } = useMicroInteraction({
|
|
142
|
+
* hoverEffect: 'lift',
|
|
143
|
+
* clickEffect: 'pop',
|
|
144
|
+
* });
|
|
145
|
+
*
|
|
146
|
+
* return <div {...handlers} style={style}>Content</div>;
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
export declare function useMicroInteraction(options?: UseMicroInteractionOptions): UseMicroInteractionReturn;
|
|
150
|
+
/** Props for quick effect wrappers */
|
|
151
|
+
interface QuickEffectProps {
|
|
152
|
+
children: React.ReactNode;
|
|
153
|
+
duration?: number;
|
|
154
|
+
disabled?: boolean;
|
|
155
|
+
className?: string;
|
|
156
|
+
style?: React.CSSProperties;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Quick hover lift effect wrapper
|
|
160
|
+
*/
|
|
161
|
+
export declare function HoverLift({ children, duration, disabled, className, style }: QuickEffectProps): import("react/jsx-runtime").JSX.Element;
|
|
162
|
+
/**
|
|
163
|
+
* Quick click pop effect wrapper
|
|
164
|
+
*/
|
|
165
|
+
export declare function ClickPop({ children, duration, disabled, className, style }: QuickEffectProps): import("react/jsx-runtime").JSX.Element;
|
|
166
|
+
/**
|
|
167
|
+
* Quick ripple effect wrapper
|
|
168
|
+
*/
|
|
169
|
+
export declare function ClickRipple({ children, duration, disabled, className, style }: QuickEffectProps): import("react/jsx-runtime").JSX.Element;
|
|
170
|
+
/**
|
|
171
|
+
* Quick focus glow effect wrapper
|
|
172
|
+
*/
|
|
173
|
+
export declare function FocusGlow({ children, disabled, className, style }: QuickEffectProps): import("react/jsx-runtime").JSX.Element;
|
|
174
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file particleEffects.tsx
|
|
3
|
+
* @description Canvas-based particle effects triggered from icon interactions.
|
|
4
|
+
*
|
|
5
|
+
* - Confetti burst on success
|
|
6
|
+
* - Sparkles trailing
|
|
7
|
+
* - Smoke/dust on remove
|
|
8
|
+
* - Fully canvas-based for performance
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* // Confetti burst on click
|
|
13
|
+
* <NtdParticleIcon icon={NtdCheck} particle="confetti" trigger="click" size="lg" />
|
|
14
|
+
*
|
|
15
|
+
* // Sparkles trailing on hover
|
|
16
|
+
* <NtdParticleIcon icon={NtdStar} particle="sparkles" trigger="hover" />
|
|
17
|
+
*
|
|
18
|
+
* // Smoke on unmount/remove
|
|
19
|
+
* <NtdParticleIcon icon={NtdTrash} particle="smoke" trigger="click" />
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import React, { ComponentType } from 'react';
|
|
23
|
+
import type { NtdIconProps, IconSize } from './types';
|
|
24
|
+
/** Predefined particle effect presets. */
|
|
25
|
+
export type ParticlePreset = 'confetti' | 'sparkles' | 'smoke' | 'dust' | 'firework' | 'hearts' | 'stars';
|
|
26
|
+
/** Low-level particle configuration. */
|
|
27
|
+
export interface ParticleConfig {
|
|
28
|
+
/** Number of particles to emit */
|
|
29
|
+
count: number;
|
|
30
|
+
/** Particle lifetime in ms */
|
|
31
|
+
lifetime: number;
|
|
32
|
+
/** Particle shapes */
|
|
33
|
+
shapes: ('circle' | 'rect' | 'triangle' | 'star')[];
|
|
34
|
+
/** Colors (randomly picked) */
|
|
35
|
+
colors: string[];
|
|
36
|
+
/** Min/max particle size in px */
|
|
37
|
+
sizeRange: [number, number];
|
|
38
|
+
/** Initial velocity range */
|
|
39
|
+
velocityRange: [number, number];
|
|
40
|
+
/** Gravity (px/s²). Positive = downward */
|
|
41
|
+
gravity: number;
|
|
42
|
+
/** Spread angle in degrees (360 = omnidirectional) */
|
|
43
|
+
spread: number;
|
|
44
|
+
/** Opacity decay (1 = fade out completely) */
|
|
45
|
+
fadeOut: number;
|
|
46
|
+
/** Rotation speed range (deg/frame) */
|
|
47
|
+
rotationRange: [number, number];
|
|
48
|
+
}
|
|
49
|
+
export interface NtdParticleIconProps {
|
|
50
|
+
/** Icon component to render */
|
|
51
|
+
icon: ComponentType<NtdIconProps>;
|
|
52
|
+
/** Particle effect preset or custom config */
|
|
53
|
+
particle: ParticlePreset | ParticleConfig;
|
|
54
|
+
/** When to trigger the effect */
|
|
55
|
+
trigger?: 'click' | 'hover' | 'mount' | 'manual';
|
|
56
|
+
/** Manual trigger (when trigger='manual') */
|
|
57
|
+
active?: boolean;
|
|
58
|
+
/** Icon size */
|
|
59
|
+
size?: IconSize;
|
|
60
|
+
/** Icon props to pass through */
|
|
61
|
+
iconProps?: Partial<NtdIconProps>;
|
|
62
|
+
/** Additional class */
|
|
63
|
+
className?: string;
|
|
64
|
+
/** Additional styles */
|
|
65
|
+
style?: React.CSSProperties;
|
|
66
|
+
/** Callback when effect completes */
|
|
67
|
+
onEffectEnd?: () => void;
|
|
68
|
+
}
|
|
69
|
+
export declare const NtdParticleIcon: React.ForwardRefExoticComponent<NtdParticleIconProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* resolver.ts — Integration with @nice2dev/ui NiceIconProvider.
|
|
3
|
+
*
|
|
4
|
+
* Creates a resolver function that maps NiceIcon name strings
|
|
5
|
+
* to @nice2dev/icons React components.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { NiceIconProvider } from '@nice2dev/ui';
|
|
10
|
+
* import { createNiceIconResolver } from '@nice2dev/icons';
|
|
11
|
+
*
|
|
12
|
+
* <NiceIconProvider resolver={createNiceIconResolver()}>
|
|
13
|
+
* <App />
|
|
14
|
+
* </NiceIconProvider>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import type { NtdIconProps, IconVariant } from './types';
|
|
19
|
+
export interface NiceIconResolverOptions {
|
|
20
|
+
/** Default icon variant (default: 'outline') */
|
|
21
|
+
variant?: IconVariant;
|
|
22
|
+
/** Default primary color (default: 'currentColor') */
|
|
23
|
+
primaryColor?: string;
|
|
24
|
+
/** Default secondary color for duotone (default: undefined) */
|
|
25
|
+
secondaryColor?: string;
|
|
26
|
+
/** Custom name mappings to extend or override defaults */
|
|
27
|
+
customMappings?: Record<string, string>;
|
|
28
|
+
/** Fallback component if icon name is not found */
|
|
29
|
+
fallback?: React.ComponentType<NtdIconProps>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Creates a resolver function compatible with NiceIconProvider from @nice2dev/ui.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* import { NiceIconProvider } from '@nice2dev/ui';
|
|
37
|
+
* import { createNiceIconResolver } from '@nice2dev/icons';
|
|
38
|
+
*
|
|
39
|
+
* // Basic usage
|
|
40
|
+
* <NiceIconProvider resolver={createNiceIconResolver()}>
|
|
41
|
+
* <NiceIcon name="home" size="lg" />
|
|
42
|
+
* </NiceIconProvider>
|
|
43
|
+
*
|
|
44
|
+
* // With options
|
|
45
|
+
* <NiceIconProvider resolver={createNiceIconResolver({
|
|
46
|
+
* variant: 'duotone',
|
|
47
|
+
* primaryColor: '#3b82f6',
|
|
48
|
+
* secondaryColor: '#e0e7ff',
|
|
49
|
+
* })}>
|
|
50
|
+
* <App />
|
|
51
|
+
* </NiceIconProvider>
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function createNiceIconResolver(options?: NiceIconResolverOptions): (name: string, size: number) => React.ReactNode | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Get a list of all available icon names that can be resolved.
|
|
57
|
+
*/
|
|
58
|
+
export declare function getResolverIconNames(): string[];
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file rsc.tsx
|
|
3
|
+
* @description React Server Components compatible exports
|
|
4
|
+
*
|
|
5
|
+
* This module provides server-renderable icon components that work
|
|
6
|
+
* without client-side JavaScript. For interactive features (animations,
|
|
7
|
+
* color scheme detection), use the main exports with "use client".
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* // In a Server Component
|
|
12
|
+
* import { NtdHomeRSC } from '@nice2dev/icons/rsc';
|
|
13
|
+
*
|
|
14
|
+
* export default function Page() {
|
|
15
|
+
* return <NtdHomeRSC size="md" variant="solid" primaryColor="#3b82f6" />;
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @version 1.0.0
|
|
20
|
+
* @since 2026-03
|
|
21
|
+
* @license MIT
|
|
22
|
+
*/
|
|
23
|
+
import type { IconVariant, GradientPreset, SemanticColor } from './types';
|
|
24
|
+
import { SIZE_MAP, GRADIENT_PRESETS, SEMANTIC_COLOR_DEFAULTS } from './types';
|
|
25
|
+
/**
|
|
26
|
+
* Props for RSC-compatible icons (subset of full NtdIconProps).
|
|
27
|
+
* Excludes client-only features like animations and color scheme detection.
|
|
28
|
+
*/
|
|
29
|
+
export interface NtdIconRSCProps {
|
|
30
|
+
/** Icon size preset or custom pixel value */
|
|
31
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number;
|
|
32
|
+
/** Icon rendering variant */
|
|
33
|
+
variant?: IconVariant;
|
|
34
|
+
/** Primary icon color */
|
|
35
|
+
primaryColor?: string;
|
|
36
|
+
/** Secondary color (for duotone/flat variants) */
|
|
37
|
+
secondaryColor?: string;
|
|
38
|
+
/** Accent color (for complex icons) */
|
|
39
|
+
accentColor?: string;
|
|
40
|
+
/** Secondary opacity for duotone variant */
|
|
41
|
+
secondaryOpacity?: number;
|
|
42
|
+
/** Stroke width for outline variant */
|
|
43
|
+
strokeWidth?: number;
|
|
44
|
+
/** Gradient preset name */
|
|
45
|
+
gradient?: GradientPreset;
|
|
46
|
+
/** Gradient direction (angle in degrees) */
|
|
47
|
+
gradientDirection?: number;
|
|
48
|
+
/** Semantic color preset */
|
|
49
|
+
color?: SemanticColor;
|
|
50
|
+
/** CSS transform: rotate */
|
|
51
|
+
rotate?: number;
|
|
52
|
+
/** CSS transform: flipX */
|
|
53
|
+
flipX?: boolean;
|
|
54
|
+
/** CSS transform: flipY */
|
|
55
|
+
flipY?: boolean;
|
|
56
|
+
/** CSS transform: scale */
|
|
57
|
+
scale?: number;
|
|
58
|
+
/** Additional class name */
|
|
59
|
+
className?: string;
|
|
60
|
+
/** Inline styles */
|
|
61
|
+
style?: React.CSSProperties;
|
|
62
|
+
/** Accessibility: aria-label */
|
|
63
|
+
'aria-label'?: string;
|
|
64
|
+
/** Accessibility: aria-hidden */
|
|
65
|
+
'aria-hidden'?: boolean;
|
|
66
|
+
/** Title for accessibility */
|
|
67
|
+
title?: string;
|
|
68
|
+
/** Role attribute */
|
|
69
|
+
role?: string;
|
|
70
|
+
/** Test ID for testing */
|
|
71
|
+
'data-testid'?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Icon render props passed to path renderers
|
|
75
|
+
*/
|
|
76
|
+
export interface IconRenderPropsRSC {
|
|
77
|
+
primaryColor: string;
|
|
78
|
+
secondaryColor: string;
|
|
79
|
+
accentColor: string;
|
|
80
|
+
secondaryOpacity: number;
|
|
81
|
+
strokeWidth: number;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Path renderer function type
|
|
85
|
+
*/
|
|
86
|
+
export type IconPathRendererRSC = (props: IconRenderPropsRSC) => React.ReactNode;
|
|
87
|
+
/**
|
|
88
|
+
* Options for createIconRSC factory
|
|
89
|
+
*/
|
|
90
|
+
export interface CreateIconRSCOptions {
|
|
91
|
+
displayName: string;
|
|
92
|
+
viewBox?: string;
|
|
93
|
+
paths: {
|
|
94
|
+
solid: IconPathRendererRSC;
|
|
95
|
+
outline: IconPathRendererRSC;
|
|
96
|
+
duotone: IconPathRendererRSC;
|
|
97
|
+
flat: IconPathRendererRSC;
|
|
98
|
+
sharp?: IconPathRendererRSC;
|
|
99
|
+
rounded?: IconPathRendererRSC;
|
|
100
|
+
mini?: IconPathRendererRSC;
|
|
101
|
+
'3d'?: IconPathRendererRSC;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Creates a React Server Component compatible icon.
|
|
106
|
+
*
|
|
107
|
+
* Unlike the standard `createIcon`, this version:
|
|
108
|
+
* - Does NOT use React hooks (useId, useSyncExternalStore, etc.)
|
|
109
|
+
* - Does NOT support animations
|
|
110
|
+
* - Does NOT support automatic dark/light mode detection
|
|
111
|
+
* - IS fully streamable and SSR-safe
|
|
112
|
+
*
|
|
113
|
+
* @param options - Icon configuration
|
|
114
|
+
* @returns A React function component (not using forwardRef)
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```tsx
|
|
118
|
+
* export const NtdHomeRSC = createIconRSC({
|
|
119
|
+
* displayName: 'NtdHomeRSC',
|
|
120
|
+
* paths: {
|
|
121
|
+
* solid: ({ primaryColor }) => <path d="..." fill={primaryColor} />,
|
|
122
|
+
* outline: ({ primaryColor, strokeWidth }) => <path d="..." stroke={primaryColor} />,
|
|
123
|
+
* duotone: ({ primaryColor, secondaryColor }) => <path d="..." />,
|
|
124
|
+
* flat: ({ primaryColor, secondaryColor }) => <path d="..." />,
|
|
125
|
+
* },
|
|
126
|
+
* });
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
export declare function createIconRSC(options: CreateIconRSCOptions): {
|
|
130
|
+
(props: NtdIconRSCProps): import("react/jsx-runtime").JSX.Element;
|
|
131
|
+
displayName: string;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Renders an icon to a static SVG string (for streaming/SSR).
|
|
135
|
+
* Useful for generating static assets or email templates.
|
|
136
|
+
*/
|
|
137
|
+
export declare function renderIconToString(Icon: ReturnType<typeof createIconRSC>, props?: NtdIconRSCProps): string;
|
|
138
|
+
/**
|
|
139
|
+
* Type guard to check if a component is an RSC-compatible icon
|
|
140
|
+
*/
|
|
141
|
+
export declare function isRSCIcon(component: unknown): component is ReturnType<typeof createIconRSC>;
|
|
142
|
+
/**
|
|
143
|
+
* Creates an RSC version from an existing icon's path config.
|
|
144
|
+
* This allows creating RSC-compatible versions from standard icons.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```tsx
|
|
148
|
+
* import { NtdHome } from '@nice2dev/icons';
|
|
149
|
+
* import { wrapAsRSC } from '@nice2dev/icons/rsc';
|
|
150
|
+
*
|
|
151
|
+
* // Note: This requires access to the original path config
|
|
152
|
+
* const NtdHomeRSC = wrapAsRSC(NtdHome);
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export declare function wrapAsRSC<T extends {
|
|
156
|
+
displayName?: string;
|
|
157
|
+
}>(originalPaths: CreateIconRSCOptions['paths'], displayName: string): ReturnType<typeof createIconRSC>;
|
|
158
|
+
export { SIZE_MAP, GRADIENT_PRESETS, SEMANTIC_COLOR_DEFAULTS };
|
|
159
|
+
export type { IconVariant, GradientPreset, SemanticColor } from './types';
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file tailwind-plugin.ts
|
|
3
|
+
* @description Tailwind CSS Plugin for @nice2dev/icons
|
|
4
|
+
*
|
|
5
|
+
* Enables Tailwind CSS utility classes directly on NiceToDev icons:
|
|
6
|
+
* <NtdHome className="text-blue-500 w-6 h-6 hover:text-blue-700" />
|
|
7
|
+
*
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
* @since 2026-03
|
|
10
|
+
* @license MIT
|
|
11
|
+
*/
|
|
12
|
+
type PluginAPI = {
|
|
13
|
+
addUtilities: (utilities: Record<string, Record<string, string | number>>) => void;
|
|
14
|
+
addComponents: (components: Record<string, unknown>) => void;
|
|
15
|
+
theme: (path: string) => Record<string, string>;
|
|
16
|
+
matchUtilities: (utilities: Record<string, (value: string) => Record<string, string>>, options: {
|
|
17
|
+
values: Record<string, string>;
|
|
18
|
+
}) => void;
|
|
19
|
+
};
|
|
20
|
+
export interface NtdTailwindPluginOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Prefix for icon-specific utilities
|
|
23
|
+
* @default 'ntd-icon'
|
|
24
|
+
*/
|
|
25
|
+
prefix?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Custom icon sizes
|
|
28
|
+
* @default { xs: '0.75rem', sm: '1rem', md: '1.5rem', lg: '2rem', xl: '3rem', '2xl': '4rem' }
|
|
29
|
+
*/
|
|
30
|
+
sizes?: Record<string, string>;
|
|
31
|
+
/**
|
|
32
|
+
* Enable animation utilities
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
animations?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Enable variant-specific utilities (solid, outline, duotone, flat)
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
variantUtilities?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Tailwind CSS Plugin for NiceToDev Icons
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // tailwind.config.js
|
|
47
|
+
* import { ntdIconPlugin } from '@nice2dev/icons/tailwind';
|
|
48
|
+
*
|
|
49
|
+
* export default {
|
|
50
|
+
* plugins: [
|
|
51
|
+
* ntdIconPlugin({
|
|
52
|
+
* prefix: 'ntd-icon',
|
|
53
|
+
* animations: true,
|
|
54
|
+
* }),
|
|
55
|
+
* ],
|
|
56
|
+
* };
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // Usage in components
|
|
60
|
+
* <NtdHome className="ntd-icon-md text-blue-500 hover:ntd-icon-bounce" />
|
|
61
|
+
* <NtdStar className="ntd-icon-lg ntd-icon-spin text-yellow-400" />
|
|
62
|
+
*/
|
|
63
|
+
export declare const ntdIconPlugin: (options?: NtdTailwindPluginOptions) => ({ addUtilities, addComponents, theme, matchUtilities }: PluginAPI) => void;
|
|
64
|
+
/**
|
|
65
|
+
* Plugin configuration for extending Tailwind theme
|
|
66
|
+
*/
|
|
67
|
+
export declare const ntdIconPluginConfig: {
|
|
68
|
+
theme: {
|
|
69
|
+
extend: {
|
|
70
|
+
spacing: {
|
|
71
|
+
'icon-xs': string;
|
|
72
|
+
'icon-sm': string;
|
|
73
|
+
'icon-md': string;
|
|
74
|
+
'icon-lg': string;
|
|
75
|
+
'icon-xl': string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Preset for common icon configurations
|
|
82
|
+
*/
|
|
83
|
+
export declare const ntdIconPreset: {
|
|
84
|
+
theme: {
|
|
85
|
+
extend: {
|
|
86
|
+
colors: {
|
|
87
|
+
ntd: {
|
|
88
|
+
primary: string;
|
|
89
|
+
secondary: string;
|
|
90
|
+
accent: string;
|
|
91
|
+
success: string;
|
|
92
|
+
warning: string;
|
|
93
|
+
error: string;
|
|
94
|
+
info: string;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
export default ntdIconPlugin;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -74,6 +74,38 @@ export type GradientPreset = 'sunset' | 'ocean' | 'forest' | 'fire' | 'ice' | 'n
|
|
|
74
74
|
export type GradientType = 'linear' | 'radial';
|
|
75
75
|
/** Gradient animation style. */
|
|
76
76
|
export type GradientAnimation = 'shift' | 'spin' | 'pulse';
|
|
77
|
+
/**
|
|
78
|
+
* Semantic color variant for contextual icons.
|
|
79
|
+
*
|
|
80
|
+
* Each maps to a CSS variable (e.g., `--ntd-icon-success`) with sensible defaults.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
84
|
+
* <NtdCheck color="success" /> // Green checkmark
|
|
85
|
+
* <NtdWarning color="warning" /> // Amber warning
|
|
86
|
+
* <NtdError color="error" /> // Red error
|
|
87
|
+
* <NtdInfo color="info" /> // Blue info
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export type SemanticColor = 'success' | 'warning' | 'error' | 'info' | 'muted' | 'primary' | 'secondary' | 'accent';
|
|
91
|
+
/**
|
|
92
|
+
* Default colors for semantic color variants.
|
|
93
|
+
* These are used when CSS variables are not defined.
|
|
94
|
+
*/
|
|
95
|
+
export declare const SEMANTIC_COLOR_DEFAULTS: Record<SemanticColor, string>;
|
|
96
|
+
/**
|
|
97
|
+
* CSS variable names for semantic colors.
|
|
98
|
+
* Define these in your CSS to customize icon colors globally.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```css
|
|
102
|
+
* :root {
|
|
103
|
+
* --ntd-icon-success: #10b981;
|
|
104
|
+
* --ntd-icon-error: #dc2626;
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export declare const SEMANTIC_COLOR_VARS: Record<SemanticColor, string>;
|
|
77
109
|
/** Gradient preset color stops. */
|
|
78
110
|
export declare const GRADIENT_PRESETS: Record<GradientPreset, readonly string[]>;
|
|
79
111
|
/**
|
|
@@ -99,6 +131,39 @@ export interface NtdIconProps extends Omit<SVGProps<SVGSVGElement>, 'ref'> {
|
|
|
99
131
|
size?: IconSize;
|
|
100
132
|
/** Rendering variant */
|
|
101
133
|
variant?: IconVariant;
|
|
134
|
+
/**
|
|
135
|
+
* Semantic color for the icon.
|
|
136
|
+
* Uses CSS variables with fallback to defaults.
|
|
137
|
+
* Overrides `primaryColor` when specified.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```tsx
|
|
141
|
+
* <NtdCheck color="success" /> // Green
|
|
142
|
+
* <NtdWarning color="warning" /> // Amber
|
|
143
|
+
* <NtdError color="error" /> // Red
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
color?: SemanticColor;
|
|
147
|
+
/**
|
|
148
|
+
* Color to use in light mode (when `prefers-color-scheme: light`).
|
|
149
|
+
* Must be used together with `darkColor` for automatic switching.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```tsx
|
|
153
|
+
* <NtdHome lightColor="#1f2937" darkColor="#f9fafb" />
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
lightColor?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Color to use in dark mode (when `prefers-color-scheme: dark`).
|
|
159
|
+
* Must be used together with `lightColor` for automatic switching.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```tsx
|
|
163
|
+
* <NtdHome lightColor="#1f2937" darkColor="#f9fafb" />
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
darkColor?: string;
|
|
102
167
|
/** Primary (main) color */
|
|
103
168
|
primaryColor?: string;
|
|
104
169
|
/** Secondary color — used in duotone variant */
|
|
@@ -139,6 +204,41 @@ export interface NtdIconProps extends Omit<SVGProps<SVGSVGElement>, 'ref'> {
|
|
|
139
204
|
gradientAngle?: number;
|
|
140
205
|
/** Animate the gradient. */
|
|
141
206
|
gradientAnimation?: GradientAnimation;
|
|
207
|
+
/**
|
|
208
|
+
* Rotate the icon by specified degrees.
|
|
209
|
+
* @example `rotate={90}` — rotate 90° clockwise
|
|
210
|
+
* @example `rotate={-45}` — rotate 45° counter-clockwise
|
|
211
|
+
*/
|
|
212
|
+
rotate?: number;
|
|
213
|
+
/**
|
|
214
|
+
* Flip the icon horizontally (mirror on Y axis).
|
|
215
|
+
* @example `flipX` — mirrors the icon left-to-right
|
|
216
|
+
*/
|
|
217
|
+
flipX?: boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Flip the icon vertically (mirror on X axis).
|
|
220
|
+
* @example `flipY` — mirrors the icon top-to-bottom
|
|
221
|
+
*/
|
|
222
|
+
flipY?: boolean;
|
|
223
|
+
/**
|
|
224
|
+
* Scale the icon by a factor.
|
|
225
|
+
* @example `scale={1.5}` — 150% size
|
|
226
|
+
* @example `scale={0.75}` — 75% size
|
|
227
|
+
*/
|
|
228
|
+
scale?: number;
|
|
229
|
+
/**
|
|
230
|
+
* Animate transform changes with CSS transition.
|
|
231
|
+
* Can be `true` for default (0.3s ease), or a custom CSS transition value.
|
|
232
|
+
* @example `transition` — default animation
|
|
233
|
+
* @example `transition="0.5s cubic-bezier(0.4, 0, 0.2, 1)"` — custom
|
|
234
|
+
*/
|
|
235
|
+
transition?: boolean | string;
|
|
236
|
+
/**
|
|
237
|
+
* Transform origin for rotate/scale/flip operations.
|
|
238
|
+
* @default 'center center'
|
|
239
|
+
* @example `transformOrigin="top left"`
|
|
240
|
+
*/
|
|
241
|
+
transformOrigin?: string;
|
|
142
242
|
/** Accessible title for screen readers */
|
|
143
243
|
title?: string;
|
|
144
244
|
}
|