Skip to content

Commit 13f0365

Browse files
author
PHAN Xuan Quang
committed
new version
1 parent b0ebd47 commit 13f0365

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+7504
-16555
lines changed

xcan/.gitignore

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,39 @@
33
# dependencies
44
/node_modules
55
/.pnp
6-
.pnp.js
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
712

813
# testing
914
/coverage
1015

16+
# next.js
17+
/.next/
18+
/out/
19+
1120
# production
1221
/build
1322

1423
# misc
1524
.DS_Store
16-
.env.local
17-
.env.development.local
18-
.env.test.local
19-
.env.production.local
25+
*.pem
2026

27+
# debug
2128
npm-debug.log*
2229
yarn-debug.log*
2330
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts

xcan/README.md

Lines changed: 198 additions & 69 deletions
Large diffs are not rendered by default.

xcan/app/favicon.ico

25.3 KB
Binary file not shown.

xcan/app/globals.css

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@300;400;500;600;700&display=swap');
2+
@import "tailwindcss";
3+
@import "tw-animate-css";
4+
5+
@custom-variant dark (&:is(.dark *));
6+
7+
@theme inline {
8+
--color-background: var(--background);
9+
--color-foreground: var(--foreground);
10+
--font-sans: 'Be Vietnam Pro', system-ui, sans-serif;
11+
--font-mono: var(--font-geist-mono);
12+
--color-sidebar-ring: var(--sidebar-ring);
13+
--color-sidebar-border: var(--sidebar-border);
14+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
15+
--color-sidebar-accent: var(--sidebar-accent);
16+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
17+
--color-sidebar-primary: var(--sidebar-primary);
18+
--color-sidebar-foreground: var(--sidebar-foreground);
19+
--color-sidebar: var(--sidebar);
20+
--color-chart-5: var(--chart-5);
21+
--color-chart-4: var(--chart-4);
22+
--color-chart-3: var(--chart-3);
23+
--color-chart-2: var(--chart-2);
24+
--color-chart-1: var(--chart-1);
25+
--color-ring: var(--ring);
26+
--color-input: var(--input);
27+
--color-border: var(--border);
28+
--color-destructive: var(--destructive);
29+
--color-accent-foreground: var(--accent-foreground);
30+
--color-accent: var(--accent);
31+
--color-muted-foreground: var(--muted-foreground);
32+
--color-muted: var(--muted);
33+
--color-secondary-foreground: var(--secondary-foreground);
34+
--color-secondary: var(--secondary);
35+
--color-primary-foreground: var(--primary-foreground);
36+
--color-primary: var(--primary);
37+
--color-popover-foreground: var(--popover-foreground);
38+
--color-popover: var(--popover);
39+
--color-card-foreground: var(--card-foreground);
40+
--color-card: var(--card);
41+
--radius-sm: calc(var(--radius) - 4px);
42+
--radius-md: calc(var(--radius) - 2px);
43+
--radius-lg: var(--radius);
44+
--radius-xl: calc(var(--radius) + 4px);
45+
}
46+
47+
:root {
48+
--radius: 0.625rem;
49+
--background: oklch(1 0 0);
50+
--foreground: oklch(0.145 0 0);
51+
--card: oklch(1 0 0);
52+
--card-foreground: oklch(0.145 0 0);
53+
--popover: oklch(1 0 0);
54+
--popover-foreground: oklch(0.145 0 0);
55+
--primary: oklch(0.205 0 0);
56+
--primary-foreground: oklch(0.985 0 0);
57+
--secondary: oklch(0.97 0 0);
58+
--secondary-foreground: oklch(0.205 0 0);
59+
--muted: oklch(0.97 0 0);
60+
--muted-foreground: oklch(0.556 0 0);
61+
--accent: oklch(0.97 0 0);
62+
--accent-foreground: oklch(0.205 0 0);
63+
--destructive: oklch(0.577 0.245 27.325);
64+
--border: oklch(0.922 0 0);
65+
--input: oklch(0.922 0 0);
66+
--ring: oklch(0.708 0 0);
67+
--chart-1: oklch(0.646 0.222 41.116);
68+
--chart-2: oklch(0.6 0.118 184.704);
69+
--chart-3: oklch(0.398 0.07 227.392);
70+
--chart-4: oklch(0.828 0.189 84.429);
71+
--chart-5: oklch(0.769 0.188 70.08);
72+
--sidebar: oklch(0.985 0 0);
73+
--sidebar-foreground: oklch(0.145 0 0);
74+
--sidebar-primary: oklch(0.205 0 0);
75+
--sidebar-primary-foreground: oklch(0.985 0 0);
76+
--sidebar-accent: oklch(0.97 0 0);
77+
--sidebar-accent-foreground: oklch(0.205 0 0);
78+
--sidebar-border: oklch(0.922 0 0);
79+
--sidebar-ring: oklch(0.708 0 0);
80+
}
81+
82+
.dark {
83+
--background: oklch(0.145 0 0);
84+
--foreground: oklch(0.985 0 0);
85+
--card: oklch(0.205 0 0);
86+
--card-foreground: oklch(0.985 0 0);
87+
--popover: oklch(0.205 0 0);
88+
--popover-foreground: oklch(0.985 0 0);
89+
--primary: oklch(0.922 0 0);
90+
--primary-foreground: oklch(0.205 0 0);
91+
--secondary: oklch(0.269 0 0);
92+
--secondary-foreground: oklch(0.985 0 0);
93+
--muted: oklch(0.269 0 0);
94+
--muted-foreground: oklch(0.708 0 0);
95+
--accent: oklch(0.269 0 0);
96+
--accent-foreground: oklch(0.985 0 0);
97+
--destructive: oklch(0.704 0.191 22.216);
98+
--border: oklch(1 0 0 / 10%);
99+
--input: oklch(1 0 0 / 15%);
100+
--ring: oklch(0.556 0 0);
101+
--chart-1: oklch(0.488 0.243 264.376);
102+
--chart-2: oklch(0.696 0.17 162.48);
103+
--chart-3: oklch(0.769 0.188 70.08);
104+
--chart-4: oklch(0.627 0.265 303.9);
105+
--chart-5: oklch(0.645 0.246 16.439);
106+
--sidebar: oklch(0.205 0 0);
107+
--sidebar-foreground: oklch(0.985 0 0);
108+
--sidebar-primary: oklch(0.488 0.243 264.376);
109+
--sidebar-primary-foreground: oklch(0.985 0 0);
110+
--sidebar-accent: oklch(0.269 0 0);
111+
--sidebar-accent-foreground: oklch(0.985 0 0);
112+
--sidebar-border: oklch(1 0 0 / 10%);
113+
--sidebar-ring: oklch(0.556 0 0);
114+
}
115+
116+
@layer base {
117+
* {
118+
@apply border-border outline-ring/50;
119+
}
120+
body {
121+
@apply bg-background text-foreground;
122+
}
123+
}

