siesa-ui-kit 1.0.5 → 1.0.6
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/dist/index.cjs +1479 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +1479 -0
- package/dist/index.js.map +1 -0
- package/package.json +23 -14
- package/claude/agents/siesa-ui-kit-specialist.md +0 -2401
- package/claude/prompts/component-template.md +0 -121
- package/claude/settings.local.json +0 -61
- package/docs/border-radius.md +0 -1261
- package/docs/colors.md +0 -832
- package/docs/dark-mode-guide.md +0 -1426
- package/docs/filters.md +0 -1243
- package/docs/icons.md +0 -1283
- package/docs/shadows.md +0 -1377
- package/docs/spacing.md +0 -1684
- package/docs/typography.md +0 -1268
- package/postcss.config.cjs +0 -6
- package/src/App.css +0 -42
- package/src/App.tsx +0 -8
- package/src/ButtonTest.tsx +0 -147
- package/src/assets/fonts/README.md +0 -261
- package/src/assets/fonts/SiesaBT/SiesaBT-Bold.otf +0 -0
- package/src/assets/fonts/SiesaBT/SiesaBT-Light.otf +0 -0
- package/src/assets/fonts/SiesaBT/SiesaBT-Regular.otf +0 -0
- package/src/assets/react.svg +0 -1
- package/src/components/Alert/Alert.stories.tsx +0 -332
- package/src/components/Alert/Alert.tsx +0 -106
- package/src/components/Alert/Alert.types.ts +0 -54
- package/src/components/Avatar/Avatar.stories.tsx +0 -494
- package/src/components/Avatar/Avatar.tsx +0 -143
- package/src/components/Avatar/Avatar.types.ts +0 -53
- package/src/components/Badge/Badge.stories.tsx +0 -339
- package/src/components/Badge/Badge.tsx +0 -278
- package/src/components/Badge/Badge.types.ts +0 -58
- package/src/components/Button/Button.stories.tsx +0 -950
- package/src/components/Button/Button.tsx +0 -337
- package/src/components/Button/Button.types.ts +0 -180
- package/src/components/Button/icons.tsx +0 -87
- package/src/components/Button/index.ts +0 -3
- package/src/components/Checkbox/Checkbox.stories.tsx +0 -453
- package/src/components/Checkbox/Checkbox.tsx +0 -208
- package/src/components/Checkbox/Checkbox.types.ts +0 -61
- package/src/components/DescriptionList/DescriptionList.stories.tsx +0 -250
- package/src/components/DescriptionList/DescriptionList.tsx +0 -96
- package/src/components/DescriptionList/DescriptionList.types.ts +0 -29
- package/src/components/Divider/Divider.stories.tsx +0 -263
- package/src/components/Divider/Divider.tsx +0 -80
- package/src/components/Divider/Divider.types.ts +0 -24
- package/src/components/Dropdown/Dropdown.stories.tsx +0 -552
- package/src/components/Dropdown/Dropdown.tsx +0 -422
- package/src/components/Dropdown/Dropdown.types.ts +0 -146
- package/src/components/Dropdown/README.md +0 -266
- package/src/components/Dropdown/icons.tsx +0 -72
- package/src/components/Dropdown/index.ts +0 -8
- package/src/components/Input/Input.stories.tsx +0 -583
- package/src/components/Input/Input.tsx +0 -204
- package/src/components/Input/Input.types.ts +0 -80
- package/src/components/Input/icons.tsx +0 -145
- package/src/components/Input/index.ts +0 -2
- package/src/components/LoginView/LoginView.stories.tsx +0 -148
- package/src/components/LoginView/LoginView.tsx +0 -426
- package/src/components/LoginView/LoginView.types.ts +0 -52
- package/src/components/LoginView/README.md +0 -396
- package/src/components/LoginView/icons.tsx +0 -85
- package/src/components/LoginView/index.ts +0 -3
- package/src/components/Navbar/Navbar.stories.tsx +0 -810
- package/src/components/Navbar/Navbar.tsx +0 -755
- package/src/components/Navbar/Navbar.types.ts +0 -219
- package/src/components/Navbar/README.md +0 -279
- package/src/components/Navbar/icons.tsx +0 -102
- package/src/components/Navbar/index.ts +0 -8
- package/src/components/NavigationBar/NavigationBar.stories.tsx +0 -406
- package/src/components/NavigationBar/NavigationBar.tsx +0 -246
- package/src/components/NavigationBar/NavigationBar.types.ts +0 -74
- package/src/components/NavigationBar/README.md +0 -469
- package/src/components/NavigationBar/index.ts +0 -2
- package/src/components/NavigationRail/NavigationRail.stories.tsx +0 -417
- package/src/components/NavigationRail/NavigationRail.tsx +0 -418
- package/src/components/NavigationRail/NavigationRail.types.ts +0 -109
- package/src/components/NavigationRail/README.md +0 -224
- package/src/components/NavigationRail/index.ts +0 -2
- package/src/components/Notification/Notification.stories.tsx +0 -513
- package/src/components/Notification/Notification.tsx +0 -145
- package/src/components/Notification/Notification.types.ts +0 -142
- package/src/components/Notification/README.md +0 -409
- package/src/components/Notification/index.ts +0 -3
- package/src/components/POSConvention/POSConvention.stories.tsx +0 -235
- package/src/components/POSConvention/POSConvention.tsx +0 -129
- package/src/components/POSConvention/POSConvention.types.ts +0 -38
- package/src/components/POSConvention/README.md +0 -123
- package/src/components/POSConvention/icons.tsx +0 -45
- package/src/components/POSConvention/index.ts +0 -3
- package/src/components/POSLocationButton/POSLocationButton.stories.tsx +0 -531
- package/src/components/POSLocationButton/POSLocationButton.tsx +0 -247
- package/src/components/POSLocationButton/POSLocationButton.types.ts +0 -87
- package/src/components/POSLocationButton/README.md +0 -253
- package/src/components/POSLocationButton/icons.tsx +0 -120
- package/src/components/POSLocationButton/index.ts +0 -14
- package/src/components/POSNumberButton/POSNumberButton.stories.tsx +0 -415
- package/src/components/POSNumberButton/POSNumberButton.tsx +0 -179
- package/src/components/POSNumberButton/POSNumberButton.types.ts +0 -51
- package/src/components/POSNumberButton/README.md +0 -321
- package/src/components/POSNumberButton/index.ts +0 -3
- package/src/components/POSProductButton/POSProductButton.stories.tsx +0 -318
- package/src/components/POSProductButton/POSProductButton.tsx +0 -152
- package/src/components/POSProductButton/POSProductButton.types.ts +0 -46
- package/src/components/POSProductButton/README.md +0 -269
- package/src/components/POSProductButton/index.ts +0 -2
- package/src/components/POSProductCard/POSProductCard.stories.tsx +0 -642
- package/src/components/POSProductCard/POSProductCard.tsx +0 -208
- package/src/components/POSProductCard/POSProductCard.types.ts +0 -76
- package/src/components/POSProductCard/README.md +0 -179
- package/src/components/POSProductCard/icons.tsx +0 -26
- package/src/components/POSProductCard/index.ts +0 -2
- package/src/components/POSProductSidebarItems/POSProductSidebarItems.stories.tsx +0 -753
- package/src/components/POSProductSidebarItems/POSProductSidebarItems.tsx +0 -332
- package/src/components/POSProductSidebarItems/POSProductSidebarItems.types.ts +0 -119
- package/src/components/POSProductSidebarItems/README.md +0 -198
- package/src/components/POSProductSidebarItems/icons.tsx +0 -21
- package/src/components/POSProductSidebarItems/index.ts +0 -3
- package/src/components/POSTable/POSTable.stories.tsx +0 -737
- package/src/components/POSTable/POSTable.tsx +0 -401
- package/src/components/POSTable/POSTable.types.ts +0 -83
- package/src/components/POSTable/README.md +0 -286
- package/src/components/POSTable/index.ts +0 -7
- package/src/components/Pagination/Pagination.stories.tsx +0 -555
- package/src/components/Pagination/Pagination.tsx +0 -286
- package/src/components/Pagination/Pagination.types.ts +0 -93
- package/src/components/Pagination/README.md +0 -298
- package/src/components/Pagination/icons.tsx +0 -47
- package/src/components/Pagination/index.ts +0 -3
- package/src/components/Quantity/Quantity.stories.tsx +0 -457
- package/src/components/Quantity/Quantity.tsx +0 -289
- package/src/components/Quantity/Quantity.types.ts +0 -70
- package/src/components/Radio/Radio.stories.tsx +0 -523
- package/src/components/Radio/Radio.tsx +0 -170
- package/src/components/Radio/Radio.types.ts +0 -122
- package/src/components/Select/README.md +0 -299
- package/src/components/Select/Select.stories.tsx +0 -673
- package/src/components/Select/Select.tsx +0 -454
- package/src/components/Select/Select.types.ts +0 -148
- package/src/components/Select/icons.tsx +0 -50
- package/src/components/Select/index.ts +0 -3
- package/src/components/SignUpView/SignUpView.stories.tsx +0 -129
- package/src/components/SignUpView/SignUpView.tsx +0 -503
- package/src/components/SignUpView/SignUpView.types.ts +0 -58
- package/src/components/SignUpView/icons.tsx +0 -71
- package/src/components/SignUpView/index.ts +0 -3
- package/src/components/Switch/README.md +0 -112
- package/src/components/Switch/Switch.stories.tsx +0 -550
- package/src/components/Switch/Switch.tsx +0 -246
- package/src/components/Switch/Switch.types.ts +0 -67
- package/src/components/Table/README.md +0 -369
- package/src/components/Table/Table.stories.tsx +0 -805
- package/src/components/Table/Table.tsx +0 -688
- package/src/components/Table/Table.types.ts +0 -204
- package/src/components/Table/index.ts +0 -9
- package/src/components/Tabs/README.md +0 -201
- package/src/components/Tabs/Tabs.stories.tsx +0 -580
- package/src/components/Tabs/Tabs.tsx +0 -356
- package/src/components/Tabs/Tabs.types.ts +0 -127
- package/src/components/Tabs/icons.tsx +0 -129
- package/src/components/Tabs/index.ts +0 -11
- package/src/components/Textarea/Textarea.stories.tsx +0 -535
- package/src/components/Textarea/Textarea.tsx +0 -188
- package/src/components/Textarea/Textarea.types.ts +0 -54
- package/src/context/ThemeContext.tsx +0 -99
- package/src/context/index.ts +0 -1
- package/src/index.css +0 -29
- package/src/index.ts +0 -39
- package/src/main.tsx +0 -10
- package/src/views/ProductsView/ProductsView.stories.tsx +0 -344
- package/src/views/ProductsView/ProductsView.tsx +0 -480
- package/src/views/ProductsView/ProductsView.types.ts +0 -238
- package/src/views/ProductsView/README.md +0 -312
- package/src/views/ProductsView/icons.tsx +0 -38
- package/src/views/ProductsView/index.ts +0 -8
- package/src/views/RecoverPasswordView/README.md +0 -269
- package/src/views/RecoverPasswordView/RecoverPasswordView.stories.tsx +0 -131
- package/src/views/RecoverPasswordView/RecoverPasswordView.tsx +0 -376
- package/src/views/RecoverPasswordView/RecoverPasswordView.types.ts +0 -56
- package/src/views/RecoverPasswordView/icons.tsx +0 -17
- package/src/views/RecoverPasswordView/index.ts +0 -2
- package/src/views/TableLayoutView/README.md +0 -268
- package/src/views/TableLayoutView/TableLayoutView.stories.tsx +0 -235
- package/src/views/TableLayoutView/TableLayoutView.tsx +0 -461
- package/src/views/TableLayoutView/TableLayoutView.types.ts +0 -209
- package/src/views/TableLayoutView/icons.tsx +0 -113
- package/src/views/TableLayoutView/index.ts +0 -6
- package/storybook/main.ts +0 -20
- package/storybook/preview.tsx +0 -84
- package/storybook/vitest.setup.ts +0 -7
- package/tailwind.config.js +0 -128
- /package/{public → dist}/,Business Logo.png +0 -0
- /package/{public → dist}/.Siesa Logo.png +0 -0
- /package/{public → dist}/bg_siesa.png +0 -0
- /package/{public → dist}/siesa_logo_mobile.png +0 -0
- /package/{public → dist}/vite.svg +0 -0
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
2
|
-
import type { TextareaProps } from './Textarea.types';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Textarea - Componente de área de texto del sistema de diseño Siesa
|
|
6
|
-
* Basado en especificaciones de Figma con Tailwind CSS
|
|
7
|
-
*
|
|
8
|
-
* Mejores prácticas implementadas:
|
|
9
|
-
* - Orden de modificadores: {responsive}:{dark}:{state}:{utility}
|
|
10
|
-
* - Dark mode con estrategia 'class' (darkMode: 'class')
|
|
11
|
-
* - Focus rings adaptativos para light y dark mode
|
|
12
|
-
* - Tokens de color consistentes con la documentación
|
|
13
|
-
* - Estados hover, focus, disabled y error completos
|
|
14
|
-
* - Typography: Paragraph Base (16px) para texto
|
|
15
|
-
*
|
|
16
|
-
* Campo de entrada de texto multi-línea con soporte para:
|
|
17
|
-
* - Estados: default, hover, focus, filled, disabled
|
|
18
|
-
* - Validación con mensajes de error
|
|
19
|
-
* - Label, description y helper text
|
|
20
|
-
* - Resize vertical, horizontal, both o none
|
|
21
|
-
* - Dark mode completo
|
|
22
|
-
* - Accesibilidad completa
|
|
23
|
-
*
|
|
24
|
-
* @see docs/colors.md - Sistema de colores
|
|
25
|
-
* @see docs/shadows.md - Sistema de sombras
|
|
26
|
-
* @see docs/typography.md - Sistema tipográfico (Paragraph, Label)
|
|
27
|
-
* @see docs/spacing.md - Sistema de espaciado
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```tsx
|
|
31
|
-
* <Textarea
|
|
32
|
-
* label="About"
|
|
33
|
-
* description="Tell us about yourself"
|
|
34
|
-
* placeholder="Write a few sentences..."
|
|
35
|
-
* helperText="Minimum 50 characters"
|
|
36
|
-
* />
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
40
|
-
(
|
|
41
|
-
{
|
|
42
|
-
label,
|
|
43
|
-
description,
|
|
44
|
-
helperText,
|
|
45
|
-
error = false,
|
|
46
|
-
errorMessage,
|
|
47
|
-
fullWidth = false,
|
|
48
|
-
resize = 'vertical',
|
|
49
|
-
className = '',
|
|
50
|
-
disabled = false,
|
|
51
|
-
id,
|
|
52
|
-
rows = 4,
|
|
53
|
-
...props
|
|
54
|
-
},
|
|
55
|
-
ref
|
|
56
|
-
) => {
|
|
57
|
-
// Generar ID único si no se proporciona
|
|
58
|
-
const textareaId = id || `textarea-${Math.random().toString(36).substr(2, 9)}`;
|
|
59
|
-
|
|
60
|
-
// ===== CLASES BASE DEL TEXTAREA =====
|
|
61
|
-
// Usando el sistema tipográfico Paragraph Base (16px = text-base)
|
|
62
|
-
// Border radius rounded-lg (8px) según especificaciones de Figma
|
|
63
|
-
// Padding: px-3 (12px) izquierda, pr-1.5 (6px) derecha para el indicador de resize
|
|
64
|
-
const baseTextareaClasses = `
|
|
65
|
-
w-full
|
|
66
|
-
px-3
|
|
67
|
-
pr-1.5
|
|
68
|
-
py-1.5
|
|
69
|
-
text-base
|
|
70
|
-
leading-6
|
|
71
|
-
font-normal
|
|
72
|
-
bg-bg-primary
|
|
73
|
-
border
|
|
74
|
-
border-border-primary
|
|
75
|
-
rounded-lg
|
|
76
|
-
outline-none
|
|
77
|
-
transition-all
|
|
78
|
-
duration-150
|
|
79
|
-
placeholder:text-content-tertiary
|
|
80
|
-
dark:bg-dark-bg-primary
|
|
81
|
-
dark:border-dark-border-primary
|
|
82
|
-
dark:text-dark-content-primary
|
|
83
|
-
dark:placeholder:text-dark-content-tertiary
|
|
84
|
-
`;
|
|
85
|
-
|
|
86
|
-
// ===== CLASES PARA ESTADOS INTERACTIVOS =====
|
|
87
|
-
// Orden de modificadores: {responsive}:{dark}:{state}:{utility}
|
|
88
|
-
// Hover: borde más opaco (zinc-400) según especificaciones de Figma
|
|
89
|
-
// Focus: solo border-2 sin ring, según especificaciones de Figma
|
|
90
|
-
const interactiveClasses = !disabled
|
|
91
|
-
? `
|
|
92
|
-
hover:border-zinc-400
|
|
93
|
-
focus:border-2
|
|
94
|
-
focus:border-primary-custom-600
|
|
95
|
-
dark:hover:border-zinc-500
|
|
96
|
-
dark:focus:border-2
|
|
97
|
-
dark:focus:border-dark-border-custom
|
|
98
|
-
`
|
|
99
|
-
: `
|
|
100
|
-
opacity-50
|
|
101
|
-
cursor-not-allowed
|
|
102
|
-
bg-bg-secondary
|
|
103
|
-
dark:bg-dark-bg-secondary
|
|
104
|
-
`;
|
|
105
|
-
|
|
106
|
-
// ===== CLASES PARA ESTADO DE ERROR =====
|
|
107
|
-
// Los colores de error son los mismos en light y dark mode
|
|
108
|
-
// Focus en error: solo border-2 sin ring, según especificaciones de Figma
|
|
109
|
-
const errorClasses = error
|
|
110
|
-
? `
|
|
111
|
-
!border-error-border
|
|
112
|
-
focus:!border-2
|
|
113
|
-
focus:!border-error-border
|
|
114
|
-
dark:!border-error-border
|
|
115
|
-
dark:focus:!border-2
|
|
116
|
-
dark:focus:!border-error-border
|
|
117
|
-
`
|
|
118
|
-
: '';
|
|
119
|
-
|
|
120
|
-
// ===== CLASES DE RESIZE =====
|
|
121
|
-
const resizeClasses =
|
|
122
|
-
resize === 'none'
|
|
123
|
-
? 'resize-none'
|
|
124
|
-
: resize === 'vertical'
|
|
125
|
-
? 'resize-y'
|
|
126
|
-
: resize === 'horizontal'
|
|
127
|
-
? 'resize-x'
|
|
128
|
-
: 'resize';
|
|
129
|
-
|
|
130
|
-
// ===== CLASES DEL CONTENEDOR =====
|
|
131
|
-
// Ancho por defecto: 312px (según especificaciones de Figma)
|
|
132
|
-
const containerClasses = fullWidth ? 'w-full' : 'w-[312px]';
|
|
133
|
-
|
|
134
|
-
return (
|
|
135
|
-
<div className={`flex flex-col gap-2 ${containerClasses} ${className}`}>
|
|
136
|
-
{/* Label and Description */}
|
|
137
|
-
{(label || description) && (
|
|
138
|
-
<div className="flex flex-col gap-1 w-full">
|
|
139
|
-
{label && (
|
|
140
|
-
<label
|
|
141
|
-
htmlFor={textareaId}
|
|
142
|
-
className="font-bold text-sm leading-5 text-content-primary dark:text-dark-content-primary"
|
|
143
|
-
>
|
|
144
|
-
{label}
|
|
145
|
-
</label>
|
|
146
|
-
)}
|
|
147
|
-
{description && (
|
|
148
|
-
<p className="text-sm leading-5 text-content-secondary dark:text-dark-content-secondary">
|
|
149
|
-
{description}
|
|
150
|
-
</p>
|
|
151
|
-
)}
|
|
152
|
-
</div>
|
|
153
|
-
)}
|
|
154
|
-
|
|
155
|
-
{/* Textarea Field */}
|
|
156
|
-
<textarea
|
|
157
|
-
ref={ref}
|
|
158
|
-
id={textareaId}
|
|
159
|
-
disabled={disabled}
|
|
160
|
-
rows={rows}
|
|
161
|
-
className={`
|
|
162
|
-
${baseTextareaClasses}
|
|
163
|
-
${interactiveClasses}
|
|
164
|
-
${errorClasses}
|
|
165
|
-
${resizeClasses}
|
|
166
|
-
`.trim().replace(/\s+/g, ' ')}
|
|
167
|
-
{...props}
|
|
168
|
-
/>
|
|
169
|
-
|
|
170
|
-
{/* Helper Text or Error Message */}
|
|
171
|
-
{(helperText || errorMessage) && (
|
|
172
|
-
<p
|
|
173
|
-
className={`
|
|
174
|
-
text-sm
|
|
175
|
-
leading-5
|
|
176
|
-
text-content-tertiary
|
|
177
|
-
dark:text-dark-content-tertiary
|
|
178
|
-
`.trim().replace(/\s+/g, ' ')}
|
|
179
|
-
>
|
|
180
|
-
{error && errorMessage ? errorMessage : helperText}
|
|
181
|
-
</p>
|
|
182
|
-
)}
|
|
183
|
-
</div>
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
Textarea.displayName = 'Textarea';
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { TextareaHTMLAttributes } from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Estados visuales del Textarea
|
|
5
|
-
*/
|
|
6
|
-
export type TextareaState = 'default' | 'hover' | 'focus' | 'filled' | 'disabled';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Props del componente Textarea
|
|
10
|
-
*/
|
|
11
|
-
export interface TextareaProps extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'size'> {
|
|
12
|
-
/**
|
|
13
|
-
* Etiqueta del campo de texto
|
|
14
|
-
*/
|
|
15
|
-
label?: string;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Descripción debajo del label (texto secundario)
|
|
19
|
-
*/
|
|
20
|
-
description?: string;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Texto de ayuda debajo del textarea
|
|
24
|
-
*/
|
|
25
|
-
helperText?: string;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Indica si hay un error de validación
|
|
29
|
-
* @default false
|
|
30
|
-
*/
|
|
31
|
-
error?: boolean;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Mensaje de error a mostrar (reemplaza helperText cuando error=true)
|
|
35
|
-
*/
|
|
36
|
-
errorMessage?: string;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Si el textarea ocupa todo el ancho del contenedor
|
|
40
|
-
* @default false
|
|
41
|
-
*/
|
|
42
|
-
fullWidth?: boolean;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Si el textarea puede redimensionarse
|
|
46
|
-
* @default 'vertical'
|
|
47
|
-
*/
|
|
48
|
-
resize?: 'none' | 'vertical' | 'horizontal' | 'both';
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Clases CSS adicionales
|
|
52
|
-
*/
|
|
53
|
-
className?: string;
|
|
54
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useContext, useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
export type Theme = 'light' | 'dark';
|
|
4
|
-
|
|
5
|
-
interface ThemeContextType {
|
|
6
|
-
theme: Theme;
|
|
7
|
-
toggleTheme: () => void;
|
|
8
|
-
setTheme: (theme: Theme) => void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const ThemeContext = createContext<ThemeContextType | undefined>(undefined);
|
|
12
|
-
|
|
13
|
-
interface ThemeProviderProps {
|
|
14
|
-
children: React.ReactNode;
|
|
15
|
-
defaultTheme?: Theme;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* ThemeProvider - Proveedor de contexto para el tema de la aplicación
|
|
20
|
-
*
|
|
21
|
-
* Maneja el estado del tema (light/dark) y lo persiste en localStorage.
|
|
22
|
-
* Aplica la clase 'dark' al elemento HTML root cuando el tema es dark.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```tsx
|
|
26
|
-
* <ThemeProvider defaultTheme="light">
|
|
27
|
-
* <App />
|
|
28
|
-
* </ThemeProvider>
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export const ThemeProvider: React.FC<ThemeProviderProps> = ({
|
|
32
|
-
children,
|
|
33
|
-
defaultTheme = 'light'
|
|
34
|
-
}) => {
|
|
35
|
-
const [theme, setThemeState] = useState<Theme>(() => {
|
|
36
|
-
// Intenta obtener el tema del localStorage
|
|
37
|
-
if (typeof window !== 'undefined') {
|
|
38
|
-
const savedTheme = localStorage.getItem('siesa-ui-theme') as Theme;
|
|
39
|
-
return savedTheme || defaultTheme;
|
|
40
|
-
}
|
|
41
|
-
return defaultTheme;
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
// Aplica o remueve la clase 'dark' del elemento root
|
|
46
|
-
const root = window.document.documentElement;
|
|
47
|
-
|
|
48
|
-
if (theme === 'dark') {
|
|
49
|
-
root.classList.add('dark');
|
|
50
|
-
} else {
|
|
51
|
-
root.classList.remove('dark');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Guarda el tema en localStorage
|
|
55
|
-
localStorage.setItem('siesa-ui-theme', theme);
|
|
56
|
-
}, [theme]);
|
|
57
|
-
|
|
58
|
-
const toggleTheme = () => {
|
|
59
|
-
setThemeState((prev) => (prev === 'light' ? 'dark' : 'light'));
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const setTheme = (newTheme: Theme) => {
|
|
63
|
-
setThemeState(newTheme);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<ThemeContext.Provider value={{ theme, toggleTheme, setTheme }}>
|
|
68
|
-
{children}
|
|
69
|
-
</ThemeContext.Provider>
|
|
70
|
-
);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* useTheme - Hook para acceder al contexto del tema
|
|
75
|
-
*
|
|
76
|
-
* @returns {ThemeContextType} Objeto con el tema actual y funciones para modificarlo
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* ```tsx
|
|
80
|
-
* function MyComponent() {
|
|
81
|
-
* const { theme, toggleTheme } = useTheme();
|
|
82
|
-
*
|
|
83
|
-
* return (
|
|
84
|
-
* <button onClick={toggleTheme}>
|
|
85
|
-
* Tema actual: {theme}
|
|
86
|
-
* </button>
|
|
87
|
-
* );
|
|
88
|
-
* }
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
export const useTheme = (): ThemeContextType => {
|
|
92
|
-
const context = useContext(ThemeContext);
|
|
93
|
-
|
|
94
|
-
if (context === undefined) {
|
|
95
|
-
throw new Error('useTheme debe ser usado dentro de un ThemeProvider');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return context;
|
|
99
|
-
};
|
package/src/context/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ThemeProvider, useTheme, type Theme } from './ThemeContext';
|
package/src/index.css
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/* ===== FUENTES PERSONALIZADAS ===== */
|
|
2
|
-
@font-face {
|
|
3
|
-
font-family: 'SiesaBT';
|
|
4
|
-
src: url('./assets/fonts/SiesaBT/SiesaBT-Regular.otf') format('opentype');
|
|
5
|
-
font-weight: 400;
|
|
6
|
-
font-style: normal;
|
|
7
|
-
font-display: swap;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
@font-face {
|
|
11
|
-
font-family: 'SiesaBT';
|
|
12
|
-
src: url('./assets/fonts/SiesaBT/SiesaBT-Light.otf') format('opentype');
|
|
13
|
-
font-weight: 300;
|
|
14
|
-
font-style: normal;
|
|
15
|
-
font-display: swap;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@font-face {
|
|
19
|
-
font-family: 'SiesaBT';
|
|
20
|
-
src: url('./assets/fonts/SiesaBT/SiesaBT-Bold.otf') format('opentype');
|
|
21
|
-
font-weight: 700;
|
|
22
|
-
font-style: normal;
|
|
23
|
-
font-display: swap;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/* ===== TAILWIND CSS ===== */
|
|
27
|
-
@tailwind base;
|
|
28
|
-
@tailwind components;
|
|
29
|
-
@tailwind utilities;
|
package/src/index.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// Componentes
|
|
2
|
-
export { Button } from './components/Button/Button';
|
|
3
|
-
export type { ButtonProps, ButtonType, ButtonSize, ButtonState } from './components/Button/Button.types';
|
|
4
|
-
|
|
5
|
-
export { Input } from './components/Input/Input';
|
|
6
|
-
export type { InputProps, InputState } from './components/Input/Input.types';
|
|
7
|
-
|
|
8
|
-
export { Textarea } from './components/Textarea/Textarea';
|
|
9
|
-
export type { TextareaProps, TextareaState } from './components/Textarea/Textarea.types';
|
|
10
|
-
|
|
11
|
-
export { Checkbox } from './components/Checkbox/Checkbox';
|
|
12
|
-
export type { CheckboxProps, CheckboxState } from './components/Checkbox/Checkbox.types';
|
|
13
|
-
|
|
14
|
-
export { Radio } from './components/Radio/Radio';
|
|
15
|
-
export type { RadioProps, RadioState } from './components/Radio/Radio.types';
|
|
16
|
-
|
|
17
|
-
export { Switch } from './components/Switch/Switch';
|
|
18
|
-
export type { SwitchProps, SwitchState } from './components/Switch/Switch.types';
|
|
19
|
-
|
|
20
|
-
export { Avatar } from './components/Avatar/Avatar';
|
|
21
|
-
export type { AvatarProps, AvatarSize, AvatarType } from './components/Avatar/Avatar.types';
|
|
22
|
-
|
|
23
|
-
export { Divider } from './components/Divider/Divider';
|
|
24
|
-
export type { DividerProps, DividerType } from './components/Divider/Divider.types';
|
|
25
|
-
|
|
26
|
-
export { DescriptionList } from './components/DescriptionList/DescriptionList';
|
|
27
|
-
export type { DescriptionListProps } from './components/DescriptionList/DescriptionList.types';
|
|
28
|
-
|
|
29
|
-
export { Alert } from './components/Alert/Alert';
|
|
30
|
-
export type { AlertProps } from './components/Alert/Alert.types';
|
|
31
|
-
|
|
32
|
-
export { Badge } from './components/Badge/Badge';
|
|
33
|
-
export type { BadgeProps, BadgeColor } from './components/Badge/Badge.types';
|
|
34
|
-
|
|
35
|
-
export { Quantity } from './components/Quantity/Quantity';
|
|
36
|
-
export type { QuantityProps } from './components/Quantity/Quantity.types';
|
|
37
|
-
|
|
38
|
-
// Context y Hooks
|
|
39
|
-
export { ThemeProvider, useTheme, type Theme } from './context';
|
package/src/main.tsx
DELETED