-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateui.sh
279 lines (238 loc) · 7.39 KB
/
createui.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#!/bin/bash
# Colores para output
GREEN="\033[0;32m"
BLUE="\033[0;34m"
RED="\033[0;31m"
YELLOW="\033[1;33m"
NC="\033[0m"
echo -e "${BLUE}=== Creando componentes y páginas ===${NC}"
# Crear layouts
create_layouts() {
echo -e "\n${YELLOW}Creando layouts...${NC}"
mkdir -p src/layouts
# Layout principal
cat > src/layouts/MainLayout.tsx << 'EOL'
import { ReactNode } from 'react';
import { Sidebar } from '../components/navigation/Sidebar';
import { TopBar } from '../components/navigation/TopBar';
interface MainLayoutProps {
children: ReactNode;
}
export const MainLayout = ({ children }: MainLayoutProps) => {
return (
<div className="min-h-screen bg-gradient-to-br from-slate-900 via-purple-900 to-slate-900">
<TopBar />
<div className="flex h-[calc(100vh-4rem)]">
<Sidebar />
<main className="flex-1 overflow-auto">
<div className="container mx-auto px-6 py-8">
{children}
</div>
</main>
</div>
</div>
);
};
EOL
# Layout de autenticación
cat > src/layouts/AuthLayout.tsx << 'EOL'
import { ReactNode } from 'react';
interface AuthLayoutProps {
children: ReactNode;
}
export const AuthLayout = ({ children }: AuthLayoutProps) => {
return (
<div className="min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-900 via-purple-900 to-slate-900">
<div className="w-full max-w-md">
{children}
</div>
</div>
);
};
EOL
}
# Crear componentes de navegación
create_navigation_components() {
echo -e "\n${YELLOW}Creando componentes de navegación...${NC}"
mkdir -p src/components/navigation
# Sidebar
cat > src/components/navigation/Sidebar.tsx << 'EOL'
import { useState } from 'react';
import { Link, useLocation } from 'react-router-dom';
import {
Shield, Activity, Cloud, Cpu, Smartphone,
Wifi, Server, Code, Settings, ChevronRight,
Menu
} from 'lucide-react';
export const Sidebar = () => {
const [collapsed, setCollapsed] = useState(false);
const location = useLocation();
const navItems = [
{ name: 'Overview', icon: Activity, path: '/' },
{ name: 'Security', icon: Shield, path: '/security' },
{ name: 'Cloud', icon: Cloud, path: '/cloud' },
{ name: 'Quantum', icon: Cpu, path: '/quantum' },
{ name: 'Mobile', icon: Smartphone, path: '/mobile' },
{ name: 'IoT', icon: Wifi, path: '/iot' },
{ name: 'Infrastructure', icon: Server, path: '/infrastructure' },
{ name: 'Development', icon: Code, path: '/development' },
{ name: 'Settings', icon: Settings, path: '/settings' }
];
return (
<div className={`${collapsed ? 'w-20' : 'w-64'} bg-slate-800/50 h-full backdrop-blur-sm border-r border-purple-500/20 transition-all duration-300`}>
{/* Sidebar content */}
</div>
);
};
EOL
# TopBar
cat > src/components/navigation/TopBar.tsx << 'EOL'
import { Bell, User, Search } from 'lucide-react';
export const TopBar = () => {
return (
<div className="h-16 bg-slate-800/50 backdrop-blur-sm border-b border-purple-500/20">
<div className="h-full px-6 flex items-center justify-between">
<div className="flex items-center gap-4">
<h1 className="text-xl font-bold text-white">AET Security</h1>
<div className="relative">
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4" />
<input
type="text"
placeholder="Search..."
className="pl-10 pr-4 py-2 bg-slate-700/50 border border-purple-500/20 rounded-lg text-white placeholder-gray-400 focus:outline-none focus:border-purple-500"
/>
</div>
</div>
<div className="flex items-center gap-4">
<button className="text-gray-400 hover:text-white transition-colors">
<Bell className="w-5 h-5" />
</button>
<button className="flex items-center gap-2 text-gray-400 hover:text-white transition-colors">
<User className="w-5 h-5" />
</button>
</div>
</div>
</div>
);
};
EOL
}
# Crear páginas principales
create_pages() {
echo -e "\n${YELLOW}Creando páginas principales...${NC}"
mkdir -p src/pages
# Página de Dashboard
cat > src/pages/Dashboard.tsx << 'EOL'
import { MainLayout } from '../layouts/MainLayout';
import { SecurityMetrics } from '../components/security/SecurityMetrics';
import { ActiveTools } from '../components/security/ActiveTools';
import { SecurityEvents } from '../components/security/SecurityEvents';
import { SystemStatus } from '../components/system/SystemStatus';
export const DashboardPage = () => {
return (
<MainLayout>
<div className="grid gap-6">
<SecurityMetrics />
<div className="grid grid-cols-2 gap-6">
<ActiveTools />
<SystemStatus />
</div>
<SecurityEvents />
</div>
</MainLayout>
);
};
EOL
# Página de Login
cat > src/pages/Login.tsx << 'EOL'
import { AuthLayout } from '../layouts/AuthLayout';
import { useState } from 'react';
import { useAuth } from '../hooks/useAuth';
export const LoginPage = () => {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const { login } = useAuth();
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
await login(email, password);
};
return (
<AuthLayout>
{/* Form content */}
</AuthLayout>
);
};
EOL
}
# Crear hooks personalizados
create_hooks() {
echo -e "\n${YELLOW}Creando hooks personalizados...${NC}"
mkdir -p src/hooks
# Hook de autenticación
cat > src/hooks/useAuth.ts << 'EOL'
import { create } from 'zustand';
interface AuthState {
user: any | null;
login: (email: string, password: string) => Promise<void>;
logout: () => Promise<void>;
}
export const useAuth = create<AuthState>((set) => ({
user: null,
login: async (email, password) => {
// Implementar lógica de login
set({ user: { email } });
},
logout: async () => {
// Implementar lógica de logout
set({ user: null });
},
}));
EOL
# Hook de tema
cat > src/hooks/useTheme.ts << 'EOL'
import { create } from 'zustand';
interface ThemeState {
theme: 'light' | 'dark';
toggleTheme: () => void;
}
export const useTheme = create<ThemeState>((set) => ({
theme: 'dark',
toggleTheme: () => set((state) => ({ theme: state.theme === 'light' ? 'dark' : 'light' })),
}));
EOL
}
# Configurar enrutamiento
setup_routing() {
echo -e "\n${YELLOW}Configurando enrutamiento...${NC}"
# Router principal
cat > src/router.tsx << 'EOL'
import { createBrowserRouter } from 'react-router-dom';
import { DashboardPage } from './pages/Dashboard';
import { LoginPage } from './pages/Login';
import { ProtectedRoute } from './components/auth/ProtectedRoute';
export const router = createBrowserRouter([
{
path: '/login',
element: <LoginPage />,
},
{
path: '/',
element: <ProtectedRoute><DashboardPage /></ProtectedRoute>,
},
// Añadir más rutas aquí
]);
EOL
}
# Función principal
main() {
create_layouts
create_navigation_components
create_pages
create_hooks
setup_routing
echo -e "${GREEN}¡Componentes y páginas creados exitosamente!${NC}"
}
# Manejo de errores
trap 'echo -e "${RED}Error: El proceso falló. Revisa los logs para más detalles.${NC}"; exit 1' ERR
# Ejecutar script
main