viconic-react-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/README.md +70 -0
- package/dist/index.js +2 -3
- package/dist/index.mjs +2 -3
- package/index.d.ts +12 -0
- package/package.json +3 -2
- package/src/index.jsx +3 -4
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Viconic React Icons
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
The official React component wrapper for [Viconic](https://viconic.io.vn), a modern, hyper-fast, CDN-powered icon system.
|
|
7
|
+
|
|
8
|
+
`viconic-react-icons` gives you access to over 200,000+ open-source, pixel-perfect icons grouped in customizable collections. The icons are loaded dynamically from our Smart CDN at runtime, meaning your React bundle stays incredibly lightweight regardless of how many icons you use.
|
|
9
|
+
|
|
10
|
+
## Highlights
|
|
11
|
+
- ? **Zero-Bundle Bloat**: SVGs are fetched magically via our CDN and injected directly into the DOM.
|
|
12
|
+
- ?? **Fully Customizable**: Compatible with Tailwind CSS and standard inline styles. Inherits color natively via `currentColor`.
|
|
13
|
+
- ?? **Smart Caching**: LocalStorage and Memory caching so icons appear instantly on repeated renders.
|
|
14
|
+
- ?? **SSR Ready**: Fully supports Next.js, Vite, and other Server-Side Rendering frameworks.
|
|
15
|
+
- ?? **TypeScript Support**: Includes built-in types for easy autocompletion.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install viconic-react-icons
|
|
21
|
+
# or
|
|
22
|
+
yarn add viconic-react-icons
|
|
23
|
+
# or
|
|
24
|
+
pnpm add viconic-react-icons
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
Import the `ViconicIcon` component and pass the unique `name` identifier corresponding to your icon of choice from [viconic.io.vn](https://viconic.io.vn).
|
|
30
|
+
|
|
31
|
+
```jsx
|
|
32
|
+
import { ViconicIcon } from "viconic-react-icons";
|
|
33
|
+
|
|
34
|
+
function App() {
|
|
35
|
+
return (
|
|
36
|
+
<div style={{ display: "flex", gap: "10px" }}>
|
|
37
|
+
{/* Basic Usage */}
|
|
38
|
+
<ViconicIcon name="h2:0" />
|
|
39
|
+
|
|
40
|
+
{/* With Tailwind CSS */}
|
|
41
|
+
<ViconicIcon name="lucide:home" className="w-8 h-8 text-blue-500" />
|
|
42
|
+
|
|
43
|
+
{/* With standard inline styles */}
|
|
44
|
+
<ViconicIcon name="fa:solid:user" style={{ fontSize: "32px", color: "green" }} />
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default App;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Props
|
|
53
|
+
|
|
54
|
+
| Prop | Type | Default | Description |
|
|
55
|
+
| ---- | ---- | ------- | ----------- |
|
|
56
|
+
| `name` | `string` | `undefined` | **Required.** The unique icon ID (e.g. `lucide:activity`, `h2:0`). |
|
|
57
|
+
| `className` | `string` | `""` | Standard CSS class names (great for Tailwind). |
|
|
58
|
+
| `style` | `React.CSSProperties` | `{}` | Inline CSS styling. |
|
|
59
|
+
| `...props` | `HTMLAttributes` | | Spread standard HTML attributes (e.g. `onClick`, `title`). |
|
|
60
|
+
|
|
61
|
+
## Architecture
|
|
62
|
+
|
|
63
|
+
This package is a React wrapper around `<viconic-icon>` Web Components. The included `copyicons-smart-loader.js` script dynamically monitors the DOM using a `MutationObserver` and rapidly replaces `<viconic-icon>` elements with actual raw `<svg>` code.
|
|
64
|
+
|
|
65
|
+
Because we fetch SVGs in parallel and cache them across user sessions, your frontend performance score will skyrocket compared to packing large icon sets directly into your JS chunks.
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
This project is licensed under the MIT License. Icon licenses depend on the specific icon families you request.
|
|
70
|
+
|
package/dist/index.js
CHANGED
|
@@ -1934,19 +1934,18 @@ var import_react = __toESM(require("react"));
|
|
|
1934
1934
|
})();
|
|
1935
1935
|
|
|
1936
1936
|
// src/index.jsx
|
|
1937
|
-
var ViconicIcon = ({ name,
|
|
1937
|
+
var ViconicIcon = ({ name, className, style, ...props }) => {
|
|
1938
1938
|
const iconRef = (0, import_react.useRef)(null);
|
|
1939
1939
|
(0, import_react.useEffect)(() => {
|
|
1940
1940
|
if (window.CopyIcons && iconRef.current) {
|
|
1941
1941
|
window.CopyIcons.forceProcess(iconRef.current);
|
|
1942
1942
|
}
|
|
1943
|
-
}, [name,
|
|
1943
|
+
}, [name, className]);
|
|
1944
1944
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
1945
1945
|
"viconic-icon",
|
|
1946
1946
|
{
|
|
1947
1947
|
ref: iconRef,
|
|
1948
1948
|
icon: name,
|
|
1949
|
-
animate,
|
|
1950
1949
|
class: className,
|
|
1951
1950
|
style,
|
|
1952
1951
|
...props
|
package/dist/index.mjs
CHANGED
|
@@ -1900,19 +1900,18 @@ import React, { useEffect, useRef } from "react";
|
|
|
1900
1900
|
})();
|
|
1901
1901
|
|
|
1902
1902
|
// src/index.jsx
|
|
1903
|
-
var ViconicIcon = ({ name,
|
|
1903
|
+
var ViconicIcon = ({ name, className, style, ...props }) => {
|
|
1904
1904
|
const iconRef = useRef(null);
|
|
1905
1905
|
useEffect(() => {
|
|
1906
1906
|
if (window.CopyIcons && iconRef.current) {
|
|
1907
1907
|
window.CopyIcons.forceProcess(iconRef.current);
|
|
1908
1908
|
}
|
|
1909
|
-
}, [name,
|
|
1909
|
+
}, [name, className]);
|
|
1910
1910
|
return /* @__PURE__ */ React.createElement(
|
|
1911
1911
|
"viconic-icon",
|
|
1912
1912
|
{
|
|
1913
1913
|
ref: iconRef,
|
|
1914
1914
|
icon: name,
|
|
1915
|
-
animate,
|
|
1916
1915
|
class: className,
|
|
1917
1916
|
style,
|
|
1918
1917
|
...props
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface ViconicIconProps extends React.HTMLAttributes<HTMLElement> {
|
|
4
|
+
/** The unique icon ID (e.g., 'lucide:activity', 'h2:0'). Required. */
|
|
5
|
+
name: string;
|
|
6
|
+
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const ViconicIcon: React.FC<ViconicIconProps>;
|
|
11
|
+
export default ViconicIcon;
|
|
12
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "viconic-react-icons",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Viconic Smart Icons loader for React",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -16,5 +16,6 @@
|
|
|
16
16
|
"react"
|
|
17
17
|
],
|
|
18
18
|
"author": "Viconic Team",
|
|
19
|
-
"license": "MIT"
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"types": "index.d.ts"
|
|
20
21
|
}
|
package/src/index.jsx
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
2
|
import './copyicons-smart-loader.js';
|
|
3
3
|
|
|
4
|
-
export const ViconicIcon = ({ name,
|
|
4
|
+
export const ViconicIcon = ({ name, className, style, ...props }) => {
|
|
5
5
|
const iconRef = useRef(null);
|
|
6
6
|
|
|
7
7
|
useEffect(() => {
|
|
8
8
|
if (window.CopyIcons && iconRef.current) {
|
|
9
9
|
window.CopyIcons.forceProcess(iconRef.current);
|
|
10
10
|
}
|
|
11
|
-
}, [name,
|
|
11
|
+
}, [name, className]);
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
14
|
<viconic-icon
|
|
15
15
|
ref={iconRef}
|
|
16
16
|
icon={name}
|
|
17
|
-
animate={animate}
|
|
18
17
|
class={className}
|
|
19
18
|
style={style}
|
|
20
19
|
{...props}
|
|
@@ -22,4 +21,4 @@ export const ViconicIcon = ({ name, animate, className, style, ...props }) => {
|
|
|
22
21
|
);
|
|
23
22
|
};
|
|
24
23
|
|
|
25
|
-
export default ViconicIcon;
|
|
24
|
+
export default ViconicIcon;
|