@juanzbdev/tooltip-react 0.0.0 → 1.0.0
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 +73 -60
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -1,75 +1,88 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @juanzbdev/tooltip-react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Un componente de Tooltip para React moderno, ligero, fluido y altamente personalizable.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Desarrollado con las mejores prácticas: animaciones fluidas (fade-in / fade-out), acoplamiento perfecto de bordes, y soporte total para Tailwind CSS o CSS puro.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
|
7
|
+
## Características
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
- **Animaciones fluidas**: Transiciones suaves de entrada y salida gracias al manejo avanzado del ciclo de vida en React.
|
|
10
|
+
- **Bordes Dinámicos**: La flecha del tooltip hereda dinámicamente el grosor y color del borde, fusionándose como una sola pieza (gracias al uso inteligente de `drop-shadow`).
|
|
11
|
+
- **Agnóstico al CSS**: Estilos neutros por defecto. Úsalo como lienzo en blanco con Tailwind CSS o tus propios estilos en línea.
|
|
12
|
+
- **Portales de React**: Renderizado seguro fuera de la jerarquía del DOM para evitar problemas con `overflow: hidden` o `z-index`.
|
|
13
|
+
- **Cero dependencias pesadas**: Construido nativamente sobre React.
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
## Instalación
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
Puedes instalarlo utilizando tu gestor de paquetes favorito:
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
```bash
|
|
20
|
+
npm install @juanzbdev/tooltip-react
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pnpm add @juanzbdev/tooltip-react
|
|
25
|
+
```
|
|
17
26
|
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
extends: [
|
|
24
|
-
// Other configs...
|
|
27
|
+
```bash
|
|
28
|
+
yarn add @juanzbdev/tooltip-react
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Uso Básico
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// Alternatively, use this for stricter rules
|
|
29
|
-
tseslint.configs.strictTypeChecked,
|
|
30
|
-
// Optionally, add this for stylistic rules
|
|
31
|
-
tseslint.configs.stylisticTypeChecked,
|
|
33
|
+
1. Importa el componente y sus estilos CSS.
|
|
34
|
+
2. Envuelve el elemento que disparará el tooltip.
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
38
|
-
tsconfigRootDir: import.meta.dirname,
|
|
39
|
-
},
|
|
40
|
-
// other options...
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
])
|
|
36
|
+
```tsx
|
|
37
|
+
import { Tooltip } from "@juanzbdev/tooltip-react";
|
|
38
|
+
// ¡Importante importar el CSS para los estilos base!
|
|
39
|
+
import "@juanzbdev/tooltip-react/style.css";
|
|
44
40
|
|
|
41
|
+
export default function App() {
|
|
42
|
+
return (
|
|
43
|
+
<div style={{ padding: "50px" }}>
|
|
44
|
+
<Tooltip label="¡Hola, soy un tooltip!" position="top">
|
|
45
|
+
<button>Pasa el mouse sobre mí</button>
|
|
46
|
+
</Tooltip>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
45
50
|
```
|
|
46
51
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// eslint.config.js
|
|
51
|
-
import reactX from 'eslint-plugin-react-x'
|
|
52
|
-
import reactDom from 'eslint-plugin-react-dom'
|
|
53
|
-
|
|
54
|
-
export default defineConfig([
|
|
55
|
-
globalIgnores(['dist']),
|
|
56
|
-
{
|
|
57
|
-
files: ['**/*.{ts,tsx}'],
|
|
58
|
-
extends: [
|
|
59
|
-
// Other configs...
|
|
60
|
-
// Enable lint rules for React
|
|
61
|
-
reactX.configs['recommended-typescript'],
|
|
62
|
-
// Enable lint rules for React DOM
|
|
63
|
-
reactDom.configs.recommended,
|
|
64
|
-
],
|
|
65
|
-
languageOptions: {
|
|
66
|
-
parserOptions: {
|
|
67
|
-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
68
|
-
tsconfigRootDir: import.meta.dirname,
|
|
69
|
-
},
|
|
70
|
-
// other options...
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
])
|
|
52
|
+
## Personalización (Tailwind / CSS)
|
|
53
|
+
|
|
54
|
+
El componente está diseñado para ser moldeable. Puedes sobreescribir completamente su apariencia usando la prop `className` (ideal para **Tailwind CSS**) o la prop `style`.
|
|
74
55
|
|
|
56
|
+
```tsx
|
|
57
|
+
<Tooltip
|
|
58
|
+
label="Tooltip verde y redondeado"
|
|
59
|
+
position="right"
|
|
60
|
+
style={{
|
|
61
|
+
backgroundColor: "#10b981",
|
|
62
|
+
borderColor: "#059669",
|
|
63
|
+
borderRadius: "12px",
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
<button>Hover me</button>
|
|
67
|
+
</Tooltip>
|
|
75
68
|
```
|
|
69
|
+
|
|
70
|
+
_¡Magia!: La flecha heredará automáticamente el color de fondo y del borde, adaptándose perfectamente a tu diseño sin que tengas que hacer trucos adicionales._
|
|
71
|
+
|
|
72
|
+
## Props (API)
|
|
73
|
+
|
|
74
|
+
| Prop | Tipo | Por defecto | Descripción |
|
|
75
|
+
| -------------------- | ---------------------------------------- | --------------------------- | --------------------------------------------------------------------------------------------- |
|
|
76
|
+
| `label` **(\*)** | `ReactNode` | `-` | El texto o componente que se mostrará dentro del tooltip. |
|
|
77
|
+
| `children` **(\*)** | `ReactNode` | `-` | El elemento (ej. botón) sobre el cual se hará hover para mostrar el tooltip. |
|
|
78
|
+
| `position` | `'top' \| 'bottom' \| 'left' \| 'right'` | `'top'` | La dirección hacia donde aparecerá el tooltip. |
|
|
79
|
+
| `showArrow` | `boolean` | `true` | Muestra u oculta la flecha del tooltip. |
|
|
80
|
+
| `disabled` | `boolean` | `false` | Desactiva temporalmente el tooltip para que no se muestre al hacer hover. |
|
|
81
|
+
| `delayHide` | `number` | `0` | Retardo en milisegundos (ms) que el tooltip esperará antes de desaparecer al quitar el mouse. |
|
|
82
|
+
| `className` | `string` | `""` | Clases CSS adicionales (ej. Tailwind) para la caja del tooltip. |
|
|
83
|
+
| `style` | `CSSProperties` | `{}` | Estilos en línea para personalizar la caja del tooltip. |
|
|
84
|
+
| `containerClassName` | `string` | `"react-tooltip-container"` | Clase CSS para el contenedor que envuelve a los `children`. |
|
|
85
|
+
|
|
86
|
+
## Licencia
|
|
87
|
+
|
|
88
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juanzbdev/tooltip-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/tooltip-react.umd.js",
|
|
6
6
|
"module": "./dist/tooltip-react.es.js",
|
|
7
7
|
"types": "./dist/tooltip-react.es.d.ts",
|
|
8
8
|
"style": "./dist/tooltip-react.css",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/juanzb/tooltip-react.git"
|
|
12
|
+
},
|
|
9
13
|
"exports": {
|
|
10
14
|
".": {
|
|
11
15
|
"types": "./dist/tooltip-react.es.d.ts",
|