@seip/blue-bird 0.4.3

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.
Files changed (53) hide show
  1. package/.env_example +26 -0
  2. package/AGENTS.md +199 -0
  3. package/README.md +79 -0
  4. package/backend/index.js +13 -0
  5. package/backend/routes/api.js +31 -0
  6. package/backend/routes/frontend.js +41 -0
  7. package/backend/routes/seo.js +39 -0
  8. package/core/app.js +325 -0
  9. package/core/auth.js +83 -0
  10. package/core/cache.js +45 -0
  11. package/core/cli/component.js +42 -0
  12. package/core/cli/init.js +118 -0
  13. package/core/cli/react.js +435 -0
  14. package/core/cli/route.js +43 -0
  15. package/core/cli/swagger.js +40 -0
  16. package/core/config.js +47 -0
  17. package/core/debug.js +249 -0
  18. package/core/logger.js +100 -0
  19. package/core/middleware.js +27 -0
  20. package/core/router.js +333 -0
  21. package/core/seo.js +100 -0
  22. package/core/swagger.js +25 -0
  23. package/core/template.js +462 -0
  24. package/core/upload.js +76 -0
  25. package/core/validate.js +380 -0
  26. package/frontend/index.html +27 -0
  27. package/frontend/landing.html +70 -0
  28. package/frontend/public/favicon.ico +0 -0
  29. package/frontend/resources/css/tailwind.css +18 -0
  30. package/frontend/resources/js/App.jsx +70 -0
  31. package/frontend/resources/js/Main.jsx +19 -0
  32. package/frontend/resources/js/blue-bird/components/Button.jsx +67 -0
  33. package/frontend/resources/js/blue-bird/components/Card.jsx +18 -0
  34. package/frontend/resources/js/blue-bird/components/DataTable.jsx +126 -0
  35. package/frontend/resources/js/blue-bird/components/Input.jsx +21 -0
  36. package/frontend/resources/js/blue-bird/components/Label.jsx +12 -0
  37. package/frontend/resources/js/blue-bird/components/LanguageButton.jsx +23 -0
  38. package/frontend/resources/js/blue-bird/components/Link.jsx +16 -0
  39. package/frontend/resources/js/blue-bird/components/Modal.jsx +27 -0
  40. package/frontend/resources/js/blue-bird/components/Skeleton.jsx +45 -0
  41. package/frontend/resources/js/blue-bird/components/Translate.jsx +12 -0
  42. package/frontend/resources/js/blue-bird/components/Typography.jsx +69 -0
  43. package/frontend/resources/js/blue-bird/contexts/LanguageContext.jsx +41 -0
  44. package/frontend/resources/js/blue-bird/contexts/SPAContext.jsx +237 -0
  45. package/frontend/resources/js/blue-bird/contexts/SnackbarContext.jsx +38 -0
  46. package/frontend/resources/js/blue-bird/contexts/ThemeContext.jsx +49 -0
  47. package/frontend/resources/js/blue-bird/locales/en.json +48 -0
  48. package/frontend/resources/js/blue-bird/locales/es.json +48 -0
  49. package/frontend/resources/js/components/Header.jsx +56 -0
  50. package/frontend/resources/js/pages/About.jsx +32 -0
  51. package/frontend/resources/js/pages/Home.jsx +82 -0
  52. package/package.json +58 -0
  53. package/vite.config.js +23 -0
