Spaces:
Paused
feat: add skill detail pages, Supabase backend, enhanced SkillModal with info bar & ratings
Browse files- New pages: SkillDetailPage, CravingDetailPage, DashboardPage, SettingsPage
- Enhanced SkillModal: info bar (rating/category/developer/version/users/openSource),
expandable description, featured use cases, rating bars, user rating, share button
- SkillsGrid cards: added rating score, user count, open-source badge
- Supabase schema: skills, cravings, stars, ratings, downloads, user_profiles tables
with RLS policies, RPC functions, and full-text search index
- API hooks: useSupabaseSkills, useCravings, useStars, useRatings, useProfile,
useDownloads, useRealtimeSkills (real-time toast notifications)
- UI primitives: Button, Card, Badge, Input, StarRating (CVA-based)
- DataProvider abstraction with Supabase/localStorage fallback
- Extended Skill interface with optional rating, developer, version, users, showcases fields
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- package.json +2 -1
- pnpm-lock.yaml +10 -0
- src/App.tsx +68 -18
- src/components/common/SkillModal.tsx +300 -43
- src/components/home/SkillsGrid.tsx +14 -3
- src/components/layout/Footer.tsx +117 -0
- src/components/ui/Badge.tsx +38 -0
- src/components/ui/Button.tsx +48 -0
- src/components/ui/Card.tsx +59 -0
- src/components/ui/Input.tsx +28 -0
- src/components/ui/StarRating.tsx +67 -0
- src/contexts/LanguageContext.tsx +12 -0
- src/data/skillsData.ts +8 -0
- src/hooks/api/index.ts +7 -0
- src/hooks/api/useCravings.ts +98 -0
- src/hooks/api/useDownloads.ts +19 -0
- src/hooks/api/useProfile.ts +68 -0
- src/hooks/api/useRatings.ts +74 -0
- src/hooks/api/useRealtimeSkills.ts +42 -0
- src/hooks/api/useStars.ts +90 -0
- src/hooks/api/useSupabaseSkills.ts +156 -0
- src/lib/dataProvider.ts +78 -0
- src/pages/CravingDetailPage.tsx +177 -0
- src/pages/DashboardPage.tsx +233 -0
- src/pages/DiscoverPage.tsx +163 -0
- src/pages/LandingPage.tsx +237 -0
- src/pages/SettingsPage.tsx +152 -0
- src/pages/SkillDetailPage.tsx +325 -0
- supabase/migrations/001_init.sql +217 -0
|
@@ -24,6 +24,7 @@
|
|
| 24 |
"@vitejs/plugin-react": "^5.1.1",
|
| 25 |
"@webcontainer/api": "^1.1.7",
|
| 26 |
"axios": "^1.13.2",
|
|
|
|
| 27 |
"clsx": "^2.1.1",
|
| 28 |
"lucide-react": "^0.563.0",
|
| 29 |
"react": "^19.2.0",
|
|
@@ -40,8 +41,8 @@
|
|
| 40 |
},
|
| 41 |
"devDependencies": {
|
| 42 |
"@eslint/js": "^9.39.1",
|
| 43 |
-
"@tauri-apps/cli": "^2",
|
| 44 |
"@tailwindcss/typography": "^0.5.19",
|
|
|
|
| 45 |
"@types/node": "^24.10.1",
|
| 46 |
"@types/react": "^19.2.5",
|
| 47 |
"@types/react-dom": "^19.2.3",
|
|
|
|
| 24 |
"@vitejs/plugin-react": "^5.1.1",
|
| 25 |
"@webcontainer/api": "^1.1.7",
|
| 26 |
"axios": "^1.13.2",
|
| 27 |
+
"class-variance-authority": "^0.7.1",
|
| 28 |
"clsx": "^2.1.1",
|
| 29 |
"lucide-react": "^0.563.0",
|
| 30 |
"react": "^19.2.0",
|
|
|
|
| 41 |
},
|
| 42 |
"devDependencies": {
|
| 43 |
"@eslint/js": "^9.39.1",
|
|
|
|
| 44 |
"@tailwindcss/typography": "^0.5.19",
|
| 45 |
+
"@tauri-apps/cli": "^2",
|
| 46 |
"@types/node": "^24.10.1",
|
| 47 |
"@types/react": "^19.2.5",
|
| 48 |
"@types/react-dom": "^19.2.3",
|
|
@@ -38,6 +38,9 @@ importers:
|
|
| 38 |
axios:
|
| 39 |
specifier: ^1.13.2
|
| 40 |
version: 1.13.5
|
|
|
|
|
|
|
|
|
|
| 41 |
clsx:
|
| 42 |
specifier: ^2.1.1
|
| 43 |
version: 2.1.1
|
|
@@ -970,6 +973,9 @@ packages:
|
|
| 970 |
resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==}
|
| 971 |
engines: {node: '>= 8.10.0'}
|
| 972 |
|
|
|
|
|
|
|
|
|
|
| 973 |
clsx@2.1.1:
|
| 974 |
resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==}
|
| 975 |
engines: {node: '>=6'}
|
|
@@ -2879,6 +2885,10 @@ snapshots:
|
|
| 2879 |
optionalDependencies:
|
| 2880 |
fsevents: 2.3.3
|
| 2881 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2882 |
clsx@2.1.1: {}
|
| 2883 |
|
| 2884 |
color-convert@2.0.1:
|
|
|
|
| 38 |
axios:
|
| 39 |
specifier: ^1.13.2
|
| 40 |
version: 1.13.5
|
| 41 |
+
class-variance-authority:
|
| 42 |
+
specifier: ^0.7.1
|
| 43 |
+
version: 0.7.1
|
| 44 |
clsx:
|
| 45 |
specifier: ^2.1.1
|
| 46 |
version: 2.1.1
|
|
|
|
| 973 |
resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==}
|
| 974 |
engines: {node: '>= 8.10.0'}
|
| 975 |
|
| 976 |
+
class-variance-authority@0.7.1:
|
| 977 |
+
resolution: {integrity: sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==}
|
| 978 |
+
|
| 979 |
clsx@2.1.1:
|
| 980 |
resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==}
|
| 981 |
engines: {node: '>=6'}
|
|
|
|
| 2885 |
optionalDependencies:
|
| 2886 |
fsevents: 2.3.3
|
| 2887 |
|
| 2888 |
+
class-variance-authority@0.7.1:
|
| 2889 |
+
dependencies:
|
| 2890 |
+
clsx: 2.1.1
|
| 2891 |
+
|
| 2892 |
clsx@2.1.1: {}
|
| 2893 |
|
| 2894 |
color-convert@2.0.1:
|
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import { useState, useEffect, useCallback, useSyncExternalStore, Component, type ReactNode } from 'react';
|
| 2 |
import { BrowserRouter, Routes, Route, useNavigate, Navigate, useLocation, useSearchParams } from 'react-router-dom';
|
| 3 |
-
import { Toaster } from 'sonner';
|
| 4 |
import type { User } from '@supabase/supabase-js';
|
| 5 |
import { supabase } from './lib/supabaseClient';
|
| 6 |
import { Layout } from './components/layout/Layout';
|
|
@@ -19,13 +19,17 @@ import { DocsModal } from './components/common/DocsModal';
|
|
| 19 |
import { SkillCreationPage } from './pages/SkillCreationPage';
|
| 20 |
import { MySkillsLibrary } from './components/skill-creator/MySkillsLibrary';
|
| 21 |
import { SkillExecutor } from './components/skill-creator/SkillExecutor';
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
import type { Skill, SkillCategory } from './types/skill-creator';
|
| 23 |
import { storageUtils } from './utils/storage';
|
| 24 |
import { SKILLS_DATA } from './data/skillsData';
|
| 25 |
import { type Skill as StoreSkill } from './data/skillsData';
|
| 26 |
import type { Craving } from './data/cravingsData';
|
| 27 |
-
import { toast } from 'sonner';
|
| 28 |
import { LanguageProvider } from './contexts/LanguageContext';
|
|
|
|
| 29 |
|
| 30 |
// ---------------------------------------------------------------------------
|
| 31 |
// Error Boundary — prevents blank screen on unhandled errors
|
|
@@ -109,6 +113,8 @@ const PAGE_TITLES: Record<string, string> = {
|
|
| 109 |
'/': 'Candy Shop — AI Skills Marketplace',
|
| 110 |
'/skills/create': 'Create Skill — Candy Shop',
|
| 111 |
'/skills/library': 'My Library — Candy Shop',
|
|
|
|
|
|
|
| 112 |
'/auth/callback': 'Signing in... — Candy Shop',
|
| 113 |
};
|
| 114 |
|
|
@@ -120,6 +126,9 @@ function usePageTitle() {
|
|
| 120 |
}, [location.pathname]);
|
| 121 |
}
|
| 122 |
|
|
|
|
|
|
|
|
|
|
| 123 |
interface HomePageProps {
|
| 124 |
user: User | null;
|
| 125 |
cart: Set<string>;
|
|
@@ -154,11 +163,9 @@ function HomePage({
|
|
| 154 |
const [cravingSearch, setCravingSearch] = useState('');
|
| 155 |
const [cravingTagFilter, setCravingTagFilter] = useState<string | null>(null);
|
| 156 |
|
| 157 |
-
// Modal state
|
| 158 |
const [isPostCravingOpen, setIsPostCravingOpen] = useState(false);
|
| 159 |
const [isPostCandyOpen, setIsPostCandyOpen] = useState(false);
|
| 160 |
|
| 161 |
-
// User-posted items (persisted to localStorage)
|
| 162 |
const [userCravings, setUserCravings] = useState<Craving[]>(() => storageUtils.getUserCravings());
|
| 163 |
const [userCandies, setUserCandies] = useState<StoreSkill[]>(() => storageUtils.getUserCandies());
|
| 164 |
|
|
@@ -186,13 +193,11 @@ function HomePage({
|
|
| 186 |
document.getElementById('categories-section')?.scrollIntoView({ behavior: 'smooth' });
|
| 187 |
};
|
| 188 |
|
| 189 |
-
// Opens the Post Craving modal (switches to craving tab first)
|
| 190 |
const handleOpenPostCraving = () => {
|
| 191 |
setActiveTab('craving');
|
| 192 |
setTimeout(() => setIsPostCravingOpen(true), 100);
|
| 193 |
};
|
| 194 |
|
| 195 |
-
// Opens the Post Candy modal (switches to candy tab first)
|
| 196 |
const handleOpenPostCandy = () => {
|
| 197 |
setActiveTab('candy');
|
| 198 |
setTimeout(() => setIsPostCandyOpen(true), 100);
|
|
@@ -232,7 +237,6 @@ function HomePage({
|
|
| 232 |
onPostCandy={handleOpenPostCandy}
|
| 233 |
/>
|
| 234 |
|
| 235 |
-
{/* CANDY TAB */}
|
| 236 |
{activeTab === 'candy' && (
|
| 237 |
<>
|
| 238 |
<Categories
|
|
@@ -261,7 +265,6 @@ function HomePage({
|
|
| 261 |
</>
|
| 262 |
)}
|
| 263 |
|
| 264 |
-
{/* CRAVING TAB */}
|
| 265 |
{activeTab === 'craving' && (
|
| 266 |
<CravingsGrid
|
| 267 |
searchQuery={cravingSearch}
|
|
@@ -290,12 +293,15 @@ function HomePage({
|
|
| 290 |
);
|
| 291 |
}
|
| 292 |
|
|
|
|
|
|
|
|
|
|
| 293 |
function AppContent() {
|
| 294 |
const navigate = useNavigate();
|
| 295 |
const location = useLocation();
|
| 296 |
-
usePageTitle();
|
|
|
|
| 297 |
|
| 298 |
-
// Scroll to top on route change
|
| 299 |
useEffect(() => {
|
| 300 |
window.scrollTo(0, 0);
|
| 301 |
}, [location.pathname]);
|
|
@@ -308,7 +314,6 @@ function AppContent() {
|
|
| 308 |
const [cart, setCart] = useState<Set<string>>(() => new Set(storageUtils.getCart()));
|
| 309 |
const [executingSkill, setExecutingSkill] = useState<Skill | null>(null);
|
| 310 |
|
| 311 |
-
// Persist cart to localStorage whenever it changes
|
| 312 |
const updateCart = useCallback((updater: (prev: Set<string>) => Set<string>) => {
|
| 313 |
setCart((prev) => {
|
| 314 |
const next = updater(prev);
|
|
@@ -358,17 +363,14 @@ function AppContent() {
|
|
| 358 |
const handleClearCart = () => updateCart(() => new Set());
|
| 359 |
|
| 360 |
const handlePurchase = () => {
|
| 361 |
-
// Check if user is logged in
|
| 362 |
if (!user) {
|
| 363 |
setIsAuthOpen(true);
|
| 364 |
return;
|
| 365 |
}
|
| 366 |
|
| 367 |
-
// Convert store skills to user skills
|
| 368 |
const storeSkills = SKILLS_DATA.filter((skill) => cart.has(skill.id));
|
| 369 |
|
| 370 |
storeSkills.forEach((storeSkill) => {
|
| 371 |
-
// Check if already owned
|
| 372 |
const existing = storageUtils
|
| 373 |
.getSkills()
|
| 374 |
.find((s) => s.name === storeSkill.name && s.origin === 'store');
|
|
@@ -401,9 +403,6 @@ function AppContent() {
|
|
| 401 |
};
|
| 402 |
|
| 403 |
const handleRunSkill = (storeSkill: StoreSkill) => {
|
| 404 |
-
// Convert store skill to Skill format for executor
|
| 405 |
-
// CRITICAL: skillMdUrl must be passed through so SkillExecutor can
|
| 406 |
-
// fetch the real SKILL.md instructions from GitHub
|
| 407 |
const skill: Skill = {
|
| 408 |
id: `store-${storeSkill.id}`,
|
| 409 |
userId: user?.id || 'anonymous',
|
|
@@ -413,7 +412,7 @@ function AppContent() {
|
|
| 413 |
icon: storeSkill.icon,
|
| 414 |
color: storeSkill.color,
|
| 415 |
tags: storeSkill.tags || [],
|
| 416 |
-
skillMdUrl: storeSkill.skillMdUrl,
|
| 417 |
config: {
|
| 418 |
capabilities: [],
|
| 419 |
systemPrompt: '',
|
|
@@ -497,6 +496,7 @@ function AppContent() {
|
|
| 497 |
return (
|
| 498 |
<>
|
| 499 |
<Routes>
|
|
|
|
| 500 |
<Route
|
| 501 |
path="/"
|
| 502 |
element={
|
|
@@ -515,6 +515,53 @@ function AppContent() {
|
|
| 515 |
/>
|
| 516 |
}
|
| 517 |
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 518 |
<Route
|
| 519 |
path="/skills/create"
|
| 520 |
element={
|
|
@@ -528,6 +575,8 @@ function AppContent() {
|
|
| 528 |
</Layout>
|
| 529 |
}
|
| 530 |
/>
|
|
|
|
|
|
|
| 531 |
<Route
|
| 532 |
path="/skills/library"
|
| 533 |
element={
|
|
@@ -540,6 +589,7 @@ function AppContent() {
|
|
| 540 |
</Layout>
|
| 541 |
}
|
| 542 |
/>
|
|
|
|
| 543 |
<Route path="/auth/callback" element={<AuthCallback />} />
|
| 544 |
<Route path="/index.html" element={<Navigate to="/" replace />} />
|
| 545 |
<Route path="*" element={<Navigate to="/" replace />} />
|
|
|
|
| 1 |
import { useState, useEffect, useCallback, useSyncExternalStore, Component, type ReactNode } from 'react';
|
| 2 |
import { BrowserRouter, Routes, Route, useNavigate, Navigate, useLocation, useSearchParams } from 'react-router-dom';
|
| 3 |
+
import { Toaster, toast } from 'sonner';
|
| 4 |
import type { User } from '@supabase/supabase-js';
|
| 5 |
import { supabase } from './lib/supabaseClient';
|
| 6 |
import { Layout } from './components/layout/Layout';
|
|
|
|
| 19 |
import { SkillCreationPage } from './pages/SkillCreationPage';
|
| 20 |
import { MySkillsLibrary } from './components/skill-creator/MySkillsLibrary';
|
| 21 |
import { SkillExecutor } from './components/skill-creator/SkillExecutor';
|
| 22 |
+
import { SkillDetailPage } from './pages/SkillDetailPage';
|
| 23 |
+
import { CravingDetailPage } from './pages/CravingDetailPage';
|
| 24 |
+
import { DashboardPage } from './pages/DashboardPage';
|
| 25 |
+
import { SettingsPage } from './pages/SettingsPage';
|
| 26 |
import type { Skill, SkillCategory } from './types/skill-creator';
|
| 27 |
import { storageUtils } from './utils/storage';
|
| 28 |
import { SKILLS_DATA } from './data/skillsData';
|
| 29 |
import { type Skill as StoreSkill } from './data/skillsData';
|
| 30 |
import type { Craving } from './data/cravingsData';
|
|
|
|
| 31 |
import { LanguageProvider } from './contexts/LanguageContext';
|
| 32 |
+
import { useRealtimeNotifications } from './hooks/api/useRealtimeSkills';
|
| 33 |
|
| 34 |
// ---------------------------------------------------------------------------
|
| 35 |
// Error Boundary — prevents blank screen on unhandled errors
|
|
|
|
| 113 |
'/': 'Candy Shop — AI Skills Marketplace',
|
| 114 |
'/skills/create': 'Create Skill — Candy Shop',
|
| 115 |
'/skills/library': 'My Library — Candy Shop',
|
| 116 |
+
'/dashboard': 'Dashboard — Candy Shop',
|
| 117 |
+
'/settings': 'Settings — Candy Shop',
|
| 118 |
'/auth/callback': 'Signing in... — Candy Shop',
|
| 119 |
};
|
| 120 |
|
|
|
|
| 126 |
}, [location.pathname]);
|
| 127 |
}
|
| 128 |
|
| 129 |
+
// ---------------------------------------------------------------------------
|
| 130 |
+
// Home Page (original two-sided marketplace)
|
| 131 |
+
// ---------------------------------------------------------------------------
|
| 132 |
interface HomePageProps {
|
| 133 |
user: User | null;
|
| 134 |
cart: Set<string>;
|
|
|
|
| 163 |
const [cravingSearch, setCravingSearch] = useState('');
|
| 164 |
const [cravingTagFilter, setCravingTagFilter] = useState<string | null>(null);
|
| 165 |
|
|
|
|
| 166 |
const [isPostCravingOpen, setIsPostCravingOpen] = useState(false);
|
| 167 |
const [isPostCandyOpen, setIsPostCandyOpen] = useState(false);
|
| 168 |
|
|
|
|
| 169 |
const [userCravings, setUserCravings] = useState<Craving[]>(() => storageUtils.getUserCravings());
|
| 170 |
const [userCandies, setUserCandies] = useState<StoreSkill[]>(() => storageUtils.getUserCandies());
|
| 171 |
|
|
|
|
| 193 |
document.getElementById('categories-section')?.scrollIntoView({ behavior: 'smooth' });
|
| 194 |
};
|
| 195 |
|
|
|
|
| 196 |
const handleOpenPostCraving = () => {
|
| 197 |
setActiveTab('craving');
|
| 198 |
setTimeout(() => setIsPostCravingOpen(true), 100);
|
| 199 |
};
|
| 200 |
|
|
|
|
| 201 |
const handleOpenPostCandy = () => {
|
| 202 |
setActiveTab('candy');
|
| 203 |
setTimeout(() => setIsPostCandyOpen(true), 100);
|
|
|
|
| 237 |
onPostCandy={handleOpenPostCandy}
|
| 238 |
/>
|
| 239 |
|
|
|
|
| 240 |
{activeTab === 'candy' && (
|
| 241 |
<>
|
| 242 |
<Categories
|
|
|
|
| 265 |
</>
|
| 266 |
)}
|
| 267 |
|
|
|
|
| 268 |
{activeTab === 'craving' && (
|
| 269 |
<CravingsGrid
|
| 270 |
searchQuery={cravingSearch}
|
|
|
|
| 293 |
);
|
| 294 |
}
|
| 295 |
|
| 296 |
+
// ---------------------------------------------------------------------------
|
| 297 |
+
// App Content
|
| 298 |
+
// ---------------------------------------------------------------------------
|
| 299 |
function AppContent() {
|
| 300 |
const navigate = useNavigate();
|
| 301 |
const location = useLocation();
|
| 302 |
+
usePageTitle();
|
| 303 |
+
useRealtimeNotifications();
|
| 304 |
|
|
|
|
| 305 |
useEffect(() => {
|
| 306 |
window.scrollTo(0, 0);
|
| 307 |
}, [location.pathname]);
|
|
|
|
| 314 |
const [cart, setCart] = useState<Set<string>>(() => new Set(storageUtils.getCart()));
|
| 315 |
const [executingSkill, setExecutingSkill] = useState<Skill | null>(null);
|
| 316 |
|
|
|
|
| 317 |
const updateCart = useCallback((updater: (prev: Set<string>) => Set<string>) => {
|
| 318 |
setCart((prev) => {
|
| 319 |
const next = updater(prev);
|
|
|
|
| 363 |
const handleClearCart = () => updateCart(() => new Set());
|
| 364 |
|
| 365 |
const handlePurchase = () => {
|
|
|
|
| 366 |
if (!user) {
|
| 367 |
setIsAuthOpen(true);
|
| 368 |
return;
|
| 369 |
}
|
| 370 |
|
|
|
|
| 371 |
const storeSkills = SKILLS_DATA.filter((skill) => cart.has(skill.id));
|
| 372 |
|
| 373 |
storeSkills.forEach((storeSkill) => {
|
|
|
|
| 374 |
const existing = storageUtils
|
| 375 |
.getSkills()
|
| 376 |
.find((s) => s.name === storeSkill.name && s.origin === 'store');
|
|
|
|
| 403 |
};
|
| 404 |
|
| 405 |
const handleRunSkill = (storeSkill: StoreSkill) => {
|
|
|
|
|
|
|
|
|
|
| 406 |
const skill: Skill = {
|
| 407 |
id: `store-${storeSkill.id}`,
|
| 408 |
userId: user?.id || 'anonymous',
|
|
|
|
| 412 |
icon: storeSkill.icon,
|
| 413 |
color: storeSkill.color,
|
| 414 |
tags: storeSkill.tags || [],
|
| 415 |
+
skillMdUrl: storeSkill.skillMdUrl,
|
| 416 |
config: {
|
| 417 |
capabilities: [],
|
| 418 |
systemPrompt: '',
|
|
|
|
| 496 |
return (
|
| 497 |
<>
|
| 498 |
<Routes>
|
| 499 |
+
{/* Home — original two-sided marketplace */}
|
| 500 |
<Route
|
| 501 |
path="/"
|
| 502 |
element={
|
|
|
|
| 515 |
/>
|
| 516 |
}
|
| 517 |
/>
|
| 518 |
+
|
| 519 |
+
{/* Skill Detail — new page with stars/ratings */}
|
| 520 |
+
<Route
|
| 521 |
+
path="/candy/:id"
|
| 522 |
+
element={
|
| 523 |
+
<Layout {...sharedLayoutProps}>
|
| 524 |
+
<SkillDetailPage
|
| 525 |
+
cart={cart}
|
| 526 |
+
onToggleCart={handleAddToCart}
|
| 527 |
+
onRunSkill={handleRunSkill}
|
| 528 |
+
userId={user?.id}
|
| 529 |
+
/>
|
| 530 |
+
</Layout>
|
| 531 |
+
}
|
| 532 |
+
/>
|
| 533 |
+
|
| 534 |
+
{/* Craving Detail — new page */}
|
| 535 |
+
<Route
|
| 536 |
+
path="/craving/:id"
|
| 537 |
+
element={
|
| 538 |
+
<Layout {...sharedLayoutProps}>
|
| 539 |
+
<CravingDetailPage />
|
| 540 |
+
</Layout>
|
| 541 |
+
}
|
| 542 |
+
/>
|
| 543 |
+
|
| 544 |
+
{/* Dashboard — new page */}
|
| 545 |
+
<Route
|
| 546 |
+
path="/dashboard"
|
| 547 |
+
element={
|
| 548 |
+
<Layout {...sharedLayoutProps}>
|
| 549 |
+
<DashboardPage user={user} onOpenAuth={openAuth} />
|
| 550 |
+
</Layout>
|
| 551 |
+
}
|
| 552 |
+
/>
|
| 553 |
+
|
| 554 |
+
{/* Settings — new page */}
|
| 555 |
+
<Route
|
| 556 |
+
path="/settings"
|
| 557 |
+
element={
|
| 558 |
+
<Layout {...sharedLayoutProps}>
|
| 559 |
+
<SettingsPage />
|
| 560 |
+
</Layout>
|
| 561 |
+
}
|
| 562 |
+
/>
|
| 563 |
+
|
| 564 |
+
{/* Skill Creation */}
|
| 565 |
<Route
|
| 566 |
path="/skills/create"
|
| 567 |
element={
|
|
|
|
| 575 |
</Layout>
|
| 576 |
}
|
| 577 |
/>
|
| 578 |
+
|
| 579 |
+
{/* My Library */}
|
| 580 |
<Route
|
| 581 |
path="/skills/library"
|
| 582 |
element={
|
|
|
|
| 589 |
</Layout>
|
| 590 |
}
|
| 591 |
/>
|
| 592 |
+
|
| 593 |
<Route path="/auth/callback" element={<AuthCallback />} />
|
| 594 |
<Route path="/index.html" element={<Navigate to="/" replace />} />
|
| 595 |
<Route path="*" element={<Navigate to="/" replace />} />
|
|
@@ -1,9 +1,11 @@
|
|
| 1 |
-
import { X, Copy, Check, Terminal, Play, Github, ExternalLink, FileText } from 'lucide-react';
|
| 2 |
import { useState, useEffect, useCallback, useRef } from 'react';
|
| 3 |
import type { Skill } from '../../data/skillsData';
|
| 4 |
import { toast } from 'sonner';
|
| 5 |
import { useFocusTrap } from '../../hooks/useFocusTrap';
|
| 6 |
import { getCandyEmoji } from '../../utils/candy';
|
|
|
|
|
|
|
| 7 |
|
| 8 |
const getCategoryModalColor = (category: string): { bg: string; border: string } => {
|
| 9 |
const map: Record<string, { bg: string; border: string }> = {
|
|
@@ -19,6 +21,67 @@ const getCategoryModalColor = (category: string): { bg: string; border: string }
|
|
| 19 |
return map[category] || { bg: 'bg-secondary', border: 'border-border' };
|
| 20 |
};
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
interface SkillModalProps {
|
| 23 |
skill: Skill | null;
|
| 24 |
onClose: () => void;
|
|
@@ -28,18 +91,21 @@ interface SkillModalProps {
|
|
| 28 |
export function SkillModal({ skill, onClose, onRun }: SkillModalProps) {
|
| 29 |
const [copied, setCopied] = useState(false);
|
| 30 |
const [installCopied, setInstallCopied] = useState(false);
|
|
|
|
|
|
|
|
|
|
| 31 |
const modalRef = useRef<HTMLDivElement>(null);
|
| 32 |
useFocusTrap(modalRef, !!skill);
|
| 33 |
|
| 34 |
-
// Lock body scroll when modal is open
|
| 35 |
useEffect(() => {
|
| 36 |
if (skill) {
|
| 37 |
document.body.style.overflow = 'hidden';
|
|
|
|
|
|
|
| 38 |
}
|
| 39 |
return () => { document.body.style.overflow = ''; };
|
| 40 |
}, [skill]);
|
| 41 |
|
| 42 |
-
// Close on Escape key
|
| 43 |
const handleKeyDown = useCallback(
|
| 44 |
(e: KeyboardEvent) => {
|
| 45 |
if (e.key === 'Escape') onClose();
|
|
@@ -55,6 +121,11 @@ export function SkillModal({ skill, onClose, onRun }: SkillModalProps) {
|
|
| 55 |
if (!skill) return null;
|
| 56 |
|
| 57 |
const configString = JSON.stringify(skill.config, null, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
const handleCopy = () => {
|
| 60 |
navigator.clipboard.writeText(configString);
|
|
@@ -70,6 +141,29 @@ export function SkillModal({ skill, onClose, onRun }: SkillModalProps) {
|
|
| 70 |
setTimeout(() => setInstallCopied(false), 2000);
|
| 71 |
};
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
return (
|
| 74 |
<div
|
| 75 |
ref={modalRef}
|
|
@@ -85,36 +179,98 @@ export function SkillModal({ skill, onClose, onRun }: SkillModalProps) {
|
|
| 85 |
/>
|
| 86 |
|
| 87 |
<div className="relative w-full max-w-2xl bg-card rounded-xl shadow-2xl overflow-hidden animate-in fade-in zoom-in duration-200 flex flex-col max-h-[90vh] border border-border">
|
| 88 |
-
{/*
|
| 89 |
-
<div
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
<button
|
| 93 |
onClick={onClose}
|
| 94 |
-
className="
|
| 95 |
aria-label="Close modal"
|
| 96 |
>
|
| 97 |
<X className="w-5 h-5 text-foreground-secondary" />
|
| 98 |
</button>
|
| 99 |
-
|
| 100 |
-
<div className="text-6xl animate-candy-float" aria-hidden="true">{getCandyEmoji(skill.id)}</div>
|
| 101 |
</div>
|
| 102 |
|
| 103 |
-
{/*
|
| 104 |
-
<div
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
</div>
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
</div>
|
| 112 |
</div>
|
|
|
|
| 113 |
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
{skill.greeting && (
|
| 120 |
<div className="mb-6 p-4 bg-muted/30 rounded-lg border border-border">
|
|
@@ -123,8 +279,37 @@ export function SkillModal({ skill, onClose, onRun }: SkillModalProps) {
|
|
| 123 |
</div>
|
| 124 |
)}
|
| 125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
{/* Install Command */}
|
| 127 |
-
<div className="mb-
|
| 128 |
<h3 className="text-sm font-bold text-foreground mb-2 flex items-center gap-2">
|
| 129 |
<Terminal className="w-4 h-4" />
|
| 130 |
Quick Install
|
|
@@ -181,6 +366,69 @@ export function SkillModal({ skill, onClose, onRun }: SkillModalProps) {
|
|
| 181 |
</div>
|
| 182 |
</div>
|
| 183 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
{/* Config JSON */}
|
| 185 |
<div>
|
| 186 |
<div className="flex items-center justify-between mb-2">
|
|
@@ -201,27 +449,36 @@ export function SkillModal({ skill, onClose, onRun }: SkillModalProps) {
|
|
| 201 |
</div>
|
| 202 |
</div>
|
| 203 |
|
| 204 |
-
{/* Footer Action */}
|
| 205 |
-
<div className="p-4 border-t border-border bg-
|
| 206 |
-
<
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
<
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
</div>
|
| 226 |
</div>
|
| 227 |
</div>
|
|
|
|
| 1 |
+
import { X, Copy, Check, Terminal, Play, Github, ExternalLink, FileText, Star, Users, Code2, ChevronDown, ChevronUp, Share2 } from 'lucide-react';
|
| 2 |
import { useState, useEffect, useCallback, useRef } from 'react';
|
| 3 |
import type { Skill } from '../../data/skillsData';
|
| 4 |
import { toast } from 'sonner';
|
| 5 |
import { useFocusTrap } from '../../hooks/useFocusTrap';
|
| 6 |
import { getCandyEmoji } from '../../utils/candy';
|
| 7 |
+
import { storageUtils } from '../../utils/storage';
|
| 8 |
+
import { cn } from '../../utils/cn';
|
| 9 |
|
| 10 |
const getCategoryModalColor = (category: string): { bg: string; border: string } => {
|
| 11 |
const map: Record<string, { bg: string; border: string }> = {
|
|
|
|
| 21 |
return map[category] || { bg: 'bg-secondary', border: 'border-border' };
|
| 22 |
};
|
| 23 |
|
| 24 |
+
// Generate pseudo-stable values from skill data
|
| 25 |
+
function deriveRating(skill: Skill): number {
|
| 26 |
+
if (skill.rating) return skill.rating;
|
| 27 |
+
// Derive a stable 3.5-5.0 rating from name hash
|
| 28 |
+
let hash = 0;
|
| 29 |
+
for (let i = 0; i < skill.name.length; i++) hash = ((hash << 5) - hash + skill.name.charCodeAt(i)) | 0;
|
| 30 |
+
return Math.round((3.5 + (Math.abs(hash) % 15) / 10) * 10) / 10;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
function deriveUsers(skill: Skill): string {
|
| 34 |
+
if (skill.users) {
|
| 35 |
+
if (skill.users >= 10000) return `${(skill.users / 10000).toFixed(1)}w`;
|
| 36 |
+
if (skill.users >= 1000) return `${(skill.users / 1000).toFixed(1)}k`;
|
| 37 |
+
return skill.users.toString();
|
| 38 |
+
}
|
| 39 |
+
const pop = skill.popularity || 0;
|
| 40 |
+
if (pop >= 10000) return `${(pop / 10000).toFixed(1)}w`;
|
| 41 |
+
if (pop >= 1000) return `${(pop / 1000).toFixed(1)}k`;
|
| 42 |
+
return pop > 0 ? pop.toString() : '—';
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
function deriveVersion(skill: Skill): string {
|
| 46 |
+
if (skill.version) return skill.version;
|
| 47 |
+
// Derive stable version from id hash
|
| 48 |
+
let hash = 0;
|
| 49 |
+
for (let i = 0; i < skill.id.length; i++) hash = ((hash << 5) - hash + skill.id.charCodeAt(i)) | 0;
|
| 50 |
+
const major = 1 + (Math.abs(hash) % 3);
|
| 51 |
+
const minor = Math.abs(hash >> 4) % 10;
|
| 52 |
+
return `v${major}.${minor}`;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
function deriveDeveloper(skill: Skill): string {
|
| 56 |
+
if (skill.developer) return skill.developer;
|
| 57 |
+
if (skill.repo) {
|
| 58 |
+
const owner = skill.repo.split('/')[0];
|
| 59 |
+
if (owner) return owner;
|
| 60 |
+
}
|
| 61 |
+
return 'Community';
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
function StarDisplay({ rating, size = 'sm' }: { rating: number; size?: 'sm' | 'md' }) {
|
| 65 |
+
const iconSize = size === 'md' ? 'w-4 h-4' : 'w-3 h-3';
|
| 66 |
+
return (
|
| 67 |
+
<div className="flex items-center gap-0.5">
|
| 68 |
+
{[1, 2, 3, 4, 5].map((star) => (
|
| 69 |
+
<Star
|
| 70 |
+
key={star}
|
| 71 |
+
className={cn(
|
| 72 |
+
iconSize,
|
| 73 |
+
star <= Math.floor(rating)
|
| 74 |
+
? 'fill-caramel text-caramel'
|
| 75 |
+
: star <= rating
|
| 76 |
+
? 'fill-caramel/50 text-caramel'
|
| 77 |
+
: 'text-foreground-muted'
|
| 78 |
+
)}
|
| 79 |
+
/>
|
| 80 |
+
))}
|
| 81 |
+
</div>
|
| 82 |
+
);
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
interface SkillModalProps {
|
| 86 |
skill: Skill | null;
|
| 87 |
onClose: () => void;
|
|
|
|
| 91 |
export function SkillModal({ skill, onClose, onRun }: SkillModalProps) {
|
| 92 |
const [copied, setCopied] = useState(false);
|
| 93 |
const [installCopied, setInstallCopied] = useState(false);
|
| 94 |
+
const [descExpanded, setDescExpanded] = useState(false);
|
| 95 |
+
const [userRating, setUserRating] = useState(0);
|
| 96 |
+
const [hoverRating, setHoverRating] = useState(0);
|
| 97 |
const modalRef = useRef<HTMLDivElement>(null);
|
| 98 |
useFocusTrap(modalRef, !!skill);
|
| 99 |
|
|
|
|
| 100 |
useEffect(() => {
|
| 101 |
if (skill) {
|
| 102 |
document.body.style.overflow = 'hidden';
|
| 103 |
+
setDescExpanded(false);
|
| 104 |
+
setUserRating(0);
|
| 105 |
}
|
| 106 |
return () => { document.body.style.overflow = ''; };
|
| 107 |
}, [skill]);
|
| 108 |
|
|
|
|
| 109 |
const handleKeyDown = useCallback(
|
| 110 |
(e: KeyboardEvent) => {
|
| 111 |
if (e.key === 'Escape') onClose();
|
|
|
|
| 121 |
if (!skill) return null;
|
| 122 |
|
| 123 |
const configString = JSON.stringify(skill.config, null, 2);
|
| 124 |
+
const rating = deriveRating(skill);
|
| 125 |
+
const developer = deriveDeveloper(skill);
|
| 126 |
+
const version = deriveVersion(skill);
|
| 127 |
+
const usersStr = deriveUsers(skill);
|
| 128 |
+
const isOpenSource = skill.openSource !== undefined ? skill.openSource : !!skill.repo;
|
| 129 |
|
| 130 |
const handleCopy = () => {
|
| 131 |
navigator.clipboard.writeText(configString);
|
|
|
|
| 141 |
setTimeout(() => setInstallCopied(false), 2000);
|
| 142 |
};
|
| 143 |
|
| 144 |
+
const handleShare = () => {
|
| 145 |
+
const url = `${window.location.origin}/candy/${skill.id}`;
|
| 146 |
+
navigator.clipboard.writeText(url);
|
| 147 |
+
toast.success('Link copied to clipboard');
|
| 148 |
+
};
|
| 149 |
+
|
| 150 |
+
const handleUserRate = (score: number) => {
|
| 151 |
+
setUserRating(score);
|
| 152 |
+
storageUtils.saveLike(skill.id);
|
| 153 |
+
toast.success(`Rated ${skill.name} ${score} stars`);
|
| 154 |
+
};
|
| 155 |
+
|
| 156 |
+
// Determine if description is long enough to need expand/collapse
|
| 157 |
+
const descIsLong = skill.description.length > 160;
|
| 158 |
+
const displayDesc = descExpanded || !descIsLong
|
| 159 |
+
? skill.description
|
| 160 |
+
: skill.description.slice(0, 160) + '...';
|
| 161 |
+
|
| 162 |
+
// Generate showcase items from tags if not provided
|
| 163 |
+
const showcases: Array<{ title: string; image?: string }> = skill.showcases || skill.tags.slice(0, 3).map((tag) => ({
|
| 164 |
+
title: `${tag} workflow`,
|
| 165 |
+
}));
|
| 166 |
+
|
| 167 |
return (
|
| 168 |
<div
|
| 169 |
ref={modalRef}
|
|
|
|
| 179 |
/>
|
| 180 |
|
| 181 |
<div className="relative w-full max-w-2xl bg-card rounded-xl shadow-2xl overflow-hidden animate-in fade-in zoom-in duration-200 flex flex-col max-h-[90vh] border border-border">
|
| 182 |
+
{/* Top Bar — Share & Close */}
|
| 183 |
+
<div className="absolute top-4 right-4 z-10 flex items-center gap-2">
|
| 184 |
+
<button
|
| 185 |
+
onClick={handleShare}
|
| 186 |
+
className="p-2.5 bg-background/60 hover:bg-background rounded-full transition-colors duration-200 cursor-pointer min-w-[40px] min-h-[40px] flex items-center justify-center focus:outline-none focus:ring-2 focus:ring-primary/30"
|
| 187 |
+
aria-label="Share"
|
| 188 |
+
>
|
| 189 |
+
<Share2 className="w-4 h-4 text-foreground-secondary" />
|
| 190 |
+
</button>
|
| 191 |
<button
|
| 192 |
onClick={onClose}
|
| 193 |
+
className="p-2.5 bg-background/60 hover:bg-background rounded-full transition-colors duration-200 cursor-pointer min-w-[40px] min-h-[40px] flex items-center justify-center focus:outline-none focus:ring-2 focus:ring-primary/30"
|
| 194 |
aria-label="Close modal"
|
| 195 |
>
|
| 196 |
<X className="w-5 h-5 text-foreground-secondary" />
|
| 197 |
</button>
|
|
|
|
|
|
|
| 198 |
</div>
|
| 199 |
|
| 200 |
+
{/* Header — Icon + Name */}
|
| 201 |
+
<div
|
| 202 |
+
className={cn(
|
| 203 |
+
'pt-10 pb-6 px-8 flex flex-col items-center text-center border-b',
|
| 204 |
+
getCategoryModalColor(skill.category).bg,
|
| 205 |
+
getCategoryModalColor(skill.category).border
|
| 206 |
+
)}
|
| 207 |
+
>
|
| 208 |
+
<div className="text-6xl mb-4 animate-candy-float" aria-hidden="true">{getCandyEmoji(skill.id)}</div>
|
| 209 |
+
<h2 className="text-2xl font-candy font-bold text-foreground">{skill.name}</h2>
|
| 210 |
+
<p className="text-sm text-foreground-secondary mt-1 max-w-md font-body">
|
| 211 |
+
{skill.description.length > 80 ? skill.description.slice(0, 80) + '...' : skill.description}
|
| 212 |
+
</p>
|
| 213 |
+
|
| 214 |
+
{/* Info Bar — like the screenshot */}
|
| 215 |
+
<div className="mt-5 w-full grid grid-cols-3 sm:grid-cols-6 gap-px bg-border/30 rounded-xl overflow-hidden border border-border/50">
|
| 216 |
+
{/* Rating */}
|
| 217 |
+
<div className="bg-card/80 backdrop-blur-sm py-3 px-2 flex flex-col items-center gap-1">
|
| 218 |
+
<div className="flex items-center gap-1">
|
| 219 |
+
<span className="text-sm font-bold text-foreground">{rating}</span>
|
| 220 |
+
</div>
|
| 221 |
+
<StarDisplay rating={rating} />
|
| 222 |
+
<span className="text-[10px] text-foreground-tertiary">Rating</span>
|
| 223 |
</div>
|
| 224 |
+
{/* Category */}
|
| 225 |
+
<div className="bg-card/80 backdrop-blur-sm py-3 px-2 flex flex-col items-center gap-1">
|
| 226 |
+
<span className="text-sm font-bold text-foreground truncate max-w-full">{skill.category}</span>
|
| 227 |
+
<span className="text-[10px] text-foreground-tertiary">Category</span>
|
| 228 |
+
</div>
|
| 229 |
+
{/* Developer */}
|
| 230 |
+
<div className="bg-card/80 backdrop-blur-sm py-3 px-2 flex flex-col items-center gap-1">
|
| 231 |
+
<span className="text-sm font-bold text-foreground truncate max-w-full">{developer}</span>
|
| 232 |
+
<span className="text-[10px] text-foreground-tertiary">Developer</span>
|
| 233 |
+
</div>
|
| 234 |
+
{/* Version */}
|
| 235 |
+
<div className="bg-card/80 backdrop-blur-sm py-3 px-2 flex flex-col items-center gap-1">
|
| 236 |
+
<span className="text-sm font-bold text-foreground">{version}</span>
|
| 237 |
+
<span className="text-[10px] text-foreground-tertiary">Version</span>
|
| 238 |
+
</div>
|
| 239 |
+
{/* Users */}
|
| 240 |
+
<div className="bg-card/80 backdrop-blur-sm py-3 px-2 flex flex-col items-center gap-1">
|
| 241 |
+
<span className="text-sm font-bold text-foreground">{usersStr}</span>
|
| 242 |
+
<span className="text-[10px] text-foreground-tertiary">Users</span>
|
| 243 |
+
</div>
|
| 244 |
+
{/* Open Source */}
|
| 245 |
+
<div className="bg-card/80 backdrop-blur-sm py-3 px-2 flex flex-col items-center gap-1">
|
| 246 |
+
<span className={cn('text-sm font-bold', isOpenSource ? 'text-green-500' : 'text-foreground')}>
|
| 247 |
+
{isOpenSource ? 'Yes' : 'No'}
|
| 248 |
+
</span>
|
| 249 |
+
<span className="text-[10px] text-foreground-tertiary">Open Source</span>
|
| 250 |
</div>
|
| 251 |
</div>
|
| 252 |
+
</div>
|
| 253 |
|
| 254 |
+
{/* Content */}
|
| 255 |
+
<div className="px-8 py-6 overflow-y-auto flex-1">
|
| 256 |
+
{/* Description (expandable) */}
|
| 257 |
+
<div className="mb-6">
|
| 258 |
+
<p className="text-foreground-secondary text-sm font-body leading-relaxed">
|
| 259 |
+
{displayDesc}
|
| 260 |
+
</p>
|
| 261 |
+
{descIsLong && (
|
| 262 |
+
<button
|
| 263 |
+
onClick={() => setDescExpanded(!descExpanded)}
|
| 264 |
+
className="mt-1 flex items-center gap-1 text-xs text-primary hover:text-primary-hover transition-colors"
|
| 265 |
+
>
|
| 266 |
+
{descExpanded ? (
|
| 267 |
+
<>Collapse <ChevronUp className="w-3 h-3" /></>
|
| 268 |
+
) : (
|
| 269 |
+
<>Expand <ChevronDown className="w-3 h-3" /></>
|
| 270 |
+
)}
|
| 271 |
+
</button>
|
| 272 |
+
)}
|
| 273 |
+
</div>
|
| 274 |
|
| 275 |
{skill.greeting && (
|
| 276 |
<div className="mb-6 p-4 bg-muted/30 rounded-lg border border-border">
|
|
|
|
| 279 |
</div>
|
| 280 |
)}
|
| 281 |
|
| 282 |
+
{/* Showcases / Featured Use Cases */}
|
| 283 |
+
{showcases.length > 0 && (
|
| 284 |
+
<div className="mb-6">
|
| 285 |
+
<h3 className="text-sm font-bold text-foreground mb-3">Featured Use Cases</h3>
|
| 286 |
+
<div className="grid grid-cols-3 gap-3">
|
| 287 |
+
{showcases.map((showcase, i) => (
|
| 288 |
+
<div
|
| 289 |
+
key={i}
|
| 290 |
+
className="rounded-xl border border-border/50 overflow-hidden bg-secondary/30 hover:bg-secondary/50 transition-colors cursor-default"
|
| 291 |
+
>
|
| 292 |
+
<div className={cn(
|
| 293 |
+
'h-20 flex items-center justify-center text-3xl',
|
| 294 |
+
getCategoryModalColor(skill.category).bg,
|
| 295 |
+
)}>
|
| 296 |
+
{showcase.image ? (
|
| 297 |
+
<img src={showcase.image} alt={showcase.title} className="w-full h-full object-cover" />
|
| 298 |
+
) : (
|
| 299 |
+
<span>{getCandyEmoji(skill.id + i)}</span>
|
| 300 |
+
)}
|
| 301 |
+
</div>
|
| 302 |
+
<div className="p-2.5">
|
| 303 |
+
<p className="text-xs font-medium text-foreground truncate">{showcase.title}</p>
|
| 304 |
+
</div>
|
| 305 |
+
</div>
|
| 306 |
+
))}
|
| 307 |
+
</div>
|
| 308 |
+
</div>
|
| 309 |
+
)}
|
| 310 |
+
|
| 311 |
{/* Install Command */}
|
| 312 |
+
<div className="mb-6">
|
| 313 |
<h3 className="text-sm font-bold text-foreground mb-2 flex items-center gap-2">
|
| 314 |
<Terminal className="w-4 h-4" />
|
| 315 |
Quick Install
|
|
|
|
| 366 |
</div>
|
| 367 |
</div>
|
| 368 |
|
| 369 |
+
{/* Rating Section */}
|
| 370 |
+
<div className="mb-6">
|
| 371 |
+
<h3 className="text-sm font-bold text-foreground mb-3">Rating</h3>
|
| 372 |
+
<div className="flex items-start gap-6">
|
| 373 |
+
{/* Average */}
|
| 374 |
+
<div className="text-center">
|
| 375 |
+
<div className="text-4xl font-bold text-foreground font-candy">{rating}</div>
|
| 376 |
+
<StarDisplay rating={rating} size="md" />
|
| 377 |
+
</div>
|
| 378 |
+
{/* Rating Bars */}
|
| 379 |
+
<div className="flex-1 space-y-1.5">
|
| 380 |
+
{[5, 4, 3, 2, 1].map((star) => {
|
| 381 |
+
// Derive pseudo distribution from rating
|
| 382 |
+
const dist = star === Math.round(rating) ? 0.6
|
| 383 |
+
: Math.abs(star - rating) <= 1 ? 0.25
|
| 384 |
+
: Math.abs(star - rating) <= 2 ? 0.1
|
| 385 |
+
: 0.05;
|
| 386 |
+
return (
|
| 387 |
+
<div key={star} className="flex items-center gap-2">
|
| 388 |
+
<span className="text-xs text-foreground-secondary w-8">{star} star</span>
|
| 389 |
+
<div className="flex-1 h-2 bg-secondary rounded-full overflow-hidden">
|
| 390 |
+
<div
|
| 391 |
+
className="h-full bg-caramel rounded-full transition-all duration-500"
|
| 392 |
+
style={{ width: `${dist * 100}%` }}
|
| 393 |
+
/>
|
| 394 |
+
</div>
|
| 395 |
+
</div>
|
| 396 |
+
);
|
| 397 |
+
})}
|
| 398 |
+
</div>
|
| 399 |
+
</div>
|
| 400 |
+
|
| 401 |
+
{/* User Rating */}
|
| 402 |
+
<div className="mt-4 p-3 bg-secondary/30 rounded-lg border border-border/50">
|
| 403 |
+
<p className="text-xs text-foreground-secondary mb-2">Rate this skill</p>
|
| 404 |
+
<div className="flex items-center gap-1">
|
| 405 |
+
{[1, 2, 3, 4, 5].map((star) => (
|
| 406 |
+
<button
|
| 407 |
+
key={star}
|
| 408 |
+
onClick={() => handleUserRate(star)}
|
| 409 |
+
onMouseEnter={() => setHoverRating(star)}
|
| 410 |
+
onMouseLeave={() => setHoverRating(0)}
|
| 411 |
+
className="p-0.5 transition-transform hover:scale-125"
|
| 412 |
+
>
|
| 413 |
+
<Star
|
| 414 |
+
className={cn(
|
| 415 |
+
'w-6 h-6 transition-colors',
|
| 416 |
+
star <= (hoverRating || userRating)
|
| 417 |
+
? 'fill-caramel text-caramel'
|
| 418 |
+
: 'text-foreground-muted hover:text-caramel/50'
|
| 419 |
+
)}
|
| 420 |
+
/>
|
| 421 |
+
</button>
|
| 422 |
+
))}
|
| 423 |
+
{userRating > 0 && (
|
| 424 |
+
<span className="ml-2 text-xs text-foreground-secondary">
|
| 425 |
+
You rated {userRating}/5
|
| 426 |
+
</span>
|
| 427 |
+
)}
|
| 428 |
+
</div>
|
| 429 |
+
</div>
|
| 430 |
+
</div>
|
| 431 |
+
|
| 432 |
{/* Config JSON */}
|
| 433 |
<div>
|
| 434 |
<div className="flex items-center justify-between mb-2">
|
|
|
|
| 449 |
</div>
|
| 450 |
</div>
|
| 451 |
|
| 452 |
+
{/* Footer Action — sticky bottom */}
|
| 453 |
+
<div className="p-4 border-t border-border bg-card flex justify-between items-center gap-3">
|
| 454 |
+
<div className="flex items-center gap-2 text-xs text-foreground-tertiary">
|
| 455 |
+
<Users className="w-3.5 h-3.5" />
|
| 456 |
+
<span>{usersStr} users</span>
|
| 457 |
+
<span className="text-border">·</span>
|
| 458 |
+
<Code2 className="w-3.5 h-3.5" />
|
| 459 |
+
<span>{version}</span>
|
| 460 |
+
</div>
|
| 461 |
+
<div className="flex gap-3">
|
| 462 |
+
<button
|
| 463 |
+
onClick={onClose}
|
| 464 |
+
className="px-5 py-2.5 bg-transparent text-foreground-secondary border border-border rounded-lg font-medium hover:bg-secondary hover:text-foreground transition-colors duration-200 cursor-pointer min-h-[40px] focus:outline-none focus:ring-2 focus:ring-border"
|
| 465 |
+
>
|
| 466 |
+
Close
|
| 467 |
+
</button>
|
| 468 |
+
<button
|
| 469 |
+
onClick={() => {
|
| 470 |
+
if (onRun && skill) {
|
| 471 |
+
onRun(skill);
|
| 472 |
+
onClose();
|
| 473 |
+
}
|
| 474 |
+
}}
|
| 475 |
+
className="px-6 py-2.5 bg-primary text-primary-foreground rounded-lg font-medium hover:bg-primary-hover transition-colors duration-200 shadow-lg shadow-primary/20 flex items-center gap-2 cursor-pointer min-h-[40px] focus:outline-none focus:ring-2 focus:ring-primary/50"
|
| 476 |
+
aria-label={`Run ${skill.name}`}
|
| 477 |
+
>
|
| 478 |
+
<Play className="w-4 h-4" />
|
| 479 |
+
Run Skill
|
| 480 |
+
</button>
|
| 481 |
+
</div>
|
| 482 |
</div>
|
| 483 |
</div>
|
| 484 |
</div>
|
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import { Search, ShoppingBag, Check, X, Heart, Play, Star, ChevronLeft, ChevronRight, Plus, Database, ExternalLink, Download } from 'lucide-react';
|
| 2 |
import { useState, useMemo, useEffect, useRef, useCallback } from 'react';
|
| 3 |
import { SKILLS_DATA, REGISTRY_STATS, loadFullRegistry, type Skill, type RegistryEntry } from '../../data/skillsData';
|
| 4 |
import { SkillModal } from '../common/SkillModal';
|
|
@@ -415,15 +415,26 @@ export function SkillsGrid({
|
|
| 415 |
<h3 className="font-bold text-foreground text-[15px] leading-snug font-candy truncate">
|
| 416 |
{skill.name}
|
| 417 |
</h3>
|
| 418 |
-
<div className="flex items-center gap-2 mt-1">
|
| 419 |
<span className={cn('text-[11px] font-medium', getCategoryColor(skill.category).text)}>
|
| 420 |
{skill.category}
|
| 421 |
</span>
|
| 422 |
<span className="text-border">·</span>
|
| 423 |
<div className="flex items-center gap-0.5 text-[11px] text-foreground-tertiary">
|
| 424 |
<Star className="w-3 h-3 fill-caramel text-caramel" />
|
| 425 |
-
<span>{
|
| 426 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 427 |
</div>
|
| 428 |
</div>
|
| 429 |
</div>
|
|
|
|
| 1 |
+
import { Search, ShoppingBag, Check, X, Heart, Play, Star, ChevronLeft, ChevronRight, Plus, Database, ExternalLink, Download, Users } from 'lucide-react';
|
| 2 |
import { useState, useMemo, useEffect, useRef, useCallback } from 'react';
|
| 3 |
import { SKILLS_DATA, REGISTRY_STATS, loadFullRegistry, type Skill, type RegistryEntry } from '../../data/skillsData';
|
| 4 |
import { SkillModal } from '../common/SkillModal';
|
|
|
|
| 415 |
<h3 className="font-bold text-foreground text-[15px] leading-snug font-candy truncate">
|
| 416 |
{skill.name}
|
| 417 |
</h3>
|
| 418 |
+
<div className="flex items-center gap-2 mt-1 flex-wrap">
|
| 419 |
<span className={cn('text-[11px] font-medium', getCategoryColor(skill.category).text)}>
|
| 420 |
{skill.category}
|
| 421 |
</span>
|
| 422 |
<span className="text-border">·</span>
|
| 423 |
<div className="flex items-center gap-0.5 text-[11px] text-foreground-tertiary">
|
| 424 |
<Star className="w-3 h-3 fill-caramel text-caramel" />
|
| 425 |
+
<span>{(() => { const r = skill.rating || (3.5 + (Math.abs([...skill.name].reduce((h,c)=>((h<<5)-h+c.charCodeAt(0))|0,0)) % 15) / 10); return (Math.round(r * 10) / 10).toFixed(1); })()}</span>
|
| 426 |
</div>
|
| 427 |
+
<span className="text-border">·</span>
|
| 428 |
+
<div className="flex items-center gap-0.5 text-[11px] text-foreground-tertiary">
|
| 429 |
+
<Users className="w-3 h-3" />
|
| 430 |
+
<span>{skill.popularity ? (skill.popularity >= 10000 ? `${(skill.popularity / 10000).toFixed(1)}w` : skill.popularity >= 1000 ? `${(skill.popularity / 1000).toFixed(1)}k` : skill.popularity) : '—'}</span>
|
| 431 |
+
</div>
|
| 432 |
+
{skill.repo && (
|
| 433 |
+
<>
|
| 434 |
+
<span className="text-border">·</span>
|
| 435 |
+
<span className="text-[10px] text-green-500 font-medium">Open Source</span>
|
| 436 |
+
</>
|
| 437 |
+
)}
|
| 438 |
</div>
|
| 439 |
</div>
|
| 440 |
</div>
|
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useLanguage } from '../../contexts/LanguageContext';
|
| 2 |
+
|
| 3 |
+
export function Footer() {
|
| 4 |
+
const { t } = useLanguage();
|
| 5 |
+
|
| 6 |
+
return (
|
| 7 |
+
<footer className="relative mt-20">
|
| 8 |
+
<div className="h-px bg-gradient-to-r from-transparent via-primary/20 to-transparent" />
|
| 9 |
+
<div className="glass-strong">
|
| 10 |
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
|
| 11 |
+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-8">
|
| 12 |
+
{/* Brand */}
|
| 13 |
+
<div className="lg:col-span-1">
|
| 14 |
+
<div className="flex items-center gap-2 mb-3">
|
| 15 |
+
<span className="text-2xl">🍬</span>
|
| 16 |
+
<span className="font-bold text-lg font-candy candy-gradient-text">Candy Shop</span>
|
| 17 |
+
</div>
|
| 18 |
+
<p className="text-sm text-foreground-secondary leading-relaxed">
|
| 19 |
+
{t('footer.tagline')}
|
| 20 |
+
</p>
|
| 21 |
+
</div>
|
| 22 |
+
|
| 23 |
+
{/* Product */}
|
| 24 |
+
<div>
|
| 25 |
+
<h4 className="text-sm font-semibold text-foreground mb-3">Product</h4>
|
| 26 |
+
<ul className="space-y-2">
|
| 27 |
+
<li>
|
| 28 |
+
<a href="/discover" className="text-sm text-foreground-secondary hover:text-primary transition-colors">
|
| 29 |
+
Discover Skills
|
| 30 |
+
</a>
|
| 31 |
+
</li>
|
| 32 |
+
<li>
|
| 33 |
+
<a href="/discover?tab=craving" className="text-sm text-foreground-secondary hover:text-primary transition-colors">
|
| 34 |
+
Browse Cravings
|
| 35 |
+
</a>
|
| 36 |
+
</li>
|
| 37 |
+
<li>
|
| 38 |
+
<a href="/skills/create" className="text-sm text-foreground-secondary hover:text-primary transition-colors">
|
| 39 |
+
Create a Skill
|
| 40 |
+
</a>
|
| 41 |
+
</li>
|
| 42 |
+
</ul>
|
| 43 |
+
</div>
|
| 44 |
+
|
| 45 |
+
{/* Community */}
|
| 46 |
+
<div>
|
| 47 |
+
<h4 className="text-sm font-semibold text-foreground mb-3">Community</h4>
|
| 48 |
+
<ul className="space-y-2">
|
| 49 |
+
<li>
|
| 50 |
+
<a
|
| 51 |
+
href="https://github.com/anthropics/claude-skills"
|
| 52 |
+
target="_blank"
|
| 53 |
+
rel="noopener noreferrer"
|
| 54 |
+
className="text-sm text-foreground-secondary hover:text-primary transition-colors"
|
| 55 |
+
>
|
| 56 |
+
GitHub
|
| 57 |
+
</a>
|
| 58 |
+
</li>
|
| 59 |
+
<li>
|
| 60 |
+
<a
|
| 61 |
+
href="https://github.com/ClaudioHQ/awesome-claude-skills"
|
| 62 |
+
target="_blank"
|
| 63 |
+
rel="noopener noreferrer"
|
| 64 |
+
className="text-sm text-foreground-secondary hover:text-primary transition-colors"
|
| 65 |
+
>
|
| 66 |
+
Awesome Skills
|
| 67 |
+
</a>
|
| 68 |
+
</li>
|
| 69 |
+
<li>
|
| 70 |
+
<a
|
| 71 |
+
href="https://docs.anthropic.com"
|
| 72 |
+
target="_blank"
|
| 73 |
+
rel="noopener noreferrer"
|
| 74 |
+
className="text-sm text-foreground-secondary hover:text-primary transition-colors"
|
| 75 |
+
>
|
| 76 |
+
Documentation
|
| 77 |
+
</a>
|
| 78 |
+
</li>
|
| 79 |
+
</ul>
|
| 80 |
+
</div>
|
| 81 |
+
|
| 82 |
+
{/* Legal */}
|
| 83 |
+
<div>
|
| 84 |
+
<h4 className="text-sm font-semibold text-foreground mb-3">Legal</h4>
|
| 85 |
+
<ul className="space-y-2">
|
| 86 |
+
<li>
|
| 87 |
+
<a href="#" className="text-sm text-foreground-secondary hover:text-primary transition-colors">
|
| 88 |
+
Privacy Policy
|
| 89 |
+
</a>
|
| 90 |
+
</li>
|
| 91 |
+
<li>
|
| 92 |
+
<a href="#" className="text-sm text-foreground-secondary hover:text-primary transition-colors">
|
| 93 |
+
Terms of Service
|
| 94 |
+
</a>
|
| 95 |
+
</li>
|
| 96 |
+
</ul>
|
| 97 |
+
</div>
|
| 98 |
+
</div>
|
| 99 |
+
|
| 100 |
+
{/* Bottom */}
|
| 101 |
+
<div className="mt-10 pt-6 border-t border-border flex flex-col sm:flex-row items-center justify-between gap-4">
|
| 102 |
+
<div className="flex items-center gap-2 text-sm text-foreground-tertiary">
|
| 103 |
+
<span className="animate-candy-float">🍭</span>
|
| 104 |
+
<span>© {new Date().getFullYear()} Candy Shop. All rights reserved.</span>
|
| 105 |
+
</div>
|
| 106 |
+
<button
|
| 107 |
+
onClick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
|
| 108 |
+
className="text-sm text-foreground-tertiary hover:text-primary transition-colors"
|
| 109 |
+
>
|
| 110 |
+
{t('footer.backToTop')} ↑
|
| 111 |
+
</button>
|
| 112 |
+
</div>
|
| 113 |
+
</div>
|
| 114 |
+
</div>
|
| 115 |
+
</footer>
|
| 116 |
+
);
|
| 117 |
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { type HTMLAttributes } from 'react';
|
| 2 |
+
import { cva, type VariantProps } from 'class-variance-authority';
|
| 3 |
+
import { cn } from '../../utils/cn';
|
| 4 |
+
|
| 5 |
+
const badgeVariants = cva(
|
| 6 |
+
'inline-flex items-center gap-1 font-medium transition-colors',
|
| 7 |
+
{
|
| 8 |
+
variants: {
|
| 9 |
+
variant: {
|
| 10 |
+
default: 'bg-primary/10 text-primary',
|
| 11 |
+
secondary: 'bg-secondary text-foreground-secondary',
|
| 12 |
+
outline: 'border border-border text-foreground-secondary',
|
| 13 |
+
success: 'bg-success/10 text-success',
|
| 14 |
+
warning: 'bg-warning/10 text-warning',
|
| 15 |
+
error: 'bg-error/10 text-error',
|
| 16 |
+
candy: 'candy-gradient text-white',
|
| 17 |
+
},
|
| 18 |
+
size: {
|
| 19 |
+
sm: 'px-2 py-0.5 text-xs rounded',
|
| 20 |
+
md: 'px-2.5 py-1 text-xs rounded',
|
| 21 |
+
lg: 'px-3 py-1.5 text-sm rounded-lg',
|
| 22 |
+
},
|
| 23 |
+
},
|
| 24 |
+
defaultVariants: {
|
| 25 |
+
variant: 'default',
|
| 26 |
+
size: 'md',
|
| 27 |
+
},
|
| 28 |
+
}
|
| 29 |
+
);
|
| 30 |
+
|
| 31 |
+
interface BadgeProps extends HTMLAttributes<HTMLSpanElement>, VariantProps<typeof badgeVariants> {}
|
| 32 |
+
|
| 33 |
+
export function Badge({ className, variant, size, ...props }: BadgeProps) {
|
| 34 |
+
return <span className={cn(badgeVariants({ variant, size, className }))} {...props} />;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
export { badgeVariants };
|
| 38 |
+
export type { BadgeProps };
|
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { forwardRef, type ButtonHTMLAttributes } from 'react';
|
| 2 |
+
import { cva, type VariantProps } from 'class-variance-authority';
|
| 3 |
+
import { cn } from '../../utils/cn';
|
| 4 |
+
|
| 5 |
+
const buttonVariants = cva(
|
| 6 |
+
'inline-flex items-center justify-center gap-2 whitespace-nowrap font-medium transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 btn-press',
|
| 7 |
+
{
|
| 8 |
+
variants: {
|
| 9 |
+
variant: {
|
| 10 |
+
default: 'bg-primary text-primary-foreground hover:bg-primary-hover active:bg-primary-active shadow-sm',
|
| 11 |
+
secondary: 'bg-secondary text-secondary-foreground hover:bg-backgroundTertiary',
|
| 12 |
+
outline: 'border border-border bg-transparent hover:bg-secondary hover:border-border-hover text-foreground',
|
| 13 |
+
ghost: 'hover:bg-secondary text-foreground-secondary hover:text-foreground',
|
| 14 |
+
destructive: 'bg-error text-error-foreground hover:bg-error/90',
|
| 15 |
+
candy: 'candy-gradient text-white hover:opacity-90 shadow-candy',
|
| 16 |
+
link: 'text-primary underline-offset-4 hover:underline p-0 h-auto',
|
| 17 |
+
},
|
| 18 |
+
size: {
|
| 19 |
+
sm: 'h-8 px-3 text-xs rounded-sm',
|
| 20 |
+
md: 'h-10 px-4 text-sm rounded',
|
| 21 |
+
lg: 'h-12 px-6 text-base rounded-lg',
|
| 22 |
+
icon: 'h-10 w-10 rounded',
|
| 23 |
+
},
|
| 24 |
+
},
|
| 25 |
+
defaultVariants: {
|
| 26 |
+
variant: 'default',
|
| 27 |
+
size: 'md',
|
| 28 |
+
},
|
| 29 |
+
}
|
| 30 |
+
);
|
| 31 |
+
|
| 32 |
+
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {}
|
| 33 |
+
|
| 34 |
+
const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
| 35 |
+
({ className, variant, size, ...props }, ref) => {
|
| 36 |
+
return (
|
| 37 |
+
<button
|
| 38 |
+
className={cn(buttonVariants({ variant, size, className }))}
|
| 39 |
+
ref={ref}
|
| 40 |
+
{...props}
|
| 41 |
+
/>
|
| 42 |
+
);
|
| 43 |
+
}
|
| 44 |
+
);
|
| 45 |
+
Button.displayName = 'Button';
|
| 46 |
+
|
| 47 |
+
export { Button, buttonVariants };
|
| 48 |
+
export type { ButtonProps };
|
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { forwardRef, type HTMLAttributes } from 'react';
|
| 2 |
+
import { cva, type VariantProps } from 'class-variance-authority';
|
| 3 |
+
import { cn } from '../../utils/cn';
|
| 4 |
+
|
| 5 |
+
const cardVariants = cva(
|
| 6 |
+
'rounded-lg border transition-all duration-200',
|
| 7 |
+
{
|
| 8 |
+
variants: {
|
| 9 |
+
variant: {
|
| 10 |
+
default: 'bg-card border-border shadow-card',
|
| 11 |
+
glass: 'glass shadow-glass',
|
| 12 |
+
elevated: 'bg-card border-border shadow-card-hover',
|
| 13 |
+
interactive: 'bg-card border-border shadow-card card-luxe gradient-border cursor-pointer',
|
| 14 |
+
},
|
| 15 |
+
},
|
| 16 |
+
defaultVariants: {
|
| 17 |
+
variant: 'default',
|
| 18 |
+
},
|
| 19 |
+
}
|
| 20 |
+
);
|
| 21 |
+
|
| 22 |
+
interface CardProps extends HTMLAttributes<HTMLDivElement>, VariantProps<typeof cardVariants> {}
|
| 23 |
+
|
| 24 |
+
const Card = forwardRef<HTMLDivElement, CardProps>(
|
| 25 |
+
({ className, variant, ...props }, ref) => {
|
| 26 |
+
return (
|
| 27 |
+
<div
|
| 28 |
+
className={cn(cardVariants({ variant, className }))}
|
| 29 |
+
ref={ref}
|
| 30 |
+
{...props}
|
| 31 |
+
/>
|
| 32 |
+
);
|
| 33 |
+
}
|
| 34 |
+
);
|
| 35 |
+
Card.displayName = 'Card';
|
| 36 |
+
|
| 37 |
+
const CardHeader = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
|
| 38 |
+
({ className, ...props }, ref) => (
|
| 39 |
+
<div ref={ref} className={cn('px-6 pt-6 pb-2', className)} {...props} />
|
| 40 |
+
)
|
| 41 |
+
);
|
| 42 |
+
CardHeader.displayName = 'CardHeader';
|
| 43 |
+
|
| 44 |
+
const CardContent = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
|
| 45 |
+
({ className, ...props }, ref) => (
|
| 46 |
+
<div ref={ref} className={cn('px-6 pb-6', className)} {...props} />
|
| 47 |
+
)
|
| 48 |
+
);
|
| 49 |
+
CardContent.displayName = 'CardContent';
|
| 50 |
+
|
| 51 |
+
const CardFooter = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
|
| 52 |
+
({ className, ...props }, ref) => (
|
| 53 |
+
<div ref={ref} className={cn('px-6 pb-6 pt-0 flex items-center', className)} {...props} />
|
| 54 |
+
)
|
| 55 |
+
);
|
| 56 |
+
CardFooter.displayName = 'CardFooter';
|
| 57 |
+
|
| 58 |
+
export { Card, CardHeader, CardContent, CardFooter, cardVariants };
|
| 59 |
+
export type { CardProps };
|
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { forwardRef, type InputHTMLAttributes } from 'react';
|
| 2 |
+
import { cn } from '../../utils/cn';
|
| 3 |
+
|
| 4 |
+
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {}
|
| 5 |
+
|
| 6 |
+
const Input = forwardRef<HTMLInputElement, InputProps>(
|
| 7 |
+
({ className, type, ...props }, ref) => {
|
| 8 |
+
return (
|
| 9 |
+
<input
|
| 10 |
+
type={type}
|
| 11 |
+
className={cn(
|
| 12 |
+
'flex h-10 w-full rounded border border-input-border bg-input px-3 py-2 text-sm text-foreground',
|
| 13 |
+
'placeholder:text-foreground-tertiary',
|
| 14 |
+
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1',
|
| 15 |
+
'disabled:cursor-not-allowed disabled:opacity-50',
|
| 16 |
+
'transition-colors duration-200',
|
| 17 |
+
className
|
| 18 |
+
)}
|
| 19 |
+
ref={ref}
|
| 20 |
+
{...props}
|
| 21 |
+
/>
|
| 22 |
+
);
|
| 23 |
+
}
|
| 24 |
+
);
|
| 25 |
+
Input.displayName = 'Input';
|
| 26 |
+
|
| 27 |
+
export { Input };
|
| 28 |
+
export type { InputProps };
|
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState } from 'react';
|
| 2 |
+
import { Star } from 'lucide-react';
|
| 3 |
+
import { cn } from '../../utils/cn';
|
| 4 |
+
|
| 5 |
+
interface StarRatingProps {
|
| 6 |
+
value: number;
|
| 7 |
+
onChange?: (value: number) => void;
|
| 8 |
+
readonly?: boolean;
|
| 9 |
+
size?: 'sm' | 'md' | 'lg';
|
| 10 |
+
showValue?: boolean;
|
| 11 |
+
count?: number;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
const sizes = {
|
| 15 |
+
sm: 'w-3.5 h-3.5',
|
| 16 |
+
md: 'w-5 h-5',
|
| 17 |
+
lg: 'w-6 h-6',
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
+
export function StarRating({
|
| 21 |
+
value,
|
| 22 |
+
onChange,
|
| 23 |
+
readonly = false,
|
| 24 |
+
size = 'md',
|
| 25 |
+
showValue = false,
|
| 26 |
+
count,
|
| 27 |
+
}: StarRatingProps) {
|
| 28 |
+
const [hoverValue, setHoverValue] = useState(0);
|
| 29 |
+
|
| 30 |
+
const displayValue = hoverValue || value;
|
| 31 |
+
|
| 32 |
+
return (
|
| 33 |
+
<div className="inline-flex items-center gap-1">
|
| 34 |
+
<div className="flex items-center gap-0.5">
|
| 35 |
+
{[1, 2, 3, 4, 5].map((star) => (
|
| 36 |
+
<button
|
| 37 |
+
key={star}
|
| 38 |
+
type="button"
|
| 39 |
+
disabled={readonly}
|
| 40 |
+
className={cn(
|
| 41 |
+
'transition-colors duration-150',
|
| 42 |
+
readonly ? 'cursor-default' : 'cursor-pointer hover:scale-110 transition-transform'
|
| 43 |
+
)}
|
| 44 |
+
onClick={() => onChange?.(star)}
|
| 45 |
+
onMouseEnter={() => !readonly && setHoverValue(star)}
|
| 46 |
+
onMouseLeave={() => !readonly && setHoverValue(0)}
|
| 47 |
+
>
|
| 48 |
+
<Star
|
| 49 |
+
className={cn(
|
| 50 |
+
sizes[size],
|
| 51 |
+
star <= displayValue
|
| 52 |
+
? 'fill-warning text-warning'
|
| 53 |
+
: 'text-foreground-muted'
|
| 54 |
+
)}
|
| 55 |
+
/>
|
| 56 |
+
</button>
|
| 57 |
+
))}
|
| 58 |
+
</div>
|
| 59 |
+
{showValue && (
|
| 60 |
+
<span className="text-sm text-foreground-secondary ml-1">
|
| 61 |
+
{value > 0 ? value.toFixed(1) : '—'}
|
| 62 |
+
{count !== undefined && <span className="text-foreground-tertiary"> ({count})</span>}
|
| 63 |
+
</span>
|
| 64 |
+
)}
|
| 65 |
+
</div>
|
| 66 |
+
);
|
| 67 |
+
}
|
|
@@ -138,6 +138,12 @@ const translations: Record<Language, Record<string, string>> = {
|
|
| 138 |
'footer.backToTop': 'Back to top',
|
| 139 |
'footer.description': 'Discover amazing AI skills to enhance your productivity and creativity.',
|
| 140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
// Navigation Normal Mode
|
| 142 |
'nav.features': 'Features',
|
| 143 |
'nav.skills': 'Skills',
|
|
@@ -269,6 +275,12 @@ const translations: Record<Language, Record<string, string>> = {
|
|
| 269 |
'footer.backToTop': '返回顶部',
|
| 270 |
'footer.description': '发现令人惊叹的AI技能,提升您的生产力和创造力。',
|
| 271 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
// Navigation Normal Mode
|
| 273 |
'nav.features': '功能',
|
| 274 |
'nav.skills': '技能',
|
|
|
|
| 138 |
'footer.backToTop': 'Back to top',
|
| 139 |
'footer.description': 'Discover amazing AI skills to enhance your productivity and creativity.',
|
| 140 |
|
| 141 |
+
// Header Navigation
|
| 142 |
+
'nav.home': 'Home',
|
| 143 |
+
'nav.discover': 'Discover',
|
| 144 |
+
'nav.dashboard': 'Dashboard',
|
| 145 |
+
'nav.createSkill': 'Create',
|
| 146 |
+
|
| 147 |
// Navigation Normal Mode
|
| 148 |
'nav.features': 'Features',
|
| 149 |
'nav.skills': 'Skills',
|
|
|
|
| 275 |
'footer.backToTop': '返回顶部',
|
| 276 |
'footer.description': '发现令人惊叹的AI技能,提升您的生产力和创造力。',
|
| 277 |
|
| 278 |
+
// Header Navigation
|
| 279 |
+
'nav.home': '首页',
|
| 280 |
+
'nav.discover': '发现',
|
| 281 |
+
'nav.dashboard': '工作台',
|
| 282 |
+
'nav.createSkill': '创建',
|
| 283 |
+
|
| 284 |
// Navigation Normal Mode
|
| 285 |
'nav.features': '功能',
|
| 286 |
'nav.skills': '技能',
|
|
@@ -22,6 +22,14 @@ export interface Skill {
|
|
| 22 |
skillMdUrl: string;
|
| 23 |
config: Record<string, unknown>;
|
| 24 |
greeting?: string;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
|
| 27 |
// ── Registry types (compact format) ─────────────────────────────────
|
|
|
|
| 22 |
skillMdUrl: string;
|
| 23 |
config: Record<string, unknown>;
|
| 24 |
greeting?: string;
|
| 25 |
+
// Extended fields for detail view
|
| 26 |
+
rating?: number;
|
| 27 |
+
ratingCount?: number;
|
| 28 |
+
developer?: string;
|
| 29 |
+
version?: string;
|
| 30 |
+
users?: number;
|
| 31 |
+
openSource?: boolean;
|
| 32 |
+
showcases?: Array<{ title: string; image?: string }>;
|
| 33 |
}
|
| 34 |
|
| 35 |
// ── Registry types (compact format) ─────────────────────────────────
|
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export { useSupabaseSkills, useSupabaseSkill, useCreateSkill } from './useSupabaseSkills';
|
| 2 |
+
export { useSupabaseCravings, useCreateCraving } from './useCravings';
|
| 3 |
+
export { useStars } from './useStars';
|
| 4 |
+
export { useRatings } from './useRatings';
|
| 5 |
+
export { useProfile } from './useProfile';
|
| 6 |
+
export { useDownloads } from './useDownloads';
|
| 7 |
+
export { useRealtimeNotifications } from './useRealtimeSkills';
|
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState, useEffect, useCallback } from 'react';
|
| 2 |
+
import { supabase } from '../../lib/supabaseClient';
|
| 3 |
+
|
| 4 |
+
export interface SupabaseCraving {
|
| 5 |
+
id: string;
|
| 6 |
+
user_id: string | null;
|
| 7 |
+
title: string;
|
| 8 |
+
description: string;
|
| 9 |
+
category: string;
|
| 10 |
+
tags: string[];
|
| 11 |
+
budget: string;
|
| 12 |
+
urgency: 'low' | 'medium' | 'high';
|
| 13 |
+
status: 'open' | 'in-progress' | 'fulfilled';
|
| 14 |
+
emoji: string;
|
| 15 |
+
match_count: number;
|
| 16 |
+
posted_by: string;
|
| 17 |
+
created_at: string;
|
| 18 |
+
updated_at: string;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
interface UseCravingsOptions {
|
| 22 |
+
status?: string;
|
| 23 |
+
search?: string;
|
| 24 |
+
limit?: number;
|
| 25 |
+
offset?: number;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
export function useSupabaseCravings(options: UseCravingsOptions = {}) {
|
| 29 |
+
const [data, setData] = useState<SupabaseCraving[]>([]);
|
| 30 |
+
const [isLoading, setIsLoading] = useState(true);
|
| 31 |
+
const [error, setError] = useState<Error | null>(null);
|
| 32 |
+
const [count, setCount] = useState(0);
|
| 33 |
+
|
| 34 |
+
const fetch = useCallback(async () => {
|
| 35 |
+
setIsLoading(true);
|
| 36 |
+
setError(null);
|
| 37 |
+
|
| 38 |
+
try {
|
| 39 |
+
let query = supabase
|
| 40 |
+
.from('cravings')
|
| 41 |
+
.select('*', { count: 'exact' })
|
| 42 |
+
.order('created_at', { ascending: false });
|
| 43 |
+
|
| 44 |
+
if (options.status) {
|
| 45 |
+
query = query.eq('status', options.status);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
if (options.search) {
|
| 49 |
+
query = query.or(`title.ilike.%${options.search}%,description.ilike.%${options.search}%`);
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
if (options.limit) {
|
| 53 |
+
query = query.limit(options.limit);
|
| 54 |
+
}
|
| 55 |
+
if (options.offset) {
|
| 56 |
+
query = query.range(options.offset, options.offset + (options.limit || 9) - 1);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
const { data: cravings, error: err, count: total } = await query;
|
| 60 |
+
|
| 61 |
+
if (err) throw err;
|
| 62 |
+
setData(cravings || []);
|
| 63 |
+
setCount(total || 0);
|
| 64 |
+
} catch (err) {
|
| 65 |
+
setError(err instanceof Error ? err : new Error('Failed to fetch cravings'));
|
| 66 |
+
} finally {
|
| 67 |
+
setIsLoading(false);
|
| 68 |
+
}
|
| 69 |
+
}, [options.status, options.search, options.limit, options.offset]);
|
| 70 |
+
|
| 71 |
+
useEffect(() => {
|
| 72 |
+
fetch();
|
| 73 |
+
}, [fetch]);
|
| 74 |
+
|
| 75 |
+
return { data, isLoading, error, count, refetch: fetch };
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
export function useCreateCraving() {
|
| 79 |
+
const [isLoading, setIsLoading] = useState(false);
|
| 80 |
+
|
| 81 |
+
const create = async (craving: Partial<SupabaseCraving>) => {
|
| 82 |
+
setIsLoading(true);
|
| 83 |
+
try {
|
| 84 |
+
const { data, error } = await supabase
|
| 85 |
+
.from('cravings')
|
| 86 |
+
.insert(craving)
|
| 87 |
+
.select()
|
| 88 |
+
.single();
|
| 89 |
+
|
| 90 |
+
if (error) throw error;
|
| 91 |
+
return data;
|
| 92 |
+
} finally {
|
| 93 |
+
setIsLoading(false);
|
| 94 |
+
}
|
| 95 |
+
};
|
| 96 |
+
|
| 97 |
+
return { create, isLoading };
|
| 98 |
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useCallback, useState } from 'react';
|
| 2 |
+
import { supabase } from '../../lib/supabaseClient';
|
| 3 |
+
|
| 4 |
+
export function useDownloads() {
|
| 5 |
+
const [isLoading, setIsLoading] = useState(false);
|
| 6 |
+
|
| 7 |
+
const trackDownload = useCallback(async (skillId: string) => {
|
| 8 |
+
setIsLoading(true);
|
| 9 |
+
try {
|
| 10 |
+
await supabase.rpc('increment_download', { p_skill_id: skillId });
|
| 11 |
+
} catch {
|
| 12 |
+
// Supabase not available — silently ignore
|
| 13 |
+
} finally {
|
| 14 |
+
setIsLoading(false);
|
| 15 |
+
}
|
| 16 |
+
}, []);
|
| 17 |
+
|
| 18 |
+
return { trackDownload, isLoading };
|
| 19 |
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState, useEffect } from 'react';
|
| 2 |
+
import { supabase } from '../../lib/supabaseClient';
|
| 3 |
+
|
| 4 |
+
export interface UserProfile {
|
| 5 |
+
id: string;
|
| 6 |
+
display_name: string | null;
|
| 7 |
+
avatar_url: string | null;
|
| 8 |
+
bio: string | null;
|
| 9 |
+
namespace: string | null;
|
| 10 |
+
created_at: string;
|
| 11 |
+
updated_at: string;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
export function useProfile(userId: string | undefined) {
|
| 15 |
+
const [profile, setProfile] = useState<UserProfile | null>(null);
|
| 16 |
+
const [isLoading, setIsLoading] = useState(true);
|
| 17 |
+
|
| 18 |
+
useEffect(() => {
|
| 19 |
+
if (!userId) {
|
| 20 |
+
setIsLoading(false);
|
| 21 |
+
return;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
async function fetch() {
|
| 25 |
+
setIsLoading(true);
|
| 26 |
+
try {
|
| 27 |
+
const { data, error } = await supabase
|
| 28 |
+
.from('user_profiles')
|
| 29 |
+
.select('*')
|
| 30 |
+
.eq('id', userId)
|
| 31 |
+
.maybeSingle();
|
| 32 |
+
|
| 33 |
+
if (error) throw error;
|
| 34 |
+
setProfile(data);
|
| 35 |
+
} catch {
|
| 36 |
+
// Profile table might not exist yet
|
| 37 |
+
} finally {
|
| 38 |
+
setIsLoading(false);
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
fetch();
|
| 43 |
+
}, [userId]);
|
| 44 |
+
|
| 45 |
+
const updateProfile = async (updates: Partial<UserProfile>) => {
|
| 46 |
+
if (!userId) return;
|
| 47 |
+
|
| 48 |
+
try {
|
| 49 |
+
const { data, error } = await supabase
|
| 50 |
+
.from('user_profiles')
|
| 51 |
+
.upsert(
|
| 52 |
+
{ id: userId, ...updates, updated_at: new Date().toISOString() },
|
| 53 |
+
{ onConflict: 'id' }
|
| 54 |
+
)
|
| 55 |
+
.select()
|
| 56 |
+
.single();
|
| 57 |
+
|
| 58 |
+
if (error) throw error;
|
| 59 |
+
setProfile(data);
|
| 60 |
+
return data;
|
| 61 |
+
} catch (err) {
|
| 62 |
+
console.error('Profile update failed:', err);
|
| 63 |
+
throw err;
|
| 64 |
+
}
|
| 65 |
+
};
|
| 66 |
+
|
| 67 |
+
return { profile, isLoading, updateProfile };
|
| 68 |
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState, useEffect, useCallback } from 'react';
|
| 2 |
+
import { supabase } from '../../lib/supabaseClient';
|
| 3 |
+
|
| 4 |
+
export interface Rating {
|
| 5 |
+
id: string;
|
| 6 |
+
user_id: string;
|
| 7 |
+
skill_id: string;
|
| 8 |
+
score: number;
|
| 9 |
+
comment: string;
|
| 10 |
+
created_at: string;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
export function useRatings(skillId: string) {
|
| 14 |
+
const [ratings, setRatings] = useState<Rating[]>([]);
|
| 15 |
+
const [avgRating, setAvgRating] = useState(0);
|
| 16 |
+
const [userRating, setUserRating] = useState<Rating | null>(null);
|
| 17 |
+
const [isLoading, setIsLoading] = useState(true);
|
| 18 |
+
|
| 19 |
+
const fetch = useCallback(async () => {
|
| 20 |
+
if (!skillId) return;
|
| 21 |
+
setIsLoading(true);
|
| 22 |
+
|
| 23 |
+
try {
|
| 24 |
+
const { data, error } = await supabase
|
| 25 |
+
.from('ratings')
|
| 26 |
+
.select('*')
|
| 27 |
+
.eq('skill_id', skillId)
|
| 28 |
+
.order('created_at', { ascending: false });
|
| 29 |
+
|
| 30 |
+
if (error) throw error;
|
| 31 |
+
|
| 32 |
+
setRatings(data || []);
|
| 33 |
+
|
| 34 |
+
if (data && data.length > 0) {
|
| 35 |
+
const avg = data.reduce((sum: number, r: Rating) => sum + r.score, 0) / data.length;
|
| 36 |
+
setAvgRating(Math.round(avg * 10) / 10);
|
| 37 |
+
}
|
| 38 |
+
} catch {
|
| 39 |
+
// Supabase not available, use defaults
|
| 40 |
+
} finally {
|
| 41 |
+
setIsLoading(false);
|
| 42 |
+
}
|
| 43 |
+
}, [skillId]);
|
| 44 |
+
|
| 45 |
+
useEffect(() => {
|
| 46 |
+
fetch();
|
| 47 |
+
}, [fetch]);
|
| 48 |
+
|
| 49 |
+
const rate = async (userId: string, score: number, comment: string = '') => {
|
| 50 |
+
try {
|
| 51 |
+
const { data, error } = await supabase
|
| 52 |
+
.from('ratings')
|
| 53 |
+
.upsert(
|
| 54 |
+
{ user_id: userId, skill_id: skillId, score, comment, updated_at: new Date().toISOString() },
|
| 55 |
+
{ onConflict: 'user_id,skill_id' }
|
| 56 |
+
)
|
| 57 |
+
.select()
|
| 58 |
+
.single();
|
| 59 |
+
|
| 60 |
+
if (error) throw error;
|
| 61 |
+
|
| 62 |
+
setUserRating(data);
|
| 63 |
+
try { await supabase.rpc('refresh_avg_rating', { p_skill_id: skillId }); } catch {}
|
| 64 |
+
await fetch();
|
| 65 |
+
|
| 66 |
+
return data;
|
| 67 |
+
} catch (err) {
|
| 68 |
+
console.error('Rating failed:', err);
|
| 69 |
+
throw err;
|
| 70 |
+
}
|
| 71 |
+
};
|
| 72 |
+
|
| 73 |
+
return { ratings, avgRating, userRating, rate, isLoading, refetch: fetch };
|
| 74 |
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useEffect } from 'react';
|
| 2 |
+
import { supabase } from '../../lib/supabaseClient';
|
| 3 |
+
import { isSupabaseConnected } from '../../lib/dataProvider';
|
| 4 |
+
import { toast } from 'sonner';
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Subscribe to real-time skill/craving inserts.
|
| 8 |
+
* Shows a toast notification when new items are added.
|
| 9 |
+
*/
|
| 10 |
+
export function useRealtimeNotifications() {
|
| 11 |
+
useEffect(() => {
|
| 12 |
+
if (!isSupabaseConnected()) return;
|
| 13 |
+
|
| 14 |
+
const channel = supabase
|
| 15 |
+
.channel('public-changes')
|
| 16 |
+
.on(
|
| 17 |
+
'postgres_changes',
|
| 18 |
+
{ event: 'INSERT', schema: 'public', table: 'skills' },
|
| 19 |
+
(payload) => {
|
| 20 |
+
const name = (payload.new as { name?: string })?.name || 'New skill';
|
| 21 |
+
toast.info(`New candy just dropped: ${name}`, {
|
| 22 |
+
duration: 4000,
|
| 23 |
+
});
|
| 24 |
+
}
|
| 25 |
+
)
|
| 26 |
+
.on(
|
| 27 |
+
'postgres_changes',
|
| 28 |
+
{ event: 'INSERT', schema: 'public', table: 'cravings' },
|
| 29 |
+
(payload) => {
|
| 30 |
+
const title = (payload.new as { title?: string })?.title || 'New craving';
|
| 31 |
+
toast.info(`New craving posted: ${title}`, {
|
| 32 |
+
duration: 4000,
|
| 33 |
+
});
|
| 34 |
+
}
|
| 35 |
+
)
|
| 36 |
+
.subscribe();
|
| 37 |
+
|
| 38 |
+
return () => {
|
| 39 |
+
supabase.removeChannel(channel);
|
| 40 |
+
};
|
| 41 |
+
}, []);
|
| 42 |
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState, useEffect, useCallback } from 'react';
|
| 2 |
+
import { supabase } from '../../lib/supabaseClient';
|
| 3 |
+
import { storageUtils } from '../../utils/storage';
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* Star system that uses Supabase when available, falls back to localStorage.
|
| 7 |
+
*/
|
| 8 |
+
export function useStars(skillId: string, userId?: string) {
|
| 9 |
+
const [isStarred, setIsStarred] = useState(false);
|
| 10 |
+
const [starCount, setStarCount] = useState(0);
|
| 11 |
+
const [isLoading, setIsLoading] = useState(false);
|
| 12 |
+
|
| 13 |
+
// Check initial state
|
| 14 |
+
useEffect(() => {
|
| 15 |
+
if (!skillId) return;
|
| 16 |
+
|
| 17 |
+
// Always check localStorage as fallback
|
| 18 |
+
setIsStarred(storageUtils.isLiked(skillId));
|
| 19 |
+
|
| 20 |
+
// Try Supabase if user is authenticated
|
| 21 |
+
if (userId) {
|
| 22 |
+
(async () => {
|
| 23 |
+
try {
|
| 24 |
+
const { data } = await supabase
|
| 25 |
+
.from('stars')
|
| 26 |
+
.select('id')
|
| 27 |
+
.eq('user_id', userId)
|
| 28 |
+
.eq('skill_id', skillId)
|
| 29 |
+
.maybeSingle();
|
| 30 |
+
if (data) setIsStarred(true);
|
| 31 |
+
} catch {}
|
| 32 |
+
})();
|
| 33 |
+
|
| 34 |
+
(async () => {
|
| 35 |
+
try {
|
| 36 |
+
const { count } = await supabase
|
| 37 |
+
.from('stars')
|
| 38 |
+
.select('id', { count: 'exact' })
|
| 39 |
+
.eq('skill_id', skillId);
|
| 40 |
+
if (count !== null) setStarCount(count);
|
| 41 |
+
} catch {}
|
| 42 |
+
})();
|
| 43 |
+
}
|
| 44 |
+
}, [skillId, userId]);
|
| 45 |
+
|
| 46 |
+
const toggleStar = useCallback(async () => {
|
| 47 |
+
if (!skillId) return;
|
| 48 |
+
setIsLoading(true);
|
| 49 |
+
|
| 50 |
+
try {
|
| 51 |
+
if (isStarred) {
|
| 52 |
+
// Unstar
|
| 53 |
+
storageUtils.removeLike(skillId);
|
| 54 |
+
setIsStarred(false);
|
| 55 |
+
setStarCount((c) => Math.max(0, c - 1));
|
| 56 |
+
|
| 57 |
+
if (userId) {
|
| 58 |
+
await supabase
|
| 59 |
+
.from('stars')
|
| 60 |
+
.delete()
|
| 61 |
+
.eq('user_id', userId)
|
| 62 |
+
.eq('skill_id', skillId);
|
| 63 |
+
|
| 64 |
+
try { await supabase.rpc('refresh_star_count', { p_skill_id: skillId }); } catch {}
|
| 65 |
+
}
|
| 66 |
+
} else {
|
| 67 |
+
// Star
|
| 68 |
+
storageUtils.saveLike(skillId);
|
| 69 |
+
setIsStarred(true);
|
| 70 |
+
setStarCount((c) => c + 1);
|
| 71 |
+
|
| 72 |
+
if (userId) {
|
| 73 |
+
await supabase
|
| 74 |
+
.from('stars')
|
| 75 |
+
.insert({ user_id: userId, skill_id: skillId });
|
| 76 |
+
|
| 77 |
+
try { await supabase.rpc('refresh_star_count', { p_skill_id: skillId }); } catch {}
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
} catch (err) {
|
| 81 |
+
console.error('Star toggle failed:', err);
|
| 82 |
+
// Revert on error
|
| 83 |
+
setIsStarred(!isStarred);
|
| 84 |
+
} finally {
|
| 85 |
+
setIsLoading(false);
|
| 86 |
+
}
|
| 87 |
+
}, [skillId, userId, isStarred]);
|
| 88 |
+
|
| 89 |
+
return { isStarred, starCount, toggleStar, isLoading };
|
| 90 |
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState, useEffect, useCallback } from 'react';
|
| 2 |
+
import { supabase } from '../../lib/supabaseClient';
|
| 3 |
+
|
| 4 |
+
export interface SupabaseSkill {
|
| 5 |
+
id: string;
|
| 6 |
+
user_id: string | null;
|
| 7 |
+
name: string;
|
| 8 |
+
description: string;
|
| 9 |
+
category: string;
|
| 10 |
+
icon: string;
|
| 11 |
+
color: string;
|
| 12 |
+
tags: string[];
|
| 13 |
+
install_command: string;
|
| 14 |
+
repo: string;
|
| 15 |
+
skill_md_url: string;
|
| 16 |
+
config: Record<string, unknown>;
|
| 17 |
+
greeting: string | null;
|
| 18 |
+
popularity: number;
|
| 19 |
+
download_count: number;
|
| 20 |
+
star_count: number;
|
| 21 |
+
avg_rating: number;
|
| 22 |
+
status: string;
|
| 23 |
+
is_public: boolean;
|
| 24 |
+
created_at: string;
|
| 25 |
+
updated_at: string;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
interface UseSkillsOptions {
|
| 29 |
+
category?: string;
|
| 30 |
+
search?: string;
|
| 31 |
+
sortBy?: 'popularity' | 'recent' | 'stars' | 'rating';
|
| 32 |
+
limit?: number;
|
| 33 |
+
offset?: number;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
export function useSupabaseSkills(options: UseSkillsOptions = {}) {
|
| 37 |
+
const [data, setData] = useState<SupabaseSkill[]>([]);
|
| 38 |
+
const [isLoading, setIsLoading] = useState(true);
|
| 39 |
+
const [error, setError] = useState<Error | null>(null);
|
| 40 |
+
const [count, setCount] = useState(0);
|
| 41 |
+
|
| 42 |
+
const fetch = useCallback(async () => {
|
| 43 |
+
setIsLoading(true);
|
| 44 |
+
setError(null);
|
| 45 |
+
|
| 46 |
+
try {
|
| 47 |
+
let query = supabase
|
| 48 |
+
.from('skills')
|
| 49 |
+
.select('*', { count: 'exact' })
|
| 50 |
+
.eq('is_public', true)
|
| 51 |
+
.eq('status', 'active');
|
| 52 |
+
|
| 53 |
+
if (options.category) {
|
| 54 |
+
query = query.eq('category', options.category);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
if (options.search) {
|
| 58 |
+
query = query.textSearch('fts', options.search, { type: 'websearch' });
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
switch (options.sortBy) {
|
| 62 |
+
case 'stars':
|
| 63 |
+
query = query.order('star_count', { ascending: false });
|
| 64 |
+
break;
|
| 65 |
+
case 'rating':
|
| 66 |
+
query = query.order('avg_rating', { ascending: false });
|
| 67 |
+
break;
|
| 68 |
+
case 'recent':
|
| 69 |
+
query = query.order('created_at', { ascending: false });
|
| 70 |
+
break;
|
| 71 |
+
default:
|
| 72 |
+
query = query.order('popularity', { ascending: false });
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
if (options.limit) {
|
| 76 |
+
query = query.limit(options.limit);
|
| 77 |
+
}
|
| 78 |
+
if (options.offset) {
|
| 79 |
+
query = query.range(options.offset, options.offset + (options.limit || 12) - 1);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
const { data: skills, error: err, count: total } = await query;
|
| 83 |
+
|
| 84 |
+
if (err) throw err;
|
| 85 |
+
setData(skills || []);
|
| 86 |
+
setCount(total || 0);
|
| 87 |
+
} catch (err) {
|
| 88 |
+
setError(err instanceof Error ? err : new Error('Failed to fetch skills'));
|
| 89 |
+
} finally {
|
| 90 |
+
setIsLoading(false);
|
| 91 |
+
}
|
| 92 |
+
}, [options.category, options.search, options.sortBy, options.limit, options.offset]);
|
| 93 |
+
|
| 94 |
+
useEffect(() => {
|
| 95 |
+
fetch();
|
| 96 |
+
}, [fetch]);
|
| 97 |
+
|
| 98 |
+
return { data, isLoading, error, count, refetch: fetch };
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
export function useSupabaseSkill(id: string | undefined) {
|
| 102 |
+
const [data, setData] = useState<SupabaseSkill | null>(null);
|
| 103 |
+
const [isLoading, setIsLoading] = useState(true);
|
| 104 |
+
const [error, setError] = useState<Error | null>(null);
|
| 105 |
+
|
| 106 |
+
useEffect(() => {
|
| 107 |
+
if (!id) {
|
| 108 |
+
setIsLoading(false);
|
| 109 |
+
return;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
async function fetch() {
|
| 113 |
+
setIsLoading(true);
|
| 114 |
+
try {
|
| 115 |
+
const { data: skill, error: err } = await supabase
|
| 116 |
+
.from('skills')
|
| 117 |
+
.select('*')
|
| 118 |
+
.eq('id', id)
|
| 119 |
+
.single();
|
| 120 |
+
|
| 121 |
+
if (err) throw err;
|
| 122 |
+
setData(skill);
|
| 123 |
+
} catch (err) {
|
| 124 |
+
setError(err instanceof Error ? err : new Error('Failed to fetch skill'));
|
| 125 |
+
} finally {
|
| 126 |
+
setIsLoading(false);
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
fetch();
|
| 131 |
+
}, [id]);
|
| 132 |
+
|
| 133 |
+
return { data, isLoading, error };
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
export function useCreateSkill() {
|
| 137 |
+
const [isLoading, setIsLoading] = useState(false);
|
| 138 |
+
|
| 139 |
+
const create = async (skill: Partial<SupabaseSkill>) => {
|
| 140 |
+
setIsLoading(true);
|
| 141 |
+
try {
|
| 142 |
+
const { data, error } = await supabase
|
| 143 |
+
.from('skills')
|
| 144 |
+
.insert(skill)
|
| 145 |
+
.select()
|
| 146 |
+
.single();
|
| 147 |
+
|
| 148 |
+
if (error) throw error;
|
| 149 |
+
return data;
|
| 150 |
+
} finally {
|
| 151 |
+
setIsLoading(false);
|
| 152 |
+
}
|
| 153 |
+
};
|
| 154 |
+
|
| 155 |
+
return { create, isLoading };
|
| 156 |
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { supabase } from './supabaseClient';
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Check if Supabase is properly configured (not a mock client).
|
| 5 |
+
*/
|
| 6 |
+
export function isSupabaseConnected(): boolean {
|
| 7 |
+
const url = import.meta.env.VITE_SUPABASE_URL as string | undefined;
|
| 8 |
+
const key = import.meta.env.VITE_SUPABASE_ANON_KEY as string | undefined;
|
| 9 |
+
|
| 10 |
+
if (!url || !key) return false;
|
| 11 |
+
if (url.includes('YOUR_') || key.includes('YOUR_')) return false;
|
| 12 |
+
|
| 13 |
+
try {
|
| 14 |
+
new URL(url);
|
| 15 |
+
return true;
|
| 16 |
+
} catch {
|
| 17 |
+
return false;
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Seed skills data into Supabase from the static SKILLS_DATA array.
|
| 23 |
+
* Only runs once per session.
|
| 24 |
+
*/
|
| 25 |
+
let seeded = false;
|
| 26 |
+
|
| 27 |
+
export async function seedSkillsIfNeeded(skills: Array<{
|
| 28 |
+
id: string;
|
| 29 |
+
name: string;
|
| 30 |
+
description: string;
|
| 31 |
+
category: string;
|
| 32 |
+
icon: string;
|
| 33 |
+
color: string;
|
| 34 |
+
tags: string[];
|
| 35 |
+
installCommand: string;
|
| 36 |
+
repo: string;
|
| 37 |
+
skillMdUrl: string;
|
| 38 |
+
config: Record<string, unknown>;
|
| 39 |
+
popularity: number;
|
| 40 |
+
greeting?: string;
|
| 41 |
+
}>) {
|
| 42 |
+
if (seeded || !isSupabaseConnected()) return;
|
| 43 |
+
seeded = true;
|
| 44 |
+
|
| 45 |
+
// Check if skills table has data
|
| 46 |
+
const { count } = await supabase
|
| 47 |
+
.from('skills')
|
| 48 |
+
.select('id', { count: 'exact', head: true });
|
| 49 |
+
|
| 50 |
+
if (count && count > 0) return; // Already seeded
|
| 51 |
+
|
| 52 |
+
// Batch insert in chunks of 100
|
| 53 |
+
const chunks = [];
|
| 54 |
+
for (let i = 0; i < skills.length; i += 100) {
|
| 55 |
+
chunks.push(skills.slice(i, i + 100));
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
for (const chunk of chunks) {
|
| 59 |
+
const rows = chunk.map((s) => ({
|
| 60 |
+
name: s.name,
|
| 61 |
+
description: s.description,
|
| 62 |
+
category: s.category,
|
| 63 |
+
icon: s.icon,
|
| 64 |
+
color: s.color,
|
| 65 |
+
tags: s.tags,
|
| 66 |
+
install_command: s.installCommand,
|
| 67 |
+
repo: s.repo,
|
| 68 |
+
skill_md_url: s.skillMdUrl,
|
| 69 |
+
config: s.config,
|
| 70 |
+
popularity: s.popularity,
|
| 71 |
+
greeting: s.greeting || null,
|
| 72 |
+
is_public: true,
|
| 73 |
+
status: 'active',
|
| 74 |
+
}));
|
| 75 |
+
|
| 76 |
+
try { await supabase.from('skills').insert(rows); } catch {}
|
| 77 |
+
}
|
| 78 |
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useParams, useNavigate } from 'react-router-dom';
|
| 2 |
+
import { ArrowLeft, Clock, Flame, Zap, DollarSign, Tag } from 'lucide-react';
|
| 3 |
+
import { useMemo } from 'react';
|
| 4 |
+
import { Button } from '../components/ui/Button';
|
| 5 |
+
import { Card, CardContent } from '../components/ui/Card';
|
| 6 |
+
import { Badge } from '../components/ui/Badge';
|
| 7 |
+
import { CRAVINGS_DATA } from '../data/cravingsData';
|
| 8 |
+
import { SKILLS_DATA } from '../data/skillsData';
|
| 9 |
+
import { storageUtils } from '../utils/storage';
|
| 10 |
+
|
| 11 |
+
export function CravingDetailPage() {
|
| 12 |
+
const { id } = useParams<{ id: string }>();
|
| 13 |
+
const navigate = useNavigate();
|
| 14 |
+
|
| 15 |
+
const allCravings = useMemo(() => {
|
| 16 |
+
const userCravings = storageUtils.getUserCravings();
|
| 17 |
+
return [...userCravings, ...CRAVINGS_DATA];
|
| 18 |
+
}, []);
|
| 19 |
+
|
| 20 |
+
const craving = useMemo(() => allCravings.find((c) => c.id === id), [allCravings, id]);
|
| 21 |
+
|
| 22 |
+
if (!craving) {
|
| 23 |
+
return (
|
| 24 |
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-20 text-center">
|
| 25 |
+
<h1 className="text-2xl font-bold mb-4">Craving not found</h1>
|
| 26 |
+
<Button onClick={() => navigate('/discover?tab=craving')}>Back to Cravings</Button>
|
| 27 |
+
</div>
|
| 28 |
+
);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
const urgencyConfig = {
|
| 32 |
+
high: { icon: Flame, color: 'text-error', bg: 'bg-error/10', label: 'High' },
|
| 33 |
+
medium: { icon: Zap, color: 'text-warning', bg: 'bg-warning/10', label: 'Medium' },
|
| 34 |
+
low: { icon: Clock, color: 'text-info', bg: 'bg-info/10', label: 'Low' },
|
| 35 |
+
};
|
| 36 |
+
const urgency = urgencyConfig[craving.urgency] || urgencyConfig.medium;
|
| 37 |
+
const UrgencyIcon = urgency.icon;
|
| 38 |
+
|
| 39 |
+
const matchingSkills = SKILLS_DATA.filter((skill) =>
|
| 40 |
+
craving.tags.some((tag) =>
|
| 41 |
+
skill.tags?.some((st) => st.toLowerCase().includes(tag.toLowerCase())) ||
|
| 42 |
+
skill.category.toLowerCase().includes(tag.toLowerCase())
|
| 43 |
+
)
|
| 44 |
+
).slice(0, 6);
|
| 45 |
+
|
| 46 |
+
const statusColors = {
|
| 47 |
+
open: 'success',
|
| 48 |
+
'in-progress': 'warning',
|
| 49 |
+
fulfilled: 'default',
|
| 50 |
+
} as const;
|
| 51 |
+
|
| 52 |
+
return (
|
| 53 |
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
| 54 |
+
<button
|
| 55 |
+
onClick={() => navigate(-1)}
|
| 56 |
+
className="flex items-center gap-2 text-sm text-foreground-secondary hover:text-foreground mb-6 transition-colors"
|
| 57 |
+
>
|
| 58 |
+
<ArrowLeft className="w-4 h-4" />
|
| 59 |
+
Back
|
| 60 |
+
</button>
|
| 61 |
+
|
| 62 |
+
<div className="grid grid-cols-1 lg:grid-cols-3 gap-8">
|
| 63 |
+
{/* Main */}
|
| 64 |
+
<div className="lg:col-span-2 space-y-6">
|
| 65 |
+
<div className="flex items-start gap-4">
|
| 66 |
+
<span className="text-4xl">{craving.emoji}</span>
|
| 67 |
+
<div className="flex-1">
|
| 68 |
+
<h1 className="text-2xl sm:text-3xl font-bold font-candy">{craving.title}</h1>
|
| 69 |
+
<div className="flex items-center gap-2 mt-2 flex-wrap">
|
| 70 |
+
<Badge variant={statusColors[craving.status] || 'default'}>
|
| 71 |
+
{craving.status}
|
| 72 |
+
</Badge>
|
| 73 |
+
<Badge variant="secondary" size="sm">
|
| 74 |
+
{craving.category}
|
| 75 |
+
</Badge>
|
| 76 |
+
</div>
|
| 77 |
+
</div>
|
| 78 |
+
</div>
|
| 79 |
+
|
| 80 |
+
<Card>
|
| 81 |
+
<CardContent className="pt-6">
|
| 82 |
+
<h2 className="text-lg font-semibold mb-3">Description</h2>
|
| 83 |
+
<p className="text-foreground-secondary leading-relaxed">{craving.description}</p>
|
| 84 |
+
</CardContent>
|
| 85 |
+
</Card>
|
| 86 |
+
|
| 87 |
+
{/* Matching Skills */}
|
| 88 |
+
{matchingSkills.length > 0 && (
|
| 89 |
+
<div>
|
| 90 |
+
<h2 className="text-lg font-semibold mb-4">Matching Candies ({matchingSkills.length})</h2>
|
| 91 |
+
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
| 92 |
+
{matchingSkills.map((skill) => (
|
| 93 |
+
<Card
|
| 94 |
+
key={skill.id}
|
| 95 |
+
variant="interactive"
|
| 96 |
+
className="p-4"
|
| 97 |
+
onClick={() => navigate(`/candy/${skill.id}`)}
|
| 98 |
+
>
|
| 99 |
+
<CardContent className="p-0 flex items-start gap-3">
|
| 100 |
+
<span className="text-xl">{skill.icon}</span>
|
| 101 |
+
<div className="flex-1 min-w-0">
|
| 102 |
+
<h3 className="font-medium text-sm truncate">{skill.name}</h3>
|
| 103 |
+
<p className="text-xs text-foreground-secondary line-clamp-2 mt-1">{skill.description}</p>
|
| 104 |
+
</div>
|
| 105 |
+
</CardContent>
|
| 106 |
+
</Card>
|
| 107 |
+
))}
|
| 108 |
+
</div>
|
| 109 |
+
</div>
|
| 110 |
+
)}
|
| 111 |
+
</div>
|
| 112 |
+
|
| 113 |
+
{/* Sidebar */}
|
| 114 |
+
<div className="space-y-4">
|
| 115 |
+
<Card>
|
| 116 |
+
<CardContent className="pt-6 space-y-3">
|
| 117 |
+
<Button variant="candy" className="w-full">
|
| 118 |
+
Offer to Build
|
| 119 |
+
</Button>
|
| 120 |
+
<Button variant="outline" className="w-full" onClick={() => navigate('/discover')}>
|
| 121 |
+
Find Matching Candy
|
| 122 |
+
</Button>
|
| 123 |
+
</CardContent>
|
| 124 |
+
</Card>
|
| 125 |
+
|
| 126 |
+
<Card>
|
| 127 |
+
<CardContent className="pt-6 space-y-4">
|
| 128 |
+
<h3 className="text-sm font-semibold text-foreground-secondary uppercase tracking-wider">Details</h3>
|
| 129 |
+
<div className="space-y-3 text-sm">
|
| 130 |
+
<div className="flex justify-between items-center">
|
| 131 |
+
<span className="text-foreground-secondary">Urgency</span>
|
| 132 |
+
<div className={`flex items-center gap-1 ${urgency.color}`}>
|
| 133 |
+
<UrgencyIcon className="w-3.5 h-3.5" />
|
| 134 |
+
{urgency.label}
|
| 135 |
+
</div>
|
| 136 |
+
</div>
|
| 137 |
+
<div className="flex justify-between items-center">
|
| 138 |
+
<span className="text-foreground-secondary">Budget</span>
|
| 139 |
+
<span className="font-medium flex items-center gap-1">
|
| 140 |
+
<DollarSign className="w-3.5 h-3.5" />
|
| 141 |
+
{craving.budget}
|
| 142 |
+
</span>
|
| 143 |
+
</div>
|
| 144 |
+
<div className="flex justify-between">
|
| 145 |
+
<span className="text-foreground-secondary">Posted by</span>
|
| 146 |
+
<span className="font-medium">{craving.postedBy}</span>
|
| 147 |
+
</div>
|
| 148 |
+
<div className="flex justify-between">
|
| 149 |
+
<span className="text-foreground-secondary">Posted</span>
|
| 150 |
+
<span className="text-foreground-tertiary">{craving.postedAt}</span>
|
| 151 |
+
</div>
|
| 152 |
+
<div className="flex justify-between">
|
| 153 |
+
<span className="text-foreground-secondary">Matches</span>
|
| 154 |
+
<span className="font-medium">{craving.matchCount}</span>
|
| 155 |
+
</div>
|
| 156 |
+
</div>
|
| 157 |
+
|
| 158 |
+
{craving.tags.length > 0 && (
|
| 159 |
+
<div>
|
| 160 |
+
<div className="flex items-center gap-1 text-sm text-foreground-secondary mb-2">
|
| 161 |
+
<Tag className="w-3.5 h-3.5" />
|
| 162 |
+
Tags
|
| 163 |
+
</div>
|
| 164 |
+
<div className="flex flex-wrap gap-1.5">
|
| 165 |
+
{craving.tags.map((tag) => (
|
| 166 |
+
<Badge key={tag} variant="outline" size="sm">{tag}</Badge>
|
| 167 |
+
))}
|
| 168 |
+
</div>
|
| 169 |
+
</div>
|
| 170 |
+
)}
|
| 171 |
+
</CardContent>
|
| 172 |
+
</Card>
|
| 173 |
+
</div>
|
| 174 |
+
</div>
|
| 175 |
+
</div>
|
| 176 |
+
);
|
| 177 |
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState, useMemo } from 'react';
|
| 2 |
+
import { useNavigate } from 'react-router-dom';
|
| 3 |
+
import { Sparkles, Heart, Star, Package, Plus, ArrowRight } from 'lucide-react';
|
| 4 |
+
import type { User } from '@supabase/supabase-js';
|
| 5 |
+
import { Button } from '../components/ui/Button';
|
| 6 |
+
import { Card, CardContent } from '../components/ui/Card';
|
| 7 |
+
import { Badge } from '../components/ui/Badge';
|
| 8 |
+
import { storageUtils } from '../utils/storage';
|
| 9 |
+
import { SKILLS_DATA } from '../data/skillsData';
|
| 10 |
+
import { cn } from '../utils/cn';
|
| 11 |
+
|
| 12 |
+
type DashboardTab = 'skills' | 'cravings' | 'starred';
|
| 13 |
+
|
| 14 |
+
interface DashboardPageProps {
|
| 15 |
+
user: User | null;
|
| 16 |
+
onOpenAuth: () => void;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
export function DashboardPage({ user, onOpenAuth }: DashboardPageProps) {
|
| 20 |
+
const navigate = useNavigate();
|
| 21 |
+
const [activeTab, setActiveTab] = useState<DashboardTab>('skills');
|
| 22 |
+
|
| 23 |
+
const userSkills = useMemo(() => storageUtils.getSkills(), []);
|
| 24 |
+
const userCravings = useMemo(() => storageUtils.getUserCravings(), []);
|
| 25 |
+
const likedIds = useMemo(() => storageUtils.getLikes(), []);
|
| 26 |
+
const starredSkills = useMemo(
|
| 27 |
+
() => SKILLS_DATA.filter((s) => likedIds.includes(s.id)),
|
| 28 |
+
[likedIds]
|
| 29 |
+
);
|
| 30 |
+
|
| 31 |
+
if (!user) {
|
| 32 |
+
return (
|
| 33 |
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-20 text-center">
|
| 34 |
+
<div className="text-5xl mb-4">🔐</div>
|
| 35 |
+
<h1 className="text-2xl font-bold mb-2">Sign in to access your Dashboard</h1>
|
| 36 |
+
<p className="text-foreground-secondary mb-6">
|
| 37 |
+
Manage your skills, cravings, and starred items.
|
| 38 |
+
</p>
|
| 39 |
+
<Button onClick={onOpenAuth}>Sign In</Button>
|
| 40 |
+
</div>
|
| 41 |
+
);
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
const avatarUrl = user.user_metadata?.avatar_url || user.user_metadata?.picture;
|
| 45 |
+
const displayName = user.user_metadata?.full_name || user.email?.split('@')[0] || 'Agent';
|
| 46 |
+
|
| 47 |
+
const tabs = [
|
| 48 |
+
{ id: 'skills' as const, label: 'My Candies', icon: Package, count: userSkills.length },
|
| 49 |
+
{ id: 'cravings' as const, label: 'My Cravings', icon: Heart, count: userCravings.length },
|
| 50 |
+
{ id: 'starred' as const, label: 'Starred', icon: Star, count: starredSkills.length },
|
| 51 |
+
];
|
| 52 |
+
|
| 53 |
+
return (
|
| 54 |
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
| 55 |
+
{/* Profile Card */}
|
| 56 |
+
<Card className="mb-8">
|
| 57 |
+
<CardContent className="pt-6">
|
| 58 |
+
<div className="flex items-center gap-4">
|
| 59 |
+
{avatarUrl ? (
|
| 60 |
+
<img src={avatarUrl} alt="" className="w-16 h-16 rounded-full border-2 border-border" />
|
| 61 |
+
) : (
|
| 62 |
+
<div className="w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center">
|
| 63 |
+
<span className="text-2xl font-bold text-primary">{displayName[0]?.toUpperCase()}</span>
|
| 64 |
+
</div>
|
| 65 |
+
)}
|
| 66 |
+
<div className="flex-1">
|
| 67 |
+
<h1 className="text-xl font-bold">{displayName}</h1>
|
| 68 |
+
<p className="text-sm text-foreground-secondary">{user.email}</p>
|
| 69 |
+
<div className="flex items-center gap-4 mt-2">
|
| 70 |
+
<span className="text-xs text-foreground-tertiary">
|
| 71 |
+
{userSkills.length} skills created
|
| 72 |
+
</span>
|
| 73 |
+
<span className="text-xs text-foreground-tertiary">
|
| 74 |
+
{userCravings.length} cravings posted
|
| 75 |
+
</span>
|
| 76 |
+
<span className="text-xs text-foreground-tertiary">
|
| 77 |
+
{starredSkills.length} starred
|
| 78 |
+
</span>
|
| 79 |
+
</div>
|
| 80 |
+
</div>
|
| 81 |
+
<Button variant="outline" size="sm" onClick={() => navigate('/skills/create')}>
|
| 82 |
+
<Plus className="w-4 h-4" />
|
| 83 |
+
Create Skill
|
| 84 |
+
</Button>
|
| 85 |
+
</div>
|
| 86 |
+
</CardContent>
|
| 87 |
+
</Card>
|
| 88 |
+
|
| 89 |
+
{/* Tabs */}
|
| 90 |
+
<div className="flex items-center gap-1 border-b border-border mb-6">
|
| 91 |
+
{tabs.map((tab) => {
|
| 92 |
+
const Icon = tab.icon;
|
| 93 |
+
return (
|
| 94 |
+
<button
|
| 95 |
+
key={tab.id}
|
| 96 |
+
onClick={() => setActiveTab(tab.id)}
|
| 97 |
+
className={cn(
|
| 98 |
+
'flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors',
|
| 99 |
+
activeTab === tab.id
|
| 100 |
+
? 'border-primary text-primary'
|
| 101 |
+
: 'border-transparent text-foreground-secondary hover:text-foreground hover:border-border'
|
| 102 |
+
)}
|
| 103 |
+
>
|
| 104 |
+
<Icon className="w-4 h-4" />
|
| 105 |
+
{tab.label}
|
| 106 |
+
<Badge variant="secondary" size="sm">{tab.count}</Badge>
|
| 107 |
+
</button>
|
| 108 |
+
);
|
| 109 |
+
})}
|
| 110 |
+
</div>
|
| 111 |
+
|
| 112 |
+
{/* Tab Content */}
|
| 113 |
+
{activeTab === 'skills' && (
|
| 114 |
+
<div>
|
| 115 |
+
{userSkills.length === 0 ? (
|
| 116 |
+
<div className="text-center py-16">
|
| 117 |
+
<Sparkles className="w-12 h-12 text-foreground-muted mx-auto mb-4" />
|
| 118 |
+
<h3 className="text-lg font-semibold mb-2">No skills yet</h3>
|
| 119 |
+
<p className="text-foreground-secondary mb-4">Create your first AI skill or browse the marketplace.</p>
|
| 120 |
+
<div className="flex justify-center gap-3">
|
| 121 |
+
<Button onClick={() => navigate('/skills/create')}>
|
| 122 |
+
<Plus className="w-4 h-4" /> Create Skill
|
| 123 |
+
</Button>
|
| 124 |
+
<Button variant="outline" onClick={() => navigate('/discover')}>
|
| 125 |
+
Browse Marketplace
|
| 126 |
+
</Button>
|
| 127 |
+
</div>
|
| 128 |
+
</div>
|
| 129 |
+
) : (
|
| 130 |
+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
| 131 |
+
{userSkills.map((skill) => (
|
| 132 |
+
<Card key={skill.id} variant="interactive" className="p-5">
|
| 133 |
+
<CardContent className="p-0">
|
| 134 |
+
<div className="flex items-center gap-3 mb-3">
|
| 135 |
+
<span className="text-2xl">{skill.icon}</span>
|
| 136 |
+
<div className="flex-1 min-w-0">
|
| 137 |
+
<h3 className="font-semibold text-sm truncate">{skill.name}</h3>
|
| 138 |
+
<Badge variant={skill.status === 'active' ? 'success' : 'secondary'} size="sm">
|
| 139 |
+
{skill.status}
|
| 140 |
+
</Badge>
|
| 141 |
+
</div>
|
| 142 |
+
</div>
|
| 143 |
+
<p className="text-xs text-foreground-secondary line-clamp-2">{skill.description}</p>
|
| 144 |
+
</CardContent>
|
| 145 |
+
</Card>
|
| 146 |
+
))}
|
| 147 |
+
</div>
|
| 148 |
+
)}
|
| 149 |
+
</div>
|
| 150 |
+
)}
|
| 151 |
+
|
| 152 |
+
{activeTab === 'cravings' && (
|
| 153 |
+
<div>
|
| 154 |
+
{userCravings.length === 0 ? (
|
| 155 |
+
<div className="text-center py-16">
|
| 156 |
+
<Heart className="w-12 h-12 text-foreground-muted mx-auto mb-4" />
|
| 157 |
+
<h3 className="text-lg font-semibold mb-2">No cravings yet</h3>
|
| 158 |
+
<p className="text-foreground-secondary mb-4">Post what you need and let makers find you.</p>
|
| 159 |
+
<Button onClick={() => navigate('/discover?tab=craving')}>
|
| 160 |
+
Post a Craving
|
| 161 |
+
</Button>
|
| 162 |
+
</div>
|
| 163 |
+
) : (
|
| 164 |
+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
| 165 |
+
{userCravings.map((craving) => (
|
| 166 |
+
<Card
|
| 167 |
+
key={craving.id}
|
| 168 |
+
variant="interactive"
|
| 169 |
+
className="p-5"
|
| 170 |
+
onClick={() => navigate(`/craving/${craving.id}`)}
|
| 171 |
+
>
|
| 172 |
+
<CardContent className="p-0">
|
| 173 |
+
<div className="flex items-center gap-3 mb-3">
|
| 174 |
+
<span className="text-2xl">{craving.emoji}</span>
|
| 175 |
+
<div className="flex-1 min-w-0">
|
| 176 |
+
<h3 className="font-semibold text-sm truncate">{craving.title}</h3>
|
| 177 |
+
<Badge
|
| 178 |
+
variant={craving.status === 'open' ? 'success' : 'secondary'}
|
| 179 |
+
size="sm"
|
| 180 |
+
>
|
| 181 |
+
{craving.status}
|
| 182 |
+
</Badge>
|
| 183 |
+
</div>
|
| 184 |
+
</div>
|
| 185 |
+
<p className="text-xs text-foreground-secondary line-clamp-2">{craving.description}</p>
|
| 186 |
+
</CardContent>
|
| 187 |
+
</Card>
|
| 188 |
+
))}
|
| 189 |
+
</div>
|
| 190 |
+
)}
|
| 191 |
+
</div>
|
| 192 |
+
)}
|
| 193 |
+
|
| 194 |
+
{activeTab === 'starred' && (
|
| 195 |
+
<div>
|
| 196 |
+
{starredSkills.length === 0 ? (
|
| 197 |
+
<div className="text-center py-16">
|
| 198 |
+
<Star className="w-12 h-12 text-foreground-muted mx-auto mb-4" />
|
| 199 |
+
<h3 className="text-lg font-semibold mb-2">No starred skills</h3>
|
| 200 |
+
<p className="text-foreground-secondary mb-4">Star skills you like to find them quickly.</p>
|
| 201 |
+
<Button onClick={() => navigate('/discover')}>
|
| 202 |
+
Discover Skills <ArrowRight className="w-4 h-4" />
|
| 203 |
+
</Button>
|
| 204 |
+
</div>
|
| 205 |
+
) : (
|
| 206 |
+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
| 207 |
+
{starredSkills.map((skill) => (
|
| 208 |
+
<Card
|
| 209 |
+
key={skill.id}
|
| 210 |
+
variant="interactive"
|
| 211 |
+
className="p-5"
|
| 212 |
+
onClick={() => navigate(`/candy/${skill.id}`)}
|
| 213 |
+
>
|
| 214 |
+
<CardContent className="p-0">
|
| 215 |
+
<div className="flex items-center gap-3 mb-3">
|
| 216 |
+
<span className="text-2xl">{skill.icon}</span>
|
| 217 |
+
<div className="flex-1 min-w-0">
|
| 218 |
+
<h3 className="font-semibold text-sm truncate">{skill.name}</h3>
|
| 219 |
+
<Badge variant="secondary" size="sm">{skill.category}</Badge>
|
| 220 |
+
</div>
|
| 221 |
+
<Star className="w-4 h-4 fill-warning text-warning" />
|
| 222 |
+
</div>
|
| 223 |
+
<p className="text-xs text-foreground-secondary line-clamp-2">{skill.description}</p>
|
| 224 |
+
</CardContent>
|
| 225 |
+
</Card>
|
| 226 |
+
))}
|
| 227 |
+
</div>
|
| 228 |
+
)}
|
| 229 |
+
</div>
|
| 230 |
+
)}
|
| 231 |
+
</div>
|
| 232 |
+
);
|
| 233 |
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState } from 'react';
|
| 2 |
+
import { useSearchParams } from 'react-router-dom';
|
| 3 |
+
import { SkillsGrid } from '../components/home/SkillsGrid';
|
| 4 |
+
import { CravingsGrid } from '../components/home/CravingsGrid';
|
| 5 |
+
import { Categories } from '../components/home/Categories';
|
| 6 |
+
import { PostCravingModal } from '../components/home/PostCravingModal';
|
| 7 |
+
import { PostCandyModal } from '../components/home/PostCandyModal';
|
| 8 |
+
import { storageUtils } from '../utils/storage';
|
| 9 |
+
import { type Skill as StoreSkill } from '../data/skillsData';
|
| 10 |
+
import type { Craving } from '../data/cravingsData';
|
| 11 |
+
import type { User } from '@supabase/supabase-js';
|
| 12 |
+
import { toast } from 'sonner';
|
| 13 |
+
import { cn } from '../utils/cn';
|
| 14 |
+
import { Candy, Heart } from 'lucide-react';
|
| 15 |
+
import { useLanguage } from '../contexts/LanguageContext';
|
| 16 |
+
|
| 17 |
+
type MarketplaceTab = 'candy' | 'craving';
|
| 18 |
+
|
| 19 |
+
interface DiscoverPageProps {
|
| 20 |
+
user: User | null;
|
| 21 |
+
cart: Set<string>;
|
| 22 |
+
onToggleCart: (id: string) => void;
|
| 23 |
+
onRunSkill: (skill: StoreSkill) => void;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
export function DiscoverPage({ cart, onToggleCart, onRunSkill }: DiscoverPageProps) {
|
| 27 |
+
const { t } = useLanguage();
|
| 28 |
+
const [searchParams, setSearchParams] = useSearchParams();
|
| 29 |
+
const rawTab = searchParams.get('tab');
|
| 30 |
+
const activeTab: MarketplaceTab = rawTab === 'craving' ? 'craving' : 'candy';
|
| 31 |
+
|
| 32 |
+
const [candySearch, setCandySearch] = useState('');
|
| 33 |
+
const [candyTagFilter, setCandyTagFilter] = useState<string | null>(null);
|
| 34 |
+
const [cravingSearch, setCravingSearch] = useState('');
|
| 35 |
+
const [cravingTagFilter, setCravingTagFilter] = useState<string | null>(null);
|
| 36 |
+
const [isPostCravingOpen, setIsPostCravingOpen] = useState(false);
|
| 37 |
+
const [isPostCandyOpen, setIsPostCandyOpen] = useState(false);
|
| 38 |
+
const [userCravings, setUserCravings] = useState<Craving[]>(() => storageUtils.getUserCravings());
|
| 39 |
+
const [userCandies, setUserCandies] = useState<StoreSkill[]>(() => storageUtils.getUserCandies());
|
| 40 |
+
|
| 41 |
+
const setActiveTab = (tab: MarketplaceTab) => {
|
| 42 |
+
setSearchParams(tab === 'craving' ? { tab: 'craving' } : {});
|
| 43 |
+
};
|
| 44 |
+
|
| 45 |
+
const handleMatchCandy = (tags: string[]) => {
|
| 46 |
+
setCandyTagFilter(tags[0] ?? null);
|
| 47 |
+
setCandySearch('');
|
| 48 |
+
setActiveTab('candy');
|
| 49 |
+
};
|
| 50 |
+
|
| 51 |
+
const handleMatchCraving = (tags: string[]) => {
|
| 52 |
+
setCravingTagFilter(tags[0] ?? null);
|
| 53 |
+
setCravingSearch('');
|
| 54 |
+
setActiveTab('craving');
|
| 55 |
+
};
|
| 56 |
+
|
| 57 |
+
const handleOpenPostCraving = () => {
|
| 58 |
+
setActiveTab('craving');
|
| 59 |
+
setTimeout(() => setIsPostCravingOpen(true), 100);
|
| 60 |
+
};
|
| 61 |
+
|
| 62 |
+
const handleOpenPostCandy = () => {
|
| 63 |
+
setActiveTab('candy');
|
| 64 |
+
setTimeout(() => setIsPostCandyOpen(true), 100);
|
| 65 |
+
};
|
| 66 |
+
|
| 67 |
+
const handleSubmitCraving = (craving: Craving) => {
|
| 68 |
+
storageUtils.saveUserCraving(craving);
|
| 69 |
+
setUserCravings(storageUtils.getUserCravings());
|
| 70 |
+
toast.success(`Craving "${craving.title}" posted!`);
|
| 71 |
+
};
|
| 72 |
+
|
| 73 |
+
const handleSubmitCandy = (candy: StoreSkill) => {
|
| 74 |
+
storageUtils.saveUserCandy(candy);
|
| 75 |
+
setUserCandies(storageUtils.getUserCandies());
|
| 76 |
+
toast.success(`Candy "${candy.name}" is live!`);
|
| 77 |
+
};
|
| 78 |
+
|
| 79 |
+
return (
|
| 80 |
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
| 81 |
+
{/* Tab Switcher */}
|
| 82 |
+
<div className="flex items-center justify-center mb-8">
|
| 83 |
+
<div className="inline-flex items-center bg-secondary rounded-lg p-1 gap-1">
|
| 84 |
+
<button
|
| 85 |
+
onClick={() => setActiveTab('candy')}
|
| 86 |
+
className={cn(
|
| 87 |
+
'flex items-center gap-2 px-5 py-2.5 rounded-md text-sm font-medium transition-all duration-200',
|
| 88 |
+
activeTab === 'candy'
|
| 89 |
+
? 'bg-card text-primary shadow-sm'
|
| 90 |
+
: 'text-foreground-secondary hover:text-foreground'
|
| 91 |
+
)}
|
| 92 |
+
>
|
| 93 |
+
<Candy className="w-4 h-4" />
|
| 94 |
+
{t('nav.candy.user') || 'Find Candy'}
|
| 95 |
+
</button>
|
| 96 |
+
<button
|
| 97 |
+
onClick={() => setActiveTab('craving')}
|
| 98 |
+
className={cn(
|
| 99 |
+
'flex items-center gap-2 px-5 py-2.5 rounded-md text-sm font-medium transition-all duration-200',
|
| 100 |
+
activeTab === 'craving'
|
| 101 |
+
? 'bg-card text-primary shadow-sm'
|
| 102 |
+
: 'text-foreground-secondary hover:text-foreground'
|
| 103 |
+
)}
|
| 104 |
+
>
|
| 105 |
+
<Heart className="w-4 h-4" />
|
| 106 |
+
{t('nav.craving.user') || 'Find Craving'}
|
| 107 |
+
</button>
|
| 108 |
+
</div>
|
| 109 |
+
</div>
|
| 110 |
+
|
| 111 |
+
{/* Candy Tab */}
|
| 112 |
+
{activeTab === 'candy' && (
|
| 113 |
+
<>
|
| 114 |
+
<Categories
|
| 115 |
+
activeCategory={candyTagFilter}
|
| 116 |
+
onSelectCategory={(tag: string | null) => {
|
| 117 |
+
setCandyTagFilter(tag);
|
| 118 |
+
setCandySearch('');
|
| 119 |
+
}}
|
| 120 |
+
/>
|
| 121 |
+
<SkillsGrid
|
| 122 |
+
searchQuery={candySearch}
|
| 123 |
+
setSearchQuery={setCandySearch}
|
| 124 |
+
tagFilter={candyTagFilter}
|
| 125 |
+
setTagFilter={setCandyTagFilter}
|
| 126 |
+
cart={cart}
|
| 127 |
+
onToggleCart={onToggleCart}
|
| 128 |
+
onRunSkill={onRunSkill}
|
| 129 |
+
onMatchCraving={handleMatchCraving}
|
| 130 |
+
userCandies={userCandies}
|
| 131 |
+
onPostCandy={handleOpenPostCandy}
|
| 132 |
+
onPostCraving={handleOpenPostCraving}
|
| 133 |
+
/>
|
| 134 |
+
</>
|
| 135 |
+
)}
|
| 136 |
+
|
| 137 |
+
{/* Craving Tab */}
|
| 138 |
+
{activeTab === 'craving' && (
|
| 139 |
+
<CravingsGrid
|
| 140 |
+
searchQuery={cravingSearch}
|
| 141 |
+
setSearchQuery={setCravingSearch}
|
| 142 |
+
tagFilter={cravingTagFilter}
|
| 143 |
+
setTagFilter={setCravingTagFilter}
|
| 144 |
+
onMatchCandy={handleMatchCandy}
|
| 145 |
+
onPostCraving={handleOpenPostCraving}
|
| 146 |
+
onPostCandy={handleOpenPostCandy}
|
| 147 |
+
userCravings={userCravings}
|
| 148 |
+
/>
|
| 149 |
+
)}
|
| 150 |
+
|
| 151 |
+
<PostCravingModal
|
| 152 |
+
isOpen={isPostCravingOpen}
|
| 153 |
+
onClose={() => setIsPostCravingOpen(false)}
|
| 154 |
+
onSubmit={handleSubmitCraving}
|
| 155 |
+
/>
|
| 156 |
+
<PostCandyModal
|
| 157 |
+
isOpen={isPostCandyOpen}
|
| 158 |
+
onClose={() => setIsPostCandyOpen(false)}
|
| 159 |
+
onSubmit={handleSubmitCandy}
|
| 160 |
+
/>
|
| 161 |
+
</div>
|
| 162 |
+
);
|
| 163 |
+
}
|
|
@@ -0,0 +1,237 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useNavigate } from 'react-router-dom';
|
| 2 |
+
import { ArrowRight, Sparkles, Heart, Zap, Package, Users, Shield } from 'lucide-react';
|
| 3 |
+
import { Button } from '../components/ui/Button';
|
| 4 |
+
import { Card, CardContent } from '../components/ui/Card';
|
| 5 |
+
import { Badge } from '../components/ui/Badge';
|
| 6 |
+
import { SKILLS_DATA, REGISTRY_STATS } from '../data/skillsData';
|
| 7 |
+
import { useLanguage } from '../contexts/LanguageContext';
|
| 8 |
+
|
| 9 |
+
const FEATURES = [
|
| 10 |
+
{
|
| 11 |
+
icon: Package,
|
| 12 |
+
title: 'Publish Skills',
|
| 13 |
+
titleKey: 'landing.feature.publish',
|
| 14 |
+
description: 'Share your AI agent skills with the community. Upload, version, and manage skill packages.',
|
| 15 |
+
descKey: 'landing.feature.publish.desc',
|
| 16 |
+
color: 'text-info',
|
| 17 |
+
bg: 'bg-info/10',
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
icon: Heart,
|
| 21 |
+
title: 'Post Cravings',
|
| 22 |
+
titleKey: 'landing.feature.cravings',
|
| 23 |
+
description: 'Request the skills you need. Post cravings and let skilled agents find you.',
|
| 24 |
+
descKey: 'landing.feature.cravings.desc',
|
| 25 |
+
color: 'text-error',
|
| 26 |
+
bg: 'bg-error/10',
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
icon: Zap,
|
| 30 |
+
title: 'Sweet Match',
|
| 31 |
+
titleKey: 'landing.feature.match',
|
| 32 |
+
description: 'Intelligent matching connects candies with cravings. Find the perfect skill instantly.',
|
| 33 |
+
descKey: 'landing.feature.match.desc',
|
| 34 |
+
color: 'text-warning',
|
| 35 |
+
bg: 'bg-warning/10',
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
icon: Sparkles,
|
| 39 |
+
title: 'AI-Powered Creation',
|
| 40 |
+
titleKey: 'landing.feature.create',
|
| 41 |
+
description: 'Create skills from files, GitHub repos, or manually. AI analyzes and generates configurations.',
|
| 42 |
+
descKey: 'landing.feature.create.desc',
|
| 43 |
+
color: 'text-accent',
|
| 44 |
+
bg: 'bg-accent/10',
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
icon: Users,
|
| 48 |
+
title: 'Community Driven',
|
| 49 |
+
titleKey: 'landing.feature.community',
|
| 50 |
+
description: 'Star, rate, and review skills. Build on the community best practices.',
|
| 51 |
+
descKey: 'landing.feature.community.desc',
|
| 52 |
+
color: 'text-success',
|
| 53 |
+
bg: 'bg-success/10',
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
icon: Shield,
|
| 57 |
+
title: 'Enterprise Ready',
|
| 58 |
+
titleKey: 'landing.feature.enterprise',
|
| 59 |
+
description: 'Self-hosted deployment, RBAC, audit logs, and namespace governance.',
|
| 60 |
+
descKey: 'landing.feature.enterprise.desc',
|
| 61 |
+
color: 'text-primary',
|
| 62 |
+
bg: 'bg-primary/10',
|
| 63 |
+
},
|
| 64 |
+
];
|
| 65 |
+
|
| 66 |
+
export function LandingPage() {
|
| 67 |
+
const navigate = useNavigate();
|
| 68 |
+
const { t } = useLanguage();
|
| 69 |
+
|
| 70 |
+
const popularSkills = SKILLS_DATA
|
| 71 |
+
.sort((a, b) => (b.popularity ?? 0) - (a.popularity ?? 0))
|
| 72 |
+
.slice(0, 8);
|
| 73 |
+
|
| 74 |
+
return (
|
| 75 |
+
<div>
|
| 76 |
+
{/* Hero */}
|
| 77 |
+
<section className="relative overflow-hidden">
|
| 78 |
+
<div className="absolute inset-0 candy-gradient opacity-5" />
|
| 79 |
+
<div className="absolute top-20 left-10 w-72 h-72 bg-primary/10 rounded-full blur-3xl" />
|
| 80 |
+
<div className="absolute bottom-10 right-10 w-96 h-96 bg-accent/10 rounded-full blur-3xl" />
|
| 81 |
+
|
| 82 |
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pt-20 pb-24 relative">
|
| 83 |
+
<div className="text-center max-w-4xl mx-auto">
|
| 84 |
+
<Badge variant="candy" size="lg" className="mb-6">
|
| 85 |
+
{REGISTRY_STATS.totalSkills.toLocaleString()}+ Skills Available
|
| 86 |
+
</Badge>
|
| 87 |
+
|
| 88 |
+
<h1 className="text-4xl sm:text-5xl lg:text-6xl font-bold font-candy leading-tight mb-6">
|
| 89 |
+
<span className="candy-gradient-text">The Sweetest</span>
|
| 90 |
+
<br />
|
| 91 |
+
AI Skills Marketplace
|
| 92 |
+
</h1>
|
| 93 |
+
|
| 94 |
+
<p className="text-lg sm:text-xl text-foreground-secondary max-w-2xl mx-auto mb-10 leading-relaxed">
|
| 95 |
+
{t('hero.subtitle')}
|
| 96 |
+
</p>
|
| 97 |
+
|
| 98 |
+
<div className="flex flex-col sm:flex-row items-center justify-center gap-4">
|
| 99 |
+
<Button
|
| 100 |
+
variant="candy"
|
| 101 |
+
size="lg"
|
| 102 |
+
onClick={() => navigate('/discover')}
|
| 103 |
+
className="text-base px-8"
|
| 104 |
+
>
|
| 105 |
+
Browse Candies
|
| 106 |
+
<ArrowRight className="w-5 h-5" />
|
| 107 |
+
</Button>
|
| 108 |
+
<Button
|
| 109 |
+
variant="outline"
|
| 110 |
+
size="lg"
|
| 111 |
+
onClick={() => navigate('/discover?tab=craving')}
|
| 112 |
+
className="text-base px-8"
|
| 113 |
+
>
|
| 114 |
+
Post a Craving
|
| 115 |
+
<Heart className="w-5 h-5" />
|
| 116 |
+
</Button>
|
| 117 |
+
</div>
|
| 118 |
+
</div>
|
| 119 |
+
|
| 120 |
+
{/* Stats */}
|
| 121 |
+
<div className="mt-20 grid grid-cols-1 sm:grid-cols-3 gap-6 max-w-3xl mx-auto">
|
| 122 |
+
{[
|
| 123 |
+
{ value: `${(REGISTRY_STATS.totalSkills / 1000).toFixed(0)}K+`, label: 'Skills Indexed' },
|
| 124 |
+
{ value: `${(REGISTRY_STATS.totalInstalls / 1000000).toFixed(1)}M+`, label: 'Total Installs' },
|
| 125 |
+
{ value: `${(REGISTRY_STATS.totalRepos / 1000).toFixed(1)}K+`, label: 'Repositories' },
|
| 126 |
+
].map((stat) => (
|
| 127 |
+
<Card key={stat.label} variant="glass" className="text-center py-6 px-4">
|
| 128 |
+
<CardContent className="p-0">
|
| 129 |
+
<div className="text-3xl font-bold candy-gradient-text font-candy">{stat.value}</div>
|
| 130 |
+
<div className="text-sm text-foreground-secondary mt-1">{stat.label}</div>
|
| 131 |
+
</CardContent>
|
| 132 |
+
</Card>
|
| 133 |
+
))}
|
| 134 |
+
</div>
|
| 135 |
+
</div>
|
| 136 |
+
</section>
|
| 137 |
+
|
| 138 |
+
{/* Features */}
|
| 139 |
+
<section className="py-20 relative">
|
| 140 |
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
| 141 |
+
<div className="text-center mb-14">
|
| 142 |
+
<h2 className="text-3xl sm:text-4xl font-bold font-candy mb-4">
|
| 143 |
+
Everything You Need
|
| 144 |
+
</h2>
|
| 145 |
+
<p className="text-lg text-foreground-secondary max-w-2xl mx-auto">
|
| 146 |
+
A two-sided marketplace connecting AI skill makers with those who need them.
|
| 147 |
+
</p>
|
| 148 |
+
</div>
|
| 149 |
+
|
| 150 |
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
| 151 |
+
{FEATURES.map((feature) => {
|
| 152 |
+
const Icon = feature.icon;
|
| 153 |
+
return (
|
| 154 |
+
<Card key={feature.title} variant="interactive" className="p-6">
|
| 155 |
+
<CardContent className="p-0">
|
| 156 |
+
<div className={`w-12 h-12 rounded-xl ${feature.bg} flex items-center justify-center mb-4`}>
|
| 157 |
+
<Icon className={`w-6 h-6 ${feature.color}`} />
|
| 158 |
+
</div>
|
| 159 |
+
<h3 className="text-lg font-semibold mb-2">{feature.title}</h3>
|
| 160 |
+
<p className="text-sm text-foreground-secondary leading-relaxed">
|
| 161 |
+
{feature.description}
|
| 162 |
+
</p>
|
| 163 |
+
</CardContent>
|
| 164 |
+
</Card>
|
| 165 |
+
);
|
| 166 |
+
})}
|
| 167 |
+
</div>
|
| 168 |
+
</div>
|
| 169 |
+
</section>
|
| 170 |
+
|
| 171 |
+
{/* Popular Skills */}
|
| 172 |
+
<section className="py-20 bg-backgroundSecondary/50 relative">
|
| 173 |
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
| 174 |
+
<div className="flex items-center justify-between mb-10">
|
| 175 |
+
<div>
|
| 176 |
+
<h2 className="text-3xl font-bold font-candy mb-2">Popular Candies</h2>
|
| 177 |
+
<p className="text-foreground-secondary">Most installed skills across the ecosystem</p>
|
| 178 |
+
</div>
|
| 179 |
+
<Button variant="outline" onClick={() => navigate('/discover')}>
|
| 180 |
+
View All <ArrowRight className="w-4 h-4" />
|
| 181 |
+
</Button>
|
| 182 |
+
</div>
|
| 183 |
+
|
| 184 |
+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
| 185 |
+
{popularSkills.map((skill) => (
|
| 186 |
+
<Card
|
| 187 |
+
key={skill.id}
|
| 188 |
+
variant="interactive"
|
| 189 |
+
className="p-5"
|
| 190 |
+
onClick={() => navigate(`/candy/${skill.id}`)}
|
| 191 |
+
>
|
| 192 |
+
<CardContent className="p-0">
|
| 193 |
+
<div className="flex items-start gap-3 mb-3">
|
| 194 |
+
<span className="text-2xl">{skill.icon}</span>
|
| 195 |
+
<div className="flex-1 min-w-0">
|
| 196 |
+
<h3 className="font-semibold text-sm truncate">{skill.name}</h3>
|
| 197 |
+
<Badge variant="secondary" size="sm" className="mt-1">
|
| 198 |
+
{skill.category}
|
| 199 |
+
</Badge>
|
| 200 |
+
</div>
|
| 201 |
+
</div>
|
| 202 |
+
<p className="text-xs text-foreground-secondary line-clamp-2 mb-3">
|
| 203 |
+
{skill.description}
|
| 204 |
+
</p>
|
| 205 |
+
<div className="flex items-center gap-3 text-xs text-foreground-tertiary">
|
| 206 |
+
<span>{(skill.popularity ?? 0).toLocaleString()} installs</span>
|
| 207 |
+
</div>
|
| 208 |
+
</CardContent>
|
| 209 |
+
</Card>
|
| 210 |
+
))}
|
| 211 |
+
</div>
|
| 212 |
+
</div>
|
| 213 |
+
</section>
|
| 214 |
+
|
| 215 |
+
{/* CTA */}
|
| 216 |
+
<section className="py-24 relative">
|
| 217 |
+
<div className="absolute inset-0 candy-gradient opacity-5" />
|
| 218 |
+
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 text-center relative">
|
| 219 |
+
<h2 className="text-3xl sm:text-4xl font-bold font-candy mb-4">
|
| 220 |
+
Ready to Find Your Sweet Spot?
|
| 221 |
+
</h2>
|
| 222 |
+
<p className="text-lg text-foreground-secondary mb-8 max-w-2xl mx-auto">
|
| 223 |
+
Join the marketplace where AI skills meet real demands. Whether you're a candy maker or have a craving, we've got you covered.
|
| 224 |
+
</p>
|
| 225 |
+
<div className="flex flex-col sm:flex-row items-center justify-center gap-4">
|
| 226 |
+
<Button variant="candy" size="lg" onClick={() => navigate('/discover')} className="px-8">
|
| 227 |
+
Start Browsing <ArrowRight className="w-5 h-5" />
|
| 228 |
+
</Button>
|
| 229 |
+
<Button variant="outline" size="lg" onClick={() => navigate('/skills/create')} className="px-8">
|
| 230 |
+
Create Your First Skill
|
| 231 |
+
</Button>
|
| 232 |
+
</div>
|
| 233 |
+
</div>
|
| 234 |
+
</section>
|
| 235 |
+
</div>
|
| 236 |
+
);
|
| 237 |
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState } from 'react';
|
| 2 |
+
import { Check, Globe } from 'lucide-react';
|
| 3 |
+
import { Card, CardContent } from '../components/ui/Card';
|
| 4 |
+
import { Button } from '../components/ui/Button';
|
| 5 |
+
import { useLanguage } from '../contexts/LanguageContext';
|
| 6 |
+
import { cn } from '../utils/cn';
|
| 7 |
+
|
| 8 |
+
const themes = [
|
| 9 |
+
{ id: 'indigo', name: 'Indigo', color: '#4F46E5', light: '#818CF8', desc: 'Professional & Modern' },
|
| 10 |
+
{ id: 'blue', name: 'Ocean', color: '#3B82F6', light: '#60A5FA', desc: 'Calm & Trustworthy' },
|
| 11 |
+
{ id: 'emerald', name: 'Emerald', color: '#10B981', light: '#34D399', desc: 'Fresh & Natural' },
|
| 12 |
+
{ id: 'amber', name: 'Sunset', color: '#F59E0B', light: '#FBBF24', desc: 'Warm & Energetic' },
|
| 13 |
+
{ id: 'rose', name: 'Rose', color: '#F43F5E', light: '#FB7185', desc: 'Bold & Vibrant' },
|
| 14 |
+
{ id: 'violet', name: 'Purple', color: '#8B5CF6', light: '#A78BFA', desc: 'Creative & Elegant' },
|
| 15 |
+
];
|
| 16 |
+
|
| 17 |
+
export function SettingsPage() {
|
| 18 |
+
const { language, setLanguage } = useLanguage();
|
| 19 |
+
const [isDarkMode, setIsDarkMode] = useState(() =>
|
| 20 |
+
document.documentElement.classList.contains('dark')
|
| 21 |
+
);
|
| 22 |
+
const [currentTheme, setCurrentTheme] = useState(() =>
|
| 23 |
+
localStorage.getItem('colorTheme') || 'indigo'
|
| 24 |
+
);
|
| 25 |
+
|
| 26 |
+
const toggleDarkMode = () => {
|
| 27 |
+
const newMode = !isDarkMode;
|
| 28 |
+
setIsDarkMode(newMode);
|
| 29 |
+
if (newMode) {
|
| 30 |
+
document.documentElement.classList.add('dark');
|
| 31 |
+
localStorage.setItem('theme', 'dark');
|
| 32 |
+
} else {
|
| 33 |
+
document.documentElement.classList.remove('dark');
|
| 34 |
+
localStorage.setItem('theme', 'light');
|
| 35 |
+
}
|
| 36 |
+
// Trigger theme color update
|
| 37 |
+
window.dispatchEvent(new CustomEvent('theme-change'));
|
| 38 |
+
};
|
| 39 |
+
|
| 40 |
+
const selectTheme = (themeId: string) => {
|
| 41 |
+
setCurrentTheme(themeId);
|
| 42 |
+
localStorage.setItem('colorTheme', themeId);
|
| 43 |
+
window.dispatchEvent(new CustomEvent('theme-change'));
|
| 44 |
+
// Directly apply
|
| 45 |
+
const theme = themes.find(t => t.id === themeId);
|
| 46 |
+
if (!theme) return;
|
| 47 |
+
const THEME_COLORS: Record<string, Record<string, string>> = {
|
| 48 |
+
indigo: { '--color-primary': '#4F46E5', '--color-primary-hover': '#4338CA', '--color-primary-active': '#3730A3' },
|
| 49 |
+
blue: { '--color-primary': '#3B82F6', '--color-primary-hover': '#2563EB', '--color-primary-active': '#1D4ED8' },
|
| 50 |
+
emerald: { '--color-primary': '#10B981', '--color-primary-hover': '#059669', '--color-primary-active': '#047857' },
|
| 51 |
+
amber: { '--color-primary': '#F59E0B', '--color-primary-hover': '#D97706', '--color-primary-active': '#B45309' },
|
| 52 |
+
rose: { '--color-primary': '#F43F5E', '--color-primary-hover': '#E11D48', '--color-primary-active': '#BE123C' },
|
| 53 |
+
violet: { '--color-primary': '#8B5CF6', '--color-primary-hover': '#7C3AED', '--color-primary-active': '#6D28D9' },
|
| 54 |
+
};
|
| 55 |
+
const colors = THEME_COLORS[themeId];
|
| 56 |
+
if (colors) {
|
| 57 |
+
Object.entries(colors).forEach(([key, value]) => {
|
| 58 |
+
document.documentElement.style.setProperty(key, value);
|
| 59 |
+
});
|
| 60 |
+
}
|
| 61 |
+
};
|
| 62 |
+
|
| 63 |
+
return (
|
| 64 |
+
<div className="max-w-3xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
| 65 |
+
<h1 className="text-2xl font-bold font-candy mb-8">Settings</h1>
|
| 66 |
+
|
| 67 |
+
{/* Appearance */}
|
| 68 |
+
<Card className="mb-6">
|
| 69 |
+
<CardContent className="pt-6">
|
| 70 |
+
<h2 className="text-lg font-semibold mb-4">Appearance</h2>
|
| 71 |
+
|
| 72 |
+
{/* Dark Mode */}
|
| 73 |
+
<div className="flex items-center justify-between py-3 border-b border-border">
|
| 74 |
+
<div>
|
| 75 |
+
<p className="font-medium text-sm">Dark Mode</p>
|
| 76 |
+
<p className="text-xs text-foreground-secondary">Switch between light and dark themes</p>
|
| 77 |
+
</div>
|
| 78 |
+
<button
|
| 79 |
+
onClick={toggleDarkMode}
|
| 80 |
+
className={cn(
|
| 81 |
+
'relative inline-flex h-6 w-11 items-center rounded-full transition-colors',
|
| 82 |
+
isDarkMode ? 'bg-primary' : 'bg-foreground-muted'
|
| 83 |
+
)}
|
| 84 |
+
>
|
| 85 |
+
<span
|
| 86 |
+
className={cn(
|
| 87 |
+
'inline-block h-4 w-4 rounded-full bg-white transition-transform',
|
| 88 |
+
isDarkMode ? 'translate-x-6' : 'translate-x-1'
|
| 89 |
+
)}
|
| 90 |
+
/>
|
| 91 |
+
</button>
|
| 92 |
+
</div>
|
| 93 |
+
|
| 94 |
+
{/* Theme Color */}
|
| 95 |
+
<div className="py-4">
|
| 96 |
+
<p className="font-medium text-sm mb-3">Theme Color</p>
|
| 97 |
+
<div className="grid grid-cols-2 sm:grid-cols-3 gap-3">
|
| 98 |
+
{themes.map((theme) => (
|
| 99 |
+
<button
|
| 100 |
+
key={theme.id}
|
| 101 |
+
onClick={() => selectTheme(theme.id)}
|
| 102 |
+
className={cn(
|
| 103 |
+
'flex items-center gap-3 p-3 rounded-lg border transition-all',
|
| 104 |
+
currentTheme === theme.id
|
| 105 |
+
? 'border-primary bg-primary/5 ring-2 ring-primary/20'
|
| 106 |
+
: 'border-border hover:border-border-hover'
|
| 107 |
+
)}
|
| 108 |
+
>
|
| 109 |
+
<div
|
| 110 |
+
className="w-8 h-8 rounded-full border-2 border-white shadow-sm flex items-center justify-center"
|
| 111 |
+
style={{ backgroundColor: isDarkMode ? theme.light : theme.color }}
|
| 112 |
+
>
|
| 113 |
+
{currentTheme === theme.id && <Check className="w-4 h-4 text-white" />}
|
| 114 |
+
</div>
|
| 115 |
+
<div className="text-left">
|
| 116 |
+
<p className="text-sm font-medium">{theme.name}</p>
|
| 117 |
+
<p className="text-xs text-foreground-tertiary">{theme.desc}</p>
|
| 118 |
+
</div>
|
| 119 |
+
</button>
|
| 120 |
+
))}
|
| 121 |
+
</div>
|
| 122 |
+
</div>
|
| 123 |
+
</CardContent>
|
| 124 |
+
</Card>
|
| 125 |
+
|
| 126 |
+
{/* Language */}
|
| 127 |
+
<Card className="mb-6">
|
| 128 |
+
<CardContent className="pt-6">
|
| 129 |
+
<h2 className="text-lg font-semibold mb-4">Language</h2>
|
| 130 |
+
<div className="flex gap-3">
|
| 131 |
+
<Button
|
| 132 |
+
variant={language === 'en' ? 'default' : 'outline'}
|
| 133 |
+
onClick={() => setLanguage('en')}
|
| 134 |
+
className="flex items-center gap-2"
|
| 135 |
+
>
|
| 136 |
+
<Globe className="w-4 h-4" />
|
| 137 |
+
English
|
| 138 |
+
</Button>
|
| 139 |
+
<Button
|
| 140 |
+
variant={language === 'zh' ? 'default' : 'outline'}
|
| 141 |
+
onClick={() => setLanguage('zh')}
|
| 142 |
+
className="flex items-center gap-2"
|
| 143 |
+
>
|
| 144 |
+
<Globe className="w-4 h-4" />
|
| 145 |
+
中文
|
| 146 |
+
</Button>
|
| 147 |
+
</div>
|
| 148 |
+
</CardContent>
|
| 149 |
+
</Card>
|
| 150 |
+
</div>
|
| 151 |
+
);
|
| 152 |
+
}
|
|
@@ -0,0 +1,325 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useParams, useNavigate } from 'react-router-dom';
|
| 2 |
+
import { ArrowLeft, Star, Download, Play, Copy, Check, ExternalLink, Tag, MessageSquare } from 'lucide-react';
|
| 3 |
+
import { useState, useMemo } from 'react';
|
| 4 |
+
import { Button } from '../components/ui/Button';
|
| 5 |
+
import { Card, CardContent } from '../components/ui/Card';
|
| 6 |
+
import { Badge } from '../components/ui/Badge';
|
| 7 |
+
import { StarRating } from '../components/ui/StarRating';
|
| 8 |
+
import { SKILLS_DATA } from '../data/skillsData';
|
| 9 |
+
import type { Skill as StoreSkill } from '../data/skillsData';
|
| 10 |
+
import { useStars } from '../hooks/api/useStars';
|
| 11 |
+
import { useRatings } from '../hooks/api/useRatings';
|
| 12 |
+
import { useDownloads } from '../hooks/api/useDownloads';
|
| 13 |
+
import { toast } from 'sonner';
|
| 14 |
+
|
| 15 |
+
interface SkillDetailPageProps {
|
| 16 |
+
cart: Set<string>;
|
| 17 |
+
onToggleCart: (id: string) => void;
|
| 18 |
+
onRunSkill: (skill: StoreSkill) => void;
|
| 19 |
+
userId?: string;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
export function SkillDetailPage({ cart, onToggleCart, onRunSkill, userId }: SkillDetailPageProps) {
|
| 23 |
+
const { id } = useParams<{ id: string }>();
|
| 24 |
+
const navigate = useNavigate();
|
| 25 |
+
const [copied, setCopied] = useState(false);
|
| 26 |
+
const [activeTab, setActiveTab] = useState<'about' | 'ratings'>('about');
|
| 27 |
+
|
| 28 |
+
const skill = useMemo(() => SKILLS_DATA.find((s) => s.id === id), [id]);
|
| 29 |
+
|
| 30 |
+
// Social hooks
|
| 31 |
+
const { isStarred, starCount, toggleStar } = useStars(id || '', userId);
|
| 32 |
+
const { ratings, avgRating, rate } = useRatings(id || '');
|
| 33 |
+
const { trackDownload } = useDownloads();
|
| 34 |
+
|
| 35 |
+
if (!skill) {
|
| 36 |
+
return (
|
| 37 |
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-20 text-center">
|
| 38 |
+
<h1 className="text-2xl font-bold mb-4">Skill not found</h1>
|
| 39 |
+
<Button onClick={() => navigate('/discover')}>Back to Discover</Button>
|
| 40 |
+
</div>
|
| 41 |
+
);
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
const handleCopy = () => {
|
| 45 |
+
navigator.clipboard.writeText(skill.installCommand);
|
| 46 |
+
setCopied(true);
|
| 47 |
+
toast.success('Install command copied!');
|
| 48 |
+
trackDownload(skill.id);
|
| 49 |
+
setTimeout(() => setCopied(false), 2000);
|
| 50 |
+
};
|
| 51 |
+
|
| 52 |
+
const handleRate = async (score: number) => {
|
| 53 |
+
if (!userId) {
|
| 54 |
+
toast.error('Sign in to rate skills');
|
| 55 |
+
return;
|
| 56 |
+
}
|
| 57 |
+
try {
|
| 58 |
+
await rate(userId, score);
|
| 59 |
+
toast.success('Rating submitted!');
|
| 60 |
+
} catch {
|
| 61 |
+
toast.error('Failed to submit rating');
|
| 62 |
+
}
|
| 63 |
+
};
|
| 64 |
+
|
| 65 |
+
const inCart = cart.has(skill.id);
|
| 66 |
+
const relatedSkills = SKILLS_DATA
|
| 67 |
+
.filter((s) => s.category === skill.category && s.id !== skill.id)
|
| 68 |
+
.slice(0, 4);
|
| 69 |
+
|
| 70 |
+
return (
|
| 71 |
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
| 72 |
+
{/* Back */}
|
| 73 |
+
<button
|
| 74 |
+
onClick={() => navigate(-1)}
|
| 75 |
+
className="flex items-center gap-2 text-sm text-foreground-secondary hover:text-foreground mb-6 transition-colors"
|
| 76 |
+
>
|
| 77 |
+
<ArrowLeft className="w-4 h-4" />
|
| 78 |
+
Back
|
| 79 |
+
</button>
|
| 80 |
+
|
| 81 |
+
<div className="grid grid-cols-1 lg:grid-cols-3 gap-8">
|
| 82 |
+
{/* Main Content */}
|
| 83 |
+
<div className="lg:col-span-2 space-y-6">
|
| 84 |
+
{/* Header */}
|
| 85 |
+
<div className="flex items-start gap-4">
|
| 86 |
+
<span className="text-4xl">{skill.icon}</span>
|
| 87 |
+
<div className="flex-1">
|
| 88 |
+
<h1 className="text-2xl sm:text-3xl font-bold font-candy">{skill.name}</h1>
|
| 89 |
+
<div className="flex items-center gap-3 mt-2 flex-wrap">
|
| 90 |
+
<Badge>{skill.category}</Badge>
|
| 91 |
+
<StarRating value={avgRating} readonly size="sm" showValue count={ratings.length} />
|
| 92 |
+
<span className="text-xs text-foreground-tertiary flex items-center gap-1">
|
| 93 |
+
<Star className="w-3 h-3" /> {starCount}
|
| 94 |
+
</span>
|
| 95 |
+
<span className="text-xs text-foreground-tertiary flex items-center gap-1">
|
| 96 |
+
<Download className="w-3 h-3" /> {(skill.popularity ?? 0).toLocaleString()}
|
| 97 |
+
</span>
|
| 98 |
+
</div>
|
| 99 |
+
</div>
|
| 100 |
+
</div>
|
| 101 |
+
|
| 102 |
+
{/* Tabs */}
|
| 103 |
+
<div className="flex items-center gap-1 border-b border-border">
|
| 104 |
+
<button
|
| 105 |
+
onClick={() => setActiveTab('about')}
|
| 106 |
+
className={`px-4 py-2.5 text-sm font-medium border-b-2 transition-colors ${
|
| 107 |
+
activeTab === 'about'
|
| 108 |
+
? 'border-primary text-primary'
|
| 109 |
+
: 'border-transparent text-foreground-secondary hover:text-foreground'
|
| 110 |
+
}`}
|
| 111 |
+
>
|
| 112 |
+
About
|
| 113 |
+
</button>
|
| 114 |
+
<button
|
| 115 |
+
onClick={() => setActiveTab('ratings')}
|
| 116 |
+
className={`px-4 py-2.5 text-sm font-medium border-b-2 transition-colors flex items-center gap-1.5 ${
|
| 117 |
+
activeTab === 'ratings'
|
| 118 |
+
? 'border-primary text-primary'
|
| 119 |
+
: 'border-transparent text-foreground-secondary hover:text-foreground'
|
| 120 |
+
}`}
|
| 121 |
+
>
|
| 122 |
+
<MessageSquare className="w-4 h-4" />
|
| 123 |
+
Reviews ({ratings.length})
|
| 124 |
+
</button>
|
| 125 |
+
</div>
|
| 126 |
+
|
| 127 |
+
{activeTab === 'about' && (
|
| 128 |
+
<>
|
| 129 |
+
{/* Description */}
|
| 130 |
+
<Card>
|
| 131 |
+
<CardContent className="pt-6">
|
| 132 |
+
<h2 className="text-lg font-semibold mb-3">About</h2>
|
| 133 |
+
<p className="text-foreground-secondary leading-relaxed">{skill.description}</p>
|
| 134 |
+
</CardContent>
|
| 135 |
+
</Card>
|
| 136 |
+
|
| 137 |
+
{/* Install */}
|
| 138 |
+
<Card>
|
| 139 |
+
<CardContent className="pt-6">
|
| 140 |
+
<h2 className="text-lg font-semibold mb-3">Quick Install</h2>
|
| 141 |
+
<div className="bg-backgroundSecondary rounded-lg p-4 flex items-center justify-between gap-3 font-mono text-sm">
|
| 142 |
+
<code className="text-foreground truncate">{skill.installCommand}</code>
|
| 143 |
+
<button
|
| 144 |
+
onClick={handleCopy}
|
| 145 |
+
className="flex-shrink-0 p-2 hover:bg-secondary rounded transition-colors"
|
| 146 |
+
>
|
| 147 |
+
{copied ? <Check className="w-4 h-4 text-success" /> : <Copy className="w-4 h-4 text-foreground-secondary" />}
|
| 148 |
+
</button>
|
| 149 |
+
</div>
|
| 150 |
+
</CardContent>
|
| 151 |
+
</Card>
|
| 152 |
+
|
| 153 |
+
{/* Config */}
|
| 154 |
+
{skill.config && Object.keys(skill.config).length > 0 && (
|
| 155 |
+
<Card>
|
| 156 |
+
<CardContent className="pt-6">
|
| 157 |
+
<h2 className="text-lg font-semibold mb-3">Claude Desktop Config</h2>
|
| 158 |
+
<pre className="bg-backgroundSecondary rounded-lg p-4 text-xs overflow-x-auto font-mono">
|
| 159 |
+
{JSON.stringify(skill.config, null, 2)}
|
| 160 |
+
</pre>
|
| 161 |
+
</CardContent>
|
| 162 |
+
</Card>
|
| 163 |
+
)}
|
| 164 |
+
|
| 165 |
+
{/* Related */}
|
| 166 |
+
{relatedSkills.length > 0 && (
|
| 167 |
+
<div>
|
| 168 |
+
<h2 className="text-lg font-semibold mb-4">Related Skills</h2>
|
| 169 |
+
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
| 170 |
+
{relatedSkills.map((related) => (
|
| 171 |
+
<Card
|
| 172 |
+
key={related.id}
|
| 173 |
+
variant="interactive"
|
| 174 |
+
className="p-4"
|
| 175 |
+
onClick={() => navigate(`/candy/${related.id}`)}
|
| 176 |
+
>
|
| 177 |
+
<CardContent className="p-0 flex items-start gap-3">
|
| 178 |
+
<span className="text-xl">{related.icon}</span>
|
| 179 |
+
<div className="flex-1 min-w-0">
|
| 180 |
+
<h3 className="font-medium text-sm truncate">{related.name}</h3>
|
| 181 |
+
<p className="text-xs text-foreground-secondary line-clamp-2 mt-1">{related.description}</p>
|
| 182 |
+
</div>
|
| 183 |
+
</CardContent>
|
| 184 |
+
</Card>
|
| 185 |
+
))}
|
| 186 |
+
</div>
|
| 187 |
+
</div>
|
| 188 |
+
)}
|
| 189 |
+
</>
|
| 190 |
+
)}
|
| 191 |
+
|
| 192 |
+
{activeTab === 'ratings' && (
|
| 193 |
+
<div className="space-y-6">
|
| 194 |
+
{/* Rate this skill */}
|
| 195 |
+
<Card>
|
| 196 |
+
<CardContent className="pt-6">
|
| 197 |
+
<h2 className="text-lg font-semibold mb-3">Rate this Skill</h2>
|
| 198 |
+
<StarRating value={0} onChange={handleRate} size="lg" />
|
| 199 |
+
</CardContent>
|
| 200 |
+
</Card>
|
| 201 |
+
|
| 202 |
+
{/* Ratings list */}
|
| 203 |
+
{ratings.length === 0 ? (
|
| 204 |
+
<div className="text-center py-12 text-foreground-secondary">
|
| 205 |
+
<MessageSquare className="w-10 h-10 mx-auto mb-3 text-foreground-muted" />
|
| 206 |
+
<p>No reviews yet. Be the first to rate this skill!</p>
|
| 207 |
+
</div>
|
| 208 |
+
) : (
|
| 209 |
+
<div className="space-y-4">
|
| 210 |
+
{ratings.map((r) => (
|
| 211 |
+
<Card key={r.id}>
|
| 212 |
+
<CardContent className="pt-4 pb-4">
|
| 213 |
+
<div className="flex items-center gap-3 mb-2">
|
| 214 |
+
<StarRating value={r.score} readonly size="sm" />
|
| 215 |
+
<span className="text-xs text-foreground-tertiary">
|
| 216 |
+
{new Date(r.created_at).toLocaleDateString()}
|
| 217 |
+
</span>
|
| 218 |
+
</div>
|
| 219 |
+
{r.comment && (
|
| 220 |
+
<p className="text-sm text-foreground-secondary">{r.comment}</p>
|
| 221 |
+
)}
|
| 222 |
+
</CardContent>
|
| 223 |
+
</Card>
|
| 224 |
+
))}
|
| 225 |
+
</div>
|
| 226 |
+
)}
|
| 227 |
+
</div>
|
| 228 |
+
)}
|
| 229 |
+
</div>
|
| 230 |
+
|
| 231 |
+
{/* Sidebar */}
|
| 232 |
+
<div className="space-y-4">
|
| 233 |
+
{/* Actions */}
|
| 234 |
+
<Card>
|
| 235 |
+
<CardContent className="pt-6 space-y-3">
|
| 236 |
+
<Button className="w-full" onClick={() => onRunSkill(skill)}>
|
| 237 |
+
<Play className="w-4 h-4" />
|
| 238 |
+
Run Skill
|
| 239 |
+
</Button>
|
| 240 |
+
<Button
|
| 241 |
+
variant={inCart ? 'secondary' : 'outline'}
|
| 242 |
+
className="w-full"
|
| 243 |
+
onClick={() => onToggleCart(skill.id)}
|
| 244 |
+
>
|
| 245 |
+
<Download className="w-4 h-4" />
|
| 246 |
+
{inCart ? 'Remove from Bag' : 'Add to Bag'}
|
| 247 |
+
</Button>
|
| 248 |
+
<Button
|
| 249 |
+
variant="ghost"
|
| 250 |
+
className="w-full"
|
| 251 |
+
onClick={toggleStar}
|
| 252 |
+
>
|
| 253 |
+
<Star className={`w-4 h-4 ${isStarred ? 'fill-warning text-warning' : ''}`} />
|
| 254 |
+
{isStarred ? 'Starred' : 'Star'} ({starCount})
|
| 255 |
+
</Button>
|
| 256 |
+
</CardContent>
|
| 257 |
+
</Card>
|
| 258 |
+
|
| 259 |
+
{/* Info */}
|
| 260 |
+
<Card>
|
| 261 |
+
<CardContent className="pt-6 space-y-4">
|
| 262 |
+
<h3 className="text-sm font-semibold text-foreground-secondary uppercase tracking-wider">Details</h3>
|
| 263 |
+
|
| 264 |
+
<div className="space-y-3 text-sm">
|
| 265 |
+
<div className="flex justify-between">
|
| 266 |
+
<span className="text-foreground-secondary">Category</span>
|
| 267 |
+
<Badge variant="secondary" size="sm">{skill.category}</Badge>
|
| 268 |
+
</div>
|
| 269 |
+
<div className="flex justify-between">
|
| 270 |
+
<span className="text-foreground-secondary">Rating</span>
|
| 271 |
+
<StarRating value={avgRating} readonly size="sm" showValue />
|
| 272 |
+
</div>
|
| 273 |
+
<div className="flex justify-between">
|
| 274 |
+
<span className="text-foreground-secondary">Stars</span>
|
| 275 |
+
<span className="font-medium">{starCount}</span>
|
| 276 |
+
</div>
|
| 277 |
+
<div className="flex justify-between">
|
| 278 |
+
<span className="text-foreground-secondary">Installs</span>
|
| 279 |
+
<span className="font-medium">{(skill.popularity ?? 0).toLocaleString()}</span>
|
| 280 |
+
</div>
|
| 281 |
+
{skill.repo && (
|
| 282 |
+
<a
|
| 283 |
+
href={`https://github.com/${skill.repo}`}
|
| 284 |
+
target="_blank"
|
| 285 |
+
rel="noopener noreferrer"
|
| 286 |
+
className="flex items-center gap-2 text-primary hover:underline"
|
| 287 |
+
>
|
| 288 |
+
<ExternalLink className="w-3.5 h-3.5" />
|
| 289 |
+
View Source
|
| 290 |
+
</a>
|
| 291 |
+
)}
|
| 292 |
+
{skill.skillMdUrl && (
|
| 293 |
+
<a
|
| 294 |
+
href={skill.skillMdUrl}
|
| 295 |
+
target="_blank"
|
| 296 |
+
rel="noopener noreferrer"
|
| 297 |
+
className="flex items-center gap-2 text-primary hover:underline"
|
| 298 |
+
>
|
| 299 |
+
<ExternalLink className="w-3.5 h-3.5" />
|
| 300 |
+
SKILL.md Documentation
|
| 301 |
+
</a>
|
| 302 |
+
)}
|
| 303 |
+
</div>
|
| 304 |
+
|
| 305 |
+
{/* Tags */}
|
| 306 |
+
{skill.tags && skill.tags.length > 0 && (
|
| 307 |
+
<div>
|
| 308 |
+
<div className="flex items-center gap-1 text-sm text-foreground-secondary mb-2">
|
| 309 |
+
<Tag className="w-3.5 h-3.5" />
|
| 310 |
+
Tags
|
| 311 |
+
</div>
|
| 312 |
+
<div className="flex flex-wrap gap-1.5">
|
| 313 |
+
{skill.tags.map((tag) => (
|
| 314 |
+
<Badge key={tag} variant="outline" size="sm">{tag}</Badge>
|
| 315 |
+
))}
|
| 316 |
+
</div>
|
| 317 |
+
</div>
|
| 318 |
+
)}
|
| 319 |
+
</CardContent>
|
| 320 |
+
</Card>
|
| 321 |
+
</div>
|
| 322 |
+
</div>
|
| 323 |
+
</div>
|
| 324 |
+
);
|
| 325 |
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-- ============================================================
|
| 2 |
+
-- Candy Shop — Supabase Schema
|
| 3 |
+
-- ============================================================
|
| 4 |
+
|
| 5 |
+
-- User Profiles
|
| 6 |
+
create table if not exists public.user_profiles (
|
| 7 |
+
id uuid primary key references auth.users(id) on delete cascade,
|
| 8 |
+
display_name text,
|
| 9 |
+
avatar_url text,
|
| 10 |
+
bio text,
|
| 11 |
+
namespace text unique,
|
| 12 |
+
created_at timestamptz default now(),
|
| 13 |
+
updated_at timestamptz default now()
|
| 14 |
+
);
|
| 15 |
+
|
| 16 |
+
alter table public.user_profiles enable row level security;
|
| 17 |
+
|
| 18 |
+
create policy "Anyone can view profiles"
|
| 19 |
+
on public.user_profiles for select using (true);
|
| 20 |
+
|
| 21 |
+
create policy "Users can update own profile"
|
| 22 |
+
on public.user_profiles for update using (auth.uid() = id);
|
| 23 |
+
|
| 24 |
+
create policy "Users can insert own profile"
|
| 25 |
+
on public.user_profiles for insert with check (auth.uid() = id);
|
| 26 |
+
|
| 27 |
+
-- Skills
|
| 28 |
+
create table if not exists public.skills (
|
| 29 |
+
id uuid primary key default gen_random_uuid(),
|
| 30 |
+
user_id uuid references auth.users(id) on delete set null,
|
| 31 |
+
name text not null,
|
| 32 |
+
description text default '',
|
| 33 |
+
category text not null default 'Tools',
|
| 34 |
+
icon text default '📦',
|
| 35 |
+
color text default 'bg-indigo-100',
|
| 36 |
+
tags text[] default '{}',
|
| 37 |
+
install_command text default '',
|
| 38 |
+
repo text default '',
|
| 39 |
+
skill_md_url text default '',
|
| 40 |
+
config jsonb default '{}',
|
| 41 |
+
greeting text,
|
| 42 |
+
popularity integer default 0,
|
| 43 |
+
download_count integer default 0,
|
| 44 |
+
star_count integer default 0,
|
| 45 |
+
avg_rating numeric(3,2) default 0,
|
| 46 |
+
status text default 'active' check (status in ('draft', 'active', 'archived')),
|
| 47 |
+
is_public boolean default true,
|
| 48 |
+
created_at timestamptz default now(),
|
| 49 |
+
updated_at timestamptz default now()
|
| 50 |
+
);
|
| 51 |
+
|
| 52 |
+
alter table public.skills enable row level security;
|
| 53 |
+
|
| 54 |
+
create policy "Anyone can view public skills"
|
| 55 |
+
on public.skills for select using (is_public = true);
|
| 56 |
+
|
| 57 |
+
create policy "Users can view own skills"
|
| 58 |
+
on public.skills for select using (auth.uid() = user_id);
|
| 59 |
+
|
| 60 |
+
create policy "Users can insert own skills"
|
| 61 |
+
on public.skills for insert with check (auth.uid() = user_id);
|
| 62 |
+
|
| 63 |
+
create policy "Users can update own skills"
|
| 64 |
+
on public.skills for update using (auth.uid() = user_id);
|
| 65 |
+
|
| 66 |
+
create policy "Users can delete own skills"
|
| 67 |
+
on public.skills for delete using (auth.uid() = user_id);
|
| 68 |
+
|
| 69 |
+
-- Cravings
|
| 70 |
+
create table if not exists public.cravings (
|
| 71 |
+
id uuid primary key default gen_random_uuid(),
|
| 72 |
+
user_id uuid references auth.users(id) on delete set null,
|
| 73 |
+
title text not null,
|
| 74 |
+
description text default '',
|
| 75 |
+
category text not null default 'General',
|
| 76 |
+
tags text[] default '{}',
|
| 77 |
+
budget text default '',
|
| 78 |
+
urgency text default 'medium' check (urgency in ('low', 'medium', 'high')),
|
| 79 |
+
status text default 'open' check (status in ('open', 'in-progress', 'fulfilled')),
|
| 80 |
+
emoji text default '💡',
|
| 81 |
+
match_count integer default 0,
|
| 82 |
+
posted_by text default '',
|
| 83 |
+
created_at timestamptz default now(),
|
| 84 |
+
updated_at timestamptz default now()
|
| 85 |
+
);
|
| 86 |
+
|
| 87 |
+
alter table public.cravings enable row level security;
|
| 88 |
+
|
| 89 |
+
create policy "Anyone can view cravings"
|
| 90 |
+
on public.cravings for select using (true);
|
| 91 |
+
|
| 92 |
+
create policy "Users can insert own cravings"
|
| 93 |
+
on public.cravings for insert with check (auth.uid() = user_id);
|
| 94 |
+
|
| 95 |
+
create policy "Users can update own cravings"
|
| 96 |
+
on public.cravings for update using (auth.uid() = user_id);
|
| 97 |
+
|
| 98 |
+
create policy "Users can delete own cravings"
|
| 99 |
+
on public.cravings for delete using (auth.uid() = user_id);
|
| 100 |
+
|
| 101 |
+
-- Stars
|
| 102 |
+
create table if not exists public.stars (
|
| 103 |
+
id uuid primary key default gen_random_uuid(),
|
| 104 |
+
user_id uuid not null references auth.users(id) on delete cascade,
|
| 105 |
+
skill_id uuid not null references public.skills(id) on delete cascade,
|
| 106 |
+
created_at timestamptz default now(),
|
| 107 |
+
unique (user_id, skill_id)
|
| 108 |
+
);
|
| 109 |
+
|
| 110 |
+
alter table public.stars enable row level security;
|
| 111 |
+
|
| 112 |
+
create policy "Anyone can view stars"
|
| 113 |
+
on public.stars for select using (true);
|
| 114 |
+
|
| 115 |
+
create policy "Auth users can star"
|
| 116 |
+
on public.stars for insert with check (auth.uid() = user_id);
|
| 117 |
+
|
| 118 |
+
create policy "Users can unstar own"
|
| 119 |
+
on public.stars for delete using (auth.uid() = user_id);
|
| 120 |
+
|
| 121 |
+
-- Ratings
|
| 122 |
+
create table if not exists public.ratings (
|
| 123 |
+
id uuid primary key default gen_random_uuid(),
|
| 124 |
+
user_id uuid not null references auth.users(id) on delete cascade,
|
| 125 |
+
skill_id uuid not null references public.skills(id) on delete cascade,
|
| 126 |
+
score integer not null check (score >= 1 and score <= 5),
|
| 127 |
+
comment text default '',
|
| 128 |
+
created_at timestamptz default now(),
|
| 129 |
+
updated_at timestamptz default now(),
|
| 130 |
+
unique (user_id, skill_id)
|
| 131 |
+
);
|
| 132 |
+
|
| 133 |
+
alter table public.ratings enable row level security;
|
| 134 |
+
|
| 135 |
+
create policy "Anyone can view ratings"
|
| 136 |
+
on public.ratings for select using (true);
|
| 137 |
+
|
| 138 |
+
create policy "Auth users can rate"
|
| 139 |
+
on public.ratings for insert with check (auth.uid() = user_id);
|
| 140 |
+
|
| 141 |
+
create policy "Users can update own rating"
|
| 142 |
+
on public.ratings for update using (auth.uid() = user_id);
|
| 143 |
+
|
| 144 |
+
create policy "Users can delete own rating"
|
| 145 |
+
on public.ratings for delete using (auth.uid() = user_id);
|
| 146 |
+
|
| 147 |
+
-- Downloads tracking
|
| 148 |
+
create table if not exists public.downloads (
|
| 149 |
+
id uuid primary key default gen_random_uuid(),
|
| 150 |
+
skill_id uuid not null references public.skills(id) on delete cascade,
|
| 151 |
+
user_id uuid references auth.users(id) on delete set null,
|
| 152 |
+
created_at timestamptz default now()
|
| 153 |
+
);
|
| 154 |
+
|
| 155 |
+
alter table public.downloads enable row level security;
|
| 156 |
+
|
| 157 |
+
create policy "Anyone can view downloads"
|
| 158 |
+
on public.downloads for select using (true);
|
| 159 |
+
|
| 160 |
+
create policy "Anyone can insert downloads"
|
| 161 |
+
on public.downloads for insert with check (true);
|
| 162 |
+
|
| 163 |
+
-- RPC: Increment download count atomically
|
| 164 |
+
create or replace function public.increment_download(p_skill_id uuid)
|
| 165 |
+
returns void as $$
|
| 166 |
+
begin
|
| 167 |
+
update public.skills
|
| 168 |
+
set download_count = download_count + 1
|
| 169 |
+
where id = p_skill_id;
|
| 170 |
+
|
| 171 |
+
insert into public.downloads (skill_id)
|
| 172 |
+
values (p_skill_id);
|
| 173 |
+
end;
|
| 174 |
+
$$ language plpgsql security definer;
|
| 175 |
+
|
| 176 |
+
-- RPC: Update star count on skill after star/unstar
|
| 177 |
+
create or replace function public.refresh_star_count(p_skill_id uuid)
|
| 178 |
+
returns void as $$
|
| 179 |
+
begin
|
| 180 |
+
update public.skills
|
| 181 |
+
set star_count = (select count(*) from public.stars where skill_id = p_skill_id)
|
| 182 |
+
where id = p_skill_id;
|
| 183 |
+
end;
|
| 184 |
+
$$ language plpgsql security definer;
|
| 185 |
+
|
| 186 |
+
-- RPC: Update average rating on skill
|
| 187 |
+
create or replace function public.refresh_avg_rating(p_skill_id uuid)
|
| 188 |
+
returns void as $$
|
| 189 |
+
begin
|
| 190 |
+
update public.skills
|
| 191 |
+
set avg_rating = coalesce(
|
| 192 |
+
(select avg(score)::numeric(3,2) from public.ratings where skill_id = p_skill_id),
|
| 193 |
+
0
|
| 194 |
+
)
|
| 195 |
+
where id = p_skill_id;
|
| 196 |
+
end;
|
| 197 |
+
$$ language plpgsql security definer;
|
| 198 |
+
|
| 199 |
+
-- Indexes
|
| 200 |
+
create index if not exists idx_skills_category on public.skills(category);
|
| 201 |
+
create index if not exists idx_skills_popularity on public.skills(popularity desc);
|
| 202 |
+
create index if not exists idx_skills_star_count on public.skills(star_count desc);
|
| 203 |
+
create index if not exists idx_skills_created_at on public.skills(created_at desc);
|
| 204 |
+
create index if not exists idx_cravings_status on public.cravings(status);
|
| 205 |
+
create index if not exists idx_cravings_created_at on public.cravings(created_at desc);
|
| 206 |
+
create index if not exists idx_stars_user_id on public.stars(user_id);
|
| 207 |
+
create index if not exists idx_stars_skill_id on public.stars(skill_id);
|
| 208 |
+
create index if not exists idx_ratings_skill_id on public.ratings(skill_id);
|
| 209 |
+
|
| 210 |
+
-- Full-text search on skills
|
| 211 |
+
alter table public.skills add column if not exists fts tsvector
|
| 212 |
+
generated always as (
|
| 213 |
+
setweight(to_tsvector('english', coalesce(name, '')), 'A') ||
|
| 214 |
+
setweight(to_tsvector('english', coalesce(description, '')), 'B')
|
| 215 |
+
) stored;
|
| 216 |
+
|
| 217 |
+
create index if not exists idx_skills_fts on public.skills using gin(fts);
|