xcan/app/layout.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use client';
2+
3+
import './globals.css';
4+
import { ThemeProvider } from '@/components/theme-provider';
5+
import { Toaster } from '@/components/ui/sonner';
6+
7+
export default function RootLayout({
8+
children,
9+
}: Readonly<{
10+
children: React.ReactNode;
11+
}>) {
12+
return (
13+
<html lang="en" suppressHydrationWarning>
14+
<head>
15+
<title>XCan - Convert Images to HTML/Tailwind</title>
16+
<meta name="description" content="Convert design images to HTML and Tailwind CSS code using Google Gemini AI" />
17+
<meta name="viewport" content="width=device-width, initial-scale=1" />
18+
<link rel="icon" href="/favicon.ico" />
19+
</head>
20+
<body className="min-h-screen bg-background font-sans antialiased">
21+
<ThemeProvider defaultTheme="dark">
22+
{children}
23+
<Toaster position="top-center" />
24+
</ThemeProvider>
25+
</body>
26+
</html>
27+
);
28+
}

xcan/app/page.tsx

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
'use client';
2+
3+
import { useEffect, useState } from 'react';
4+
import { Navbar } from '@/components/navbar';
5+
import { ApiKeyForm } from '@/components/auth-wizard/api-key-form';
6+
import { Converter } from '@/components/image-converter/converter';
7+
import { API_KEY_STORAGE_KEY } from '@/lib/services/api';
8+
import { motion, AnimatePresence } from 'framer-motion';
9+
10+
export default function Home() {
11+
const [isAuthenticated, setIsAuthenticated] = useState(false);
12+
const [isLoading, setIsLoading] = useState(true);
13+
14+
useEffect(() => {
15+
// Check if API key exists in localStorage
16+
const apiKey = localStorage.getItem(API_KEY_STORAGE_KEY);
17+
setIsAuthenticated(!!apiKey);
18+
setIsLoading(false);
19+
}, []);
20+
21+
// Listen for changes to the API key in localStorage (from API key update dialog)
22+
useEffect(() => {
23+
const handleStorageChange = () => {
24+
const apiKey = localStorage.getItem(API_KEY_STORAGE_KEY);
25+
setIsAuthenticated(!!apiKey);
26+
};
27+
28+
window.addEventListener('storage', handleStorageChange);
29+
return () => window.removeEventListener('storage', handleStorageChange);
30+
}, []);
31+
32+
const handleAuthSuccess = () => {
33+
setIsAuthenticated(true);
34+
};
35+
36+
if (isLoading) {
37+
return (
38+
<div className="fixed inset-0 flex items-center justify-center bg-background/80 backdrop-blur-sm">
39+
<div className="w-12 h-12 rounded-full border-4 border-primary/30 border-t-primary animate-spin"></div>
40+
</div>
41+
);
42+
}
43+
44+
return (
45+
<div className="min-h-screen flex flex-col bg-gradient-to-br from-background to-background/90 antialiased">
46+
<Navbar />
47+
48+
<main className="flex-1 w-full">
49+
<AnimatePresence mode="wait">
50+
{isAuthenticated ? (
51+
<motion.div
52+
key="converter"
53+
initial={{ opacity: 0 }}
54+
animate={{ opacity: 1 }}
55+
exit={{ opacity: 0 }}
56+
transition={{ duration: 0.4 }}
57+
>
58+
<Converter />
59+
</motion.div>
60+
) : (
61+
<motion.div
62+
key="auth"
63+
initial={{ opacity: 0 }}
64+
animate={{ opacity: 1 }}
65+
exit={{ opacity: 0 }}
66+
transition={{ duration: 0.4 }}
67+
className="flex items-center justify-center px-4 py-16 min-h-[calc(100vh-10rem)]"
68+
>
69+
<ApiKeyForm onSuccess={handleAuthSuccess} />
70+
</motion.div>
71+
)}
72+
</AnimatePresence>
73+
</main>
74+
</div>
75+
);
76+
}

xcan/components.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "new-york",
4+
"rsc": true,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "",
8+
"css": "app/globals.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils",
16+
"ui": "@/components/ui",
17+
"lib": "@/lib",
18+
"hooks": "@/hooks"
19+
},
20+
"iconLibrary": "lucide"
21+
}

0 commit comments

Comments
 (0)