@@ -0,0 +1,380 @@
1
+ import xss from "xss";
2
+
3
+ const messages_default = {
4
+ es: {
5
+ required: (f) => `El campo ${f} es obligatorio`,
6
+ min: (f, n) => `El campo ${f} debe tener al menos ${n} caracteres`,
7
+ max: (f, n) => `El campo ${f} no puede tener más de ${n} caracteres`,
8
+ email: (f) => `El campo ${f} debe ser un email válido`,
9
+ number: (f) => `El campo ${f} debe ser numérico`,
10
+ alpha: (f) => `El campo ${f} solo puede contener letras`,
11
+ alphanumeric: (f) => `El campo ${f} solo puede contener letras y números`,
12
+ boolean: (f) => `El campo ${f} debe ser verdadero o falso`,
13
+ date: (f) => `El campo ${f} debe ser una fecha válida`,
14
+ url: (f) => `El campo ${f} debe ser una URL válida`,
15
+ in: (f, v) => `El campo ${f} debe ser uno de: ${v.join(", ")}`,
16
+ equals: (f, v) => `El campo ${f} debe ser igual a ${v}`,
17
+ password: () => `La contraseña debe tener mayúsculas, minúsculas y números`,
18
+ pattern: (f) => `El campo ${f} no cumple el patrón requerido`,
19
+ },
20
+ en: {
21
+ required: (f) => `${f} is required`,
22
+ min: (f, n) => `${f} must be at least ${n} characters`,
23
+ max: (f, n) => `${f} must be at most ${n} characters`,
24
+ email: (f) => `${f} must be a valid email`,
25
+ number: (f) => `${f} must be numeric`,
26
+ alpha: (f) => `${f} must contain only letters`,
27
+ alphanumeric: (f) => `${f} must contain only letters and numbers`,
28
+ boolean: (f) => `${f} must be true or false`,
29
+ date: (f) => `${f} must be a valid date`,
30
+ url: (f) => `${f} must be a valid URL`,
31
+ in: (f, v) => `${f} must be one of: ${v.join(", ")}`,
32
+ equals: (f, v) => `${f} must equal ${v}`,
33
+ password: () => `Password must contain uppercase, lowercase and numbers`,
34
+ pattern: (f) => `${f} does not match the required pattern`,
35
+ },
36
+ pt: {
37
+ required: (f) => `O campo ${f} é obrigatório`,
38
+ min: (f, n) => `O campo ${f} deve ter pelo menos ${n} caracteres`,
39
+ max: (f, n) => `O campo ${f} não pode ter mais de ${n} caracteres`,
40
+ email: (f) => `O campo ${f} deve ser um email válido`,
41
+ number: (f) => `O campo ${f} deve ser numérico`,
42
+ alpha: (f) => `O campo ${f} só pode conter letras`,
43
+ alphanumeric: (f) => `O campo ${f} só pode conter letras e números`,
44
+ boolean: (f) => `O campo ${f} deve ser verdadeiro ou falso`,
45
+ date: (f) => `O campo ${f} deve ser uma data válida`,
46
+ url: (f) => `O campo ${f} deve ser uma URL válida`,
47
+ in: (f, v) => `O campo ${f} deve ser um de: ${v.join(", ")}`,
48
+ equals: (f, v) => `O campo ${f} deve ser igual a ${v}`,
49
+ password: () => `A senha deve conter maiúsculas, minúsculas e números`,
50
+ pattern: (f) => `O campo ${f} não corresponde ao padrão exigido`,
51
+ },
52
+ br: {
53
+ required: (f) => `O campo ${f} é obrigatório`,
54
+ min: (f, n) => `O campo ${f} deve ter pelo menos ${n} caracteres`,
55
+ max: (f, n) => `O campo ${f} não pode ter mais de ${n} caracteres`,
56
+ email: (f) => `O campo ${f} deve ser um email válido`,
57
+ number: (f) => `O campo ${f} deve ser numérico`,
58
+ alpha: (f) => `O campo ${f} só pode conter letras`,
59
+ alphanumeric: (f) => `O campo ${f} só pode conter letras e números`,
60
+ boolean: (f) => `O campo ${f} deve ser verdadeiro ou falso`,
61
+ date: (f) => `O campo ${f} deve ser uma data válida`,
62
+ url: (f) => `O campo ${f} deve ser uma URL válida`,
63
+ in: (f, v) => `O campo ${f} deve ser um de: ${v.join(", ")}`,
64
+ equals: (f, v) => `O campo ${f} deve ser igual a ${v}`,
65
+ password: () => `A senha deve conter maiúsculas, minúsculas e números`,
66
+ pattern: (f) => `O campo ${f} não corresponde ao padrão exigido`,
67
+ },
68
+ fr: {
69
+ required: (f) => `Le champ ${f} est obligatoire`,
70
+ min: (f, n) => `Le champ ${f} doit contenir au moins ${n} caractères`,
71
+ max: (f, n) => `Le champ ${f} ne peut pas contenir plus de ${n} caractères`,
72
+ email: (f) => `Le champ ${f} doit être un email valide`,
73
+ number: (f) => `Le champ ${f} doit être numérique`,
74
+ alpha: (f) => `Le champ ${f} ne peut contenir que des lettres`,
75
+ alphanumeric: (f) =>
76
+ `Le champ ${f} ne peut contenir que des lettres et des chiffres`,
77
+ boolean: (f) => `Le champ ${f} doit être vrai ou faux`,
78
+ date: (f) => `Le champ ${f} doit être une date valide`,
79
+ url: (f) => `Le champ ${f} doit être une URL valide`,
80
+ in: (f, v) => `Le champ ${f} doit être l'un de: ${v.join(", ")}`,
81
+ equals: (f, v) => `Le champ ${f} doit être égal à ${v}`,
82
+ password: () =>
83
+ `Le mot de passe doit contenir des majuscules, des minuscules et des chiffres`,
84
+ pattern: (f) => `Le champ ${f} ne correspond pas au modèle requis`,
85
+ },
86
+ };
87
+
88
+ const validators = {
89
+ isEmpty: (value) => value === undefined || value === null || value === "",
90
+ isEmail: (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value),
91
+ isNumeric: (value) => !isNaN(value) && !isNaN(parseFloat(value)),
92
+ isAlpha: (value) => /^[a-zA-Z]+$/.test(value),
93
+ isAlphanumeric: (value) => /^[a-zA-Z0-9]+$/.test(value),
94
+ isBoolean: (value) =>
95
+ value === true || value === false || value === "true" || value === "false",
96
+ isISO8601: (value) => !isNaN(Date.parse(value)),
97
+ isURL: (value) => {
98
+ try {
99
+ new URL(value);
100
+ return true;
101
+ } catch {
102
+ return false;
103
+ }
104
+ },
105
+ isLength: (value, { min, max }) => {
106
+ const len = String(value).length;
107
+ if (min !== undefined && len < min) return false;
108
+ if (max !== undefined && len > max) return false;
109
+ return true;
110
+ },
111
+ isIn: (value, values) => values.includes(value),
112
+ equals: (value, comparison) => value === comparison,
113
+ matches: (value, pattern) => pattern.test(value),
114
+ };
115
+
116
+ /**
117
+ * Comprehensive Validator class for handling multi-language data validation.
118
+ */
119
+ class Validator {
120
+ /**
121
+ * Initializes the Validator instance with a schema and optional language settings.
122
+ * @param {Object} schema - Validation rules for each field (e.g., { email: { required: true, email: true } }).
123
+ * @param {string} [lang_default=null] - Default language for error messages (e.g., "en", "es").
124
+ * @param {Object} [messages=null] - Custom message overrides for validation rules.
125
+ * @example
126
+ * const loginSchema = {
127
+ * email: { required: true, email: true },
128
+ * password: { required: true, min: 6 }
129
+ * };
130
+ * const loginValidator = new Validator(loginSchema, 'es');
131
+ */
132
+ constructor(schema, lang_default = null, messages = null) {
133
+ this.schema = schema;
134
+ this.lang_default = lang_default;
135
+ this.messages = messages ? messages : messages_default;
136
+ }
137
+
138
+ /**
139
+ * Validates the request body against the defined schema.
140
+ * @param {import('express').Request} req - The Express request object containing the body to validate.
141
+ * @returns {Promise<{success: boolean, error: boolean, errors: Array<{field: string, message: string}>, message: Array<string>, html: Array<string>}>} Validation results.
142
+ * @example
143
+ * const loginSchema = {
144
+ * email: { required: true, email: true },
145
+ * password: { required: true, min: 6 }
146
+ * };
147
+ * const loginValidator = new Validator(loginSchema, 'es');
148
+ * const result = await loginValidator.validate(req);
149
+ */
150
+ async validate(req) {
151
+ let lang =
152
+ req?.body?.lang ||
153
+ req?.query?.lang ||
154
+ req?.params?.lang ||
155
+ req?.cookies?.lang ||
156
+ req?.headers["accept-language"]?.split(",")[0]?.split("-")[0] ||
157
+ req?.session?.lang ||
158
+ this.lang_default ||
159
+ "es";
160
+ const msg = this.messages[lang] || this.messages.es;
161
+ const errors = [];
162
+ const messages = [];
163
+ const body = req.body || {};
164
+
165
+ for (const [field, config] of Object.entries(this.schema)) {
166
+ let value = body[field];
167
+
168
+ if (config.xss !== false && typeof value === "string") {
169
+ body[field] = xss(value);
170
+ value = body[field];
171
+ }
172
+
173
+ if (config.required && validators.isEmpty(value)) {
174
+ messages.push(config.messages?.required || msg.required(field));
175
+ errors.push({
176
+ field: field,
177
+ message: config.messages?.required || msg.required(field),
178
+ });
179
+ continue;
180
+ }
181
+
182
+ if (!validators.isEmpty(value)) {
183
+ if (
184
+ config.min !== undefined &&
185
+ !validators.isLength(value, { min: config.min })
186
+ ) {
187
+ messages.push(config.messages?.min || msg.min(field, config.min));
188
+ errors.push({
189
+ field: field,
190
+ message: config.messages?.min || msg.min(field, config.min),
191
+ });
192
+ }
193
+ if (
194
+ config.max !== undefined &&
195
+ !validators.isLength(value, { max: config.max })
196
+ ) {
197
+ messages.push(config.messages?.max || msg.max(field, config.max));
198
+ errors.push({
199
+ field: field,
200
+ message: config.messages?.max || msg.max(field, config.max),
201
+ });
202
+ }
203
+ if (config.email && !validators.isEmail(value)) {
204
+ messages.push(config.messages?.email || msg.email(field));
205
+ errors.push({
206
+ field: field,
207
+ message: config.messages?.email || msg.email(field),
208
+ });
209
+ }
210
+ if (config.number && !validators.isNumeric(value)) {
211
+ messages.push(config.messages?.number || msg.number(field));
212
+ errors.push({
213
+ field: field,
214
+ message: config.messages?.number || msg.number(field),
215
+ });
216
+ }
217
+ if (config.alpha && !validators.isAlpha(value)) {
218
+ messages.push(config.messages?.alpha || msg.alpha(field));
219
+ errors.push({
220
+ field: field,
221
+ message: config.messages?.alpha || msg.alpha(field),
222
+ });
223
+ }
224
+ if (config.alphanumeric && !validators.isAlphanumeric(value)) {
225
+ messages.push(
226
+ config.messages?.alphanumeric || msg.alphanumeric(field),
227
+ );
228
+ errors.push({
229
+ field: field,
230
+ message: config.messages?.alphanumeric || msg.alphanumeric(field),
231
+ });
232
+ }
233
+ if (config.boolean && !validators.isBoolean(value)) {
234
+ messages.push(config.messages?.boolean || msg.boolean(field));
235
+ errors.push({
236
+ field: field,
237
+ message: config.messages?.boolean || msg.boolean(field),
238
+ });
239
+ }
240
+ if (config.date && !validators.isISO8601(value)) {
241
+ messages.push(config.messages?.date || msg.date(field));
242
+ errors.push({
243
+ field: field,
244
+ message: config.messages?.date || msg.date(field),
245
+ });
246
+ }
247
+ if (config.url && !validators.isURL(value)) {
248
+ messages.push(config.messages?.url || msg.url(field));
249
+ errors.push({
250
+ field: field,
251
+ message: config.messages?.url || msg.url(field),
252
+ });
253
+ }
254
+ if (config.in && !validators.isIn(value, config.in)) {
255
+ messages.push(config.messages?.in || msg.in(field, config.in));
256
+ errors.push({
257
+ field: field,
258
+ message: config.messages?.in || msg.in(field, config.in),
259
+ });
260
+ }
261
+ if (
262
+ config.equals !== undefined &&
263
+ !validators.equals(value, config.equals)
264
+ ) {
265
+ messages.push(
266
+ config.messages?.equals || msg.equals(field, config.equals),
267
+ );
268
+ errors.push({
269
+ field: field,
270
+ message:
271
+ config.messages?.equals || msg.equals(field, config.equals),
272
+ });
273
+ }
274
+ if (
275
+ config.password &&
276
+ !validators.matches(value, /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d).{6,}$/)
277
+ ) {
278
+ messages.push(config.messages?.password || msg.password(field));
279
+ errors.push({
280
+ field: field,
281
+ message: config.messages?.password || msg.password(field),
282
+ });
283
+ }
284
+ if (config.pattern && !validators.matches(value, config.pattern)) {
285
+ messages.push(config.messages?.pattern || msg.pattern(field));
286
+ errors.push({
287
+ field: field,
288
+ message: config.messages?.pattern || msg.pattern(field),
289
+ });
290
+ }
291
+ }
292
+ }
293
+
294
+ if (errors.length > 0 || messages.length > 0) {
295
+ return {
296
+ success: false,
297
+ error: true,
298
+ errors: errors,
299
+ message: messages,
300
+ };
301
+ }
302
+
303
+ return { success: true, error: false, errors: [], message: [], html: [] };
304
+ }
305
+
306
+ /**
307
+ * Express middleware for automated validation of the request body.
308
+ * Returns a 400 Bad Request response with validation results if errors occur.
309
+ * @returns {Function} Express middleware function (req, res, next).
310
+ * @example
311
+ *
312
+ * const loginSchema = {
313
+ * email: { required: true, email: true },
314
+ * password: { required: true, min: 6 }
315
+ * };
316
+ * const loginValidator = new Validator(loginSchema, 'es');
317
+ * routerUsers.post('/login', loginValidator.middleware(), (req, res) => {
318
+ * res.json({ message: 'Login successful' });
319
+ * });
320
+ */
321
+ middleware() {
322
+ return async (req, res, next) => {
323
+ const result = await this.validate(req);
324
+ if (!result.success) {
325
+ return res.status(400).json(result);
326
+ }
327
+ next();
328
+ };
329
+ }
330
+
331
+ /**
332
+ * Express middleware for explicitly sanitizing request data against XSS.
333
+ * Can be used on specific routes where HTML input is not expected.
334
+ * @returns {Function} Express middleware function.
335
+ */
336
+ static xssMiddleware() {
337
+ return (req, res, next) => {
338
+ if (req.body && typeof req.body === "object") {
339
+ Validator.mutateSanitized(req.body);
340
+ }
341
+ if (req.query && typeof req.query === "object") {
342
+ Validator.mutateSanitized(req.query);
343
+ }
344
+ if (req.params && typeof req.params === "object") {
345
+ Validator.mutateSanitized(req.params);
346
+ }
347
+ next();
348
+ };
349
+ }
350
+
351
+ static mutateSanitized(obj) {
352
+ for (const key in obj) {
353
+ if (typeof obj[key] === "string") {
354
+ obj[key] = xss(obj[key]);
355
+ } else if (typeof obj[key] === "object" && obj[key] !== null) {
356
+ Validator.mutateSanitized(obj[key]);
357
+ }
358
+ }
359
+ }
360
+
361
+ static sanitizeObject(obj) {
362
+ if (typeof obj === "string") return xss(obj);
363
+
364
+ if (Array.isArray(obj)) {
365
+ return obj.map((item) => Validator.sanitizeObject(item));
366
+ }
367
+
368
+ if (typeof obj === "object" && obj !== null) {
369
+ const sanitized = {};
370
+ for (const key in obj) {
371
+ sanitized[key] = Validator.sanitizeObject(obj[key]);
372
+ }
373
+ return sanitized;
374
+ }
375
+
376
+ return obj;
377
+ }
378
+ }
379
+
380
+ export default Validator;
@@ -0,0 +1,27 @@
1
+ <!DOCTYPE html>
2
+ <html lang="__LANG__">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>__TITLE__</title>
7
+ <link rel="icon" href="/favicon.ico" />
8
+ <meta name="description" content="__DESCRIPTION__" />
9
+ <meta name="keywords" content="__KEYWORDS__" />
10
+ <meta name="author" content="__AUTHOR__" />
11
+ <link rel="preconnect" href="https://fonts.googleapis.com">
12
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
13
+ <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@100..900&family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap" rel="stylesheet">
14
+ __HEAD_OPTIONS__
15
+ __LINK_STYLES__
16
+ __SCRIPTS_HEAD__
17
+ __VITE_ASSETS__
18
+ __STYLES_SKELETON__
19
+ </head>
20
+ <body class="__CLASS_BODY__">
21
+ <div id="root" data-react-component="__COMPONENT__" data-props='__PROPS__'>
22
+ __SKELETON__
23
+ </div>
24
+ __SCRIPTS_BODY__
25
+ </body>
26
+
27
+ </html>
@@ -0,0 +1,70 @@
1
+ <!DOCTYPE html>
2
+ <html lang="__LANG__">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>__TITLE__</title>
8
+ <meta name="description" content="__DESCRIPTION__">
9
+ <meta name="keywords" content="__KEYWORDS__">
10
+ <meta name="author" content="__AUTHOR__">
11
+ <link rel="icon" href="/favicon.ico" />
12
+ __HEAD_OPTIONS__
13
+ <script src="https://cdn.tailwindcss.com"></script>
14
+ <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@400;700&display=swap" rel="stylesheet">
15
+ <style>
16
+ body {
17
+ font-family: 'Outfit', sans-serif;
18
+ }
19
+
20
+ .hero-gradient {
21
+ background: radial-gradient(circle at top right, #f0f9ff 0%, #ffffff 100%);
22
+ }
23
+ </style>
24
+ __LINK_STYLES__
25
+ __SCRIPTS_HEAD__
26
+ __VITE_ASSETS__
27
+ __STYLES_SKELETON__
28
+ </head>
29
+
30
+ <body class="__CLASS_BODY__ hero-gradient min-h-screen">
31
+ <div id="root">
32
+ <!-- Landing Content -->
33
+ <nav class="p-6 flex justify-between items-center max-w-7xl mx-auto">
34
+ <div class="text-2xl font-bold text-sky-600">Blue Bird</div>
35
+ <div class="space-x-6 text-slate-600 font-medium">
36
+ <a href="#features" class="hover:text-sky-600">Features</a>
37
+ </div>
38
+ </nav>
39
+
40
+ <main class="max-w-7xl mx-auto px-6 pt-20 pb-32 text-center">
41
+ <h1 class="text-6xl md:text-8xl font-black text-slate-900 mb-8 tracking-tight">
42
+ Built for <span class="text-sky-600">Speed.</span>
43
+ </h1>
44
+ <p class="text-xl text-slate-600 max-w-2xl mx-auto mb-12 leading-relaxed">
45
+ This page was served in under 1ms thanks to Blue Bird's in-memory caching. No heavy bundles, just pure
46
+ performance.
47
+ </p>
48
+
49
+ <div class="flex flex-col sm:flex-row justify-center gap-4 mb-20">
50
+ <div class="p-8 bg-white rounded-3xl shadow-xl shadow-sky-100 border border-slate-50 flex-1 max-w-sm">
51
+ <div class="text-3xl mb-4">🚀</div>
52
+ <h3 class="font-bold text-xl mb-2">Static First</h3>
53
+ <p class="text-slate-500 text-sm">Perfect for SEO and instant first contentful paint.</p>
54
+ </div>
55
+ <div class="p-8 bg-white rounded-3xl shadow-xl shadow-sky-100 border border-slate-50 flex-1 max-w-sm">
56
+ <div class="text-3xl mb-4">💎</div>
57
+ <h3 class="font-bold text-xl mb-2">Hybrid Ready</h3>
58
+ <p class="text-slate-500 text-sm">Hydrate React in the background whenever you need it.</p>
59
+ </div>
60
+ </div>
61
+
62
+ <footer class="text-slate-400 text-sm italic">
63
+ Served by Blue Bird Framework &copy; 2026
64
+ </footer>
65
+ </main>
66
+ </div>
67
+ __SCRIPTS_BODY__
68
+ </body>
69
+
70
+ </html>
Binary file
@@ -0,0 +1,18 @@
1
+ @import "tailwindcss";
2
+ @custom-variant dark (&:where(.dark, .dark *));
3
+
4
+ @theme {
5
+ --font-sans: "Outfit", ui-sans-serif, system-ui, sans-serif;
6
+ --font-mono: "JetBrains Mono", ui-monospace, monospace;
7
+
8
+ --color-skye-50: #f0f9ff;
9
+ --color-skye-100: #e0f2fe;
10
+ --color-skye-200: #bae6fd;
11
+ --color-skye-300: #7dd3fc;
12
+ --color-skye-400: #38bdf8;
13
+ --color-skye-500: #0ea5e9;
14
+ --color-skye-600: #0284c7;
15
+ --color-skye-700: #0369a1;
16
+ --color-skye-800: #075985;
17
+ --color-skye-900: #0c4a6e;
18
+ }
@@ -0,0 +1,70 @@
1
+ import React, { lazy, Suspense } from 'react';
2
+ import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
3
+ import { ThemeProvider } from './blue-bird/contexts/ThemeContext.jsx';
4
+ import Skeleton from './blue-bird/components/Skeleton.jsx';
5
+ import { LanguageProvider } from './blue-bird/contexts/LanguageContext.jsx';
6
+ import { SPAProvider } from './blue-bird/contexts/SPAContext.jsx';
7
+
8
+ const Home = lazy(() => import('./pages/Home'));
9
+ const About = lazy(() => import('./pages/About'));
10
+
11
+ /**
12
+ * Supported languages and default language.
13
+ * Leave LANGUAGES empty for monolingual applications.
14
+ */
15
+ const LANGUAGES = ["en", "es"];
16
+ const DEFAULT_LANGUAGE = "en";
17
+
18
+ /**
19
+ * Route definitions.
20
+ */
21
+ const ROUTES = [
22
+ { path: "/", element: <Home /> },
23
+ { path: "/about", element: <About /> },
24
+ ];
25
+
26
+ /**
27
+ * Generates routes for all language prefixes if LANGUAGES is defined.
28
+ */
29
+ function generateRoutes(routes, languages = []) {
30
+ const allRoutes = [];
31
+
32
+ routes.forEach(({ path: routePath, element }) => {
33
+ // Base path
34
+ allRoutes.push(
35
+ <Route key={routePath} path={routePath} element={element} />
36
+ );
37
+
38
+ // Language-prefixed paths (only if multiple languages are used)
39
+ if (languages && languages.length > 0) {
40
+ languages.forEach((lang) => {
41
+ const langPath = `/${lang}${routePath === "/" ? "" : routePath}`;
42
+ allRoutes.push(
43
+ <Route key={langPath} path={langPath} element={element} />
44
+ );
45
+ });
46
+ }
47
+ });
48
+
49
+ return allRoutes;
50
+ }
51
+
52
+ export default function App(_props) {
53
+ const { lang } = _props.props;
54
+
55
+ return (
56
+ <ThemeProvider>
57
+ <LanguageProvider initialLang={lang}>
58
+ <Router>
59
+ <SPAProvider languages={LANGUAGES} defaultLanguage={DEFAULT_LANGUAGE}>
60
+ <Suspense fallback={<Skeleton />}>
61
+ <Routes>
62
+ {generateRoutes(ROUTES, LANGUAGES)}
63
+ </Routes>
64
+ </Suspense>
65
+ </SPAProvider>
66
+ </Router>
67
+ </LanguageProvider>
68
+ </ThemeProvider>
69
+ );
70
+ }
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+ import App from './App';
4
+ import "../css/tailwind.css"
5
+
6
+
7
+ document.addEventListener('DOMContentLoaded', () => {
8
+ document.querySelectorAll('[data-react-component]').forEach(el => {
9
+ const component = {
10
+ component: el.dataset.reactComponent
11
+ };
12
+ const props = JSON.parse(el.dataset.props || '{}');
13
+ const allProps = {
14
+ ...props,
15
+ ...component
16
+ }
17
+ createRoot(el).render(<App {...allProps} />);
18
+ });
19
+ });
@@ -0,0 +1,67 @@
1
+ import React from 'react';
2
+
3
+ export default function Button({ children, variant = 'default', size = 'default', className = '', ...props }) {
4
+ const baseStyle = "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50";
5
+
6
+ const variants = {
7
+ default: "bg-slate-900 dark:bg-slate-100 text-slate-50 dark:text-slate-900 hover:bg-slate-900/90 dark:hover:bg-slate-100/90",
8
+ destructive: "bg-red-500 text-slate-50 hover:bg-red-500/90 dark:bg-red-900 dark:hover:bg-red-900/90",
9
+ outline: "border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 text-slate-900 dark:text-slate-100 hover:bg-slate-100 dark:hover:bg-slate-800",
10
+ secondary: "bg-slate-100 dark:bg-slate-800 text-slate-900 dark:text-slate-100 hover:bg-slate-100/80 dark:hover:bg-slate-800/80",
11
+ ghost: "hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-900 dark:text-slate-100",
12
+ link: "text-slate-900 dark:text-slate-100 underline-offset-4 hover:underline",
13
+ fill: "bg-gray-100 dark:bg-slate-800 text-gray-900 dark:text-slate-100 hover:bg-gray-100/80 dark:hover:bg-slate-800/80 w-full",
14
+ blue: "bg-blue-500 text-white hover:bg-blue-500/90 w-full",
15
+ blue_light: "bg-blue-100 text-blue-500 hover:bg-blue-100/80 w-full font-semibold",
16
+ green: "bg-green-500 text-white hover:bg-green-500/90 w-full",
17
+ green_light: "bg-green-100 text-green-500 hover:bg-green-100/80 w-full font-semibold",
18
+ red: "bg-red-500 text-white hover:bg-red-500/90 w-full",
19
+ red_light: "bg-red-100 text-red-500 hover:bg-red-100/80 w-full font-semibold",
20
+ yellow: "bg-yellow-500 text-white hover:bg-yellow-500/90 w-full",
21
+ yellow_light: "bg-yellow-100 text-yellow-500 hover:bg-yellow-100/80 w-full font-semibold",
22
+ purple: "bg-purple-500 text-white hover:bg-purple-500/90 w-full",
23
+ purple_light: "bg-purple-100 text-purple-500 hover:bg-purple-100/80 w-full font-semibold",
24
+ pink: "bg-pink-500 text-white hover:bg-pink-500/90 w-full",
25
+ pink_light: "bg-pink-100 text-pink-500 hover:bg-pink-100/80 w-full font-semibold",
26
+ orange: "bg-orange-500 text-white hover:bg-orange-500/90 w-full",
27
+ orange_light: "bg-orange-100 text-orange-500 hover:bg-orange-100/80 w-full font-semibold",
28
+ cyan: "bg-cyan-500 text-white hover:bg-cyan-500/90 w-full",
29
+ cyan_light: "bg-cyan-100 text-cyan-500 hover:bg-cyan-100/80 w-full font-semibold",
30
+ teal: "bg-teal-500 text-white hover:bg-teal-500/90 w-full",
31
+ teal_light: "bg-teal-100 text-teal-500 hover:bg-teal-100/80 w-full font-semibold",
32
+ lime: "bg-lime-500 text-white hover:bg-lime-500/90 w-full",
33
+ lime_light: "bg-lime-100 text-lime-500 hover:bg-lime-100/80 w-full font-semibold",
34
+ indigo: "bg-indigo-500 text-white hover:bg-indigo-500/90 w-full",
35
+ indigo_light: "bg-indigo-100 text-indigo-500 hover:bg-indigo-100/80 w-full font-semibold",
36
+ violet: "bg-violet-500 text-white hover:bg-violet-500/90 w-full",
37
+ violet_light: "bg-violet-100 text-violet-500 hover:bg-violet-100/80 w-full font-semibold",
38
+ fuchsia: "bg-fuchsia-500 text-white hover:bg-fuchsia-500/90 w-full",
39
+ fuchsia_light: "bg-fuchsia-100 text-fuchsia-500 hover:bg-fuchsia-100/80 w-full font-semibold",
40
+ rose: "bg-rose-500 text-white hover:bg-rose-500/90 w-full",
41
+ rose_light: "bg-rose-100 text-rose-500 hover:bg-rose-100/80 w-full font-semibold",
42
+ emerald: "bg-emerald-500 text-white hover:bg-emerald-500/90 w-full",
43
+ emerald_light: "bg-emerald-100 text-emerald-500 hover:bg-emerald-100/80 w-full font-semibold",
44
+ sky: "bg-sky-500 text-white hover:bg-sky-500/90 w-full",
45
+ sky_light: "bg-sky-100 text-sky-500 hover:bg-sky-100/80 w-full font-semibold",
46
+ slate: "bg-slate-500 text-white hover:bg-slate-500/90 w-full",
47
+ gray: "bg-gray-500 text-white hover:bg-gray-500/90 w-full",
48
+ zinc: "bg-zinc-500 text-white hover:bg-zinc-500/90 w-full",
49
+ neutral: "bg-neutral-500 text-white hover:bg-neutral-500/90 w-full",
50
+ stone: "bg-stone-500 text-white hover:bg-stone-500/90 w-full",
51
+ };
52
+
53
+ const sizes = {
54
+ default: "h-10 px-4 py-2",
55
+ sm: "h-9 rounded-md px-3",
56
+ lg: "h-11 rounded-md px-8",
57
+ icon: "h-10 w-10"
58
+ };
59
+
60
+ const style = `${baseStyle} ${variants[variant] || variants.default} ${sizes[size] || sizes.default} ${className}`;
61
+
62
+ return (
63
+ <button className={style} {...props}>
64
+ {children}
65
+ </button>
66
+ );
67
+ }
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import Typography from './Typography';
3
+
4
+ export default function Card({ children, className = '', title, description, border = true, shadow = true }) {
5
+ return (
6
+ <div className={`rounded-lg ${border ? "border border-slate-200 dark:border-slate-800" : ""} ${shadow ? "shadow-sm" : ""} bg-white dark:bg-slate-900 text-slate-900 dark:text-slate-100 ${className}`}>
7
+ {(title || description) && (
8
+ <div className="flex flex-col space-y-1.5 p-6">
9
+ {title && <Typography variant='h5' className="font-semibold leading-none tracking-tight">{title}</Typography>}
10
+ {description && <Typography variant='p' className="text-sm text-slate-500 dark:text-slate-400">{description}</Typography>}
11
+ </div>
12
+ )}
13
+ <div className={`p-6 ${title || description ? 'pt-0' : ''}`}>
14
+ {children}
15
+ </div>
16
+ </div>
17
+ );
18
+ }