Spaces:
Paused
Paused
feat: enhance UI and functionality for candy and craving features
Browse files- Update styles for app loader and text colors based on color scheme preferences.
- Disable Hot Module Replacement (HMR) in Vite to prevent state corruption during development.
- Remove unused App.css and CandyIcon components to streamline the codebase.
- Introduce new modal components for posting cravings and candies, enhancing user interaction.
- Refactor HomePage and SkillsGrid components to support new craving and candy functionalities, including search and filtering options.
- Update layout components to accommodate new navigation actions for cravings and candies.
- index.html +8 -2
- src/App.css +0 -42
- src/App.tsx +174 -42
- src/components/common/CandyIcon.tsx +0 -45
- src/components/home/CravingsGrid.tsx +450 -0
- src/components/home/ExternalResources.tsx +7 -4
- src/components/home/Hero.tsx +147 -133
- src/components/home/PostCandyModal.tsx +288 -0
- src/components/home/PostCravingModal.tsx +285 -0
- src/components/home/SkillsGrid.tsx +66 -100
- src/components/layout/Header.tsx +277 -87
- src/components/layout/Layout.tsx +13 -3
- src/components/layout/Sidebar.tsx +128 -164
- src/components/normal-mode/Hero.tsx +0 -102
- src/components/normal-mode/Layout.tsx +0 -70
- src/components/normal-mode/SkillsGrid.tsx +0 -328
- src/components/normal-mode/index.ts +0 -3
- src/components/skill-creator/MySkillsLibrary.tsx +1 -2
- src/components/skill-creator/SkillExecutor.tsx +3 -3
- src/components/skill-creator/SkillPreviewEditor.tsx +1 -2
- src/contexts/LanguageContext.tsx +18 -2
- src/data/cravingsData.ts +211 -0
- src/index.css +5 -0
- src/utils/storage.ts +36 -0
- vite.config.ts +4 -1
index.html
CHANGED
|
@@ -39,10 +39,13 @@
|
|
| 39 |
flex-direction: column;
|
| 40 |
align-items: center;
|
| 41 |
justify-content: center;
|
| 42 |
-
background: #
|
| 43 |
z-index: 9999;
|
| 44 |
transition: opacity 0.3s ease-out;
|
| 45 |
}
|
|
|
|
|
|
|
|
|
|
| 46 |
#app-loader.hidden {
|
| 47 |
opacity: 0;
|
| 48 |
pointer-events: none;
|
|
@@ -57,10 +60,13 @@
|
|
| 57 |
}
|
| 58 |
#app-loader p {
|
| 59 |
margin-top: 16px;
|
| 60 |
-
color: #
|
| 61 |
font-family: system-ui, -apple-system, sans-serif;
|
| 62 |
font-size: 14px;
|
| 63 |
}
|
|
|
|
|
|
|
|
|
|
| 64 |
@keyframes spin {
|
| 65 |
to { transform: rotate(360deg); }
|
| 66 |
}
|
|
|
|
| 39 |
flex-direction: column;
|
| 40 |
align-items: center;
|
| 41 |
justify-content: center;
|
| 42 |
+
background: #FFF8F0;
|
| 43 |
z-index: 9999;
|
| 44 |
transition: opacity 0.3s ease-out;
|
| 45 |
}
|
| 46 |
+
@media (prefers-color-scheme: dark) {
|
| 47 |
+
#app-loader { background: #1A0E0A; }
|
| 48 |
+
}
|
| 49 |
#app-loader.hidden {
|
| 50 |
opacity: 0;
|
| 51 |
pointer-events: none;
|
|
|
|
| 60 |
}
|
| 61 |
#app-loader p {
|
| 62 |
margin-top: 16px;
|
| 63 |
+
color: #7A6058;
|
| 64 |
font-family: system-ui, -apple-system, sans-serif;
|
| 65 |
font-size: 14px;
|
| 66 |
}
|
| 67 |
+
@media (prefers-color-scheme: dark) {
|
| 68 |
+
#app-loader p { color: #B8A898; }
|
| 69 |
+
}
|
| 70 |
@keyframes spin {
|
| 71 |
to { transform: rotate(360deg); }
|
| 72 |
}
|
src/App.css
DELETED
|
@@ -1,42 +0,0 @@
|
|
| 1 |
-
#root {
|
| 2 |
-
max-width: 1280px;
|
| 3 |
-
margin: 0 auto;
|
| 4 |
-
padding: 2rem;
|
| 5 |
-
text-align: center;
|
| 6 |
-
}
|
| 7 |
-
|
| 8 |
-
.logo {
|
| 9 |
-
height: 6em;
|
| 10 |
-
padding: 1.5em;
|
| 11 |
-
will-change: filter;
|
| 12 |
-
transition: filter 300ms;
|
| 13 |
-
}
|
| 14 |
-
.logo:hover {
|
| 15 |
-
filter: drop-shadow(0 0 2em #646cffaa);
|
| 16 |
-
}
|
| 17 |
-
.logo.react:hover {
|
| 18 |
-
filter: drop-shadow(0 0 2em #61dafbaa);
|
| 19 |
-
}
|
| 20 |
-
|
| 21 |
-
@keyframes logo-spin {
|
| 22 |
-
from {
|
| 23 |
-
transform: rotate(0deg);
|
| 24 |
-
}
|
| 25 |
-
to {
|
| 26 |
-
transform: rotate(360deg);
|
| 27 |
-
}
|
| 28 |
-
}
|
| 29 |
-
|
| 30 |
-
@media (prefers-reduced-motion: no-preference) {
|
| 31 |
-
a:nth-of-type(2) .logo {
|
| 32 |
-
animation: logo-spin infinite 20s linear;
|
| 33 |
-
}
|
| 34 |
-
}
|
| 35 |
-
|
| 36 |
-
.card {
|
| 37 |
-
padding: 2em;
|
| 38 |
-
}
|
| 39 |
-
|
| 40 |
-
.read-the-docs {
|
| 41 |
-
color: #888;
|
| 42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/App.tsx
CHANGED
|
@@ -1,11 +1,14 @@
|
|
| 1 |
import { useState, useEffect, useCallback, useSyncExternalStore, Component, type ReactNode } from 'react';
|
| 2 |
-
import { BrowserRouter, Routes, Route, useNavigate, Navigate, useLocation } 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';
|
| 7 |
-
import { Hero } from './components/home/Hero';
|
| 8 |
import { SkillsGrid } from './components/home/SkillsGrid';
|
|
|
|
|
|
|
|
|
|
| 9 |
import { Categories } from './components/home/Categories';
|
| 10 |
import { ExternalResources } from './components/home/ExternalResources';
|
| 11 |
import { FAQ } from './components/home/FAQ';
|
|
@@ -20,9 +23,9 @@ import type { Skill, SkillCategory } from './types/skill-creator';
|
|
| 20 |
import { storageUtils } from './utils/storage';
|
| 21 |
import { SKILLS_DATA } from './data/skillsData';
|
| 22 |
import { type Skill as StoreSkill } from './data/skillsData';
|
|
|
|
| 23 |
import { toast } from 'sonner';
|
| 24 |
import { LanguageProvider } from './contexts/LanguageContext';
|
| 25 |
-
import { VersionModeProvider } from './contexts/VersionModeContext';
|
| 26 |
|
| 27 |
// ---------------------------------------------------------------------------
|
| 28 |
// Error Boundary — prevents blank screen on unhandled errors
|
|
@@ -125,6 +128,10 @@ interface HomePageProps {
|
|
| 125 |
onOpenCart: () => void;
|
| 126 |
onOpenDocs: () => void;
|
| 127 |
onRunSkill: (skill: StoreSkill) => void;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
}
|
| 129 |
|
| 130 |
function HomePage({
|
|
@@ -135,50 +142,153 @@ function HomePage({
|
|
| 135 |
onOpenCart,
|
| 136 |
onOpenDocs,
|
| 137 |
onRunSkill,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
}: HomePageProps) {
|
| 139 |
-
const [
|
| 140 |
-
const
|
|
|
|
| 141 |
|
| 142 |
-
const
|
| 143 |
-
|
| 144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
};
|
| 146 |
|
| 147 |
const handleCategoryScroll = () => {
|
| 148 |
document.getElementById('categories-section')?.scrollIntoView({ behavior: 'smooth' });
|
| 149 |
};
|
| 150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
return (
|
| 152 |
-
<
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
/>
|
| 170 |
-
<
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
setTagFilter={setTagFilter}
|
| 175 |
-
cart={cart}
|
| 176 |
-
onToggleCart={onToggleCart}
|
| 177 |
-
onRunSkill={onRunSkill}
|
| 178 |
/>
|
| 179 |
-
|
| 180 |
-
<FAQ />
|
| 181 |
-
</Layout>
|
| 182 |
);
|
| 183 |
}
|
| 184 |
|
|
@@ -356,6 +466,22 @@ function AppContent() {
|
|
| 356 |
}, 100);
|
| 357 |
}, [navigate]);
|
| 358 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 359 |
const sharedLayoutProps = {
|
| 360 |
onOpenAuth: openAuth,
|
| 361 |
onOpenCart: openCart,
|
|
@@ -364,6 +490,10 @@ function AppContent() {
|
|
| 364 |
onNavFind: navToFind,
|
| 365 |
onNavCd: navToCd,
|
| 366 |
onNavMan: openDocs,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 367 |
};
|
| 368 |
|
| 369 |
return (
|
|
@@ -380,6 +510,10 @@ function AppContent() {
|
|
| 380 |
onOpenCart={openCart}
|
| 381 |
onOpenDocs={openDocs}
|
| 382 |
onRunSkill={handleRunSkill}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
/>
|
| 384 |
}
|
| 385 |
/>
|
|
@@ -465,12 +599,10 @@ function App() {
|
|
| 465 |
return (
|
| 466 |
<ErrorBoundary>
|
| 467 |
<Router {...routerProps}>
|
| 468 |
-
<
|
| 469 |
-
<
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
</LanguageProvider>
|
| 473 |
-
</VersionModeProvider>
|
| 474 |
</Router>
|
| 475 |
</ErrorBoundary>
|
| 476 |
);
|
|
|
|
| 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';
|
| 7 |
+
import { Hero, type MarketplaceTab } from './components/home/Hero';
|
| 8 |
import { SkillsGrid } from './components/home/SkillsGrid';
|
| 9 |
+
import { CravingsGrid } from './components/home/CravingsGrid';
|
| 10 |
+
import { PostCravingModal } from './components/home/PostCravingModal';
|
| 11 |
+
import { PostCandyModal } from './components/home/PostCandyModal';
|
| 12 |
import { Categories } from './components/home/Categories';
|
| 13 |
import { ExternalResources } from './components/home/ExternalResources';
|
| 14 |
import { FAQ } from './components/home/FAQ';
|
|
|
|
| 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
|
|
|
|
| 128 |
onOpenCart: () => void;
|
| 129 |
onOpenDocs: () => void;
|
| 130 |
onRunSkill: (skill: StoreSkill) => void;
|
| 131 |
+
onNavCandy: () => void;
|
| 132 |
+
onNavCraving: () => void;
|
| 133 |
+
onNavPostCraving: () => void;
|
| 134 |
+
onNavPostCandy: () => void;
|
| 135 |
}
|
| 136 |
|
| 137 |
function HomePage({
|
|
|
|
| 142 |
onOpenCart,
|
| 143 |
onOpenDocs,
|
| 144 |
onRunSkill,
|
| 145 |
+
onNavCandy,
|
| 146 |
+
onNavCraving,
|
| 147 |
+
onNavPostCraving,
|
| 148 |
+
onNavPostCandy,
|
| 149 |
}: HomePageProps) {
|
| 150 |
+
const [searchParams, setSearchParams] = useSearchParams();
|
| 151 |
+
const rawTab = searchParams.get('tab');
|
| 152 |
+
const activeTab: MarketplaceTab = rawTab === 'craving' ? 'craving' : 'candy';
|
| 153 |
|
| 154 |
+
const [candySearch, setCandySearch] = useState('');
|
| 155 |
+
const [candyTagFilter, setCandyTagFilter] = useState<string | null>(null);
|
| 156 |
+
const [cravingSearch, setCravingSearch] = useState('');
|
| 157 |
+
const [cravingTagFilter, setCravingTagFilter] = useState<string | null>(null);
|
| 158 |
+
|
| 159 |
+
// Modal state
|
| 160 |
+
const [isPostCravingOpen, setIsPostCravingOpen] = useState(false);
|
| 161 |
+
const [isPostCandyOpen, setIsPostCandyOpen] = useState(false);
|
| 162 |
+
|
| 163 |
+
// User-posted items (persisted to localStorage)
|
| 164 |
+
const [userCravings, setUserCravings] = useState<Craving[]>(() => storageUtils.getUserCravings());
|
| 165 |
+
const [userCandies, setUserCandies] = useState<StoreSkill[]>(() => storageUtils.getUserCandies());
|
| 166 |
+
|
| 167 |
+
const setActiveTab = (tab: MarketplaceTab) => {
|
| 168 |
+
setSearchParams(tab === 'craving' ? { tab: 'craving' } : {});
|
| 169 |
+
setTimeout(() => {
|
| 170 |
+
const id = tab === 'craving' ? 'cravings-grid' : 'skills-grid';
|
| 171 |
+
document.getElementById(id)?.scrollIntoView({ behavior: 'smooth' });
|
| 172 |
+
}, 50);
|
| 173 |
+
};
|
| 174 |
+
|
| 175 |
+
const handleMatchCandy = (tags: string[]) => {
|
| 176 |
+
setCandyTagFilter(tags[0] ?? null);
|
| 177 |
+
setCandySearch('');
|
| 178 |
+
setActiveTab('candy');
|
| 179 |
+
};
|
| 180 |
+
|
| 181 |
+
const handleMatchCraving = (tags: string[]) => {
|
| 182 |
+
setCravingTagFilter(tags[0] ?? null);
|
| 183 |
+
setCravingSearch('');
|
| 184 |
+
setActiveTab('craving');
|
| 185 |
};
|
| 186 |
|
| 187 |
const handleCategoryScroll = () => {
|
| 188 |
document.getElementById('categories-section')?.scrollIntoView({ behavior: 'smooth' });
|
| 189 |
};
|
| 190 |
|
| 191 |
+
// Opens the Post Craving modal (switches to craving tab first)
|
| 192 |
+
const handleOpenPostCraving = () => {
|
| 193 |
+
setActiveTab('craving');
|
| 194 |
+
setTimeout(() => setIsPostCravingOpen(true), 100);
|
| 195 |
+
};
|
| 196 |
+
|
| 197 |
+
// Opens the Post Candy modal (switches to candy tab first)
|
| 198 |
+
const handleOpenPostCandy = () => {
|
| 199 |
+
setActiveTab('candy');
|
| 200 |
+
setTimeout(() => setIsPostCandyOpen(true), 100);
|
| 201 |
+
};
|
| 202 |
+
|
| 203 |
+
const handleSubmitCraving = (craving: Craving) => {
|
| 204 |
+
storageUtils.saveUserCraving(craving);
|
| 205 |
+
setUserCravings(storageUtils.getUserCravings());
|
| 206 |
+
toast.success(`Craving "${craving.title}" posted! Agents will find you.`);
|
| 207 |
+
};
|
| 208 |
+
|
| 209 |
+
const handleSubmitCandy = (candy: StoreSkill) => {
|
| 210 |
+
storageUtils.saveUserCandy(candy);
|
| 211 |
+
setUserCandies(storageUtils.getUserCandies());
|
| 212 |
+
toast.success(`Candy "${candy.name}" is live in the marketplace!`);
|
| 213 |
+
};
|
| 214 |
+
|
| 215 |
return (
|
| 216 |
+
<>
|
| 217 |
+
<Layout
|
| 218 |
+
onOpenAuth={onOpenAuth}
|
| 219 |
+
onOpenCart={onOpenCart}
|
| 220 |
+
user={user}
|
| 221 |
+
cartCount={cart.size}
|
| 222 |
+
onNavFind={() => setActiveTab('candy')}
|
| 223 |
+
onNavCd={handleCategoryScroll}
|
| 224 |
+
onNavMan={onOpenDocs}
|
| 225 |
+
onNavCandy={onNavCandy}
|
| 226 |
+
onNavCraving={onNavCraving}
|
| 227 |
+
onNavPostCraving={handleOpenPostCraving}
|
| 228 |
+
onNavPostCandy={handleOpenPostCandy}
|
| 229 |
+
>
|
| 230 |
+
<Hero
|
| 231 |
+
activeTab={activeTab}
|
| 232 |
+
onTabChange={setActiveTab}
|
| 233 |
+
onPostCraving={handleOpenPostCraving}
|
| 234 |
+
onPostCandy={handleOpenPostCandy}
|
| 235 |
+
/>
|
| 236 |
+
|
| 237 |
+
{/* CANDY TAB */}
|
| 238 |
+
{activeTab === 'candy' && (
|
| 239 |
+
<>
|
| 240 |
+
<Categories
|
| 241 |
+
activeCategory={candyTagFilter}
|
| 242 |
+
onSelectCategory={(tag: string | null) => {
|
| 243 |
+
setCandyTagFilter(tag);
|
| 244 |
+
setCandySearch('');
|
| 245 |
+
document.getElementById('skills-grid')?.scrollIntoView({ behavior: 'smooth' });
|
| 246 |
+
}}
|
| 247 |
+
/>
|
| 248 |
+
<SkillsGrid
|
| 249 |
+
searchQuery={candySearch}
|
| 250 |
+
setSearchQuery={setCandySearch}
|
| 251 |
+
tagFilter={candyTagFilter}
|
| 252 |
+
setTagFilter={setCandyTagFilter}
|
| 253 |
+
cart={cart}
|
| 254 |
+
onToggleCart={onToggleCart}
|
| 255 |
+
onRunSkill={onRunSkill}
|
| 256 |
+
onMatchCraving={handleMatchCraving}
|
| 257 |
+
userCandies={userCandies}
|
| 258 |
+
onPostCandy={handleOpenPostCandy}
|
| 259 |
+
onPostCraving={handleOpenPostCraving}
|
| 260 |
+
/>
|
| 261 |
+
<ExternalResources />
|
| 262 |
+
<FAQ />
|
| 263 |
+
</>
|
| 264 |
+
)}
|
| 265 |
+
|
| 266 |
+
{/* CRAVING TAB */}
|
| 267 |
+
{activeTab === 'craving' && (
|
| 268 |
+
<CravingsGrid
|
| 269 |
+
searchQuery={cravingSearch}
|
| 270 |
+
setSearchQuery={setCravingSearch}
|
| 271 |
+
tagFilter={cravingTagFilter}
|
| 272 |
+
setTagFilter={setCravingTagFilter}
|
| 273 |
+
onMatchCandy={handleMatchCandy}
|
| 274 |
+
onPostCraving={handleOpenPostCraving}
|
| 275 |
+
onPostCandy={handleOpenPostCandy}
|
| 276 |
+
userCravings={userCravings}
|
| 277 |
+
/>
|
| 278 |
+
)}
|
| 279 |
+
</Layout>
|
| 280 |
+
|
| 281 |
+
<PostCravingModal
|
| 282 |
+
isOpen={isPostCravingOpen}
|
| 283 |
+
onClose={() => setIsPostCravingOpen(false)}
|
| 284 |
+
onSubmit={handleSubmitCraving}
|
| 285 |
/>
|
| 286 |
+
<PostCandyModal
|
| 287 |
+
isOpen={isPostCandyOpen}
|
| 288 |
+
onClose={() => setIsPostCandyOpen(false)}
|
| 289 |
+
onSubmit={handleSubmitCandy}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
/>
|
| 291 |
+
</>
|
|
|
|
|
|
|
| 292 |
);
|
| 293 |
}
|
| 294 |
|
|
|
|
| 466 |
}, 100);
|
| 467 |
}, [navigate]);
|
| 468 |
|
| 469 |
+
const navToCandy = useCallback(() => {
|
| 470 |
+
navigate('/');
|
| 471 |
+
}, [navigate]);
|
| 472 |
+
|
| 473 |
+
const navToCraving = useCallback(() => {
|
| 474 |
+
navigate('/?tab=craving');
|
| 475 |
+
}, [navigate]);
|
| 476 |
+
|
| 477 |
+
const navToPostCraving = useCallback(() => {
|
| 478 |
+
navigate('/');
|
| 479 |
+
}, [navigate]);
|
| 480 |
+
|
| 481 |
+
const navToPostCandy = useCallback(() => {
|
| 482 |
+
navigate('/?tab=craving');
|
| 483 |
+
}, [navigate]);
|
| 484 |
+
|
| 485 |
const sharedLayoutProps = {
|
| 486 |
onOpenAuth: openAuth,
|
| 487 |
onOpenCart: openCart,
|
|
|
|
| 490 |
onNavFind: navToFind,
|
| 491 |
onNavCd: navToCd,
|
| 492 |
onNavMan: openDocs,
|
| 493 |
+
onNavCandy: navToCandy,
|
| 494 |
+
onNavCraving: navToCraving,
|
| 495 |
+
onNavPostCraving: navToPostCraving,
|
| 496 |
+
onNavPostCandy: navToPostCandy,
|
| 497 |
};
|
| 498 |
|
| 499 |
return (
|
|
|
|
| 510 |
onOpenCart={openCart}
|
| 511 |
onOpenDocs={openDocs}
|
| 512 |
onRunSkill={handleRunSkill}
|
| 513 |
+
onNavCandy={navToCandy}
|
| 514 |
+
onNavCraving={navToCraving}
|
| 515 |
+
onNavPostCraving={navToPostCraving}
|
| 516 |
+
onNavPostCandy={navToPostCandy}
|
| 517 |
/>
|
| 518 |
}
|
| 519 |
/>
|
|
|
|
| 599 |
return (
|
| 600 |
<ErrorBoundary>
|
| 601 |
<Router {...routerProps}>
|
| 602 |
+
<LanguageProvider>
|
| 603 |
+
<AppContent />
|
| 604 |
+
<ThemedToaster />
|
| 605 |
+
</LanguageProvider>
|
|
|
|
|
|
|
| 606 |
</Router>
|
| 607 |
</ErrorBoundary>
|
| 608 |
);
|
src/components/common/CandyIcon.tsx
DELETED
|
@@ -1,45 +0,0 @@
|
|
| 1 |
-
interface CandyIconProps {
|
| 2 |
-
size?: number;
|
| 3 |
-
className?: string;
|
| 4 |
-
animate?: boolean;
|
| 5 |
-
animationDelay?: string;
|
| 6 |
-
}
|
| 7 |
-
|
| 8 |
-
export function CandyIcon({ size = 24, className = '', animate = false, animationDelay }: CandyIconProps) {
|
| 9 |
-
return (
|
| 10 |
-
<svg
|
| 11 |
-
xmlns="http://www.w3.org/2000/svg"
|
| 12 |
-
viewBox="0 0 100 100"
|
| 13 |
-
width={size}
|
| 14 |
-
height={size}
|
| 15 |
-
className={`${animate ? 'animate-candy-float' : ''} ${className}`}
|
| 16 |
-
style={animationDelay ? { animationDelay } : undefined}
|
| 17 |
-
aria-hidden="true"
|
| 18 |
-
>
|
| 19 |
-
{/* Left wrapper twist */}
|
| 20 |
-
<path d="M8 50 Q15 42, 22 46 Q18 50, 22 54 Q15 58, 8 50Z" fill="#ff6b9d" opacity="0.9" />
|
| 21 |
-
<path d="M8 50 Q15 44, 20 48" stroke="#e0558a" strokeWidth="1.5" fill="none" opacity="0.6" />
|
| 22 |
-
<path d="M8 50 Q15 56, 20 52" stroke="#e0558a" strokeWidth="1.5" fill="none" opacity="0.6" />
|
| 23 |
-
{/* Right wrapper twist */}
|
| 24 |
-
<path d="M92 50 Q85 42, 78 46 Q82 50, 78 54 Q85 58, 92 50Z" fill="#ff6b9d" opacity="0.9" />
|
| 25 |
-
<path d="M92 50 Q85 44, 80 48" stroke="#e0558a" strokeWidth="1.5" fill="none" opacity="0.6" />
|
| 26 |
-
<path d="M92 50 Q85 56, 80 52" stroke="#e0558a" strokeWidth="1.5" fill="none" opacity="0.6" />
|
| 27 |
-
{/* Candy body */}
|
| 28 |
-
<ellipse cx="50" cy="50" rx="30" ry="22" fill="url(#cg)" stroke="#e0558a" strokeWidth="2" />
|
| 29 |
-
{/* Candy stripes */}
|
| 30 |
-
<path d="M32 38 Q40 58, 35 62" stroke="rgba(255,255,255,0.4)" strokeWidth="4" strokeLinecap="round" fill="none" />
|
| 31 |
-
<path d="M44 36 Q48 56, 44 64" stroke="rgba(255,255,255,0.4)" strokeWidth="4" strokeLinecap="round" fill="none" />
|
| 32 |
-
<path d="M56 36 Q56 56, 54 64" stroke="rgba(255,255,255,0.4)" strokeWidth="4" strokeLinecap="round" fill="none" />
|
| 33 |
-
<path d="M67 38 Q64 56, 65 62" stroke="rgba(255,255,255,0.4)" strokeWidth="4" strokeLinecap="round" fill="none" />
|
| 34 |
-
{/* Shine highlight */}
|
| 35 |
-
<ellipse cx="42" cy="42" rx="10" ry="6" fill="rgba(255,255,255,0.3)" transform="rotate(-15, 42, 42)" />
|
| 36 |
-
<defs>
|
| 37 |
-
<linearGradient id="cg" x1="0%" y1="0%" x2="100%" y2="100%">
|
| 38 |
-
<stop offset="0%" stopColor="#ff8ec4" />
|
| 39 |
-
<stop offset="50%" stopColor="#ff6b9d" />
|
| 40 |
-
<stop offset="100%" stopColor="#e84d8a" />
|
| 41 |
-
</linearGradient>
|
| 42 |
-
</defs>
|
| 43 |
-
</svg>
|
| 44 |
-
);
|
| 45 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/components/home/CravingsGrid.tsx
ADDED
|
@@ -0,0 +1,450 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Search, Clock, DollarSign, Tag, Zap, ChevronLeft, ChevronRight, Plus, Flame } from 'lucide-react';
|
| 2 |
+
import type { LucideIcon } from 'lucide-react';
|
| 3 |
+
import { useState, useMemo, useRef, useEffect } from 'react';
|
| 4 |
+
import { CRAVINGS_DATA, type Craving, type CravingUrgency } from '../../data/cravingsData';
|
| 5 |
+
import { cn } from '../../utils/cn';
|
| 6 |
+
import { useDebounce } from '../../hooks/useDebounce';
|
| 7 |
+
|
| 8 |
+
interface CravingsGridProps {
|
| 9 |
+
searchQuery: string;
|
| 10 |
+
setSearchQuery: (q: string) => void;
|
| 11 |
+
tagFilter: string | null;
|
| 12 |
+
setTagFilter: (t: string | null) => void;
|
| 13 |
+
onMatchCandy?: (tags: string[]) => void;
|
| 14 |
+
onPostCraving?: () => void;
|
| 15 |
+
onPostCandy?: () => void;
|
| 16 |
+
userCravings?: Craving[];
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
const URGENCY_CONFIG: Record<CravingUrgency, { label: string; color: string; bg: string; Icon: LucideIcon }> = {
|
| 20 |
+
high: {
|
| 21 |
+
label: 'Urgent',
|
| 22 |
+
color: 'text-red-400',
|
| 23 |
+
bg: 'bg-red-500/10 border-red-500/20',
|
| 24 |
+
Icon: Flame,
|
| 25 |
+
},
|
| 26 |
+
medium: {
|
| 27 |
+
label: 'Normal',
|
| 28 |
+
color: 'text-amber-400',
|
| 29 |
+
bg: 'bg-amber-500/10 border-amber-500/20',
|
| 30 |
+
Icon: Zap,
|
| 31 |
+
},
|
| 32 |
+
low: {
|
| 33 |
+
label: 'Flexible',
|
| 34 |
+
color: 'text-emerald-400',
|
| 35 |
+
bg: 'bg-emerald-500/10 border-emerald-500/20',
|
| 36 |
+
Icon: Clock,
|
| 37 |
+
},
|
| 38 |
+
};
|
| 39 |
+
|
| 40 |
+
const STATUS_CONFIG = {
|
| 41 |
+
open: { label: 'Open', dot: 'bg-emerald-400 animate-pulse', text: 'text-emerald-400' },
|
| 42 |
+
'in-progress': { label: 'In Progress', dot: 'bg-amber-400', text: 'text-amber-400' },
|
| 43 |
+
fulfilled: { label: 'Fulfilled', dot: 'bg-gray-400', text: 'text-gray-400' },
|
| 44 |
+
};
|
| 45 |
+
|
| 46 |
+
const CATEGORY_COLORS: Record<string, string> = {
|
| 47 |
+
Development: 'text-blue-400',
|
| 48 |
+
Design: 'text-pink-400',
|
| 49 |
+
Marketing: 'text-orange-400',
|
| 50 |
+
Productivity: 'text-emerald-400',
|
| 51 |
+
Tools: 'text-violet-400',
|
| 52 |
+
Research: 'text-cyan-400',
|
| 53 |
+
Mobile: 'text-lime-400',
|
| 54 |
+
Writing: 'text-yellow-400',
|
| 55 |
+
};
|
| 56 |
+
|
| 57 |
+
function timeAgo(isoDate: string): string {
|
| 58 |
+
const diff = Date.now() - new Date(isoDate).getTime();
|
| 59 |
+
const days = Math.floor(diff / 86400000);
|
| 60 |
+
if (days === 0) return 'Today';
|
| 61 |
+
if (days === 1) return 'Yesterday';
|
| 62 |
+
return `${days}d ago`;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
const ITEMS_PER_PAGE = 9;
|
| 66 |
+
|
| 67 |
+
export function CravingsGrid({
|
| 68 |
+
searchQuery,
|
| 69 |
+
setSearchQuery,
|
| 70 |
+
tagFilter,
|
| 71 |
+
setTagFilter,
|
| 72 |
+
onMatchCandy,
|
| 73 |
+
onPostCraving,
|
| 74 |
+
onPostCandy,
|
| 75 |
+
userCravings = [],
|
| 76 |
+
}: CravingsGridProps) {
|
| 77 |
+
const debouncedQuery = useDebounce(searchQuery, 300);
|
| 78 |
+
const isDebouncing = searchQuery !== debouncedQuery;
|
| 79 |
+
const [currentPage, setCurrentPage] = useState(0);
|
| 80 |
+
const gridRef = useRef<HTMLDivElement>(null);
|
| 81 |
+
const searchRef = useRef<HTMLInputElement>(null);
|
| 82 |
+
|
| 83 |
+
const prevFiltersRef = useRef({ searchQuery: debouncedQuery, tagFilter });
|
| 84 |
+
useEffect(() => {
|
| 85 |
+
const prev = prevFiltersRef.current;
|
| 86 |
+
if (prev.searchQuery !== debouncedQuery || prev.tagFilter !== tagFilter) {
|
| 87 |
+
setCurrentPage(0);
|
| 88 |
+
prevFiltersRef.current = { searchQuery: debouncedQuery, tagFilter };
|
| 89 |
+
}
|
| 90 |
+
}, [debouncedQuery, tagFilter]);
|
| 91 |
+
|
| 92 |
+
const allCravings = useMemo(() => [...userCravings, ...CRAVINGS_DATA], [userCravings]);
|
| 93 |
+
|
| 94 |
+
const filtered = useMemo(() => {
|
| 95 |
+
return allCravings.filter((c) => {
|
| 96 |
+
const q = debouncedQuery.toLowerCase();
|
| 97 |
+
const matchesSearch =
|
| 98 |
+
!q ||
|
| 99 |
+
c.title.toLowerCase().includes(q) ||
|
| 100 |
+
c.description.toLowerCase().includes(q) ||
|
| 101 |
+
c.tags.some((t) => t.toLowerCase().includes(q)) ||
|
| 102 |
+
c.category.toLowerCase().includes(q);
|
| 103 |
+
const matchesTag = !tagFilter || c.tags.includes(tagFilter) || c.category === tagFilter;
|
| 104 |
+
return matchesSearch && matchesTag;
|
| 105 |
+
});
|
| 106 |
+
}, [debouncedQuery, tagFilter, allCravings]);
|
| 107 |
+
|
| 108 |
+
const totalPages = Math.max(1, Math.ceil(filtered.length / ITEMS_PER_PAGE));
|
| 109 |
+
const pageCravings = filtered.slice(currentPage * ITEMS_PER_PAGE, (currentPage + 1) * ITEMS_PER_PAGE);
|
| 110 |
+
|
| 111 |
+
const goToPage = (page: number) => {
|
| 112 |
+
const clamped = Math.max(0, Math.min(page, totalPages - 1));
|
| 113 |
+
setCurrentPage(clamped);
|
| 114 |
+
gridRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
| 115 |
+
};
|
| 116 |
+
|
| 117 |
+
// Collect popular tags from cravings
|
| 118 |
+
const popularTags = useMemo(() => {
|
| 119 |
+
const counts: Record<string, number> = {};
|
| 120 |
+
CRAVINGS_DATA.forEach((c) => c.tags.forEach((t) => { counts[t] = (counts[t] || 0) + 1; }));
|
| 121 |
+
return Object.entries(counts).sort((a, b) => b[1] - a[1]).slice(0, 6).map(([tag]) => tag);
|
| 122 |
+
}, []);
|
| 123 |
+
|
| 124 |
+
return (
|
| 125 |
+
<section className="py-20 bg-background" id="cravings-grid">
|
| 126 |
+
<div className="container max-w-7xl mx-auto px-4">
|
| 127 |
+
{/* Header */}
|
| 128 |
+
<div className="flex flex-col md:flex-row md:items-end justify-between gap-6 mb-12">
|
| 129 |
+
<div>
|
| 130 |
+
<h2 className="text-3xl font-candy font-bold mb-2 text-foreground">
|
| 131 |
+
{tagFilter ? `Cravings: ${tagFilter}` : 'Fresh Cravings'}
|
| 132 |
+
</h2>
|
| 133 |
+
<div className="flex items-center gap-2 text-foreground-tertiary font-mono text-sm">
|
| 134 |
+
<span>$ ls ./requests</span>
|
| 135 |
+
{tagFilter && (
|
| 136 |
+
<button
|
| 137 |
+
onClick={() => setTagFilter(null)}
|
| 138 |
+
className="px-2 py-0.5 bg-secondary text-secondary-foreground rounded-lg hover:bg-secondary/80 transition-colors flex items-center gap-1 text-xs"
|
| 139 |
+
>
|
| 140 |
+
--filter="{tagFilter}" ×
|
| 141 |
+
</button>
|
| 142 |
+
)}
|
| 143 |
+
</div>
|
| 144 |
+
</div>
|
| 145 |
+
|
| 146 |
+
<div className="flex gap-3 items-center w-full md:w-auto">
|
| 147 |
+
{/* Search */}
|
| 148 |
+
<div className="relative flex-1 md:w-80">
|
| 149 |
+
<Search className="absolute left-4 top-1/2 -translate-y-1/2 h-4 w-4 text-foreground-tertiary" />
|
| 150 |
+
<input
|
| 151 |
+
ref={searchRef}
|
| 152 |
+
type="text"
|
| 153 |
+
value={searchQuery}
|
| 154 |
+
onChange={(e) => setSearchQuery(e.target.value)}
|
| 155 |
+
placeholder="Search cravings..."
|
| 156 |
+
className={cn(
|
| 157 |
+
'w-full h-11 pl-11 pr-4 glass border border-border/50 rounded-xl text-sm font-mono',
|
| 158 |
+
'focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary/30',
|
| 159 |
+
'transition-all placeholder:text-foreground-tertiary',
|
| 160 |
+
'shadow-warm hover:shadow-warm-lg'
|
| 161 |
+
)}
|
| 162 |
+
/>
|
| 163 |
+
</div>
|
| 164 |
+
|
| 165 |
+
{/* Post CTAs — both always available */}
|
| 166 |
+
{onPostCandy && (
|
| 167 |
+
<button
|
| 168 |
+
onClick={onPostCandy}
|
| 169 |
+
className="h-11 px-4 flex items-center gap-2 bg-rose-500/10 border border-rose-500/30 text-rose-500 rounded-xl font-body font-semibold text-sm hover:bg-rose-500/20 hover:border-rose-500/50 transition-all duration-200 btn-press whitespace-nowrap"
|
| 170 |
+
>
|
| 171 |
+
<Plus className="w-4 h-4" />
|
| 172 |
+
Post Candy
|
| 173 |
+
</button>
|
| 174 |
+
)}
|
| 175 |
+
{onPostCraving && (
|
| 176 |
+
<button
|
| 177 |
+
onClick={onPostCraving}
|
| 178 |
+
className="h-11 px-4 flex items-center gap-2 bg-gradient-to-r from-blue-500 to-indigo-500 text-white rounded-xl font-body font-semibold text-sm hover:shadow-[0_4px_20px_rgba(59,130,246,0.4)] transition-all duration-200 btn-press whitespace-nowrap shadow-[0_2px_12px_rgba(59,130,246,0.25)]"
|
| 179 |
+
>
|
| 180 |
+
<Plus className="w-4 h-4" />
|
| 181 |
+
Post Craving
|
| 182 |
+
</button>
|
| 183 |
+
)}
|
| 184 |
+
</div>
|
| 185 |
+
</div>
|
| 186 |
+
|
| 187 |
+
{/* Skeleton */}
|
| 188 |
+
{isDebouncing && (
|
| 189 |
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
| 190 |
+
{Array.from({ length: 6 }).map((_, i) => (
|
| 191 |
+
<div key={i} className="bg-card/80 rounded-xl border border-border/50 overflow-hidden">
|
| 192 |
+
<div className="p-5 space-y-3">
|
| 193 |
+
<div className="h-5 bg-secondary/30 rounded-lg animate-pulse w-3/4" />
|
| 194 |
+
<div className="h-4 bg-secondary/30 rounded-lg animate-pulse w-full" />
|
| 195 |
+
<div className="h-4 bg-secondary/30 rounded-lg animate-pulse w-5/6" />
|
| 196 |
+
<div className="flex gap-2 pt-2">
|
| 197 |
+
<div className="h-5 w-16 bg-secondary/30 rounded-full animate-pulse" />
|
| 198 |
+
<div className="h-5 w-12 bg-secondary/30 rounded-full animate-pulse" />
|
| 199 |
+
</div>
|
| 200 |
+
</div>
|
| 201 |
+
<div className="h-12 bg-secondary/20 animate-pulse" />
|
| 202 |
+
</div>
|
| 203 |
+
))}
|
| 204 |
+
</div>
|
| 205 |
+
)}
|
| 206 |
+
|
| 207 |
+
{/* Grid */}
|
| 208 |
+
{!isDebouncing && pageCravings.length > 0 && (
|
| 209 |
+
<div ref={gridRef} className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 stagger-reveal">
|
| 210 |
+
{pageCravings.map((craving) => (
|
| 211 |
+
<CravingCard
|
| 212 |
+
key={craving.id}
|
| 213 |
+
craving={craving}
|
| 214 |
+
isUserPosted={craving.postedBy === 'You'}
|
| 215 |
+
onMatchCandy={onMatchCandy}
|
| 216 |
+
onTagClick={(tag) => { setTagFilter(tag); setSearchQuery(''); }}
|
| 217 |
+
/>
|
| 218 |
+
))}
|
| 219 |
+
</div>
|
| 220 |
+
)}
|
| 221 |
+
|
| 222 |
+
{/* Empty */}
|
| 223 |
+
{!isDebouncing && filtered.length === 0 && (
|
| 224 |
+
<div className="flex flex-col items-center justify-center py-24 text-center">
|
| 225 |
+
<div className="w-20 h-20 rounded-2xl glass flex items-center justify-center mb-6 shadow-warm text-4xl">
|
| 226 |
+
😋
|
| 227 |
+
</div>
|
| 228 |
+
<h3 className="text-lg font-candy font-bold text-foreground mb-2">No cravings found</h3>
|
| 229 |
+
<p className="text-foreground-secondary text-sm font-body max-w-md mb-6">
|
| 230 |
+
{searchQuery
|
| 231 |
+
? `No cravings match "${searchQuery}". Try a different search.`
|
| 232 |
+
: `No cravings in this category yet.`}
|
| 233 |
+
</p>
|
| 234 |
+
<div className="flex flex-wrap gap-3 justify-center">
|
| 235 |
+
{searchQuery && (
|
| 236 |
+
<button
|
| 237 |
+
onClick={() => setSearchQuery('')}
|
| 238 |
+
className="px-4 py-2 text-sm font-body font-medium glass text-foreground rounded-xl hover:shadow-warm-lg transition-all btn-press"
|
| 239 |
+
>
|
| 240 |
+
Clear search
|
| 241 |
+
</button>
|
| 242 |
+
)}
|
| 243 |
+
{tagFilter && (
|
| 244 |
+
<button
|
| 245 |
+
onClick={() => setTagFilter(null)}
|
| 246 |
+
className="px-4 py-2 text-sm font-body font-medium bg-gradient-to-r from-primary to-primary-hover text-primary-foreground rounded-xl shadow-candy hover:shadow-candy-lg transition-all btn-press"
|
| 247 |
+
>
|
| 248 |
+
Show all cravings
|
| 249 |
+
</button>
|
| 250 |
+
)}
|
| 251 |
+
</div>
|
| 252 |
+
|
| 253 |
+
{searchQuery && (
|
| 254 |
+
<div className="flex flex-col items-center gap-3 mt-6">
|
| 255 |
+
<p className="text-xs text-foreground-tertiary font-mono">Try searching for:</p>
|
| 256 |
+
<div className="flex flex-wrap gap-2 justify-center">
|
| 257 |
+
{popularTags.map((tag) => (
|
| 258 |
+
<button
|
| 259 |
+
key={tag}
|
| 260 |
+
onClick={() => setSearchQuery(tag)}
|
| 261 |
+
className="px-3 py-1 text-xs font-mono glass text-foreground-secondary rounded-full border border-border/30 hover:bg-primary/10 hover:text-primary hover:border-primary/30 transition-all cursor-pointer btn-press"
|
| 262 |
+
>
|
| 263 |
+
{tag}
|
| 264 |
+
</button>
|
| 265 |
+
))}
|
| 266 |
+
</div>
|
| 267 |
+
</div>
|
| 268 |
+
)}
|
| 269 |
+
</div>
|
| 270 |
+
)}
|
| 271 |
+
|
| 272 |
+
{/* Pagination */}
|
| 273 |
+
{!isDebouncing && totalPages > 1 && (
|
| 274 |
+
<div className="flex flex-col items-center gap-4 pt-10">
|
| 275 |
+
<div className="flex items-center gap-2">
|
| 276 |
+
<button
|
| 277 |
+
onClick={() => goToPage(currentPage - 1)}
|
| 278 |
+
disabled={currentPage === 0}
|
| 279 |
+
className={cn(
|
| 280 |
+
'p-2 rounded-full transition-all duration-200 btn-press',
|
| 281 |
+
currentPage === 0 ? 'text-foreground-muted cursor-not-allowed' : 'text-foreground-secondary hover:text-foreground hover:bg-secondary/70 cursor-pointer'
|
| 282 |
+
)}
|
| 283 |
+
>
|
| 284 |
+
<ChevronLeft className="w-5 h-5" />
|
| 285 |
+
</button>
|
| 286 |
+
|
| 287 |
+
{Array.from({ length: totalPages }, (_, i) => (
|
| 288 |
+
<button
|
| 289 |
+
key={i}
|
| 290 |
+
onClick={() => goToPage(i)}
|
| 291 |
+
className={cn(
|
| 292 |
+
'min-w-[32px] h-8 rounded-lg text-xs font-mono transition-all duration-200 cursor-pointer btn-press',
|
| 293 |
+
i === currentPage
|
| 294 |
+
? 'bg-gradient-to-r from-primary to-primary-hover text-primary-foreground shadow-candy font-bold'
|
| 295 |
+
: 'text-foreground-secondary hover:bg-secondary/70 hover:text-foreground'
|
| 296 |
+
)}
|
| 297 |
+
>
|
| 298 |
+
{i + 1}
|
| 299 |
+
</button>
|
| 300 |
+
))}
|
| 301 |
+
|
| 302 |
+
<button
|
| 303 |
+
onClick={() => goToPage(currentPage + 1)}
|
| 304 |
+
disabled={currentPage === totalPages - 1}
|
| 305 |
+
className={cn(
|
| 306 |
+
'p-2 rounded-full transition-all duration-200 btn-press',
|
| 307 |
+
currentPage === totalPages - 1 ? 'text-foreground-muted cursor-not-allowed' : 'text-foreground-secondary hover:text-foreground hover:bg-secondary/70 cursor-pointer'
|
| 308 |
+
)}
|
| 309 |
+
>
|
| 310 |
+
<ChevronRight className="w-5 h-5" />
|
| 311 |
+
</button>
|
| 312 |
+
</div>
|
| 313 |
+
<span className="text-xs text-foreground-tertiary font-mono">
|
| 314 |
+
{currentPage + 1} / {totalPages}
|
| 315 |
+
</span>
|
| 316 |
+
</div>
|
| 317 |
+
)}
|
| 318 |
+
</div>
|
| 319 |
+
</section>
|
| 320 |
+
);
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
function CravingCard({
|
| 324 |
+
craving,
|
| 325 |
+
isUserPosted,
|
| 326 |
+
onMatchCandy,
|
| 327 |
+
onTagClick,
|
| 328 |
+
}: {
|
| 329 |
+
craving: Craving;
|
| 330 |
+
isUserPosted?: boolean;
|
| 331 |
+
onMatchCandy?: (tags: string[]) => void;
|
| 332 |
+
onTagClick: (tag: string) => void;
|
| 333 |
+
}) {
|
| 334 |
+
const urgency = URGENCY_CONFIG[craving.urgency];
|
| 335 |
+
const status = STATUS_CONFIG[craving.status];
|
| 336 |
+
const catColor = CATEGORY_COLORS[craving.category] || 'text-foreground-secondary';
|
| 337 |
+
|
| 338 |
+
return (
|
| 339 |
+
<div
|
| 340 |
+
className={cn(
|
| 341 |
+
'group bg-card/80 glass rounded-xl border',
|
| 342 |
+
isUserPosted ? 'border-primary/30 ring-1 ring-primary/10' : 'border-border/50',
|
| 343 |
+
'hover:shadow-card-hover hover:border-primary/20',
|
| 344 |
+
'transition-all duration-300 flex flex-col h-full overflow-hidden',
|
| 345 |
+
'card-luxe gradient-border'
|
| 346 |
+
)}
|
| 347 |
+
>
|
| 348 |
+
{/* Your Post Banner */}
|
| 349 |
+
{isUserPosted && (
|
| 350 |
+
<div className="px-5 pt-3 pb-0 flex items-center gap-1.5">
|
| 351 |
+
<span className="text-[10px] font-semibold bg-primary/10 text-primary px-2 py-0.5 rounded-full border border-primary/20 font-mono">
|
| 352 |
+
✦ Your Post
|
| 353 |
+
</span>
|
| 354 |
+
</div>
|
| 355 |
+
)}
|
| 356 |
+
|
| 357 |
+
{/* Card Top Bar */}
|
| 358 |
+
<div className={cn('px-5 pb-3', isUserPosted ? 'pt-2' : 'pt-5')}>
|
| 359 |
+
<div className="flex items-start justify-between gap-3 mb-3">
|
| 360 |
+
{/* Emoji + Status */}
|
| 361 |
+
<div className="flex items-center gap-3">
|
| 362 |
+
<span className="text-2xl animate-candy-float" style={{ animationDelay: '0.3s' }}>
|
| 363 |
+
{craving.emoji}
|
| 364 |
+
</span>
|
| 365 |
+
<div className="flex items-center gap-1.5">
|
| 366 |
+
<span className={cn('w-1.5 h-1.5 rounded-full', status.dot)} />
|
| 367 |
+
<span className={cn('text-[11px] font-mono', status.text)}>{status.label}</span>
|
| 368 |
+
</div>
|
| 369 |
+
</div>
|
| 370 |
+
|
| 371 |
+
{/* Urgency Badge */}
|
| 372 |
+
<span
|
| 373 |
+
className={cn(
|
| 374 |
+
'flex items-center gap-1 text-[10px] font-semibold px-2 py-1 rounded-full border',
|
| 375 |
+
urgency.color,
|
| 376 |
+
urgency.bg
|
| 377 |
+
)}
|
| 378 |
+
>
|
| 379 |
+
<urgency.Icon className="w-3 h-3" />
|
| 380 |
+
{urgency.label}
|
| 381 |
+
</span>
|
| 382 |
+
</div>
|
| 383 |
+
|
| 384 |
+
{/* Title */}
|
| 385 |
+
<h3 className="font-bold text-foreground text-[15px] leading-snug font-candy line-clamp-2 mb-1">
|
| 386 |
+
{craving.title}
|
| 387 |
+
</h3>
|
| 388 |
+
|
| 389 |
+
{/* Category */}
|
| 390 |
+
<span className={cn('text-[11px] font-medium', catColor)}>{craving.category}</span>
|
| 391 |
+
</div>
|
| 392 |
+
|
| 393 |
+
{/* Description */}
|
| 394 |
+
<div className="px-5 pb-3 flex-1">
|
| 395 |
+
<p className="text-[13px] text-foreground-secondary line-clamp-3 leading-relaxed font-body">
|
| 396 |
+
{craving.description}
|
| 397 |
+
</p>
|
| 398 |
+
</div>
|
| 399 |
+
|
| 400 |
+
{/* Tags */}
|
| 401 |
+
<div className="px-5 pb-3">
|
| 402 |
+
<div className="flex flex-wrap gap-1.5">
|
| 403 |
+
{craving.tags.slice(0, 3).map((tag) => (
|
| 404 |
+
<button
|
| 405 |
+
key={tag}
|
| 406 |
+
onClick={() => onTagClick(tag)}
|
| 407 |
+
className="text-[10px] font-medium bg-secondary/50 text-foreground-tertiary px-2 py-0.5 rounded-full hover:bg-primary/10 hover:text-primary transition-colors cursor-pointer"
|
| 408 |
+
>
|
| 409 |
+
#{tag.toLowerCase()}
|
| 410 |
+
</button>
|
| 411 |
+
))}
|
| 412 |
+
{craving.tags.length > 3 && (
|
| 413 |
+
<span className="text-[10px] text-foreground-tertiary px-1 py-0.5">+{craving.tags.length - 3}</span>
|
| 414 |
+
)}
|
| 415 |
+
</div>
|
| 416 |
+
</div>
|
| 417 |
+
|
| 418 |
+
{/* Meta row */}
|
| 419 |
+
<div className="px-5 pb-4 flex items-center gap-3 text-[11px] text-foreground-tertiary font-mono">
|
| 420 |
+
<span className="flex items-center gap-1">
|
| 421 |
+
<DollarSign className="w-3 h-3" />
|
| 422 |
+
{craving.budget}
|
| 423 |
+
</span>
|
| 424 |
+
<span className="text-border">·</span>
|
| 425 |
+
<span className="flex items-center gap-1">
|
| 426 |
+
<Clock className="w-3 h-3" />
|
| 427 |
+
{timeAgo(craving.postedAt)}
|
| 428 |
+
</span>
|
| 429 |
+
<span className="text-border">·</span>
|
| 430 |
+
<span>by {craving.postedBy}</span>
|
| 431 |
+
</div>
|
| 432 |
+
|
| 433 |
+
{/* Actions */}
|
| 434 |
+
<div className="px-5 pb-5 pt-1 border-t border-border/30 mt-auto flex items-center gap-2">
|
| 435 |
+
{onMatchCandy && (
|
| 436 |
+
<button
|
| 437 |
+
onClick={() => onMatchCandy(craving.tags)}
|
| 438 |
+
className="flex-1 flex items-center justify-center gap-2 h-9 rounded-lg bg-primary/10 text-primary text-sm font-body font-medium hover:bg-primary hover:text-primary-foreground transition-all duration-200 btn-press"
|
| 439 |
+
>
|
| 440 |
+
<Tag className="w-3.5 h-3.5" />
|
| 441 |
+
Find Matching Candy
|
| 442 |
+
</button>
|
| 443 |
+
)}
|
| 444 |
+
<span className="text-[11px] font-mono text-foreground-tertiary flex items-center gap-1 whitespace-nowrap">
|
| 445 |
+
<span className="text-primary font-bold">{craving.matchCount}</span> matches
|
| 446 |
+
</span>
|
| 447 |
+
</div>
|
| 448 |
+
</div>
|
| 449 |
+
);
|
| 450 |
+
}
|
src/components/home/ExternalResources.tsx
CHANGED
|
@@ -6,21 +6,24 @@ const EXTERNAL_LINKS = [
|
|
| 6 |
nameKey: 'external.anthropic',
|
| 7 |
descriptionKey: 'external.anthropicDesc',
|
| 8 |
url: 'https://github.com/anthropics/claude-skills',
|
| 9 |
-
|
|
|
|
| 10 |
color: 'border-border hover:border-primary',
|
| 11 |
},
|
| 12 |
{
|
| 13 |
nameKey: 'external.obra',
|
| 14 |
descriptionKey: 'external.obraDesc',
|
| 15 |
url: 'https://github.com/obra/superpowers',
|
| 16 |
-
|
|
|
|
| 17 |
color: 'border-border hover:border-warning',
|
| 18 |
},
|
| 19 |
{
|
| 20 |
nameKey: 'external.awesome',
|
| 21 |
descriptionKey: 'external.awesomeDesc',
|
| 22 |
url: 'https://github.com/ClaudioHQ/awesome-claude-skills',
|
| 23 |
-
|
|
|
|
| 24 |
color: 'border-border hover:border-primary',
|
| 25 |
},
|
| 26 |
];
|
|
@@ -46,7 +49,7 @@ export function ExternalResources() {
|
|
| 46 |
className={`group bg-card p-6 rounded-xl border shadow-sm transition-all duration-200 hover:shadow-md flex items-start gap-4 cursor-pointer focus:outline-none focus:ring-2 focus:ring-primary/30 ${link.color}`}
|
| 47 |
aria-label={`${t(link.nameKey)} - opens in new tab`}
|
| 48 |
>
|
| 49 |
-
<div className="mt-1 shrink-0">{link.
|
| 50 |
<div>
|
| 51 |
<h3 className="font-bold text-foreground group-hover:text-primary transition-colors duration-200 flex items-center gap-2">
|
| 52 |
{t(link.nameKey)}
|
|
|
|
| 6 |
nameKey: 'external.anthropic',
|
| 7 |
descriptionKey: 'external.anthropicDesc',
|
| 8 |
url: 'https://github.com/anthropics/claude-skills',
|
| 9 |
+
Icon: Github,
|
| 10 |
+
iconClass: 'w-5 h-5 text-foreground-secondary',
|
| 11 |
color: 'border-border hover:border-primary',
|
| 12 |
},
|
| 13 |
{
|
| 14 |
nameKey: 'external.obra',
|
| 15 |
descriptionKey: 'external.obraDesc',
|
| 16 |
url: 'https://github.com/obra/superpowers',
|
| 17 |
+
Icon: Zap,
|
| 18 |
+
iconClass: 'w-5 h-5 text-warning',
|
| 19 |
color: 'border-border hover:border-warning',
|
| 20 |
},
|
| 21 |
{
|
| 22 |
nameKey: 'external.awesome',
|
| 23 |
descriptionKey: 'external.awesomeDesc',
|
| 24 |
url: 'https://github.com/ClaudioHQ/awesome-claude-skills',
|
| 25 |
+
Icon: Rocket,
|
| 26 |
+
iconClass: 'w-5 h-5 text-primary',
|
| 27 |
color: 'border-border hover:border-primary',
|
| 28 |
},
|
| 29 |
];
|
|
|
|
| 49 |
className={`group bg-card p-6 rounded-xl border shadow-sm transition-all duration-200 hover:shadow-md flex items-start gap-4 cursor-pointer focus:outline-none focus:ring-2 focus:ring-primary/30 ${link.color}`}
|
| 50 |
aria-label={`${t(link.nameKey)} - opens in new tab`}
|
| 51 |
>
|
| 52 |
+
<div className="mt-1 shrink-0"><link.Icon className={link.iconClass} /></div>
|
| 53 |
<div>
|
| 54 |
<h3 className="font-bold text-foreground group-hover:text-primary transition-colors duration-200 flex items-center gap-2">
|
| 55 |
{t(link.nameKey)}
|
src/components/home/Hero.tsx
CHANGED
|
@@ -1,38 +1,33 @@
|
|
| 1 |
-
import { Search, FileText, Code2, TrendingUp, Candy, Package } from 'lucide-react';
|
| 2 |
import { useState, useEffect, useMemo } from 'react';
|
|
|
|
| 3 |
import { useLanguage } from '../../contexts/LanguageContext';
|
| 4 |
-
import { SKILLS_DATA
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
interface HeroProps {
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
| 8 |
}
|
| 9 |
|
| 10 |
-
const
|
| 11 |
-
const
|
|
|
|
| 12 |
|
| 13 |
-
export function Hero({
|
| 14 |
const { t, language } = useLanguage();
|
| 15 |
const [displayText, setDisplayText] = useState('');
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
name: cat.name,
|
| 21 |
-
count: SKILLS_DATA.filter(s => s.category === cat.name).length,
|
| 22 |
-
}));
|
| 23 |
-
const maxCount = Math.max(...counts.map(c => c.count));
|
| 24 |
-
return counts.map(c => ({
|
| 25 |
-
name: c.name,
|
| 26 |
-
pct: maxCount > 0 ? Math.max(10, (c.count / maxCount) * 100) : 10,
|
| 27 |
-
}));
|
| 28 |
-
}, []);
|
| 29 |
|
| 30 |
useEffect(() => {
|
| 31 |
let index = 0;
|
| 32 |
-
const typingSpeed = 50;
|
| 33 |
-
|
| 34 |
setDisplayText('');
|
| 35 |
-
|
| 36 |
const timer = setInterval(() => {
|
| 37 |
if (index <= fullText.length) {
|
| 38 |
setDisplayText(fullText.slice(0, index));
|
|
@@ -40,136 +35,155 @@ export function Hero({ onOpenDocs }: HeroProps) {
|
|
| 40 |
} else {
|
| 41 |
clearInterval(timer);
|
| 42 |
}
|
| 43 |
-
},
|
| 44 |
-
|
| 45 |
return () => clearInterval(timer);
|
| 46 |
-
}, [fullText, language]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
return (
|
| 49 |
-
<section className="relative pt-
|
| 50 |
{/* Floating candy decorations */}
|
| 51 |
<div className="absolute inset-0 pointer-events-none overflow-hidden" aria-hidden="true">
|
| 52 |
-
<span className="absolute top-
|
| 53 |
-
<span className="absolute top-
|
| 54 |
-
<span className="absolute bottom-
|
| 55 |
-
<span className="absolute top-
|
| 56 |
-
<span className="absolute bottom-
|
| 57 |
</div>
|
| 58 |
|
| 59 |
-
<div className="
|
| 60 |
-
{/*
|
| 61 |
-
<div className="flex
|
| 62 |
-
<
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
</div>
|
| 66 |
-
|
| 67 |
-
<div className="relative">
|
| 68 |
-
<h1 className="text-4xl sm:text-5xl lg:text-6xl font-candy font-bold tracking-tight leading-[1.1]">
|
| 69 |
-
<span className="candy-gradient-raspberry-gold">{displayText}</span>
|
| 70 |
-
<span className="inline-block w-3 h-10 ml-1 -mb-1 bg-primary/70 animate-pulse rounded-sm"></span>
|
| 71 |
-
</h1>
|
| 72 |
-
<p className="mt-4 text-xl text-foreground-secondary font-mono">
|
| 73 |
-
<span className="text-primary">{'>'} npm install intelligence</span>
|
| 74 |
-
</p>
|
| 75 |
-
</div>
|
| 76 |
|
| 77 |
-
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
<button
|
| 83 |
-
onClick={
|
| 84 |
-
|
| 85 |
-
}
|
| 86 |
-
className="h-12 px-7 bg-gradient-to-r from-primary to-primary-hover text-primary-foreground rounded-xl font-body font-semibold hover:shadow-candy-lg transition-all duration-300 flex items-center gap-2 shadow-candy cursor-pointer btn-press focus:outline-none focus:ring-2 focus:ring-primary/50"
|
| 87 |
>
|
| 88 |
-
<
|
| 89 |
-
|
| 90 |
</button>
|
|
|
|
| 91 |
<button
|
| 92 |
-
onClick={
|
| 93 |
-
className="h-
|
| 94 |
>
|
| 95 |
-
<
|
| 96 |
-
|
| 97 |
</button>
|
| 98 |
</div>
|
| 99 |
-
|
| 100 |
-
{/* Real stats */}
|
| 101 |
-
<div className="flex items-center gap-6 pt-4">
|
| 102 |
-
<div className="flex items-center gap-2 text-sm font-mono">
|
| 103 |
-
<Package className="w-4 h-4 text-primary" />
|
| 104 |
-
<span className="text-foreground font-bold">{TOTAL_SKILLS}</span>
|
| 105 |
-
<span className="text-foreground-secondary">{t('hero.skillsAvailable') || 'skills'}</span>
|
| 106 |
-
</div>
|
| 107 |
-
<div className="w-px h-4 bg-border" />
|
| 108 |
-
<div className="flex items-center gap-2 text-sm font-mono">
|
| 109 |
-
<span className="text-foreground font-bold">{TOTAL_CATEGORIES}</span>
|
| 110 |
-
<span className="text-foreground-secondary">{t('hero.categoriesCount') || 'categories'}</span>
|
| 111 |
-
</div>
|
| 112 |
-
</div>
|
| 113 |
</div>
|
| 114 |
|
| 115 |
-
{/*
|
| 116 |
-
<div className="
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
{
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
<
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
<div className="p-2 bg-primary/10 rounded-xl">
|
| 140 |
-
<TrendingUp className="w-5 h-5 text-primary" />
|
| 141 |
-
</div>
|
| 142 |
-
</div>
|
| 143 |
-
|
| 144 |
-
{/* Category breakdown chart */}
|
| 145 |
-
<div className="h-32 flex items-end gap-2 justify-between px-2">
|
| 146 |
-
{chartData.map(({ name, pct }) => (
|
| 147 |
-
<div key={name} className="w-full bg-secondary/50 rounded-t-sm relative group" title={`${name}: ${pct.toFixed(0)}%`}>
|
| 148 |
-
<div
|
| 149 |
-
className="absolute bottom-0 w-full bg-gradient-to-t from-primary to-primary/60 rounded-t-sm transition-all duration-300 group-hover:from-primary/90 group-hover:to-primary/50"
|
| 150 |
-
style={{ height: `${pct}%` }}
|
| 151 |
-
></div>
|
| 152 |
-
</div>
|
| 153 |
-
))}
|
| 154 |
-
</div>
|
| 155 |
-
</div>
|
| 156 |
-
</div>
|
| 157 |
-
|
| 158 |
-
{/* Floating Code Card */}
|
| 159 |
-
<div className="absolute -bottom-6 -left-6 glass-strong p-4 rounded-xl shadow-candy border border-primary/10 font-mono text-sm max-w-[240px] hidden sm:block animate-candy-float" style={{ animationDelay: '0.5s' }}>
|
| 160 |
-
<div className="flex items-center gap-2 text-xs text-foreground-tertiary mb-2">
|
| 161 |
-
<Code2 className="w-3 h-3" />
|
| 162 |
-
<span>skill.ts</span>
|
| 163 |
-
</div>
|
| 164 |
-
<div>
|
| 165 |
-
<span className="text-syntax-keyword">const</span>{' '}
|
| 166 |
-
<span className="text-syntax-variable">ai</span> ={' '}
|
| 167 |
-
<span className="text-syntax-function">await</span>{' '}
|
| 168 |
-
<span className="text-caramel">useSkill</span>();
|
| 169 |
-
</div>
|
| 170 |
-
<div className="text-syntax-comment text-xs mt-1 flex items-center gap-1">
|
| 171 |
-
{t('hero.comment')} <Candy className="w-3 h-3 inline text-primary" />
|
| 172 |
-
</div>
|
| 173 |
</div>
|
| 174 |
</div>
|
| 175 |
</div>
|
|
|
|
|
|
|
| 1 |
import { useState, useEffect, useMemo } from 'react';
|
| 2 |
+
import { Plus } from 'lucide-react';
|
| 3 |
import { useLanguage } from '../../contexts/LanguageContext';
|
| 4 |
+
import { SKILLS_DATA } from '../../data/skillsData';
|
| 5 |
+
import { CRAVINGS_DATA } from '../../data/cravingsData';
|
| 6 |
+
|
| 7 |
+
export type MarketplaceTab = 'candy' | 'craving';
|
| 8 |
|
| 9 |
interface HeroProps {
|
| 10 |
+
activeTab: MarketplaceTab;
|
| 11 |
+
onTabChange: (tab: MarketplaceTab) => void;
|
| 12 |
+
onPostCraving: () => void;
|
| 13 |
+
onPostCandy: () => void;
|
| 14 |
}
|
| 15 |
|
| 16 |
+
const TOTAL_CANDIES = SKILLS_DATA.length;
|
| 17 |
+
const TOTAL_CRAVINGS = CRAVINGS_DATA.length;
|
| 18 |
+
const OPEN_CRAVINGS = CRAVINGS_DATA.filter((c) => c.status === 'open').length;
|
| 19 |
|
| 20 |
+
export function Hero({ activeTab, onTabChange, onPostCraving, onPostCandy }: HeroProps) {
|
| 21 |
const { t, language } = useLanguage();
|
| 22 |
const [displayText, setDisplayText] = useState('');
|
| 23 |
+
|
| 24 |
+
const fullText = activeTab === 'candy'
|
| 25 |
+
? t('hero.tagline')
|
| 26 |
+
: 'Post your craving, get your candy';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
useEffect(() => {
|
| 29 |
let index = 0;
|
|
|
|
|
|
|
| 30 |
setDisplayText('');
|
|
|
|
| 31 |
const timer = setInterval(() => {
|
| 32 |
if (index <= fullText.length) {
|
| 33 |
setDisplayText(fullText.slice(0, index));
|
|
|
|
| 35 |
} else {
|
| 36 |
clearInterval(timer);
|
| 37 |
}
|
| 38 |
+
}, 45);
|
|
|
|
| 39 |
return () => clearInterval(timer);
|
| 40 |
+
}, [fullText, language, activeTab]);
|
| 41 |
+
|
| 42 |
+
const urgentCount = useMemo(
|
| 43 |
+
() => CRAVINGS_DATA.filter((c) => c.urgency === 'high' && c.status === 'open').length,
|
| 44 |
+
[]
|
| 45 |
+
);
|
| 46 |
|
| 47 |
return (
|
| 48 |
+
<section className="relative pt-10 pb-16 lg:pt-16 lg:pb-24 overflow-hidden">
|
| 49 |
{/* Floating candy decorations */}
|
| 50 |
<div className="absolute inset-0 pointer-events-none overflow-hidden" aria-hidden="true">
|
| 51 |
+
<span className="absolute top-16 left-[8%] text-3xl opacity-[0.12] animate-candy-float" style={{ animationDelay: '0s' }}>🍭</span>
|
| 52 |
+
<span className="absolute top-32 right-[12%] text-2xl opacity-[0.10] animate-candy-float" style={{ animationDelay: '1.5s' }}>🍬</span>
|
| 53 |
+
<span className="absolute bottom-16 left-[18%] text-2xl opacity-[0.10] animate-candy-float" style={{ animationDelay: '3s' }}>🧁</span>
|
| 54 |
+
<span className="absolute top-8 right-[28%] text-xl opacity-[0.07] animate-candy-float" style={{ animationDelay: '2s' }}>🍫</span>
|
| 55 |
+
<span className="absolute bottom-24 right-[8%] text-2xl opacity-[0.07] animate-candy-float" style={{ animationDelay: '4s' }}>🍰</span>
|
| 56 |
</div>
|
| 57 |
|
| 58 |
+
<div className="flex flex-col items-center text-center gap-8 relative">
|
| 59 |
+
{/* Badge */}
|
| 60 |
+
<div className="inline-flex items-center gap-2 px-4 py-1.5 rounded-full glass border border-primary/20 text-primary text-xs font-mono font-medium shadow-candy">
|
| 61 |
+
<span className="flex h-1.5 w-1.5 rounded-full bg-primary animate-pulse" />
|
| 62 |
+
AI Skills Marketplace · v2.0
|
| 63 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
+
{/* Headline */}
|
| 66 |
+
<div className="max-w-3xl">
|
| 67 |
+
<h1 className="text-4xl sm:text-5xl lg:text-6xl font-candy font-bold tracking-tight leading-[1.1]">
|
| 68 |
+
<span className="candy-gradient-raspberry-gold">{displayText}</span>
|
| 69 |
+
<span className="inline-block w-3 h-10 ml-1 -mb-1 bg-primary/70 animate-pulse rounded-sm" />
|
| 70 |
+
</h1>
|
| 71 |
+
<p className="mt-5 text-lg text-foreground-secondary max-w-xl mx-auto leading-relaxed font-body">
|
| 72 |
+
{activeTab === 'candy'
|
| 73 |
+
? 'Discover AI skills built by the community. Share yours, or tell us what you need.'
|
| 74 |
+
: 'Browse open requests from users. Fulfill a craving, or add your own to the board.'}
|
| 75 |
</p>
|
| 76 |
+
</div>
|
| 77 |
+
|
| 78 |
+
{/* === TAB SWITCHER === */}
|
| 79 |
+
<div className="flex items-center gap-1 p-1.5 glass rounded-2xl border border-border/50 shadow-warm">
|
| 80 |
+
<button
|
| 81 |
+
onClick={() => onTabChange('candy')}
|
| 82 |
+
className={`
|
| 83 |
+
relative flex items-center gap-2.5 px-6 py-3 rounded-xl font-body font-semibold text-sm
|
| 84 |
+
transition-all duration-300 btn-press focus:outline-none focus:ring-2 focus:ring-rose-500/30
|
| 85 |
+
${activeTab === 'candy'
|
| 86 |
+
? 'bg-gradient-to-r from-rose-500 to-pink-500 text-white shadow-[0_4px_20px_rgba(244,63,94,0.35)]'
|
| 87 |
+
: 'text-foreground-secondary hover:text-foreground hover:bg-secondary/50'}
|
| 88 |
+
`}
|
| 89 |
+
>
|
| 90 |
+
<span className="text-xl leading-none">🍬</span>
|
| 91 |
+
<span>Find Candy</span>
|
| 92 |
+
<span className={`
|
| 93 |
+
text-[10px] font-mono font-bold px-1.5 py-0.5 rounded-full
|
| 94 |
+
${activeTab === 'candy' ? 'bg-white/20 text-white' : 'bg-secondary text-foreground-tertiary'}
|
| 95 |
+
`}>
|
| 96 |
+
{TOTAL_CANDIES}
|
| 97 |
+
</span>
|
| 98 |
+
</button>
|
| 99 |
+
|
| 100 |
+
<button
|
| 101 |
+
onClick={() => onTabChange('craving')}
|
| 102 |
+
className={`
|
| 103 |
+
relative flex items-center gap-2.5 px-6 py-3 rounded-xl font-body font-semibold text-sm
|
| 104 |
+
transition-all duration-300 btn-press focus:outline-none focus:ring-2 focus:ring-blue-500/30
|
| 105 |
+
${activeTab === 'craving'
|
| 106 |
+
? 'bg-gradient-to-r from-blue-500 to-indigo-500 text-white shadow-[0_4px_20px_rgba(59,130,246,0.35)]'
|
| 107 |
+
: 'text-foreground-secondary hover:text-foreground hover:bg-secondary/50'}
|
| 108 |
+
`}
|
| 109 |
+
>
|
| 110 |
+
<span className="text-xl leading-none">😋</span>
|
| 111 |
+
<span>Find Craving</span>
|
| 112 |
+
<span className={`
|
| 113 |
+
text-[10px] font-mono font-bold px-1.5 py-0.5 rounded-full
|
| 114 |
+
${activeTab === 'craving' ? 'bg-white/20 text-white' : 'bg-secondary text-foreground-tertiary'}
|
| 115 |
+
`}>
|
| 116 |
+
{OPEN_CRAVINGS}
|
| 117 |
+
</span>
|
| 118 |
+
</button>
|
| 119 |
+
</div>
|
| 120 |
|
| 121 |
+
{/* Context-aware sub-label */}
|
| 122 |
+
<p className="text-xs font-mono text-foreground-tertiary -mt-4">
|
| 123 |
+
{activeTab === 'candy'
|
| 124 |
+
? `${TOTAL_CANDIES} skills available · run instantly · post yours to grow the marketplace`
|
| 125 |
+
: `${OPEN_CRAVINGS} open requests · ${urgentCount} urgent · post candy to fulfill demand`}
|
| 126 |
+
</p>
|
| 127 |
+
|
| 128 |
+
{/* CTAs */}
|
| 129 |
+
<div className="flex flex-col items-center gap-3">
|
| 130 |
+
<button
|
| 131 |
+
onClick={() => {
|
| 132 |
+
const id = activeTab === 'candy' ? 'skills-grid' : 'cravings-grid';
|
| 133 |
+
document.getElementById(id)?.scrollIntoView({ behavior: 'smooth' });
|
| 134 |
+
}}
|
| 135 |
+
className={`h-11 px-8 text-white rounded-xl font-body font-semibold transition-all duration-300 flex items-center gap-2 cursor-pointer btn-press focus:outline-none ${
|
| 136 |
+
activeTab === 'candy'
|
| 137 |
+
? 'bg-gradient-to-r from-rose-500 to-pink-500 shadow-[0_4px_20px_rgba(244,63,94,0.35)] hover:shadow-[0_6px_28px_rgba(244,63,94,0.45)]'
|
| 138 |
+
: 'bg-gradient-to-r from-blue-500 to-indigo-500 shadow-[0_4px_20px_rgba(59,130,246,0.35)] hover:shadow-[0_6px_28px_rgba(59,130,246,0.45)]'
|
| 139 |
+
}`}
|
| 140 |
+
>
|
| 141 |
+
{activeTab === 'candy' ? '🍬 Browse Candy' : '😋 Browse Cravings'}
|
| 142 |
+
</button>
|
| 143 |
+
|
| 144 |
+
<div className="flex items-center gap-3">
|
| 145 |
<button
|
| 146 |
+
onClick={onPostCandy}
|
| 147 |
+
className="h-9 px-5 bg-rose-500/10 border border-rose-500/30 text-rose-500 rounded-xl font-body font-semibold text-sm hover:bg-rose-500/20 hover:border-rose-500/50 transition-all duration-200 flex items-center gap-1.5 cursor-pointer btn-press focus:outline-none"
|
|
|
|
|
|
|
| 148 |
>
|
| 149 |
+
<Plus className="w-3.5 h-3.5" />
|
| 150 |
+
Post Candy
|
| 151 |
</button>
|
| 152 |
+
<span className="text-border text-sm">or</span>
|
| 153 |
<button
|
| 154 |
+
onClick={onPostCraving}
|
| 155 |
+
className="h-9 px-5 bg-blue-500/10 border border-blue-500/30 text-blue-500 rounded-xl font-body font-semibold text-sm hover:bg-blue-500/20 hover:border-blue-500/50 transition-all duration-200 flex items-center gap-1.5 cursor-pointer btn-press focus:outline-none"
|
| 156 |
>
|
| 157 |
+
<Plus className="w-3.5 h-3.5" />
|
| 158 |
+
Post Craving
|
| 159 |
</button>
|
| 160 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
</div>
|
| 162 |
|
| 163 |
+
{/* Stats row */}
|
| 164 |
+
<div className="flex flex-wrap items-center justify-center gap-6 pt-2 text-sm font-mono">
|
| 165 |
+
<button
|
| 166 |
+
onClick={() => onTabChange('candy')}
|
| 167 |
+
className={`flex items-center gap-2 transition-colors ${activeTab === 'candy' ? 'text-primary' : 'text-foreground-secondary hover:text-foreground'}`}
|
| 168 |
+
>
|
| 169 |
+
<span className="text-base">🍬</span>
|
| 170 |
+
<span className="font-bold">{TOTAL_CANDIES}</span>
|
| 171 |
+
<span className="text-foreground-tertiary">candies</span>
|
| 172 |
+
</button>
|
| 173 |
+
<div className="w-px h-4 bg-border" />
|
| 174 |
+
<button
|
| 175 |
+
onClick={() => onTabChange('craving')}
|
| 176 |
+
className={`flex items-center gap-2 transition-colors ${activeTab === 'craving' ? 'text-primary' : 'text-foreground-secondary hover:text-foreground'}`}
|
| 177 |
+
>
|
| 178 |
+
<span className="text-base">😋</span>
|
| 179 |
+
<span className="font-bold">{TOTAL_CRAVINGS}</span>
|
| 180 |
+
<span className="text-foreground-tertiary">cravings</span>
|
| 181 |
+
</button>
|
| 182 |
+
<div className="w-px h-4 bg-border" />
|
| 183 |
+
<div className="flex items-center gap-2 text-foreground-secondary">
|
| 184 |
+
<span className="w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse" />
|
| 185 |
+
<span className="font-bold text-foreground">{urgentCount}</span>
|
| 186 |
+
<span className="text-foreground-tertiary">urgent now</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
</div>
|
| 188 |
</div>
|
| 189 |
</div>
|
src/components/home/PostCandyModal.tsx
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState, useEffect, useRef } from 'react';
|
| 2 |
+
import { X, Tag, Send, Terminal } from 'lucide-react';
|
| 3 |
+
import { cn } from '../../utils/cn';
|
| 4 |
+
import type { Skill, SkillCategory } from '../../data/skillsData';
|
| 5 |
+
|
| 6 |
+
const CATEGORIES: SkillCategory[] = [
|
| 7 |
+
'Development', 'Design', 'Marketing', 'Productivity',
|
| 8 |
+
'Tools', 'Research', 'Mobile', 'Writing',
|
| 9 |
+
];
|
| 10 |
+
|
| 11 |
+
const CATEGORY_EMOJIS: Record<SkillCategory, string> = {
|
| 12 |
+
Development: '💻', Design: '🎨', Marketing: '📣', Productivity: '⚡',
|
| 13 |
+
Tools: '🔧', Research: '🔭', Mobile: '📱', Writing: '✍️',
|
| 14 |
+
};
|
| 15 |
+
|
| 16 |
+
const CATEGORY_COLORS: Record<SkillCategory, string> = {
|
| 17 |
+
Development: 'bg-blue-100 border-blue-200 text-blue-700',
|
| 18 |
+
Design: 'bg-pink-100 border-pink-200 text-pink-700',
|
| 19 |
+
Marketing: 'bg-orange-100 border-orange-200 text-orange-700',
|
| 20 |
+
Productivity: 'bg-emerald-100 border-emerald-200 text-emerald-700',
|
| 21 |
+
Tools: 'bg-violet-100 border-violet-200 text-violet-700',
|
| 22 |
+
Research: 'bg-cyan-100 border-cyan-200 text-cyan-700',
|
| 23 |
+
Mobile: 'bg-lime-100 border-lime-200 text-lime-700',
|
| 24 |
+
Writing: 'bg-yellow-100 border-yellow-200 text-yellow-700',
|
| 25 |
+
};
|
| 26 |
+
|
| 27 |
+
interface PostCandyModalProps {
|
| 28 |
+
isOpen: boolean;
|
| 29 |
+
onClose: () => void;
|
| 30 |
+
onSubmit: (candy: Skill) => void;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
export function PostCandyModal({ isOpen, onClose, onSubmit }: PostCandyModalProps) {
|
| 34 |
+
const [name, setName] = useState('');
|
| 35 |
+
const [description, setDescription] = useState('');
|
| 36 |
+
const [category, setCategory] = useState<SkillCategory>('Development');
|
| 37 |
+
const [tags, setTags] = useState('');
|
| 38 |
+
const [installCommand, setInstallCommand] = useState('');
|
| 39 |
+
const [systemPrompt, setSystemPrompt] = useState('');
|
| 40 |
+
const [errors, setErrors] = useState<Record<string, string>>({});
|
| 41 |
+
const [submitting, setSubmitting] = useState(false);
|
| 42 |
+
const nameRef = useRef<HTMLInputElement>(null);
|
| 43 |
+
|
| 44 |
+
useEffect(() => {
|
| 45 |
+
if (isOpen) {
|
| 46 |
+
setTimeout(() => nameRef.current?.focus(), 50);
|
| 47 |
+
} else {
|
| 48 |
+
setName(''); setDescription(''); setCategory('Development');
|
| 49 |
+
setTags(''); setInstallCommand(''); setSystemPrompt(''); setErrors({});
|
| 50 |
+
}
|
| 51 |
+
}, [isOpen]);
|
| 52 |
+
|
| 53 |
+
useEffect(() => {
|
| 54 |
+
const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); };
|
| 55 |
+
document.addEventListener('keydown', onKey);
|
| 56 |
+
return () => document.removeEventListener('keydown', onKey);
|
| 57 |
+
}, [onClose]);
|
| 58 |
+
|
| 59 |
+
const validate = () => {
|
| 60 |
+
const e: Record<string, string> = {};
|
| 61 |
+
if (!name.trim()) e.name = 'Name is required';
|
| 62 |
+
else if (name.trim().length < 3) e.name = 'Name must be at least 3 characters';
|
| 63 |
+
if (!description.trim()) e.description = 'Description is required';
|
| 64 |
+
else if (description.trim().length < 20) e.description = 'Please describe your candy in at least 20 characters';
|
| 65 |
+
return e;
|
| 66 |
+
};
|
| 67 |
+
|
| 68 |
+
const handleSubmit = (e: React.FormEvent) => {
|
| 69 |
+
e.preventDefault();
|
| 70 |
+
const errs = validate();
|
| 71 |
+
if (Object.keys(errs).length > 0) { setErrors(errs); return; }
|
| 72 |
+
|
| 73 |
+
setSubmitting(true);
|
| 74 |
+
const tagList = tags.split(',').map(t => t.trim()).filter(Boolean);
|
| 75 |
+
const id = `user-candy-${Date.now()}`;
|
| 76 |
+
|
| 77 |
+
const newCandy: Skill = {
|
| 78 |
+
id,
|
| 79 |
+
name: name.trim(),
|
| 80 |
+
description: description.trim(),
|
| 81 |
+
category,
|
| 82 |
+
icon: CATEGORY_EMOJIS[category],
|
| 83 |
+
color: CATEGORY_COLORS[category],
|
| 84 |
+
installCommand: installCommand.trim() || `npx skills add community/${id}`,
|
| 85 |
+
tags: tagList.length > 0 ? tagList : [category],
|
| 86 |
+
popularity: 0,
|
| 87 |
+
repo: '',
|
| 88 |
+
skillMdUrl: '',
|
| 89 |
+
config: systemPrompt.trim() ? { systemPrompt: systemPrompt.trim() } : {},
|
| 90 |
+
};
|
| 91 |
+
|
| 92 |
+
setTimeout(() => {
|
| 93 |
+
onSubmit(newCandy);
|
| 94 |
+
setSubmitting(false);
|
| 95 |
+
onClose();
|
| 96 |
+
}, 400);
|
| 97 |
+
};
|
| 98 |
+
|
| 99 |
+
if (!isOpen) return null;
|
| 100 |
+
|
| 101 |
+
return (
|
| 102 |
+
<div
|
| 103 |
+
className="fixed inset-0 z-50 flex items-center justify-center p-4"
|
| 104 |
+
role="dialog"
|
| 105 |
+
aria-modal="true"
|
| 106 |
+
aria-labelledby="post-candy-title"
|
| 107 |
+
>
|
| 108 |
+
{/* Backdrop */}
|
| 109 |
+
<div
|
| 110 |
+
className="absolute inset-0 bg-black/60 backdrop-blur-sm"
|
| 111 |
+
onClick={onClose}
|
| 112 |
+
/>
|
| 113 |
+
|
| 114 |
+
{/* Modal */}
|
| 115 |
+
<div className="relative w-full max-w-lg glass border border-border/50 rounded-2xl shadow-glass animate-fade-in overflow-hidden">
|
| 116 |
+
{/* Header */}
|
| 117 |
+
<div className="flex items-center justify-between px-6 py-4 border-b border-border/50">
|
| 118 |
+
<div className="flex items-center gap-3">
|
| 119 |
+
<span className="text-2xl animate-candy-float">🍬</span>
|
| 120 |
+
<div>
|
| 121 |
+
<h2 id="post-candy-title" className="font-candy font-bold text-foreground text-lg">
|
| 122 |
+
Post a Candy
|
| 123 |
+
</h2>
|
| 124 |
+
<p className="text-xs text-foreground-tertiary font-mono">Share your AI skill with the world</p>
|
| 125 |
+
</div>
|
| 126 |
+
</div>
|
| 127 |
+
<button
|
| 128 |
+
onClick={onClose}
|
| 129 |
+
className="p-2 rounded-lg text-foreground-secondary hover:text-foreground hover:bg-secondary/50 transition-colors"
|
| 130 |
+
>
|
| 131 |
+
<X className="w-4 h-4" />
|
| 132 |
+
</button>
|
| 133 |
+
</div>
|
| 134 |
+
|
| 135 |
+
{/* Form */}
|
| 136 |
+
<form onSubmit={handleSubmit} className="px-6 py-5 space-y-4 max-h-[70vh] overflow-y-auto">
|
| 137 |
+
{/* Name */}
|
| 138 |
+
<div>
|
| 139 |
+
<label className="block text-sm font-medium text-foreground mb-1.5">
|
| 140 |
+
Candy Name <span className="text-red-400">*</span>
|
| 141 |
+
</label>
|
| 142 |
+
<input
|
| 143 |
+
ref={nameRef}
|
| 144 |
+
type="text"
|
| 145 |
+
value={name}
|
| 146 |
+
onChange={e => { setName(e.target.value); setErrors(p => ({ ...p, name: '' })); }}
|
| 147 |
+
placeholder="e.g. React Code Reviewer, SEO Content Generator"
|
| 148 |
+
className={cn(
|
| 149 |
+
'w-full h-11 px-4 glass border rounded-xl text-sm font-body',
|
| 150 |
+
'focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary/30',
|
| 151 |
+
'transition-all placeholder:text-foreground-tertiary',
|
| 152 |
+
errors.name ? 'border-red-400/50' : 'border-border/50'
|
| 153 |
+
)}
|
| 154 |
+
/>
|
| 155 |
+
{errors.name && <p className="mt-1 text-xs text-red-400">{errors.name}</p>}
|
| 156 |
+
</div>
|
| 157 |
+
|
| 158 |
+
{/* Description */}
|
| 159 |
+
<div>
|
| 160 |
+
<label className="block text-sm font-medium text-foreground mb-1.5">
|
| 161 |
+
What does it do? <span className="text-red-400">*</span>
|
| 162 |
+
</label>
|
| 163 |
+
<textarea
|
| 164 |
+
value={description}
|
| 165 |
+
onChange={e => { setDescription(e.target.value); setErrors(p => ({ ...p, description: '' })); }}
|
| 166 |
+
placeholder="Describe what your AI skill can do, who it's for, and what makes it special."
|
| 167 |
+
rows={3}
|
| 168 |
+
className={cn(
|
| 169 |
+
'w-full px-4 py-3 glass border rounded-xl text-sm font-body resize-none',
|
| 170 |
+
'focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary/30',
|
| 171 |
+
'transition-all placeholder:text-foreground-tertiary',
|
| 172 |
+
errors.description ? 'border-red-400/50' : 'border-border/50'
|
| 173 |
+
)}
|
| 174 |
+
/>
|
| 175 |
+
<div className="flex items-center justify-between mt-1">
|
| 176 |
+
{errors.description
|
| 177 |
+
? <p className="text-xs text-red-400">{errors.description}</p>
|
| 178 |
+
: <span />}
|
| 179 |
+
<span className={cn('text-xs font-mono', description.length < 20 ? 'text-foreground-tertiary' : 'text-emerald-400')}>
|
| 180 |
+
{description.length}/20 min
|
| 181 |
+
</span>
|
| 182 |
+
</div>
|
| 183 |
+
</div>
|
| 184 |
+
|
| 185 |
+
{/* Category */}
|
| 186 |
+
<div>
|
| 187 |
+
<label className="block text-sm font-medium text-foreground mb-1.5">Category</label>
|
| 188 |
+
<div className="grid grid-cols-4 gap-1.5">
|
| 189 |
+
{CATEGORIES.map(c => (
|
| 190 |
+
<button
|
| 191 |
+
key={c}
|
| 192 |
+
type="button"
|
| 193 |
+
onClick={() => setCategory(c)}
|
| 194 |
+
className={cn(
|
| 195 |
+
'flex flex-col items-center gap-1 py-2 rounded-xl border text-xs font-medium transition-all btn-press',
|
| 196 |
+
category === c
|
| 197 |
+
? 'bg-primary/10 text-primary border-primary/30'
|
| 198 |
+
: 'bg-secondary/20 text-foreground-tertiary border-border/30 hover:bg-secondary/40'
|
| 199 |
+
)}
|
| 200 |
+
>
|
| 201 |
+
<span className="text-base">{CATEGORY_EMOJIS[c]}</span>
|
| 202 |
+
<span>{c}</span>
|
| 203 |
+
</button>
|
| 204 |
+
))}
|
| 205 |
+
</div>
|
| 206 |
+
</div>
|
| 207 |
+
|
| 208 |
+
{/* Tags */}
|
| 209 |
+
<div>
|
| 210 |
+
<label className="block text-sm font-medium text-foreground mb-1.5">
|
| 211 |
+
<Tag className="w-3.5 h-3.5 inline mr-1 text-foreground-tertiary" />
|
| 212 |
+
Tags <span className="text-foreground-tertiary text-xs font-normal">(comma-separated)</span>
|
| 213 |
+
</label>
|
| 214 |
+
<input
|
| 215 |
+
type="text"
|
| 216 |
+
value={tags}
|
| 217 |
+
onChange={e => setTags(e.target.value)}
|
| 218 |
+
placeholder="React, TypeScript, AI, Automation"
|
| 219 |
+
className="w-full h-11 px-4 glass border border-border/50 rounded-xl text-sm font-body focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary/30 transition-all placeholder:text-foreground-tertiary"
|
| 220 |
+
/>
|
| 221 |
+
</div>
|
| 222 |
+
|
| 223 |
+
{/* System Prompt */}
|
| 224 |
+
<div>
|
| 225 |
+
<label className="block text-sm font-medium text-foreground mb-1.5">
|
| 226 |
+
System Prompt <span className="text-foreground-tertiary text-xs font-normal">(optional)</span>
|
| 227 |
+
</label>
|
| 228 |
+
<textarea
|
| 229 |
+
value={systemPrompt}
|
| 230 |
+
onChange={e => setSystemPrompt(e.target.value)}
|
| 231 |
+
placeholder="You are an expert AI that helps with... (Define the behavior of your candy skill)"
|
| 232 |
+
rows={3}
|
| 233 |
+
className="w-full px-4 py-3 glass border border-border/50 rounded-xl text-sm font-mono resize-none focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary/30 transition-all placeholder:text-foreground-tertiary"
|
| 234 |
+
/>
|
| 235 |
+
</div>
|
| 236 |
+
|
| 237 |
+
{/* Install Command */}
|
| 238 |
+
<div>
|
| 239 |
+
<label className="block text-sm font-medium text-foreground mb-1.5">
|
| 240 |
+
<Terminal className="w-3.5 h-3.5 inline mr-1 text-foreground-tertiary" />
|
| 241 |
+
Install Command <span className="text-foreground-tertiary text-xs font-normal">(optional)</span>
|
| 242 |
+
</label>
|
| 243 |
+
<input
|
| 244 |
+
type="text"
|
| 245 |
+
value={installCommand}
|
| 246 |
+
onChange={e => setInstallCommand(e.target.value)}
|
| 247 |
+
placeholder="npx skills add your-org/your-skill"
|
| 248 |
+
className="w-full h-11 px-4 glass border border-border/50 rounded-xl text-sm font-mono focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary/30 transition-all placeholder:text-foreground-tertiary"
|
| 249 |
+
/>
|
| 250 |
+
</div>
|
| 251 |
+
</form>
|
| 252 |
+
|
| 253 |
+
{/* Footer */}
|
| 254 |
+
<div className="flex items-center gap-3 px-6 py-4 border-t border-border/50">
|
| 255 |
+
<button
|
| 256 |
+
type="button"
|
| 257 |
+
onClick={onClose}
|
| 258 |
+
className="flex-1 h-10 rounded-xl border border-border/50 text-sm font-body font-medium text-foreground-secondary hover:text-foreground hover:bg-secondary/50 transition-all"
|
| 259 |
+
>
|
| 260 |
+
Cancel
|
| 261 |
+
</button>
|
| 262 |
+
<button
|
| 263 |
+
onClick={handleSubmit}
|
| 264 |
+
disabled={submitting}
|
| 265 |
+
className={cn(
|
| 266 |
+
'flex-1 h-10 rounded-xl text-sm font-body font-semibold transition-all btn-press',
|
| 267 |
+
'bg-gradient-to-r from-primary to-primary-hover text-primary-foreground shadow-candy',
|
| 268 |
+
'hover:shadow-candy-lg flex items-center justify-center gap-2',
|
| 269 |
+
submitting && 'opacity-70 cursor-not-allowed'
|
| 270 |
+
)}
|
| 271 |
+
>
|
| 272 |
+
{submitting ? (
|
| 273 |
+
<span className="flex items-center gap-2">
|
| 274 |
+
<span className="w-3.5 h-3.5 border-2 border-white/40 border-t-white rounded-full animate-spin" />
|
| 275 |
+
Posting...
|
| 276 |
+
</span>
|
| 277 |
+
) : (
|
| 278 |
+
<>
|
| 279 |
+
<Send className="w-3.5 h-3.5" />
|
| 280 |
+
Post Candy
|
| 281 |
+
</>
|
| 282 |
+
)}
|
| 283 |
+
</button>
|
| 284 |
+
</div>
|
| 285 |
+
</div>
|
| 286 |
+
</div>
|
| 287 |
+
);
|
| 288 |
+
}
|
src/components/home/PostCravingModal.tsx
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState, useEffect, useRef } from 'react';
|
| 2 |
+
import { X, Flame, Zap, Clock, DollarSign, Tag, Send } from 'lucide-react';
|
| 3 |
+
import { cn } from '../../utils/cn';
|
| 4 |
+
import type { Craving, CravingCategory, CravingUrgency } from '../../data/cravingsData';
|
| 5 |
+
|
| 6 |
+
const CATEGORIES: CravingCategory[] = [
|
| 7 |
+
'Development', 'Design', 'Marketing', 'Productivity',
|
| 8 |
+
'Tools', 'Research', 'Mobile', 'Writing',
|
| 9 |
+
];
|
| 10 |
+
|
| 11 |
+
const BUDGETS = ['Free', 'Under $50', '$50–150', '$150–400', '$400–1000', '$1000+', 'Open to offers'];
|
| 12 |
+
|
| 13 |
+
const CATEGORY_EMOJIS: Record<CravingCategory, string> = {
|
| 14 |
+
Development: '💻', Design: '🎨', Marketing: '📣', Productivity: '⚡',
|
| 15 |
+
Tools: '🔧', Research: '🔭', Mobile: '📱', Writing: '✍️',
|
| 16 |
+
};
|
| 17 |
+
|
| 18 |
+
interface PostCravingModalProps {
|
| 19 |
+
isOpen: boolean;
|
| 20 |
+
onClose: () => void;
|
| 21 |
+
onSubmit: (craving: Craving) => void;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
export function PostCravingModal({ isOpen, onClose, onSubmit }: PostCravingModalProps) {
|
| 25 |
+
const [title, setTitle] = useState('');
|
| 26 |
+
const [description, setDescription] = useState('');
|
| 27 |
+
const [category, setCategory] = useState<CravingCategory>('Development');
|
| 28 |
+
const [tags, setTags] = useState('');
|
| 29 |
+
const [budget, setBudget] = useState('$50–150');
|
| 30 |
+
const [urgency, setUrgency] = useState<CravingUrgency>('medium');
|
| 31 |
+
const [errors, setErrors] = useState<Record<string, string>>({});
|
| 32 |
+
const [submitting, setSubmitting] = useState(false);
|
| 33 |
+
const titleRef = useRef<HTMLInputElement>(null);
|
| 34 |
+
|
| 35 |
+
useEffect(() => {
|
| 36 |
+
if (isOpen) {
|
| 37 |
+
setTimeout(() => titleRef.current?.focus(), 50);
|
| 38 |
+
} else {
|
| 39 |
+
setTitle(''); setDescription(''); setCategory('Development');
|
| 40 |
+
setTags(''); setBudget('$50–150'); setUrgency('medium'); setErrors({});
|
| 41 |
+
}
|
| 42 |
+
}, [isOpen]);
|
| 43 |
+
|
| 44 |
+
useEffect(() => {
|
| 45 |
+
const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); };
|
| 46 |
+
document.addEventListener('keydown', onKey);
|
| 47 |
+
return () => document.removeEventListener('keydown', onKey);
|
| 48 |
+
}, [onClose]);
|
| 49 |
+
|
| 50 |
+
const validate = () => {
|
| 51 |
+
const e: Record<string, string> = {};
|
| 52 |
+
if (!title.trim()) e.title = 'Title is required';
|
| 53 |
+
else if (title.trim().length < 10) e.title = 'Title must be at least 10 characters';
|
| 54 |
+
if (!description.trim()) e.description = 'Description is required';
|
| 55 |
+
else if (description.trim().length < 30) e.description = 'Please describe your craving in at least 30 characters';
|
| 56 |
+
return e;
|
| 57 |
+
};
|
| 58 |
+
|
| 59 |
+
const handleSubmit = (e: React.FormEvent) => {
|
| 60 |
+
e.preventDefault();
|
| 61 |
+
const errs = validate();
|
| 62 |
+
if (Object.keys(errs).length > 0) { setErrors(errs); return; }
|
| 63 |
+
|
| 64 |
+
setSubmitting(true);
|
| 65 |
+
const tagList = tags.split(',').map(t => t.trim()).filter(Boolean);
|
| 66 |
+
const newCraving: Craving = {
|
| 67 |
+
id: `user-craving-${Date.now()}`,
|
| 68 |
+
title: title.trim(),
|
| 69 |
+
description: description.trim(),
|
| 70 |
+
category,
|
| 71 |
+
tags: tagList.length > 0 ? tagList : [category],
|
| 72 |
+
budget,
|
| 73 |
+
urgency,
|
| 74 |
+
postedBy: 'You',
|
| 75 |
+
postedAt: new Date().toISOString(),
|
| 76 |
+
matchCount: 0,
|
| 77 |
+
status: 'open',
|
| 78 |
+
emoji: CATEGORY_EMOJIS[category],
|
| 79 |
+
};
|
| 80 |
+
|
| 81 |
+
setTimeout(() => {
|
| 82 |
+
onSubmit(newCraving);
|
| 83 |
+
setSubmitting(false);
|
| 84 |
+
onClose();
|
| 85 |
+
}, 400);
|
| 86 |
+
};
|
| 87 |
+
|
| 88 |
+
if (!isOpen) return null;
|
| 89 |
+
|
| 90 |
+
return (
|
| 91 |
+
<div
|
| 92 |
+
className="fixed inset-0 z-50 flex items-center justify-center p-4"
|
| 93 |
+
role="dialog"
|
| 94 |
+
aria-modal="true"
|
| 95 |
+
aria-labelledby="post-craving-title"
|
| 96 |
+
>
|
| 97 |
+
{/* Backdrop */}
|
| 98 |
+
<div
|
| 99 |
+
className="absolute inset-0 bg-black/60 backdrop-blur-sm"
|
| 100 |
+
onClick={onClose}
|
| 101 |
+
/>
|
| 102 |
+
|
| 103 |
+
{/* Modal */}
|
| 104 |
+
<div className="relative w-full max-w-lg glass border border-border/50 rounded-2xl shadow-glass animate-fade-in overflow-hidden">
|
| 105 |
+
{/* Header */}
|
| 106 |
+
<div className="flex items-center justify-between px-6 py-4 border-b border-border/50">
|
| 107 |
+
<div className="flex items-center gap-3">
|
| 108 |
+
<span className="text-2xl">😋</span>
|
| 109 |
+
<div>
|
| 110 |
+
<h2 id="post-craving-title" className="font-candy font-bold text-foreground text-lg">
|
| 111 |
+
Post a Craving
|
| 112 |
+
</h2>
|
| 113 |
+
<p className="text-xs text-foreground-tertiary font-mono">Tell agents what you need</p>
|
| 114 |
+
</div>
|
| 115 |
+
</div>
|
| 116 |
+
<button
|
| 117 |
+
onClick={onClose}
|
| 118 |
+
className="p-2 rounded-lg text-foreground-secondary hover:text-foreground hover:bg-secondary/50 transition-colors"
|
| 119 |
+
>
|
| 120 |
+
<X className="w-4 h-4" />
|
| 121 |
+
</button>
|
| 122 |
+
</div>
|
| 123 |
+
|
| 124 |
+
{/* Form */}
|
| 125 |
+
<form onSubmit={handleSubmit} className="px-6 py-5 space-y-4 max-h-[70vh] overflow-y-auto">
|
| 126 |
+
{/* Title */}
|
| 127 |
+
<div>
|
| 128 |
+
<label className="block text-sm font-medium text-foreground mb-1.5">
|
| 129 |
+
What do you need? <span className="text-red-400">*</span>
|
| 130 |
+
</label>
|
| 131 |
+
<input
|
| 132 |
+
ref={titleRef}
|
| 133 |
+
type="text"
|
| 134 |
+
value={title}
|
| 135 |
+
onChange={e => { setTitle(e.target.value); setErrors(p => ({ ...p, title: '' })); }}
|
| 136 |
+
placeholder="e.g. Automated code review for my React monorepo"
|
| 137 |
+
className={cn(
|
| 138 |
+
'w-full h-11 px-4 glass border rounded-xl text-sm font-body',
|
| 139 |
+
'focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary/30',
|
| 140 |
+
'transition-all placeholder:text-foreground-tertiary',
|
| 141 |
+
errors.title ? 'border-red-400/50' : 'border-border/50'
|
| 142 |
+
)}
|
| 143 |
+
/>
|
| 144 |
+
{errors.title && <p className="mt-1 text-xs text-red-400">{errors.title}</p>}
|
| 145 |
+
</div>
|
| 146 |
+
|
| 147 |
+
{/* Description */}
|
| 148 |
+
<div>
|
| 149 |
+
<label className="block text-sm font-medium text-foreground mb-1.5">
|
| 150 |
+
Describe in detail <span className="text-red-400">*</span>
|
| 151 |
+
</label>
|
| 152 |
+
<textarea
|
| 153 |
+
value={description}
|
| 154 |
+
onChange={e => { setDescription(e.target.value); setErrors(p => ({ ...p, description: '' })); }}
|
| 155 |
+
placeholder="What exactly do you need? What are your requirements, constraints, and expected outputs?"
|
| 156 |
+
rows={4}
|
| 157 |
+
className={cn(
|
| 158 |
+
'w-full px-4 py-3 glass border rounded-xl text-sm font-body resize-none',
|
| 159 |
+
'focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary/30',
|
| 160 |
+
'transition-all placeholder:text-foreground-tertiary',
|
| 161 |
+
errors.description ? 'border-red-400/50' : 'border-border/50'
|
| 162 |
+
)}
|
| 163 |
+
/>
|
| 164 |
+
<div className="flex items-center justify-between mt-1">
|
| 165 |
+
{errors.description
|
| 166 |
+
? <p className="text-xs text-red-400">{errors.description}</p>
|
| 167 |
+
: <span />}
|
| 168 |
+
<span className={cn('text-xs font-mono', description.length < 30 ? 'text-foreground-tertiary' : 'text-emerald-400')}>
|
| 169 |
+
{description.length}/30 min
|
| 170 |
+
</span>
|
| 171 |
+
</div>
|
| 172 |
+
</div>
|
| 173 |
+
|
| 174 |
+
{/* Category + Budget row */}
|
| 175 |
+
<div className="grid grid-cols-2 gap-3">
|
| 176 |
+
<div>
|
| 177 |
+
<label className="block text-sm font-medium text-foreground mb-1.5">Category</label>
|
| 178 |
+
<select
|
| 179 |
+
value={category}
|
| 180 |
+
onChange={e => setCategory(e.target.value as CravingCategory)}
|
| 181 |
+
className="w-full h-11 px-3 glass border border-border/50 rounded-xl text-sm font-body focus:outline-none focus:ring-2 focus:ring-primary/30 bg-transparent"
|
| 182 |
+
>
|
| 183 |
+
{CATEGORIES.map(c => (
|
| 184 |
+
<option key={c} value={c}>{CATEGORY_EMOJIS[c]} {c}</option>
|
| 185 |
+
))}
|
| 186 |
+
</select>
|
| 187 |
+
</div>
|
| 188 |
+
<div>
|
| 189 |
+
<label className="block text-sm font-medium text-foreground mb-1.5">
|
| 190 |
+
<DollarSign className="w-3.5 h-3.5 inline mr-1 text-foreground-tertiary" />
|
| 191 |
+
Budget
|
| 192 |
+
</label>
|
| 193 |
+
<select
|
| 194 |
+
value={budget}
|
| 195 |
+
onChange={e => setBudget(e.target.value)}
|
| 196 |
+
className="w-full h-11 px-3 glass border border-border/50 rounded-xl text-sm font-body focus:outline-none focus:ring-2 focus:ring-primary/30 bg-transparent"
|
| 197 |
+
>
|
| 198 |
+
{BUDGETS.map(b => <option key={b} value={b}>{b}</option>)}
|
| 199 |
+
</select>
|
| 200 |
+
</div>
|
| 201 |
+
</div>
|
| 202 |
+
|
| 203 |
+
{/* Tags */}
|
| 204 |
+
<div>
|
| 205 |
+
<label className="block text-sm font-medium text-foreground mb-1.5">
|
| 206 |
+
<Tag className="w-3.5 h-3.5 inline mr-1 text-foreground-tertiary" />
|
| 207 |
+
Tags <span className="text-foreground-tertiary text-xs font-normal">(comma-separated)</span>
|
| 208 |
+
</label>
|
| 209 |
+
<input
|
| 210 |
+
type="text"
|
| 211 |
+
value={tags}
|
| 212 |
+
onChange={e => setTags(e.target.value)}
|
| 213 |
+
placeholder="React, TypeScript, GitHub, Automation"
|
| 214 |
+
className="w-full h-11 px-4 glass border border-border/50 rounded-xl text-sm font-body focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary/30 transition-all placeholder:text-foreground-tertiary"
|
| 215 |
+
/>
|
| 216 |
+
</div>
|
| 217 |
+
|
| 218 |
+
{/* Urgency */}
|
| 219 |
+
<div>
|
| 220 |
+
<label className="block text-sm font-medium text-foreground mb-2">Urgency</label>
|
| 221 |
+
<div className="flex gap-2">
|
| 222 |
+
{([
|
| 223 |
+
{ value: 'low', label: 'Flexible', icon: <Clock className="w-3.5 h-3.5" />, color: 'emerald' },
|
| 224 |
+
{ value: 'medium', label: 'Normal', icon: <Zap className="w-3.5 h-3.5" />, color: 'amber' },
|
| 225 |
+
{ value: 'high', label: 'Urgent', icon: <Flame className="w-3.5 h-3.5" />, color: 'red' },
|
| 226 |
+
] as const).map(({ value, label, icon, color }) => (
|
| 227 |
+
<button
|
| 228 |
+
key={value}
|
| 229 |
+
type="button"
|
| 230 |
+
onClick={() => setUrgency(value)}
|
| 231 |
+
className={cn(
|
| 232 |
+
'flex-1 flex items-center justify-center gap-2 h-10 rounded-xl text-sm font-medium border transition-all btn-press',
|
| 233 |
+
urgency === value
|
| 234 |
+
? color === 'emerald'
|
| 235 |
+
? 'bg-emerald-500/15 text-emerald-400 border-emerald-500/30'
|
| 236 |
+
: color === 'amber'
|
| 237 |
+
? 'bg-amber-500/15 text-amber-400 border-amber-500/30'
|
| 238 |
+
: 'bg-red-500/15 text-red-400 border-red-500/30'
|
| 239 |
+
: 'bg-secondary/30 text-foreground-tertiary border-border/30 hover:bg-secondary/50'
|
| 240 |
+
)}
|
| 241 |
+
>
|
| 242 |
+
{icon}
|
| 243 |
+
{label}
|
| 244 |
+
</button>
|
| 245 |
+
))}
|
| 246 |
+
</div>
|
| 247 |
+
</div>
|
| 248 |
+
</form>
|
| 249 |
+
|
| 250 |
+
{/* Footer */}
|
| 251 |
+
<div className="flex items-center gap-3 px-6 py-4 border-t border-border/50">
|
| 252 |
+
<button
|
| 253 |
+
type="button"
|
| 254 |
+
onClick={onClose}
|
| 255 |
+
className="flex-1 h-10 rounded-xl border border-border/50 text-sm font-body font-medium text-foreground-secondary hover:text-foreground hover:bg-secondary/50 transition-all"
|
| 256 |
+
>
|
| 257 |
+
Cancel
|
| 258 |
+
</button>
|
| 259 |
+
<button
|
| 260 |
+
onClick={handleSubmit}
|
| 261 |
+
disabled={submitting}
|
| 262 |
+
className={cn(
|
| 263 |
+
'flex-1 h-10 rounded-xl text-sm font-body font-semibold transition-all btn-press',
|
| 264 |
+
'bg-gradient-to-r from-primary to-primary-hover text-primary-foreground shadow-candy',
|
| 265 |
+
'hover:shadow-candy-lg flex items-center justify-center gap-2',
|
| 266 |
+
submitting && 'opacity-70 cursor-not-allowed'
|
| 267 |
+
)}
|
| 268 |
+
>
|
| 269 |
+
{submitting ? (
|
| 270 |
+
<span className="flex items-center gap-2">
|
| 271 |
+
<span className="w-3.5 h-3.5 border-2 border-white/40 border-t-white rounded-full animate-spin" />
|
| 272 |
+
Posting...
|
| 273 |
+
</span>
|
| 274 |
+
) : (
|
| 275 |
+
<>
|
| 276 |
+
<Send className="w-3.5 h-3.5" />
|
| 277 |
+
Post Craving
|
| 278 |
+
</>
|
| 279 |
+
)}
|
| 280 |
+
</button>
|
| 281 |
+
</div>
|
| 282 |
+
</div>
|
| 283 |
+
</div>
|
| 284 |
+
);
|
| 285 |
+
}
|
src/components/home/SkillsGrid.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import { Search, ShoppingBag, Check, X, Heart, Play, Star, ChevronLeft, ChevronRight } from 'lucide-react';
|
| 2 |
import { useState, useMemo, useEffect, useRef } from 'react';
|
| 3 |
import { SKILLS_DATA, type Skill } from '../../data/skillsData';
|
| 4 |
import { SkillModal } from '../common/SkillModal';
|
|
@@ -6,7 +6,6 @@ import { storageUtils } from '../../utils/storage';
|
|
| 6 |
import { cn } from '../../utils/cn';
|
| 7 |
import { toast } from 'sonner';
|
| 8 |
import { useLanguage } from '../../contexts/LanguageContext';
|
| 9 |
-
import { useVersionMode } from '../../contexts/VersionModeContext';
|
| 10 |
import { useDebounce } from '../../hooks/useDebounce';
|
| 11 |
import { CANDY_EMOJIS } from '../../utils/candy';
|
| 12 |
|
|
@@ -18,6 +17,10 @@ interface SkillsGridProps {
|
|
| 18 |
cart: Set<string>;
|
| 19 |
onToggleCart: (id: string) => void;
|
| 20 |
onRunSkill: (skill: Skill) => void;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
}
|
| 22 |
|
| 23 |
const getCategoryColor = (category: string) => {
|
|
@@ -51,9 +54,12 @@ export function SkillsGrid({
|
|
| 51 |
cart,
|
| 52 |
onToggleCart,
|
| 53 |
onRunSkill,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
}: SkillsGridProps) {
|
| 55 |
const { t } = useLanguage();
|
| 56 |
-
const { mode } = useVersionMode();
|
| 57 |
const debouncedSearchQuery = useDebounce(searchQuery, 300);
|
| 58 |
const isDebouncing = searchQuery !== debouncedSearchQuery;
|
| 59 |
const [selectedSkill, setSelectedSkill] = useState<Skill | null>(null);
|
|
@@ -104,21 +110,28 @@ export function SkillsGrid({
|
|
| 104 |
}
|
| 105 |
};
|
| 106 |
|
|
|
|
|
|
|
| 107 |
const filteredSkills = useMemo(() => {
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
const totalPages = Math.max(1, Math.ceil(filteredSkills.length / ITEMS_PER_PAGE));
|
| 124 |
const pageSkills = filteredSkills.slice(currentPage * ITEMS_PER_PAGE, (currentPage + 1) * ITEMS_PER_PAGE);
|
|
@@ -216,8 +229,8 @@ export function SkillsGrid({
|
|
| 216 |
</div>
|
| 217 |
</div>
|
| 218 |
|
| 219 |
-
<div className="w-full md:w-
|
| 220 |
-
<div className="relative">
|
| 221 |
<Search className="absolute left-4 top-1/2 -translate-y-1/2 h-4 w-4 text-foreground-tertiary" />
|
| 222 |
<input
|
| 223 |
ref={searchInputRef}
|
|
@@ -237,6 +250,24 @@ export function SkillsGrid({
|
|
| 237 |
<span className="text-xs">⌘</span>K
|
| 238 |
</kbd>
|
| 239 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
</div>
|
| 241 |
</div>
|
| 242 |
|
|
@@ -288,88 +319,16 @@ export function SkillsGrid({
|
|
| 288 |
'card-luxe gradient-border'
|
| 289 |
)}
|
| 290 |
>
|
| 291 |
-
{/*
|
| 292 |
-
{
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
<div className="flex items-center gap-1.5">
|
| 297 |
-
<div className="w-2.5 h-2.5 rounded-full bg-red-400/80"></div>
|
| 298 |
-
<div className="w-2.5 h-2.5 rounded-full bg-yellow-400/80"></div>
|
| 299 |
-
<div className="w-2.5 h-2.5 rounded-full bg-green-400/80"></div>
|
| 300 |
-
</div>
|
| 301 |
-
<span className="ml-3 text-[11px] font-mono text-foreground-tertiary truncate">{skill.id}.ts</span>
|
| 302 |
-
<div className="ml-auto flex items-center gap-1.5">
|
| 303 |
-
<span className="animate-candy-float inline-block text-sm" style={{ animationDelay: `${(skillIndex % 5) * 0.4}s` }}>
|
| 304 |
-
{CANDY_EMOJIS[skillIndex % CANDY_EMOJIS.length]}
|
| 305 |
</span>
|
| 306 |
</div>
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
{/* Code Body */}
|
| 310 |
-
<div className="p-4 flex-1 font-mono text-[13px] leading-[1.7] space-y-1">
|
| 311 |
-
<div>
|
| 312 |
-
<span className="text-syntax-keyword">import</span>{' '}
|
| 313 |
-
<span className="text-syntax-variable">{skill.name.replace(/\s+/g, '')}</span>{' '}
|
| 314 |
-
<span className="text-syntax-keyword">from</span>{' '}
|
| 315 |
-
<span className="text-syntax-string truncate text-xs">"{skill.installCommand.split(' ').pop()}"</span>
|
| 316 |
-
</div>
|
| 317 |
-
<div className="h-2" />
|
| 318 |
-
<p className="text-syntax-comment text-xs line-clamp-2 leading-relaxed">
|
| 319 |
-
// {skill.description}
|
| 320 |
-
</p>
|
| 321 |
-
<div className="h-1" />
|
| 322 |
-
<div className="flex flex-wrap gap-1.5 pt-1">
|
| 323 |
-
<span className="text-[10px] font-semibold bg-primary/8 text-primary px-1.5 py-0.5 rounded">{skill.category}</span>
|
| 324 |
-
{skill.tags.slice(0, 3).map(tag => (
|
| 325 |
-
<span key={tag} className="text-[10px] bg-secondary/40 text-foreground-tertiary px-1.5 py-0.5 rounded">{tag}</span>
|
| 326 |
-
))}
|
| 327 |
-
</div>
|
| 328 |
-
</div>
|
| 329 |
-
|
| 330 |
-
{/* Status Bar */}
|
| 331 |
-
<div className="px-4 py-2 border-t border-border/50 bg-secondary/10 flex items-center justify-between group-hover:bg-secondary/20 transition-colors">
|
| 332 |
-
<div className="flex items-center gap-1 text-[11px] font-mono text-foreground-tertiary">
|
| 333 |
-
<Star className="w-3 h-3 fill-caramel text-caramel" />
|
| 334 |
-
<span>{skill.popularity || 0}</span>
|
| 335 |
-
</div>
|
| 336 |
-
<div className="flex items-center gap-1">
|
| 337 |
-
<button
|
| 338 |
-
onClick={(e) => { e.stopPropagation(); onRunSkill(skill); }}
|
| 339 |
-
className="p-1.5 rounded-md hover:text-green-500 hover:bg-green-500/10 transition-colors cursor-pointer focus:outline-none"
|
| 340 |
-
title={t('skills.runSkill')}
|
| 341 |
-
aria-label={`Run ${skill.name}`}
|
| 342 |
-
>
|
| 343 |
-
<Play className="w-3.5 h-3.5" />
|
| 344 |
-
</button>
|
| 345 |
-
<button
|
| 346 |
-
onClick={(e) => { e.preventDefault(); e.stopPropagation(); handleLike(skill.id); }}
|
| 347 |
-
className="p-1.5 rounded-md hover:text-pink-500 hover:bg-pink-500/10 transition-colors cursor-pointer focus:outline-none"
|
| 348 |
-
type="button"
|
| 349 |
-
aria-label={likedSkills.has(skill.id) ? 'Unlike' : 'Like'}
|
| 350 |
-
>
|
| 351 |
-
<Heart className={cn('w-3.5 h-3.5', likedSkills.has(skill.id) ? 'fill-pink-500 text-pink-500' : '')} />
|
| 352 |
-
</button>
|
| 353 |
-
<button
|
| 354 |
-
onClick={(e) => { e.stopPropagation(); onToggleCart(skill.id); }}
|
| 355 |
-
className={cn(
|
| 356 |
-
'p-1.5 rounded-md transition-colors cursor-pointer focus:outline-none',
|
| 357 |
-
cart.has(skill.id) ? 'text-green-500' : 'hover:text-primary hover:bg-primary/10'
|
| 358 |
-
)}
|
| 359 |
-
aria-label={cart.has(skill.id) ? t('skills.removeFromBag', { name: skill.name }) : t('skills.addToBag', { name: skill.name })}
|
| 360 |
-
>
|
| 361 |
-
{cart.has(skill.id) ? <Check className="w-3.5 h-3.5" /> : <ShoppingBag className="w-3.5 h-3.5" />}
|
| 362 |
-
</button>
|
| 363 |
-
</div>
|
| 364 |
-
</div>
|
| 365 |
-
</>
|
| 366 |
-
)}
|
| 367 |
-
|
| 368 |
-
{/* === User Mode: Clean card === */}
|
| 369 |
-
{mode === 'user' && (
|
| 370 |
-
<>
|
| 371 |
{/* Card Header */}
|
| 372 |
-
<div className=
|
| 373 |
<div className="flex items-start gap-3.5">
|
| 374 |
<div className={cn(
|
| 375 |
'w-12 h-12 rounded-2xl flex items-center justify-center text-2xl flex-shrink-0',
|
|
@@ -432,6 +391,15 @@ export function SkillsGrid({
|
|
| 432 |
<Play className="w-3.5 h-3.5 fill-current" />
|
| 433 |
{t('skills.runSkill')}
|
| 434 |
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 435 |
<button
|
| 436 |
onClick={(e) => { e.stopPropagation(); handleLike(skill.id); }}
|
| 437 |
className={cn(
|
|
@@ -455,8 +423,6 @@ export function SkillsGrid({
|
|
| 455 |
{cart.has(skill.id) ? <Check className="w-3.5 h-3.5" /> : <ShoppingBag className="w-3.5 h-3.5" />}
|
| 456 |
</button>
|
| 457 |
</div>
|
| 458 |
-
</>
|
| 459 |
-
)}
|
| 460 |
</div>
|
| 461 |
))}
|
| 462 |
</div>
|
|
|
|
| 1 |
+
import { Search, ShoppingBag, Check, X, Heart, Play, Star, ChevronLeft, ChevronRight, Plus } from 'lucide-react';
|
| 2 |
import { useState, useMemo, useEffect, useRef } from 'react';
|
| 3 |
import { SKILLS_DATA, type Skill } from '../../data/skillsData';
|
| 4 |
import { SkillModal } from '../common/SkillModal';
|
|
|
|
| 6 |
import { cn } from '../../utils/cn';
|
| 7 |
import { toast } from 'sonner';
|
| 8 |
import { useLanguage } from '../../contexts/LanguageContext';
|
|
|
|
| 9 |
import { useDebounce } from '../../hooks/useDebounce';
|
| 10 |
import { CANDY_EMOJIS } from '../../utils/candy';
|
| 11 |
|
|
|
|
| 17 |
cart: Set<string>;
|
| 18 |
onToggleCart: (id: string) => void;
|
| 19 |
onRunSkill: (skill: Skill) => void;
|
| 20 |
+
onMatchCraving?: (tags: string[]) => void;
|
| 21 |
+
userCandies?: Skill[];
|
| 22 |
+
onPostCandy?: () => void;
|
| 23 |
+
onPostCraving?: () => void;
|
| 24 |
}
|
| 25 |
|
| 26 |
const getCategoryColor = (category: string) => {
|
|
|
|
| 54 |
cart,
|
| 55 |
onToggleCart,
|
| 56 |
onRunSkill,
|
| 57 |
+
onMatchCraving,
|
| 58 |
+
userCandies = [],
|
| 59 |
+
onPostCandy,
|
| 60 |
+
onPostCraving,
|
| 61 |
}: SkillsGridProps) {
|
| 62 |
const { t } = useLanguage();
|
|
|
|
| 63 |
const debouncedSearchQuery = useDebounce(searchQuery, 300);
|
| 64 |
const isDebouncing = searchQuery !== debouncedSearchQuery;
|
| 65 |
const [selectedSkill, setSelectedSkill] = useState<Skill | null>(null);
|
|
|
|
| 110 |
}
|
| 111 |
};
|
| 112 |
|
| 113 |
+
const allSkills = useMemo(() => [...userCandies, ...SKILLS_DATA], [userCandies]);
|
| 114 |
+
|
| 115 |
const filteredSkills = useMemo(() => {
|
| 116 |
+
const filtered = allSkills.filter((skill) => {
|
| 117 |
+
const matchesSearch =
|
| 118 |
+
skill.name.toLowerCase().includes(debouncedSearchQuery.toLowerCase()) ||
|
| 119 |
+
skill.description.toLowerCase().includes(debouncedSearchQuery.toLowerCase()) ||
|
| 120 |
+
skill.tags.some(t => t.toLowerCase().includes(debouncedSearchQuery.toLowerCase()));
|
| 121 |
+
|
| 122 |
+
const matchesTag = tagFilter ?
|
| 123 |
+
(skill.tags.includes(tagFilter) || skill.category === tagFilter) : true;
|
| 124 |
+
|
| 125 |
+
return matchesSearch && matchesTag;
|
| 126 |
+
});
|
| 127 |
+
// User-posted candies always float to top, then sort by popularity
|
| 128 |
+
return filtered.sort((a, b) => {
|
| 129 |
+
const aUser = a.id.startsWith('user-candy-') ? 1 : 0;
|
| 130 |
+
const bUser = b.id.startsWith('user-candy-') ? 1 : 0;
|
| 131 |
+
if (aUser !== bUser) return bUser - aUser;
|
| 132 |
+
return (b.popularity || 0) - (a.popularity || 0);
|
| 133 |
+
});
|
| 134 |
+
}, [debouncedSearchQuery, tagFilter, allSkills]);
|
| 135 |
|
| 136 |
const totalPages = Math.max(1, Math.ceil(filteredSkills.length / ITEMS_PER_PAGE));
|
| 137 |
const pageSkills = filteredSkills.slice(currentPage * ITEMS_PER_PAGE, (currentPage + 1) * ITEMS_PER_PAGE);
|
|
|
|
| 229 |
</div>
|
| 230 |
</div>
|
| 231 |
|
| 232 |
+
<div className="flex gap-3 items-center w-full md:w-auto">
|
| 233 |
+
<div className="relative flex-1 md:w-80">
|
| 234 |
<Search className="absolute left-4 top-1/2 -translate-y-1/2 h-4 w-4 text-foreground-tertiary" />
|
| 235 |
<input
|
| 236 |
ref={searchInputRef}
|
|
|
|
| 250 |
<span className="text-xs">⌘</span>K
|
| 251 |
</kbd>
|
| 252 |
</div>
|
| 253 |
+
{onPostCandy && (
|
| 254 |
+
<button
|
| 255 |
+
onClick={onPostCandy}
|
| 256 |
+
className="h-11 px-4 flex items-center gap-2 bg-gradient-to-r from-rose-500 to-pink-500 text-white rounded-xl font-body font-semibold text-sm hover:shadow-[0_4px_20px_rgba(244,63,94,0.4)] transition-all duration-200 btn-press whitespace-nowrap shadow-[0_2px_12px_rgba(244,63,94,0.25)]"
|
| 257 |
+
>
|
| 258 |
+
<Plus className="w-4 h-4" />
|
| 259 |
+
Post Candy
|
| 260 |
+
</button>
|
| 261 |
+
)}
|
| 262 |
+
{onPostCraving && (
|
| 263 |
+
<button
|
| 264 |
+
onClick={onPostCraving}
|
| 265 |
+
className="h-11 px-4 flex items-center gap-2 bg-blue-500/10 border border-blue-500/30 text-blue-500 rounded-xl font-body font-semibold text-sm hover:bg-blue-500/20 hover:border-blue-500/50 transition-all duration-200 btn-press whitespace-nowrap"
|
| 266 |
+
>
|
| 267 |
+
<Plus className="w-4 h-4" />
|
| 268 |
+
Post Craving
|
| 269 |
+
</button>
|
| 270 |
+
)}
|
| 271 |
</div>
|
| 272 |
</div>
|
| 273 |
|
|
|
|
| 319 |
'card-luxe gradient-border'
|
| 320 |
)}
|
| 321 |
>
|
| 322 |
+
{/* Your Candy badge */}
|
| 323 |
+
{skill.id.startsWith('user-candy-') && (
|
| 324 |
+
<div className="px-5 pt-3 pb-0">
|
| 325 |
+
<span className="text-[10px] font-semibold bg-primary/10 text-primary px-2 py-0.5 rounded-full border border-primary/20 font-mono">
|
| 326 |
+
✦ Your Candy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
</span>
|
| 328 |
</div>
|
| 329 |
+
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
{/* Card Header */}
|
| 331 |
+
<div className={cn('p-5', skill.id.startsWith('user-candy-') ? 'pt-2 pb-0' : 'pb-0')}>
|
| 332 |
<div className="flex items-start gap-3.5">
|
| 333 |
<div className={cn(
|
| 334 |
'w-12 h-12 rounded-2xl flex items-center justify-center text-2xl flex-shrink-0',
|
|
|
|
| 391 |
<Play className="w-3.5 h-3.5 fill-current" />
|
| 392 |
{t('skills.runSkill')}
|
| 393 |
</button>
|
| 394 |
+
{onMatchCraving && (
|
| 395 |
+
<button
|
| 396 |
+
onClick={(e) => { e.stopPropagation(); onMatchCraving(skill.tags); }}
|
| 397 |
+
className="h-9 px-2.5 rounded-lg flex items-center justify-center gap-1.5 text-[11px] font-body font-medium bg-secondary/50 text-foreground-tertiary hover:text-primary hover:bg-primary/10 transition-all duration-200 btn-press whitespace-nowrap"
|
| 398 |
+
title="Find matching cravings"
|
| 399 |
+
>
|
| 400 |
+
😋
|
| 401 |
+
</button>
|
| 402 |
+
)}
|
| 403 |
<button
|
| 404 |
onClick={(e) => { e.stopPropagation(); handleLike(skill.id); }}
|
| 405 |
className={cn(
|
|
|
|
| 423 |
{cart.has(skill.id) ? <Check className="w-3.5 h-3.5" /> : <ShoppingBag className="w-3.5 h-3.5" />}
|
| 424 |
</button>
|
| 425 |
</div>
|
|
|
|
|
|
|
| 426 |
</div>
|
| 427 |
))}
|
| 428 |
</div>
|
src/components/layout/Header.tsx
CHANGED
|
@@ -1,8 +1,19 @@
|
|
| 1 |
-
import {
|
| 2 |
-
|
| 3 |
-
import { useNavigate } from 'react-router-dom';
|
| 4 |
import type { User } from '@supabase/supabase-js';
|
| 5 |
import { supabase } from '../../lib/supabaseClient';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
interface HeaderProps {
|
| 8 |
onOpenAuth: () => void;
|
|
@@ -12,107 +23,286 @@ interface HeaderProps {
|
|
| 12 |
onNavFind: () => void;
|
| 13 |
onNavCd: () => void;
|
| 14 |
onNavMan: () => void;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
}
|
| 16 |
|
| 17 |
-
export function Header({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
const navigate = useNavigate();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
return (
|
| 21 |
-
<
|
| 22 |
-
<
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
<
|
| 26 |
-
<
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
</div>
|
| 38 |
-
</div>
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
<
|
| 44 |
-
<span className="group-hover:translate-x-0.5 transition-transform">find --sweet</span>
|
| 45 |
-
</button>
|
| 46 |
-
<button onClick={onNavCd} className="hover:text-primary transition-colors flex items-center gap-2 group cursor-pointer rounded px-1 py-0.5 focus:outline-none focus:ring-2 focus:ring-primary/30">
|
| 47 |
-
<span className="text-secondary">$</span>
|
| 48 |
-
<span className="group-hover:translate-x-0.5 transition-transform">cd /chocolates</span>
|
| 49 |
-
</button>
|
| 50 |
-
<button onClick={onNavMan} className="hover:text-primary transition-colors flex items-center gap-2 group cursor-pointer rounded px-1 py-0.5 focus:outline-none focus:ring-2 focus:ring-primary/30">
|
| 51 |
-
<span className="text-secondary">$</span>
|
| 52 |
-
<span className="group-hover:translate-x-0.5 transition-transform">man recipes</span>
|
| 53 |
-
</button>
|
| 54 |
-
|
| 55 |
-
{user && (
|
| 56 |
-
<>
|
| 57 |
<button
|
| 58 |
-
onClick={() =>
|
| 59 |
-
className="
|
|
|
|
| 60 |
>
|
| 61 |
-
<
|
| 62 |
-
<span className="group-hover:translate-x-0.5 transition-transform">create skills</span>
|
| 63 |
</button>
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
className="
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
/>
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
</div>
|
|
|
|
| 98 |
<button
|
| 99 |
-
onClick={
|
| 100 |
-
className="
|
| 101 |
-
title="Sign Out"
|
| 102 |
>
|
| 103 |
-
|
| 104 |
</button>
|
| 105 |
-
|
| 106 |
-
|
|
|
|
| 107 |
<button
|
| 108 |
-
onClick={
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
|
|
|
| 112 |
</button>
|
| 113 |
-
|
| 114 |
</div>
|
| 115 |
-
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
);
|
| 118 |
}
|
|
|
|
| 1 |
+
import { useState, useEffect, useRef } from 'react';
|
| 2 |
+
import { ShoppingBag, User as UserIcon, LogOut, Plus, Library, Menu, X, Moon, Sun, Check, Settings, Globe } from 'lucide-react';
|
| 3 |
+
import { useNavigate, useLocation } from 'react-router-dom';
|
| 4 |
import type { User } from '@supabase/supabase-js';
|
| 5 |
import { supabase } from '../../lib/supabaseClient';
|
| 6 |
+
import { useLanguage } from '../../contexts/LanguageContext';
|
| 7 |
+
import { cn } from '../../utils/cn';
|
| 8 |
+
|
| 9 |
+
const themes = [
|
| 10 |
+
{ id: 'indigo', name: 'Indigo', color: '#6366F1', light: '#818CF8' },
|
| 11 |
+
{ id: 'blue', name: 'Ocean', color: '#3B82F6', light: '#60A5FA' },
|
| 12 |
+
{ id: 'emerald', name: 'Emerald', color: '#10B981', light: '#34D399' },
|
| 13 |
+
{ id: 'amber', name: 'Sunset', color: '#F59E0B', light: '#FBBF24' },
|
| 14 |
+
{ id: 'rose', name: 'Rose', color: '#F43F5E', light: '#FB7185' },
|
| 15 |
+
{ id: 'violet', name: 'Purple', color: '#8B5CF6', light: '#A78BFA' },
|
| 16 |
+
];
|
| 17 |
|
| 18 |
interface HeaderProps {
|
| 19 |
onOpenAuth: () => void;
|
|
|
|
| 23 |
onNavFind: () => void;
|
| 24 |
onNavCd: () => void;
|
| 25 |
onNavMan: () => void;
|
| 26 |
+
isDarkMode: boolean;
|
| 27 |
+
onToggleTheme: () => void;
|
| 28 |
+
currentTheme: string;
|
| 29 |
+
onChangeTheme: (theme: string) => void;
|
| 30 |
}
|
| 31 |
|
| 32 |
+
export function Header({
|
| 33 |
+
onOpenAuth,
|
| 34 |
+
onOpenCart,
|
| 35 |
+
user,
|
| 36 |
+
cartCount,
|
| 37 |
+
onNavFind,
|
| 38 |
+
onNavCd,
|
| 39 |
+
onNavMan,
|
| 40 |
+
isDarkMode,
|
| 41 |
+
onToggleTheme,
|
| 42 |
+
currentTheme,
|
| 43 |
+
onChangeTheme,
|
| 44 |
+
}: HeaderProps) {
|
| 45 |
const navigate = useNavigate();
|
| 46 |
+
const location = useLocation();
|
| 47 |
+
const { t, language, setLanguage } = useLanguage();
|
| 48 |
+
const [mobileOpen, setMobileOpen] = useState(false);
|
| 49 |
+
const [settingsOpen, setSettingsOpen] = useState(false);
|
| 50 |
+
const settingsRef = useRef<HTMLDivElement>(null);
|
| 51 |
+
|
| 52 |
+
useEffect(() => {
|
| 53 |
+
function handleClickOutside(e: MouseEvent) {
|
| 54 |
+
if (settingsRef.current && !settingsRef.current.contains(e.target as Node)) {
|
| 55 |
+
setSettingsOpen(false);
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
document.addEventListener('mousedown', handleClickOutside);
|
| 59 |
+
return () => document.removeEventListener('mousedown', handleClickOutside);
|
| 60 |
+
}, []);
|
| 61 |
+
|
| 62 |
+
const navLinks = [
|
| 63 |
+
{ label: t('nav.find.user'), action: onNavFind },
|
| 64 |
+
{ label: t('nav.cd.user'), action: onNavCd },
|
| 65 |
+
{ label: t('nav.man.user'), action: onNavMan },
|
| 66 |
+
];
|
| 67 |
|
| 68 |
return (
|
| 69 |
+
<>
|
| 70 |
+
<header className="sticky top-0 z-50 w-full border-b border-border bg-background/95 backdrop-blur-sm">
|
| 71 |
+
<div className="flex h-16 items-center justify-between px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto">
|
| 72 |
+
{/* Logo */}
|
| 73 |
+
<div className="flex items-center gap-8">
|
| 74 |
+
<button
|
| 75 |
+
onClick={() => navigate('/')}
|
| 76 |
+
className="flex items-center gap-2 hover:opacity-80 transition-opacity"
|
| 77 |
+
>
|
| 78 |
+
<span className="font-candy font-bold text-foreground text-lg">🍭 Candy Shop</span>
|
| 79 |
+
</button>
|
| 80 |
+
|
| 81 |
+
{/* Desktop Nav */}
|
| 82 |
+
<nav className="hidden md:flex items-center gap-1">
|
| 83 |
+
{navLinks.map((link) => (
|
| 84 |
+
<button
|
| 85 |
+
key={link.label}
|
| 86 |
+
onClick={link.action}
|
| 87 |
+
className="px-3 py-2 text-sm text-foreground-secondary hover:text-foreground rounded-lg hover:bg-secondary transition-colors"
|
| 88 |
+
>
|
| 89 |
+
{link.label}
|
| 90 |
+
</button>
|
| 91 |
+
))}
|
| 92 |
+
{user && (
|
| 93 |
+
<>
|
| 94 |
+
<button
|
| 95 |
+
onClick={() => navigate('/skills/create')}
|
| 96 |
+
className={cn(
|
| 97 |
+
'px-3 py-2 text-sm rounded-lg transition-colors flex items-center gap-1.5',
|
| 98 |
+
location.pathname === '/skills/create'
|
| 99 |
+
? 'text-primary bg-primary/10'
|
| 100 |
+
: 'text-foreground-secondary hover:text-foreground hover:bg-secondary'
|
| 101 |
+
)}
|
| 102 |
+
>
|
| 103 |
+
<Plus className="w-3.5 h-3.5" />
|
| 104 |
+
{t('nav.create.user')}
|
| 105 |
+
</button>
|
| 106 |
+
<button
|
| 107 |
+
onClick={() => navigate('/skills/library')}
|
| 108 |
+
className={cn(
|
| 109 |
+
'px-3 py-2 text-sm rounded-lg transition-colors flex items-center gap-1.5',
|
| 110 |
+
location.pathname === '/skills/library'
|
| 111 |
+
? 'text-primary bg-primary/10'
|
| 112 |
+
: 'text-foreground-secondary hover:text-foreground hover:bg-secondary'
|
| 113 |
+
)}
|
| 114 |
+
>
|
| 115 |
+
<Library className="w-3.5 h-3.5" />
|
| 116 |
+
{t('nav.library.user')}
|
| 117 |
+
</button>
|
| 118 |
+
</>
|
| 119 |
+
)}
|
| 120 |
+
</nav>
|
| 121 |
</div>
|
|
|
|
| 122 |
|
| 123 |
+
{/* Right side */}
|
| 124 |
+
<div className="flex items-center gap-2">
|
| 125 |
+
{/* Settings Dropdown */}
|
| 126 |
+
<div ref={settingsRef} className="relative hidden md:block">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
<button
|
| 128 |
+
onClick={() => setSettingsOpen(!settingsOpen)}
|
| 129 |
+
className="p-2 text-foreground-secondary hover:text-foreground hover:bg-secondary rounded-lg transition-colors"
|
| 130 |
+
aria-label="Settings"
|
| 131 |
>
|
| 132 |
+
<Settings className="w-4.5 h-4.5" />
|
|
|
|
| 133 |
</button>
|
| 134 |
+
|
| 135 |
+
{settingsOpen && (
|
| 136 |
+
<div className="absolute right-0 top-full mt-2 w-56 bg-card border border-border rounded-xl shadow-lg py-2 animate-fade-in z-50">
|
| 137 |
+
{/* Theme Colors */}
|
| 138 |
+
<div className="px-3 py-1.5 text-xs font-medium text-foreground-tertiary uppercase tracking-wider">
|
| 139 |
+
{t('chooseTheme')}
|
| 140 |
+
</div>
|
| 141 |
+
<div className="px-3 py-2 flex gap-2">
|
| 142 |
+
{themes.map((theme) => (
|
| 143 |
+
<button
|
| 144 |
+
key={theme.id}
|
| 145 |
+
onClick={() => onChangeTheme(theme.id)}
|
| 146 |
+
className={cn(
|
| 147 |
+
'w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all',
|
| 148 |
+
currentTheme === theme.id
|
| 149 |
+
? 'border-foreground scale-110'
|
| 150 |
+
: 'border-transparent hover:scale-110'
|
| 151 |
+
)}
|
| 152 |
+
style={{ backgroundColor: isDarkMode ? theme.light : theme.color }}
|
| 153 |
+
title={t(`theme.${theme.id}`)}
|
| 154 |
+
>
|
| 155 |
+
{currentTheme === theme.id && <Check className="w-3 h-3 text-white" />}
|
| 156 |
+
</button>
|
| 157 |
+
))}
|
| 158 |
+
</div>
|
| 159 |
+
|
| 160 |
+
<div className="h-px bg-border my-1" />
|
| 161 |
+
|
| 162 |
+
{/* Dark Mode */}
|
| 163 |
+
<button
|
| 164 |
+
onClick={onToggleTheme}
|
| 165 |
+
className="w-full flex items-center gap-3 px-3 py-2 text-sm text-foreground-secondary hover:text-foreground hover:bg-secondary transition-colors"
|
| 166 |
+
>
|
| 167 |
+
{isDarkMode ? <Sun className="w-4 h-4" /> : <Moon className="w-4 h-4" />}
|
| 168 |
+
<span>{isDarkMode ? t('lightMode') : t('darkMode')}</span>
|
| 169 |
+
</button>
|
| 170 |
+
|
| 171 |
+
{/* Language */}
|
| 172 |
+
<button
|
| 173 |
+
onClick={() => setLanguage(language === 'en' ? 'zh' : 'en')}
|
| 174 |
+
className="w-full flex items-center gap-3 px-3 py-2 text-sm text-foreground-secondary hover:text-foreground hover:bg-secondary transition-colors"
|
| 175 |
+
>
|
| 176 |
+
<Globe className="w-4 h-4" />
|
| 177 |
+
<span>{language === 'en' ? '中文' : 'English'}</span>
|
| 178 |
+
</button>
|
| 179 |
+
|
| 180 |
+
</div>
|
| 181 |
+
)}
|
| 182 |
+
</div>
|
| 183 |
+
|
| 184 |
+
{/* Cart */}
|
| 185 |
+
<button
|
| 186 |
+
onClick={onOpenCart}
|
| 187 |
+
className="p-2 text-foreground-secondary hover:text-foreground hover:bg-secondary rounded-lg transition-colors relative"
|
| 188 |
+
aria-label={`${t('cart')} (${cartCount})`}
|
| 189 |
+
>
|
| 190 |
+
<ShoppingBag className="w-4.5 h-4.5" />
|
| 191 |
+
{cartCount > 0 && (
|
| 192 |
+
<span className="absolute -top-0.5 -right-0.5 w-4 h-4 bg-primary text-primary-foreground text-[10px] font-bold rounded-full flex items-center justify-center">
|
| 193 |
+
{cartCount}
|
| 194 |
</span>
|
| 195 |
+
)}
|
| 196 |
+
</button>
|
| 197 |
+
|
| 198 |
+
{/* Auth */}
|
| 199 |
+
{user ? (
|
| 200 |
+
<div className="hidden md:flex items-center gap-2">
|
| 201 |
+
<div className="flex items-center gap-2 px-3 py-1.5 rounded-lg hover:bg-secondary transition-colors">
|
| 202 |
+
{user.user_metadata?.avatar_url ? (
|
| 203 |
+
<img
|
| 204 |
+
src={user.user_metadata.avatar_url}
|
| 205 |
+
alt="Avatar"
|
| 206 |
+
className="w-6 h-6 rounded-full"
|
| 207 |
+
/>
|
| 208 |
+
) : (
|
| 209 |
+
<UserIcon className="w-4 h-4 text-foreground-secondary" />
|
| 210 |
+
)}
|
| 211 |
+
<span className="text-sm text-foreground">
|
| 212 |
+
{user.user_metadata?.full_name || user.email?.split('@')[0] || 'User'}
|
| 213 |
+
</span>
|
| 214 |
+
</div>
|
| 215 |
+
<button
|
| 216 |
+
onClick={() => supabase.auth.signOut()}
|
| 217 |
+
className="p-2 text-foreground-secondary hover:text-error rounded-lg transition-colors"
|
| 218 |
+
title={t('logout')}
|
| 219 |
+
>
|
| 220 |
+
<LogOut className="w-4 h-4" />
|
| 221 |
+
</button>
|
| 222 |
</div>
|
| 223 |
+
) : (
|
| 224 |
<button
|
| 225 |
+
onClick={onOpenAuth}
|
| 226 |
+
className="hidden md:flex items-center h-9 px-4 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:bg-primary-hover transition-colors"
|
|
|
|
| 227 |
>
|
| 228 |
+
{t('login')}
|
| 229 |
</button>
|
| 230 |
+
)}
|
| 231 |
+
|
| 232 |
+
{/* Mobile Menu Toggle */}
|
| 233 |
<button
|
| 234 |
+
onClick={() => setMobileOpen(!mobileOpen)}
|
| 235 |
+
className="md:hidden p-2 text-foreground-secondary hover:text-foreground rounded-lg transition-colors"
|
| 236 |
+
aria-label="Menu"
|
| 237 |
+
>
|
| 238 |
+
{mobileOpen ? <X className="w-5 h-5" /> : <Menu className="w-5 h-5" />}
|
| 239 |
</button>
|
| 240 |
+
</div>
|
| 241 |
</div>
|
| 242 |
+
|
| 243 |
+
{/* Mobile Menu */}
|
| 244 |
+
{mobileOpen && (
|
| 245 |
+
<div className="md:hidden border-t border-border bg-background animate-fade-in">
|
| 246 |
+
<div className="px-4 py-4 space-y-1">
|
| 247 |
+
{navLinks.map((link) => (
|
| 248 |
+
<button
|
| 249 |
+
key={link.label}
|
| 250 |
+
onClick={() => { link.action(); setMobileOpen(false); }}
|
| 251 |
+
className="w-full text-left px-3 py-2.5 text-sm text-foreground-secondary hover:text-foreground hover:bg-secondary rounded-lg transition-colors"
|
| 252 |
+
>
|
| 253 |
+
{link.label}
|
| 254 |
+
</button>
|
| 255 |
+
))}
|
| 256 |
+
{user && (
|
| 257 |
+
<>
|
| 258 |
+
<button
|
| 259 |
+
onClick={() => { navigate('/skills/create'); setMobileOpen(false); }}
|
| 260 |
+
className="w-full text-left px-3 py-2.5 text-sm text-foreground-secondary hover:text-foreground hover:bg-secondary rounded-lg transition-colors flex items-center gap-2"
|
| 261 |
+
>
|
| 262 |
+
<Plus className="w-4 h-4" /> {t('nav.create.user')}
|
| 263 |
+
</button>
|
| 264 |
+
<button
|
| 265 |
+
onClick={() => { navigate('/skills/library'); setMobileOpen(false); }}
|
| 266 |
+
className="w-full text-left px-3 py-2.5 text-sm text-foreground-secondary hover:text-foreground hover:bg-secondary rounded-lg transition-colors flex items-center gap-2"
|
| 267 |
+
>
|
| 268 |
+
<Library className="w-4 h-4" /> {t('nav.library.user')}
|
| 269 |
+
</button>
|
| 270 |
+
</>
|
| 271 |
+
)}
|
| 272 |
+
|
| 273 |
+
<div className="h-px bg-border my-2" />
|
| 274 |
+
|
| 275 |
+
<button
|
| 276 |
+
onClick={onToggleTheme}
|
| 277 |
+
className="w-full text-left px-3 py-2.5 text-sm text-foreground-secondary hover:text-foreground hover:bg-secondary rounded-lg transition-colors flex items-center gap-2"
|
| 278 |
+
>
|
| 279 |
+
{isDarkMode ? <Sun className="w-4 h-4" /> : <Moon className="w-4 h-4" />}
|
| 280 |
+
{isDarkMode ? t('lightMode') : t('darkMode')}
|
| 281 |
+
</button>
|
| 282 |
+
|
| 283 |
+
<button
|
| 284 |
+
onClick={() => setLanguage(language === 'en' ? 'zh' : 'en')}
|
| 285 |
+
className="w-full text-left px-3 py-2.5 text-sm text-foreground-secondary hover:text-foreground hover:bg-secondary rounded-lg transition-colors flex items-center gap-2"
|
| 286 |
+
>
|
| 287 |
+
<Globe className="w-4 h-4" />
|
| 288 |
+
{language === 'en' ? '中文' : 'English'}
|
| 289 |
+
</button>
|
| 290 |
+
|
| 291 |
+
{!user && (
|
| 292 |
+
<>
|
| 293 |
+
<div className="h-px bg-border my-2" />
|
| 294 |
+
<button
|
| 295 |
+
onClick={() => { onOpenAuth(); setMobileOpen(false); }}
|
| 296 |
+
className="w-full h-10 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:bg-primary-hover transition-colors"
|
| 297 |
+
>
|
| 298 |
+
{t('login')}
|
| 299 |
+
</button>
|
| 300 |
+
</>
|
| 301 |
+
)}
|
| 302 |
+
</div>
|
| 303 |
+
</div>
|
| 304 |
+
)}
|
| 305 |
+
</header>
|
| 306 |
+
</>
|
| 307 |
);
|
| 308 |
}
|
src/components/layout/Layout.tsx
CHANGED
|
@@ -90,6 +90,10 @@ interface LayoutProps {
|
|
| 90 |
onNavFind: () => void;
|
| 91 |
onNavCd: () => void;
|
| 92 |
onNavMan: () => void;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
}
|
| 94 |
|
| 95 |
export function Layout({
|
|
@@ -101,6 +105,10 @@ export function Layout({
|
|
| 101 |
onNavFind,
|
| 102 |
onNavCd,
|
| 103 |
onNavMan,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
}: LayoutProps) {
|
| 105 |
const { t } = useLanguage();
|
| 106 |
const [isDarkMode, setIsDarkMode] = useState(false);
|
|
@@ -164,14 +172,16 @@ export function Layout({
|
|
| 164 |
onNavFind={onNavFind}
|
| 165 |
onNavCd={onNavCd}
|
| 166 |
onNavMan={onNavMan}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
isDarkMode={isDarkMode}
|
| 168 |
onToggleTheme={toggleTheme}
|
| 169 |
currentTheme={currentTheme}
|
| 170 |
onChangeTheme={changeTheme}
|
| 171 |
/>
|
| 172 |
-
<main className="lg:pl-64 pt-14
|
| 173 |
-
{/* Spacer for title bar overlay */}
|
| 174 |
-
<div className="hidden lg:block h-11" aria-hidden="true" />
|
| 175 |
<div className="container max-w-7xl mx-auto px-4 sm:px-8 py-8 md:py-12">{children}</div>
|
| 176 |
</main>
|
| 177 |
|
|
|
|
| 90 |
onNavFind: () => void;
|
| 91 |
onNavCd: () => void;
|
| 92 |
onNavMan: () => void;
|
| 93 |
+
onNavCandy: () => void;
|
| 94 |
+
onNavCraving: () => void;
|
| 95 |
+
onNavPostCraving: () => void;
|
| 96 |
+
onNavPostCandy: () => void;
|
| 97 |
}
|
| 98 |
|
| 99 |
export function Layout({
|
|
|
|
| 105 |
onNavFind,
|
| 106 |
onNavCd,
|
| 107 |
onNavMan,
|
| 108 |
+
onNavCandy,
|
| 109 |
+
onNavCraving,
|
| 110 |
+
onNavPostCraving,
|
| 111 |
+
onNavPostCandy,
|
| 112 |
}: LayoutProps) {
|
| 113 |
const { t } = useLanguage();
|
| 114 |
const [isDarkMode, setIsDarkMode] = useState(false);
|
|
|
|
| 172 |
onNavFind={onNavFind}
|
| 173 |
onNavCd={onNavCd}
|
| 174 |
onNavMan={onNavMan}
|
| 175 |
+
onNavCandy={onNavCandy}
|
| 176 |
+
onNavCraving={onNavCraving}
|
| 177 |
+
onNavPostCraving={onNavPostCraving}
|
| 178 |
+
onNavPostCandy={onNavPostCandy}
|
| 179 |
isDarkMode={isDarkMode}
|
| 180 |
onToggleTheme={toggleTheme}
|
| 181 |
currentTheme={currentTheme}
|
| 182 |
onChangeTheme={changeTheme}
|
| 183 |
/>
|
| 184 |
+
<main className="lg:pl-64 pt-14 min-h-screen relative">
|
|
|
|
|
|
|
| 185 |
<div className="container max-w-7xl mx-auto px-4 sm:px-8 py-8 md:py-12">{children}</div>
|
| 186 |
</main>
|
| 187 |
|
src/components/layout/Sidebar.tsx
CHANGED
|
@@ -1,8 +1,6 @@
|
|
| 1 |
import { useState, useEffect } from 'react';
|
| 2 |
import { useNavigate, useLocation } from 'react-router-dom';
|
| 3 |
import {
|
| 4 |
-
Search,
|
| 5 |
-
Grid3X3,
|
| 6 |
BookOpen,
|
| 7 |
Plus,
|
| 8 |
Library,
|
|
@@ -12,20 +10,20 @@ import {
|
|
| 12 |
ChevronLeft,
|
| 13 |
ChevronRight,
|
| 14 |
Menu,
|
| 15 |
-
X,
|
| 16 |
Moon,
|
| 17 |
Sun,
|
| 18 |
Palette,
|
| 19 |
Check,
|
| 20 |
ChevronDown,
|
| 21 |
Sparkles,
|
| 22 |
-
|
|
|
|
| 23 |
} from 'lucide-react';
|
|
|
|
| 24 |
import type { User as SupabaseUser } from '@supabase/supabase-js';
|
| 25 |
import { supabase } from '../../lib/supabaseClient';
|
| 26 |
import { cn } from '../../utils/cn';
|
| 27 |
import { useLanguage } from '../../contexts/LanguageContext';
|
| 28 |
-
import { useVersionMode } from '../../contexts/VersionModeContext';
|
| 29 |
|
| 30 |
interface SidebarProps {
|
| 31 |
onOpenAuth: () => void;
|
|
@@ -35,64 +33,82 @@ interface SidebarProps {
|
|
| 35 |
onNavFind: () => void;
|
| 36 |
onNavCd: () => void;
|
| 37 |
onNavMan: () => void;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
isDarkMode: boolean;
|
| 39 |
onToggleTheme: () => void;
|
| 40 |
currentTheme: string;
|
| 41 |
onChangeTheme: (theme: string) => void;
|
| 42 |
}
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
{ id: 'man', labelKey: 'nav.man', userLabelKey: 'nav.man.user', icon: BookOpen, action: 'man' },
|
| 48 |
];
|
| 49 |
|
| 50 |
-
const userNavItems = [
|
| 51 |
-
{ id: 'create', labelKey: 'nav.create', userLabelKey: 'nav.create.user', icon:
|
| 52 |
{ id: 'library', labelKey: 'nav.library', userLabelKey: 'nav.library.user', icon: Library, action: 'library' },
|
| 53 |
];
|
| 54 |
|
| 55 |
-
// 主题配置
|
| 56 |
const themes = [
|
| 57 |
-
{
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
light: '#818CF8',
|
| 62 |
-
description: 'Professional & Modern',
|
| 63 |
-
},
|
| 64 |
-
{
|
| 65 |
-
id: 'blue',
|
| 66 |
-
name: 'Ocean',
|
| 67 |
-
color: '#3B82F6',
|
| 68 |
-
light: '#60A5FA',
|
| 69 |
-
description: 'Calm & Trustworthy',
|
| 70 |
-
},
|
| 71 |
-
{
|
| 72 |
-
id: 'emerald',
|
| 73 |
-
name: 'Emerald',
|
| 74 |
-
color: '#10B981',
|
| 75 |
-
light: '#34D399',
|
| 76 |
-
description: 'Fresh & Natural',
|
| 77 |
-
},
|
| 78 |
-
{
|
| 79 |
-
id: 'amber',
|
| 80 |
-
name: 'Sunset',
|
| 81 |
-
color: '#F59E0B',
|
| 82 |
-
light: '#FBBF24',
|
| 83 |
-
description: 'Warm & Energetic',
|
| 84 |
-
},
|
| 85 |
{ id: 'rose', name: 'Rose', color: '#F43F5E', light: '#FB7185', description: 'Bold & Vibrant' },
|
| 86 |
-
{
|
| 87 |
-
id: 'violet',
|
| 88 |
-
name: 'Purple',
|
| 89 |
-
color: '#8B5CF6',
|
| 90 |
-
light: '#A78BFA',
|
| 91 |
-
description: 'Creative & Elegant',
|
| 92 |
-
},
|
| 93 |
];
|
| 94 |
|
| 95 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
export function Sidebar({
|
| 98 |
onOpenAuth,
|
|
@@ -102,6 +118,10 @@ export function Sidebar({
|
|
| 102 |
onNavFind,
|
| 103 |
onNavCd,
|
| 104 |
onNavMan,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
isDarkMode,
|
| 106 |
onToggleTheme,
|
| 107 |
currentTheme,
|
|
@@ -110,13 +130,19 @@ export function Sidebar({
|
|
| 110 |
const navigate = useNavigate();
|
| 111 |
const location = useLocation();
|
| 112 |
const { t, language, setLanguage } = useLanguage();
|
| 113 |
-
const { mode, toggleMode } = useVersionMode();
|
| 114 |
|
| 115 |
-
// Determine which nav item is active based on current route
|
| 116 |
const getActiveAction = (): string | null => {
|
| 117 |
if (location.pathname === '/skills/create') return 'create';
|
| 118 |
if (location.pathname === '/skills/library') return 'library';
|
| 119 |
-
if (location.pathname === '/')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
return null;
|
| 121 |
};
|
| 122 |
const activeAction = getActiveAction();
|
|
@@ -124,7 +150,20 @@ export function Sidebar({
|
|
| 124 |
const [mobileOpen, setMobileOpen] = useState(false);
|
| 125 |
const [showThemeSelector, setShowThemeSelector] = useState(false);
|
| 126 |
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
useEffect(() => {
|
| 129 |
function handleClickOutside(event: MouseEvent) {
|
| 130 |
const target = event.target as HTMLElement;
|
|
@@ -138,21 +177,15 @@ export function Sidebar({
|
|
| 138 |
|
| 139 |
const handleNavAction = (action: string) => {
|
| 140 |
switch (action) {
|
| 141 |
-
case '
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
case '
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
case 'man':
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
case 'create':
|
| 151 |
-
navigate('/skills/create');
|
| 152 |
-
break;
|
| 153 |
-
case 'library':
|
| 154 |
-
navigate('/skills/library');
|
| 155 |
-
break;
|
| 156 |
}
|
| 157 |
setMobileOpen(false);
|
| 158 |
};
|
|
@@ -167,31 +200,6 @@ export function Sidebar({
|
|
| 167 |
setMobileOpen(false);
|
| 168 |
};
|
| 169 |
|
| 170 |
-
const NavButton = ({ item }: { item: (typeof navItems)[0] }) => {
|
| 171 |
-
const isActive = activeAction === item.action;
|
| 172 |
-
const label = mode === 'user' ? t(item.userLabelKey) : t(item.labelKey);
|
| 173 |
-
return (
|
| 174 |
-
<button
|
| 175 |
-
onClick={() => handleNavAction(item.action)}
|
| 176 |
-
className={cn(
|
| 177 |
-
'w-full flex items-center gap-3 px-3 py-2.5 rounded-lg',
|
| 178 |
-
'text-sm font-mono transition-all duration-200 cursor-pointer',
|
| 179 |
-
'focus:outline-none focus:ring-2 focus:ring-primary/30',
|
| 180 |
-
isActive
|
| 181 |
-
? 'bg-gradient-to-r from-primary/10 to-primary/5 text-primary border border-primary/20 shadow-sm'
|
| 182 |
-
: 'hover:bg-secondary/70 hover:text-foreground border border-transparent',
|
| 183 |
-
collapsed ? 'justify-center' : 'justify-start'
|
| 184 |
-
)}
|
| 185 |
-
title={collapsed ? label : undefined}
|
| 186 |
-
aria-label={label}
|
| 187 |
-
aria-current={isActive ? 'page' : undefined}
|
| 188 |
-
>
|
| 189 |
-
<item.icon className={cn('w-5 h-5 flex-shrink-0', isActive ? 'text-primary' : 'text-foreground-secondary')} />
|
| 190 |
-
{!collapsed && <span className="truncate">{label}</span>}
|
| 191 |
-
</button>
|
| 192 |
-
);
|
| 193 |
-
};
|
| 194 |
-
|
| 195 |
const themeSelector = (
|
| 196 |
<div data-theme-panel className="relative">
|
| 197 |
<button
|
|
@@ -221,7 +229,6 @@ export function Sidebar({
|
|
| 221 |
)}
|
| 222 |
</button>
|
| 223 |
|
| 224 |
-
{/* 主题选择下拉菜单 */}
|
| 225 |
{showThemeSelector && (
|
| 226 |
<div
|
| 227 |
className={cn(
|
|
@@ -270,21 +277,16 @@ export function Sidebar({
|
|
| 270 |
|
| 271 |
const sidebarContent = (
|
| 272 |
<>
|
| 273 |
-
{/* macOS Title Bar Spacer */}
|
| 274 |
-
<div className="h-11 flex-shrink-0" aria-hidden="true" />
|
| 275 |
-
|
| 276 |
-
{/* Logo */}
|
| 277 |
<div
|
| 278 |
className={cn(
|
| 279 |
-
'flex items-center gap-3 px-4 border-b border-border',
|
| 280 |
-
'py-3',
|
| 281 |
collapsed ? 'justify-center' : 'justify-between'
|
| 282 |
)}
|
| 283 |
>
|
| 284 |
{!collapsed && (
|
| 285 |
<button
|
| 286 |
onClick={() => navigate('/')}
|
| 287 |
-
className="flex items-center gap-2 hover:opacity-80 transition-opacity duration-200 cursor-pointer focus:outline-none focus:ring-2 focus:ring-primary/30 rounded-lg px-1
|
| 288 |
aria-label="Go to home page"
|
| 289 |
>
|
| 290 |
<span className="text-2xl leading-none animate-candy-float" aria-hidden="true">🍭</span>
|
|
@@ -294,10 +296,16 @@ export function Sidebar({
|
|
| 294 |
{collapsed && <span className="text-2xl leading-none animate-candy-float">🍭</span>}
|
| 295 |
</div>
|
| 296 |
|
| 297 |
-
{/* Navigation */}
|
| 298 |
<nav className="flex-1 px-3 py-4 space-y-1 overflow-y-auto">
|
| 299 |
{navItems.map((item) => (
|
| 300 |
-
<NavButton
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
))}
|
| 302 |
|
| 303 |
{user && (
|
|
@@ -310,23 +318,27 @@ export function Sidebar({
|
|
| 310 |
)}
|
| 311 |
</div>
|
| 312 |
{userNavItems.map((item) => (
|
| 313 |
-
<NavButton
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
))}
|
| 315 |
</>
|
| 316 |
)}
|
| 317 |
</nav>
|
| 318 |
|
| 319 |
-
{/* Bottom Section */}
|
| 320 |
<div
|
| 321 |
className={cn(
|
| 322 |
'border-t border-border px-3 py-4 space-y-2',
|
| 323 |
collapsed ? 'items-center' : ''
|
| 324 |
)}
|
| 325 |
>
|
| 326 |
-
{/* Theme Selector */}
|
| 327 |
{themeSelector}
|
| 328 |
|
| 329 |
-
{/* Light/Dark Mode Toggle */}
|
| 330 |
<button
|
| 331 |
onClick={onToggleTheme}
|
| 332 |
className={cn(
|
|
@@ -345,7 +357,6 @@ export function Sidebar({
|
|
| 345 |
{!collapsed && <span>{isDarkMode ? t('lightMode') : t('darkMode')}</span>}
|
| 346 |
</button>
|
| 347 |
|
| 348 |
-
{/* Language Toggle */}
|
| 349 |
<button
|
| 350 |
onClick={() => setLanguage(language === 'en' ? 'zh' : 'en')}
|
| 351 |
className={cn(
|
|
@@ -362,7 +373,6 @@ export function Sidebar({
|
|
| 362 |
{!collapsed && <span>{t('language')}</span>}
|
| 363 |
</button>
|
| 364 |
|
| 365 |
-
{/* Cart */}
|
| 366 |
<button
|
| 367 |
onClick={onOpenCart}
|
| 368 |
className={cn(
|
|
@@ -384,7 +394,6 @@ export function Sidebar({
|
|
| 384 |
{!collapsed && <span>{t('cart')}</span>}
|
| 385 |
</button>
|
| 386 |
|
| 387 |
-
{/* User Section */}
|
| 388 |
{user ? (
|
| 389 |
<div
|
| 390 |
className={cn(
|
|
@@ -393,7 +402,6 @@ export function Sidebar({
|
|
| 393 |
collapsed ? 'justify-center' : ''
|
| 394 |
)}
|
| 395 |
>
|
| 396 |
-
{/* Avatar */}
|
| 397 |
{(() => {
|
| 398 |
const avatarUrl =
|
| 399 |
user.user_metadata?.avatar_url ||
|
|
@@ -455,33 +463,6 @@ export function Sidebar({
|
|
| 455 |
</button>
|
| 456 |
)}
|
| 457 |
|
| 458 |
-
{/* Mode Switcher - Dev/User */}
|
| 459 |
-
<button
|
| 460 |
-
onClick={toggleMode}
|
| 461 |
-
className={cn(
|
| 462 |
-
'w-full flex items-center gap-3 px-3 py-2.5 rounded-xl',
|
| 463 |
-
'text-sm font-body font-semibold transition-all duration-200',
|
| 464 |
-
'bg-gradient-to-r from-primary/10 via-caramel/10 to-mint/10',
|
| 465 |
-
'hover:from-primary/15 hover:via-caramel/15 hover:to-mint/15',
|
| 466 |
-
'border border-primary/20 hover:border-primary/30',
|
| 467 |
-
'btn-press',
|
| 468 |
-
collapsed ? 'justify-center' : 'justify-start'
|
| 469 |
-
)}
|
| 470 |
-
title={collapsed ? (mode === 'dev' ? 'Switch to User Mode' : 'Switch to Dev Mode') : undefined}
|
| 471 |
-
>
|
| 472 |
-
{mode === 'dev' ? (
|
| 473 |
-
<Home className="w-5 h-5 text-primary" />
|
| 474 |
-
) : (
|
| 475 |
-
<Sparkles className="w-5 h-5 text-primary" />
|
| 476 |
-
)}
|
| 477 |
-
{!collapsed && (
|
| 478 |
-
<span className="text-primary">
|
| 479 |
-
{mode === 'dev' ? 'User Mode' : 'Dev Mode'}
|
| 480 |
-
</span>
|
| 481 |
-
)}
|
| 482 |
-
</button>
|
| 483 |
-
|
| 484 |
-
{/* Collapse Toggle - Desktop */}
|
| 485 |
<button
|
| 486 |
onClick={() => setCollapsed(!collapsed)}
|
| 487 |
className={cn(
|
|
@@ -507,12 +488,11 @@ export function Sidebar({
|
|
| 507 |
|
| 508 |
return (
|
| 509 |
<>
|
| 510 |
-
|
| 511 |
-
<div className="lg:hidden fixed top-0 left-0 right-0 z-40 h-14 glass border-b border-border/50 flex items-center justify-between px-4">
|
| 512 |
<button
|
| 513 |
onClick={() => setMobileOpen(true)}
|
| 514 |
className={cn(
|
| 515 |
-
'p-2 rounded-lg
|
| 516 |
'hover:bg-secondary transition-colors duration-200 cursor-pointer',
|
| 517 |
'min-w-[40px] min-h-[40px] flex items-center justify-center',
|
| 518 |
'focus:outline-none focus:ring-2 focus:ring-primary/30'
|
|
@@ -522,10 +502,11 @@ export function Sidebar({
|
|
| 522 |
>
|
| 523 |
<Menu className="w-5 h-5" />
|
| 524 |
</button>
|
|
|
|
| 525 |
|
| 526 |
<button
|
| 527 |
onClick={() => navigate('/')}
|
| 528 |
-
className="flex items-center gap-2 hover:opacity-80 transition-opacity
|
| 529 |
>
|
| 530 |
<span className="text-xl leading-none animate-candy-float">🍭</span>
|
| 531 |
<span className="font-bold text-base font-candy">Candy Shop</span>
|
|
@@ -533,7 +514,7 @@ export function Sidebar({
|
|
| 533 |
|
| 534 |
<button
|
| 535 |
onClick={onOpenCart}
|
| 536 |
-
className="p-2 rounded-lg hover:bg-secondary transition-colors duration-200 relative min-w-[40px] min-h-[40px] flex items-center justify-center
|
| 537 |
aria-label={`Cart (${cartCount} items)`}
|
| 538 |
>
|
| 539 |
<ShoppingBag className="w-5 h-5" />
|
|
@@ -545,39 +526,22 @@ export function Sidebar({
|
|
| 545 |
</button>
|
| 546 |
</div>
|
| 547 |
|
| 548 |
-
{/* Mobile Overlay */}
|
| 549 |
-
{mobileOpen && (
|
| 550 |
-
<div
|
| 551 |
-
className="lg:hidden fixed inset-0 z-40 bg-black/50"
|
| 552 |
-
onClick={() => setMobileOpen(false)}
|
| 553 |
-
/>
|
| 554 |
-
)}
|
| 555 |
-
|
| 556 |
-
{/* Mobile Sidebar */}
|
| 557 |
<aside
|
| 558 |
className={cn(
|
| 559 |
-
'lg:hidden fixed inset-y-0 left-0 z-
|
|
|
|
| 560 |
'transform transition-transform duration-300',
|
| 561 |
mobileOpen ? 'translate-x-0' : '-translate-x-full'
|
| 562 |
)}
|
| 563 |
>
|
| 564 |
-
|
| 565 |
-
onClick={() => setMobileOpen(false)}
|
| 566 |
-
className="absolute top-4 right-4 p-2.5 rounded-lg hover:bg-secondary transition-colors duration-200 cursor-pointer min-w-[44px] min-h-[44px] flex items-center justify-center focus:outline-none focus:ring-2 focus:ring-primary/30"
|
| 567 |
-
aria-label="Close navigation menu"
|
| 568 |
-
>
|
| 569 |
-
<X className="w-5 h-5" />
|
| 570 |
-
</button>
|
| 571 |
-
<div className="pt-12">
|
| 572 |
-
{sidebarContent}
|
| 573 |
-
</div>
|
| 574 |
</aside>
|
| 575 |
|
| 576 |
-
{/* Desktop Sidebar */}
|
| 577 |
<aside
|
| 578 |
className={cn(
|
| 579 |
-
'hidden lg:flex flex-col fixed inset-y-0 left-0 z-
|
| 580 |
-
'glass
|
|
|
|
| 581 |
collapsed ? 'w-16' : 'w-64'
|
| 582 |
)}
|
| 583 |
>
|
|
|
|
| 1 |
import { useState, useEffect } from 'react';
|
| 2 |
import { useNavigate, useLocation } from 'react-router-dom';
|
| 3 |
import {
|
|
|
|
|
|
|
| 4 |
BookOpen,
|
| 5 |
Plus,
|
| 6 |
Library,
|
|
|
|
| 10 |
ChevronLeft,
|
| 11 |
ChevronRight,
|
| 12 |
Menu,
|
|
|
|
| 13 |
Moon,
|
| 14 |
Sun,
|
| 15 |
Palette,
|
| 16 |
Check,
|
| 17 |
ChevronDown,
|
| 18 |
Sparkles,
|
| 19 |
+
Candy,
|
| 20 |
+
Heart,
|
| 21 |
} from 'lucide-react';
|
| 22 |
+
import type { LucideIcon } from 'lucide-react';
|
| 23 |
import type { User as SupabaseUser } from '@supabase/supabase-js';
|
| 24 |
import { supabase } from '../../lib/supabaseClient';
|
| 25 |
import { cn } from '../../utils/cn';
|
| 26 |
import { useLanguage } from '../../contexts/LanguageContext';
|
|
|
|
| 27 |
|
| 28 |
interface SidebarProps {
|
| 29 |
onOpenAuth: () => void;
|
|
|
|
| 33 |
onNavFind: () => void;
|
| 34 |
onNavCd: () => void;
|
| 35 |
onNavMan: () => void;
|
| 36 |
+
onNavCandy: () => void;
|
| 37 |
+
onNavCraving: () => void;
|
| 38 |
+
onNavPostCraving: () => void;
|
| 39 |
+
onNavPostCandy: () => void;
|
| 40 |
isDarkMode: boolean;
|
| 41 |
onToggleTheme: () => void;
|
| 42 |
currentTheme: string;
|
| 43 |
onChangeTheme: (theme: string) => void;
|
| 44 |
}
|
| 45 |
|
| 46 |
+
interface NavItem {
|
| 47 |
+
id: string;
|
| 48 |
+
labelKey: string;
|
| 49 |
+
userLabelKey: string;
|
| 50 |
+
icon: LucideIcon;
|
| 51 |
+
action: string;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
const navItems: NavItem[] = [
|
| 55 |
+
{ id: 'candy', labelKey: 'nav.candy', userLabelKey: 'nav.candy.user', icon: Candy, action: 'candy' },
|
| 56 |
+
{ id: 'craving', labelKey: 'nav.craving', userLabelKey: 'nav.craving.user', icon: Heart, action: 'craving' },
|
| 57 |
+
{ id: 'post-craving', labelKey: 'nav.postCraving', userLabelKey: 'nav.postCraving.user', icon: Plus, action: 'post-craving' },
|
| 58 |
+
{ id: 'post-candy', labelKey: 'nav.postCandy', userLabelKey: 'nav.postCandy.user', icon: Candy, action: 'post-candy' },
|
| 59 |
{ id: 'man', labelKey: 'nav.man', userLabelKey: 'nav.man.user', icon: BookOpen, action: 'man' },
|
| 60 |
];
|
| 61 |
|
| 62 |
+
const userNavItems: NavItem[] = [
|
| 63 |
+
{ id: 'create', labelKey: 'nav.create', userLabelKey: 'nav.create.user', icon: Sparkles, action: 'create' },
|
| 64 |
{ id: 'library', labelKey: 'nav.library', userLabelKey: 'nav.library.user', icon: Library, action: 'library' },
|
| 65 |
];
|
| 66 |
|
|
|
|
| 67 |
const themes = [
|
| 68 |
+
{ id: 'indigo', name: 'Indigo', color: '#5E6AD2', light: '#818CF8', description: 'Professional & Modern' },
|
| 69 |
+
{ id: 'blue', name: 'Ocean', color: '#3B82F6', light: '#60A5FA', description: 'Calm & Trustworthy' },
|
| 70 |
+
{ id: 'emerald', name: 'Emerald', color: '#10B981', light: '#34D399', description: 'Fresh & Natural' },
|
| 71 |
+
{ id: 'amber', name: 'Sunset', color: '#F59E0B', light: '#FBBF24', description: 'Warm & Energetic' },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
{ id: 'rose', name: 'Rose', color: '#F43F5E', light: '#FB7185', description: 'Bold & Vibrant' },
|
| 73 |
+
{ id: 'violet', name: 'Purple', color: '#8B5CF6', light: '#A78BFA', description: 'Creative & Elegant' },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
];
|
| 75 |
|
| 76 |
+
// Extracted as a top-level component to avoid HMR issues
|
| 77 |
+
function NavButton({
|
| 78 |
+
item,
|
| 79 |
+
isActive,
|
| 80 |
+
collapsed,
|
| 81 |
+
onAction,
|
| 82 |
+
label,
|
| 83 |
+
}: {
|
| 84 |
+
item: NavItem;
|
| 85 |
+
isActive: boolean;
|
| 86 |
+
collapsed: boolean;
|
| 87 |
+
onAction: (action: string) => void;
|
| 88 |
+
label: string;
|
| 89 |
+
}) {
|
| 90 |
+
const Icon = item.icon;
|
| 91 |
+
return (
|
| 92 |
+
<button
|
| 93 |
+
onClick={() => onAction(item.action)}
|
| 94 |
+
className={cn(
|
| 95 |
+
'w-full flex items-center gap-3 px-3 py-2.5 rounded-lg',
|
| 96 |
+
'text-sm font-mono transition-all duration-200 cursor-pointer',
|
| 97 |
+
'focus:outline-none focus:ring-2 focus:ring-primary/30',
|
| 98 |
+
isActive
|
| 99 |
+
? 'bg-gradient-to-r from-primary/10 to-primary/5 text-primary border border-primary/20 shadow-sm'
|
| 100 |
+
: 'hover:bg-secondary/70 hover:text-foreground border border-transparent',
|
| 101 |
+
collapsed ? 'justify-center' : 'justify-start'
|
| 102 |
+
)}
|
| 103 |
+
title={collapsed ? label : undefined}
|
| 104 |
+
aria-label={label}
|
| 105 |
+
aria-current={isActive ? 'page' : undefined}
|
| 106 |
+
>
|
| 107 |
+
<Icon className={cn('w-5 h-5 flex-shrink-0', isActive ? 'text-primary' : 'text-foreground-secondary')} />
|
| 108 |
+
{!collapsed && <span className="truncate">{label}</span>}
|
| 109 |
+
</button>
|
| 110 |
+
);
|
| 111 |
+
}
|
| 112 |
|
| 113 |
export function Sidebar({
|
| 114 |
onOpenAuth,
|
|
|
|
| 118 |
onNavFind,
|
| 119 |
onNavCd,
|
| 120 |
onNavMan,
|
| 121 |
+
onNavCandy,
|
| 122 |
+
onNavCraving,
|
| 123 |
+
onNavPostCraving,
|
| 124 |
+
onNavPostCandy,
|
| 125 |
isDarkMode,
|
| 126 |
onToggleTheme,
|
| 127 |
currentTheme,
|
|
|
|
| 130 |
const navigate = useNavigate();
|
| 131 |
const location = useLocation();
|
| 132 |
const { t, language, setLanguage } = useLanguage();
|
|
|
|
| 133 |
|
|
|
|
| 134 |
const getActiveAction = (): string | null => {
|
| 135 |
if (location.pathname === '/skills/create') return 'create';
|
| 136 |
if (location.pathname === '/skills/library') return 'library';
|
| 137 |
+
if (location.pathname === '/') {
|
| 138 |
+
const params = new URLSearchParams(location.search);
|
| 139 |
+
const tab = params.get('tab');
|
| 140 |
+
const modal = params.get('modal');
|
| 141 |
+
if (modal === 'post-candy') return 'post-candy';
|
| 142 |
+
if (modal === 'post-craving') return 'post-craving';
|
| 143 |
+
if (tab === 'craving') return 'craving';
|
| 144 |
+
return 'candy';
|
| 145 |
+
}
|
| 146 |
return null;
|
| 147 |
};
|
| 148 |
const activeAction = getActiveAction();
|
|
|
|
| 150 |
const [mobileOpen, setMobileOpen] = useState(false);
|
| 151 |
const [showThemeSelector, setShowThemeSelector] = useState(false);
|
| 152 |
|
| 153 |
+
useEffect(() => {
|
| 154 |
+
const mql = window.matchMedia('(min-width: 1024px)');
|
| 155 |
+
function handleChange(e: MediaQueryListEvent | MediaQueryList) {
|
| 156 |
+
if (e.matches) {
|
| 157 |
+
setMobileOpen(false);
|
| 158 |
+
} else {
|
| 159 |
+
setCollapsed(false);
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
handleChange(mql);
|
| 163 |
+
mql.addEventListener('change', handleChange);
|
| 164 |
+
return () => mql.removeEventListener('change', handleChange);
|
| 165 |
+
}, []);
|
| 166 |
+
|
| 167 |
useEffect(() => {
|
| 168 |
function handleClickOutside(event: MouseEvent) {
|
| 169 |
const target = event.target as HTMLElement;
|
|
|
|
| 177 |
|
| 178 |
const handleNavAction = (action: string) => {
|
| 179 |
switch (action) {
|
| 180 |
+
case 'candy': onNavCandy(); break;
|
| 181 |
+
case 'craving': onNavCraving(); break;
|
| 182 |
+
case 'post-craving': onNavPostCraving(); break;
|
| 183 |
+
case 'post-candy': onNavPostCandy(); break;
|
| 184 |
+
case 'find': onNavFind(); break;
|
| 185 |
+
case 'cd': onNavCd(); break;
|
| 186 |
+
case 'man': onNavMan(); break;
|
| 187 |
+
case 'create': navigate('/skills/create'); break;
|
| 188 |
+
case 'library': navigate('/skills/library'); break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
}
|
| 190 |
setMobileOpen(false);
|
| 191 |
};
|
|
|
|
| 200 |
setMobileOpen(false);
|
| 201 |
};
|
| 202 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
const themeSelector = (
|
| 204 |
<div data-theme-panel className="relative">
|
| 205 |
<button
|
|
|
|
| 229 |
)}
|
| 230 |
</button>
|
| 231 |
|
|
|
|
| 232 |
{showThemeSelector && (
|
| 233 |
<div
|
| 234 |
className={cn(
|
|
|
|
| 277 |
|
| 278 |
const sidebarContent = (
|
| 279 |
<>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
<div
|
| 281 |
className={cn(
|
| 282 |
+
'flex items-center gap-3 px-4 border-b border-border/50 h-14 flex-shrink-0',
|
|
|
|
| 283 |
collapsed ? 'justify-center' : 'justify-between'
|
| 284 |
)}
|
| 285 |
>
|
| 286 |
{!collapsed && (
|
| 287 |
<button
|
| 288 |
onClick={() => navigate('/')}
|
| 289 |
+
className="flex items-center gap-2 hover:opacity-80 transition-opacity duration-200 cursor-pointer focus:outline-none focus:ring-2 focus:ring-primary/30 rounded-lg px-1"
|
| 290 |
aria-label="Go to home page"
|
| 291 |
>
|
| 292 |
<span className="text-2xl leading-none animate-candy-float" aria-hidden="true">🍭</span>
|
|
|
|
| 296 |
{collapsed && <span className="text-2xl leading-none animate-candy-float">🍭</span>}
|
| 297 |
</div>
|
| 298 |
|
|
|
|
| 299 |
<nav className="flex-1 px-3 py-4 space-y-1 overflow-y-auto">
|
| 300 |
{navItems.map((item) => (
|
| 301 |
+
<NavButton
|
| 302 |
+
key={item.id}
|
| 303 |
+
item={item}
|
| 304 |
+
isActive={activeAction === item.action}
|
| 305 |
+
collapsed={collapsed}
|
| 306 |
+
onAction={handleNavAction}
|
| 307 |
+
label={t(item.userLabelKey)}
|
| 308 |
+
/>
|
| 309 |
))}
|
| 310 |
|
| 311 |
{user && (
|
|
|
|
| 318 |
)}
|
| 319 |
</div>
|
| 320 |
{userNavItems.map((item) => (
|
| 321 |
+
<NavButton
|
| 322 |
+
key={item.id}
|
| 323 |
+
item={item}
|
| 324 |
+
isActive={activeAction === item.action}
|
| 325 |
+
collapsed={collapsed}
|
| 326 |
+
onAction={handleNavAction}
|
| 327 |
+
label={t(item.userLabelKey)}
|
| 328 |
+
/>
|
| 329 |
))}
|
| 330 |
</>
|
| 331 |
)}
|
| 332 |
</nav>
|
| 333 |
|
|
|
|
| 334 |
<div
|
| 335 |
className={cn(
|
| 336 |
'border-t border-border px-3 py-4 space-y-2',
|
| 337 |
collapsed ? 'items-center' : ''
|
| 338 |
)}
|
| 339 |
>
|
|
|
|
| 340 |
{themeSelector}
|
| 341 |
|
|
|
|
| 342 |
<button
|
| 343 |
onClick={onToggleTheme}
|
| 344 |
className={cn(
|
|
|
|
| 357 |
{!collapsed && <span>{isDarkMode ? t('lightMode') : t('darkMode')}</span>}
|
| 358 |
</button>
|
| 359 |
|
|
|
|
| 360 |
<button
|
| 361 |
onClick={() => setLanguage(language === 'en' ? 'zh' : 'en')}
|
| 362 |
className={cn(
|
|
|
|
| 373 |
{!collapsed && <span>{t('language')}</span>}
|
| 374 |
</button>
|
| 375 |
|
|
|
|
| 376 |
<button
|
| 377 |
onClick={onOpenCart}
|
| 378 |
className={cn(
|
|
|
|
| 394 |
{!collapsed && <span>{t('cart')}</span>}
|
| 395 |
</button>
|
| 396 |
|
|
|
|
| 397 |
{user ? (
|
| 398 |
<div
|
| 399 |
className={cn(
|
|
|
|
| 402 |
collapsed ? 'justify-center' : ''
|
| 403 |
)}
|
| 404 |
>
|
|
|
|
| 405 |
{(() => {
|
| 406 |
const avatarUrl =
|
| 407 |
user.user_metadata?.avatar_url ||
|
|
|
|
| 463 |
</button>
|
| 464 |
)}
|
| 465 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 466 |
<button
|
| 467 |
onClick={() => setCollapsed(!collapsed)}
|
| 468 |
className={cn(
|
|
|
|
| 488 |
|
| 489 |
return (
|
| 490 |
<>
|
| 491 |
+
<div className="fixed top-0 left-0 right-0 z-30 h-14 glass border-b border-border/50 flex items-center justify-between px-4">
|
|
|
|
| 492 |
<button
|
| 493 |
onClick={() => setMobileOpen(true)}
|
| 494 |
className={cn(
|
| 495 |
+
'lg:hidden p-2 rounded-lg',
|
| 496 |
'hover:bg-secondary transition-colors duration-200 cursor-pointer',
|
| 497 |
'min-w-[40px] min-h-[40px] flex items-center justify-center',
|
| 498 |
'focus:outline-none focus:ring-2 focus:ring-primary/30'
|
|
|
|
| 502 |
>
|
| 503 |
<Menu className="w-5 h-5" />
|
| 504 |
</button>
|
| 505 |
+
<div className="hidden lg:block w-10" />
|
| 506 |
|
| 507 |
<button
|
| 508 |
onClick={() => navigate('/')}
|
| 509 |
+
className="flex items-center gap-2 hover:opacity-80 transition-opacity"
|
| 510 |
>
|
| 511 |
<span className="text-xl leading-none animate-candy-float">🍭</span>
|
| 512 |
<span className="font-bold text-base font-candy">Candy Shop</span>
|
|
|
|
| 514 |
|
| 515 |
<button
|
| 516 |
onClick={onOpenCart}
|
| 517 |
+
className="p-2 rounded-lg hover:bg-secondary transition-colors duration-200 relative min-w-[40px] min-h-[40px] flex items-center justify-center"
|
| 518 |
aria-label={`Cart (${cartCount} items)`}
|
| 519 |
>
|
| 520 |
<ShoppingBag className="w-5 h-5" />
|
|
|
|
| 526 |
</button>
|
| 527 |
</div>
|
| 528 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 529 |
<aside
|
| 530 |
className={cn(
|
| 531 |
+
'lg:hidden fixed inset-y-0 left-0 z-40 flex flex-col w-72 glass',
|
| 532 |
+
'after:content-[""] after:absolute after:right-0 after:top-0 after:bottom-0 after:w-px after:bg-border/50',
|
| 533 |
'transform transition-transform duration-300',
|
| 534 |
mobileOpen ? 'translate-x-0' : '-translate-x-full'
|
| 535 |
)}
|
| 536 |
>
|
| 537 |
+
{sidebarContent}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 538 |
</aside>
|
| 539 |
|
|
|
|
| 540 |
<aside
|
| 541 |
className={cn(
|
| 542 |
+
'hidden lg:flex flex-col fixed inset-y-0 left-0 z-40',
|
| 543 |
+
'glass transition-all duration-300',
|
| 544 |
+
'after:content-[""] after:absolute after:right-0 after:top-0 after:bottom-0 after:w-px after:bg-border/50',
|
| 545 |
collapsed ? 'w-16' : 'w-64'
|
| 546 |
)}
|
| 547 |
>
|
src/components/normal-mode/Hero.tsx
DELETED
|
@@ -1,102 +0,0 @@
|
|
| 1 |
-
import { Sparkles, Search, FileText, Terminal } from 'lucide-react';
|
| 2 |
-
import { useLanguage } from '../../contexts/LanguageContext';
|
| 3 |
-
|
| 4 |
-
interface NormalHeroProps {
|
| 5 |
-
onOpenDocs?: () => void;
|
| 6 |
-
}
|
| 7 |
-
|
| 8 |
-
export function NormalHero({ onOpenDocs }: NormalHeroProps) {
|
| 9 |
-
const { t } = useLanguage();
|
| 10 |
-
|
| 11 |
-
const features = [
|
| 12 |
-
{
|
| 13 |
-
icon: Sparkles,
|
| 14 |
-
title: t('hero.feature1.title') || 'Smart AI Skills',
|
| 15 |
-
description: t('hero.feature1.description') || 'Discover intelligent AI capabilities tailored for you',
|
| 16 |
-
},
|
| 17 |
-
{
|
| 18 |
-
icon: Search,
|
| 19 |
-
title: t('hero.feature2.title') || 'Easy Discovery',
|
| 20 |
-
description: t('hero.feature2.description') || 'Find the perfect skills with our intuitive search',
|
| 21 |
-
},
|
| 22 |
-
{
|
| 23 |
-
icon: Terminal,
|
| 24 |
-
title: t('hero.feature3.title') || 'Pro Mode Available',
|
| 25 |
-
description: t('hero.feature3.description') || 'Switch to Pro Mode for advanced features',
|
| 26 |
-
},
|
| 27 |
-
];
|
| 28 |
-
|
| 29 |
-
return (
|
| 30 |
-
<section className="relative overflow-hidden py-16 lg:py-24 bg-background">
|
| 31 |
-
{/* Subtle background effects */}
|
| 32 |
-
<div className="absolute inset-0 overflow-hidden pointer-events-none">
|
| 33 |
-
<div className="absolute top-10 left-10 w-64 h-64 bg-primary/5 rounded-full blur-3xl" />
|
| 34 |
-
<div className="absolute bottom-10 right-10 w-80 h-80 bg-primary/5 rounded-full blur-3xl" />
|
| 35 |
-
</div>
|
| 36 |
-
|
| 37 |
-
<div className="container max-w-7xl mx-auto px-4 relative z-10">
|
| 38 |
-
<div className="text-center max-w-3xl mx-auto">
|
| 39 |
-
{/* Badge */}
|
| 40 |
-
<div className="inline-flex items-center gap-2 px-3 py-1.5 rounded-full bg-secondary border border-border mb-6">
|
| 41 |
-
<span className="flex h-1.5 w-1.5 rounded-full bg-primary animate-pulse"></span>
|
| 42 |
-
<span className="text-sm font-medium text-foreground">
|
| 43 |
-
User Friendly Interface
|
| 44 |
-
</span>
|
| 45 |
-
</div>
|
| 46 |
-
|
| 47 |
-
{/* Main heading */}
|
| 48 |
-
<h1 className="text-4xl sm:text-5xl lg:text-6xl font-bold mb-4 leading-tight text-foreground">
|
| 49 |
-
{t('hero.title') || 'Discover Amazing'}
|
| 50 |
-
<span className="text-primary"> AI Skills</span>
|
| 51 |
-
</h1>
|
| 52 |
-
|
| 53 |
-
{/* Subtitle */}
|
| 54 |
-
<p className="text-lg text-muted-foreground mb-8 max-w-2xl mx-auto leading-relaxed">
|
| 55 |
-
{t('hero.subtitleNormal') || 'Enhance your productivity and creativity with our curated collection of AI-powered skills. Simple, intuitive, and powerful.'}
|
| 56 |
-
</p>
|
| 57 |
-
|
| 58 |
-
{/* CTA buttons */}
|
| 59 |
-
<div className="flex flex-col sm:flex-row items-center justify-center gap-3 mb-12">
|
| 60 |
-
<button
|
| 61 |
-
onClick={() => document.getElementById('skills')?.scrollIntoView({ behavior: 'smooth' })}
|
| 62 |
-
className="group flex items-center justify-center gap-2 px-6 py-3 rounded-lg bg-primary text-primary-foreground font-medium text-sm hover:bg-primary-hover transition-all duration-200 shadow-md hover:shadow-lg"
|
| 63 |
-
>
|
| 64 |
-
<Search className="w-4 h-4" />
|
| 65 |
-
{t('hero.exploreBtn') || 'Explore Skills'}
|
| 66 |
-
</button>
|
| 67 |
-
<button
|
| 68 |
-
onClick={onOpenDocs}
|
| 69 |
-
className="flex items-center justify-center gap-2 px-6 py-3 rounded-lg bg-card border border-border text-foreground font-medium text-sm hover:bg-secondary transition-all duration-200"
|
| 70 |
-
>
|
| 71 |
-
<FileText className="w-4 h-4" />
|
| 72 |
-
{t('hero.learnMoreBtn') || 'Learn More'}
|
| 73 |
-
</button>
|
| 74 |
-
</div>
|
| 75 |
-
|
| 76 |
-
{/* Feature cards */}
|
| 77 |
-
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 max-w-4xl mx-auto">
|
| 78 |
-
{features.map((feature, index) => {
|
| 79 |
-
const Icon = feature.icon;
|
| 80 |
-
return (
|
| 81 |
-
<div
|
| 82 |
-
key={index}
|
| 83 |
-
className="group p-5 rounded-xl bg-card border border-border hover:border-primary/50 hover:shadow-md transition-all duration-300"
|
| 84 |
-
>
|
| 85 |
-
<div className="inline-flex p-2.5 rounded-lg bg-primary/10 mb-3 group-hover:scale-110 transition-transform duration-300">
|
| 86 |
-
<Icon className="w-5 h-5 text-primary" />
|
| 87 |
-
</div>
|
| 88 |
-
<h3 className="text-base font-semibold text-foreground mb-1.5">
|
| 89 |
-
{feature.title}
|
| 90 |
-
</h3>
|
| 91 |
-
<p className="text-muted-foreground text-sm leading-relaxed">
|
| 92 |
-
{feature.description}
|
| 93 |
-
</p>
|
| 94 |
-
</div>
|
| 95 |
-
);
|
| 96 |
-
})}
|
| 97 |
-
</div>
|
| 98 |
-
</div>
|
| 99 |
-
</div>
|
| 100 |
-
</section>
|
| 101 |
-
);
|
| 102 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/components/normal-mode/Layout.tsx
DELETED
|
@@ -1,70 +0,0 @@
|
|
| 1 |
-
import { useState } from 'react';
|
| 2 |
-
import { Menu, X, Github, ShoppingBag } from 'lucide-react';
|
| 3 |
-
import { useLanguage } from '../../contexts/LanguageContext';
|
| 4 |
-
import { useVersionMode } from '../../contexts/VersionModeContext';
|
| 5 |
-
|
| 6 |
-
export function NormalLayout({ children, onOpenAuth, onOpenCart, cartCount }: any) {
|
| 7 |
-
const { t } = useLanguage();
|
| 8 |
-
const { toggleMode } = useVersionMode();
|
| 9 |
-
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
|
| 10 |
-
|
| 11 |
-
const handleCartClick = () => {
|
| 12 |
-
if (onOpenCart) {
|
| 13 |
-
onOpenCart();
|
| 14 |
-
} else {
|
| 15 |
-
onOpenAuth();
|
| 16 |
-
}
|
| 17 |
-
};
|
| 18 |
-
|
| 19 |
-
return (
|
| 20 |
-
<div className="min-h-screen bg-background">
|
| 21 |
-
<header className="fixed top-0 left-0 right-0 z-50 bg-background/80 backdrop-blur-md border-b border-border">
|
| 22 |
-
<div className="container max-w-7xl mx-auto px-4 h-14">
|
| 23 |
-
<div className="flex items-center justify-between">
|
| 24 |
-
<div className="flex items-center gap-3">
|
| 25 |
-
<span className="text-lg font-bold text-foreground">
|
| 26 |
-
Candy Shop
|
| 27 |
-
</span>
|
| 28 |
-
<span className="hidden sm:inline-flex items-center px-2 py-0.5 rounded-md bg-primary/10 border border-primary/20 text-primary text-xs font-medium">
|
| 29 |
-
User Mode
|
| 30 |
-
</span>
|
| 31 |
-
</div>
|
| 32 |
-
|
| 33 |
-
<nav className="hidden md:flex items-center gap-6">
|
| 34 |
-
<a href="#skills" className="text-muted-foreground hover:text-foreground transition-colors duration-200 text-sm font-medium">
|
| 35 |
-
{t('nav.skills') || 'Skills'}
|
| 36 |
-
</a>
|
| 37 |
-
</nav>
|
| 38 |
-
|
| 39 |
-
<div className="flex items-center gap-2">
|
| 40 |
-
<button onClick={toggleMode} className="hidden sm:flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-secondary hover:bg-secondary/80 text-foreground text-sm font-medium transition-all duration-200" title="Switch to Pro Mode">
|
| 41 |
-
<Github className="w-3.5 h-3.5" />
|
| 42 |
-
<span>Pro Mode</span>
|
| 43 |
-
</button>
|
| 44 |
-
|
| 45 |
-
<button onClick={handleCartClick} className="relative p-2 rounded-md hover:bg-secondary transition-colors duration-200">
|
| 46 |
-
<ShoppingBag className="w-4 h-4 text-foreground" />
|
| 47 |
-
{cartCount > 0 && <span className="absolute -top-0.5 -right-0.5 w-4 h-4 rounded-full bg-primary text-white text-xs flex items-center justify-center font-bold">{cartCount}</span>}
|
| 48 |
-
</button>
|
| 49 |
-
|
| 50 |
-
<button onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)} className="md:hidden p-2 rounded-md hover:bg-secondary transition-colors duration-200" aria-label="Toggle menu">
|
| 51 |
-
{isMobileMenuOpen ? <X className="w-5 h-5 text-foreground" /> : <Menu className="w-5 h-5 text-foreground" />}
|
| 52 |
-
</button>
|
| 53 |
-
</div>
|
| 54 |
-
</div>
|
| 55 |
-
</div>
|
| 56 |
-
|
| 57 |
-
{isMobileMenuOpen && (
|
| 58 |
-
<div className="md:hidden border-t border-border bg-background">
|
| 59 |
-
<div className="container max-w-7xl mx-auto px-4 py-3 space-y-2">
|
| 60 |
-
<a href="#skills" className="block py-2 text-muted-foreground hover:text-foreground text-sm font-medium" onClick={() => setIsMobileMenuOpen(false)}>{t('nav.skills') || 'Skills'}</a>
|
| 61 |
-
<button onClick={() => { toggleMode(); setIsMobileMenuOpen(false); }} className="w-full flex items-center justify-center gap-2 py-2 rounded-md bg-secondary text-foreground text-sm font-medium">Switch to Pro Mode</button>
|
| 62 |
-
</div>
|
| 63 |
-
</div>
|
| 64 |
-
)}
|
| 65 |
-
</header>
|
| 66 |
-
|
| 67 |
-
<main className="pt-14">{children}</main>
|
| 68 |
-
</div>
|
| 69 |
-
);
|
| 70 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/components/normal-mode/SkillsGrid.tsx
DELETED
|
@@ -1,328 +0,0 @@
|
|
| 1 |
-
import { Search, Heart, ShoppingBag, Check, Play, Star, Github } from 'lucide-react';
|
| 2 |
-
import { useState, useMemo } from 'react';
|
| 3 |
-
import { SKILLS_DATA, type Skill } from '../../data/skillsData';
|
| 4 |
-
import { getCandyEmoji } from '../../utils/candy';
|
| 5 |
-
import { SkillModal } from '../common/SkillModal';
|
| 6 |
-
import { storageUtils } from '../../utils/storage';
|
| 7 |
-
import { toast } from 'sonner';
|
| 8 |
-
import { useLanguage } from '../../contexts/LanguageContext';
|
| 9 |
-
|
| 10 |
-
interface NormalSkillsGridProps {
|
| 11 |
-
searchQuery: string;
|
| 12 |
-
setSearchQuery: (q: string) => void;
|
| 13 |
-
categoryFilter: string | null;
|
| 14 |
-
cart: Set<string>;
|
| 15 |
-
onToggleCart: (id: string) => void;
|
| 16 |
-
onRunSkill: (skill: Skill) => void;
|
| 17 |
-
}
|
| 18 |
-
|
| 19 |
-
export function NormalSkillsGrid({
|
| 20 |
-
searchQuery,
|
| 21 |
-
setSearchQuery,
|
| 22 |
-
categoryFilter,
|
| 23 |
-
cart,
|
| 24 |
-
onToggleCart,
|
| 25 |
-
onRunSkill,
|
| 26 |
-
}: NormalSkillsGridProps) {
|
| 27 |
-
const { t } = useLanguage();
|
| 28 |
-
const [selectedSkill, setSelectedSkill] = useState<Skill | null>(null);
|
| 29 |
-
const [likedSkills, setLikedSkills] = useState<Set<string>>(() => new Set(storageUtils.getLikes()));
|
| 30 |
-
|
| 31 |
-
const handleLike = (skillId: string) => {
|
| 32 |
-
const isLiked = likedSkills.has(skillId);
|
| 33 |
-
const skillName = SKILLS_DATA.find((s) => s.id === skillId)?.name || skillId;
|
| 34 |
-
|
| 35 |
-
if (isLiked) {
|
| 36 |
-
storageUtils.removeLike(skillId);
|
| 37 |
-
setLikedSkills((prev) => {
|
| 38 |
-
const next = new Set(prev);
|
| 39 |
-
next.delete(skillId);
|
| 40 |
-
return next;
|
| 41 |
-
});
|
| 42 |
-
} else {
|
| 43 |
-
storageUtils.saveLike(skillId);
|
| 44 |
-
setLikedSkills((prev) => {
|
| 45 |
-
const next = new Set(prev);
|
| 46 |
-
next.add(skillId);
|
| 47 |
-
return next;
|
| 48 |
-
});
|
| 49 |
-
toast.success(`Liked ${skillName}`);
|
| 50 |
-
}
|
| 51 |
-
};
|
| 52 |
-
|
| 53 |
-
const filteredSkills = useMemo(() => {
|
| 54 |
-
return SKILLS_DATA.filter((skill) => {
|
| 55 |
-
const matchesSearch =
|
| 56 |
-
skill.name.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
| 57 |
-
skill.description.toLowerCase().includes(searchQuery.toLowerCase());
|
| 58 |
-
const matchesCategory = categoryFilter ? skill.category === categoryFilter : true;
|
| 59 |
-
return matchesSearch && matchesCategory;
|
| 60 |
-
}).sort((a, b) => (b.popularity || 0) - (a.popularity || 0));
|
| 61 |
-
}, [searchQuery, categoryFilter]);
|
| 62 |
-
|
| 63 |
-
// Use same colors as Pro Mode for consistency
|
| 64 |
-
const getCategoryColor = (category: string) => {
|
| 65 |
-
const colors: Record<string, { bg: string; text: string; border: string; solid: string; hex: string }> = {
|
| 66 |
-
'Knowledge': {
|
| 67 |
-
bg: 'bg-blue-500/10',
|
| 68 |
-
text: 'text-blue-400',
|
| 69 |
-
border: 'border-blue-500/20',
|
| 70 |
-
solid: 'bg-blue-500',
|
| 71 |
-
hex: '#3b82f6',
|
| 72 |
-
},
|
| 73 |
-
'Analysis': {
|
| 74 |
-
bg: 'bg-violet-500/10',
|
| 75 |
-
text: 'text-violet-400',
|
| 76 |
-
border: 'border-violet-500/20',
|
| 77 |
-
solid: 'bg-violet-500',
|
| 78 |
-
hex: '#8b5cf6',
|
| 79 |
-
},
|
| 80 |
-
'Development': {
|
| 81 |
-
bg: 'bg-orange-500/10',
|
| 82 |
-
text: 'text-orange-400',
|
| 83 |
-
border: 'border-orange-500/20',
|
| 84 |
-
solid: 'bg-orange-500',
|
| 85 |
-
hex: '#f97316',
|
| 86 |
-
},
|
| 87 |
-
'Design': {
|
| 88 |
-
bg: 'bg-pink-500/10',
|
| 89 |
-
text: 'text-pink-400',
|
| 90 |
-
border: 'border-pink-500/20',
|
| 91 |
-
solid: 'bg-pink-500',
|
| 92 |
-
hex: '#ec4899',
|
| 93 |
-
},
|
| 94 |
-
'Marketing': {
|
| 95 |
-
bg: 'bg-red-500/10',
|
| 96 |
-
text: 'text-red-400',
|
| 97 |
-
border: 'border-red-500/20',
|
| 98 |
-
solid: 'bg-red-500',
|
| 99 |
-
hex: '#ef4444',
|
| 100 |
-
},
|
| 101 |
-
'Productivity': {
|
| 102 |
-
bg: 'bg-amber-500/10',
|
| 103 |
-
text: 'text-amber-400',
|
| 104 |
-
border: 'border-amber-500/20',
|
| 105 |
-
solid: 'bg-amber-500',
|
| 106 |
-
hex: '#f59e0b',
|
| 107 |
-
},
|
| 108 |
-
'Tools': {
|
| 109 |
-
bg: 'bg-emerald-500/10',
|
| 110 |
-
text: 'text-emerald-400',
|
| 111 |
-
border: 'border-emerald-500/20',
|
| 112 |
-
solid: 'bg-emerald-500',
|
| 113 |
-
hex: '#10b981',
|
| 114 |
-
},
|
| 115 |
-
'Research': {
|
| 116 |
-
bg: 'bg-cyan-500/10',
|
| 117 |
-
text: 'text-cyan-400',
|
| 118 |
-
border: 'border-cyan-500/20',
|
| 119 |
-
solid: 'bg-cyan-500',
|
| 120 |
-
hex: '#06b6d4',
|
| 121 |
-
},
|
| 122 |
-
'Mobile': {
|
| 123 |
-
bg: 'bg-indigo-500/10',
|
| 124 |
-
text: 'text-indigo-400',
|
| 125 |
-
border: 'border-indigo-500/20',
|
| 126 |
-
solid: 'bg-indigo-500',
|
| 127 |
-
hex: '#6366f1',
|
| 128 |
-
},
|
| 129 |
-
'Writing': {
|
| 130 |
-
bg: 'bg-rose-500/10',
|
| 131 |
-
text: 'text-rose-400',
|
| 132 |
-
border: 'border-rose-500/20',
|
| 133 |
-
solid: 'bg-rose-500',
|
| 134 |
-
hex: '#f43f5e',
|
| 135 |
-
},
|
| 136 |
-
'Creative': {
|
| 137 |
-
bg: 'bg-purple-500/10',
|
| 138 |
-
text: 'text-purple-400',
|
| 139 |
-
border: 'border-purple-500/20',
|
| 140 |
-
solid: 'bg-purple-500',
|
| 141 |
-
hex: '#a855f7',
|
| 142 |
-
},
|
| 143 |
-
'Developer': {
|
| 144 |
-
bg: 'bg-green-500/10',
|
| 145 |
-
text: 'text-green-400',
|
| 146 |
-
border: 'border-green-500/20',
|
| 147 |
-
solid: 'bg-green-500',
|
| 148 |
-
hex: '#22c55e',
|
| 149 |
-
},
|
| 150 |
-
'Communication': {
|
| 151 |
-
bg: 'bg-rose-500/10',
|
| 152 |
-
text: 'text-rose-400',
|
| 153 |
-
border: 'border-rose-500/20',
|
| 154 |
-
solid: 'bg-rose-500',
|
| 155 |
-
hex: '#f43f5e',
|
| 156 |
-
},
|
| 157 |
-
'Analytics': {
|
| 158 |
-
bg: 'bg-amber-500/10',
|
| 159 |
-
text: 'text-amber-400',
|
| 160 |
-
border: 'border-amber-500/20',
|
| 161 |
-
solid: 'bg-amber-500',
|
| 162 |
-
hex: '#f59e0b',
|
| 163 |
-
},
|
| 164 |
-
};
|
| 165 |
-
return colors[category] || {
|
| 166 |
-
bg: 'bg-gray-500/10',
|
| 167 |
-
text: 'text-gray-400',
|
| 168 |
-
border: 'border-gray-500/20',
|
| 169 |
-
solid: 'bg-gray-500',
|
| 170 |
-
hex: '#6b7280',
|
| 171 |
-
};
|
| 172 |
-
};
|
| 173 |
-
|
| 174 |
-
return (
|
| 175 |
-
<>
|
| 176 |
-
<section id="skills" className="py-12 bg-background">
|
| 177 |
-
<div className="container max-w-7xl mx-auto px-4">
|
| 178 |
-
{/* Section Header & Search - Consistent with Pro Mode */}
|
| 179 |
-
<div className="flex flex-col md:flex-row md:items-end justify-between gap-4 mb-8">
|
| 180 |
-
<div>
|
| 181 |
-
<h2 className="text-2xl md:text-3xl font-bold mb-1.5 text-foreground">
|
| 182 |
-
{categoryFilter ? `${categoryFilter} Skills` : 'Discover Skills'}
|
| 183 |
-
</h2>
|
| 184 |
-
<div className="flex items-center gap-2 text-muted-foreground text-sm">
|
| 185 |
-
<span>Browse {filteredSkills.length} available skills</span>
|
| 186 |
-
</div>
|
| 187 |
-
</div>
|
| 188 |
-
|
| 189 |
-
<div className="w-full md:w-72 relative">
|
| 190 |
-
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" />
|
| 191 |
-
<input
|
| 192 |
-
type="text"
|
| 193 |
-
value={searchQuery}
|
| 194 |
-
onChange={(e) => setSearchQuery(e.target.value)}
|
| 195 |
-
placeholder={t('skills.search') || 'Search skills...'}
|
| 196 |
-
className="w-full pl-10 pr-4 py-2.5 rounded-lg bg-card border border-border text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent transition-all"
|
| 197 |
-
/>
|
| 198 |
-
</div>
|
| 199 |
-
</div>
|
| 200 |
-
|
| 201 |
-
{/* Skills Grid - Visual Cards with gradient backgrounds */}
|
| 202 |
-
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
| 203 |
-
{filteredSkills.map((skill) => {
|
| 204 |
-
const colors = getCategoryColor(skill.category);
|
| 205 |
-
return (
|
| 206 |
-
<div
|
| 207 |
-
key={skill.id}
|
| 208 |
-
className="group relative rounded-xl border border-border hover:border-primary/50 overflow-hidden hover:shadow-lg hover:shadow-primary/5 transition-all duration-300 cursor-pointer"
|
| 209 |
-
style={{
|
| 210 |
-
background: `linear-gradient(135deg, var(--color-card) 55%, ${colors.hex}12 100%)`,
|
| 211 |
-
}}
|
| 212 |
-
onClick={() => setSelectedSkill(skill)}
|
| 213 |
-
>
|
| 214 |
-
{/* Visual top bar - transitioning from code style to colorful */}
|
| 215 |
-
<div className={`h-2 ${colors.solid} relative overflow-hidden`}>
|
| 216 |
-
<div className="absolute inset-0 bg-gradient-to-r from-white/20 to-transparent" />
|
| 217 |
-
</div>
|
| 218 |
-
|
| 219 |
-
<div className="p-4">
|
| 220 |
-
{/* Header with icon and category */}
|
| 221 |
-
<div className="flex items-start gap-3 mb-3">
|
| 222 |
-
<div className={`w-11 h-11 rounded-lg ${colors.bg} ${colors.border} border flex items-center justify-center text-xl flex-shrink-0 transition-all group-hover:scale-110`}>
|
| 223 |
-
<span className="animate-candy-float inline-block">{getCandyEmoji(skill.id)}</span>
|
| 224 |
-
</div>
|
| 225 |
-
<div className="min-w-0 flex-1">
|
| 226 |
-
<h3 className="font-semibold text-foreground group-hover:text-primary transition-colors truncate">
|
| 227 |
-
{skill.name}
|
| 228 |
-
</h3>
|
| 229 |
-
<span className={`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${colors.bg} ${colors.text}`}>
|
| 230 |
-
{skill.category}
|
| 231 |
-
</span>
|
| 232 |
-
</div>
|
| 233 |
-
|
| 234 |
-
{/* Popularity indicator */}
|
| 235 |
-
<div className="flex items-center gap-1 text-xs text-muted-foreground flex-shrink-0">
|
| 236 |
-
<Star className="w-3.5 h-3.5 fill-amber-400 text-amber-400" />
|
| 237 |
-
<span className="font-medium">{skill.popularity || 0}</span>
|
| 238 |
-
</div>
|
| 239 |
-
</div>
|
| 240 |
-
|
| 241 |
-
{/* Description */}
|
| 242 |
-
<p className="text-sm text-muted-foreground mb-3 line-clamp-2 leading-relaxed">
|
| 243 |
-
{skill.description}
|
| 244 |
-
</p>
|
| 245 |
-
|
| 246 |
-
{/* Source Link */}
|
| 247 |
-
<a
|
| 248 |
-
href={`https://github.com/${skill.repo}`}
|
| 249 |
-
target="_blank"
|
| 250 |
-
rel="noopener noreferrer"
|
| 251 |
-
onClick={(e) => e.stopPropagation()}
|
| 252 |
-
className="inline-flex items-center gap-1.5 text-xs text-muted-foreground hover:text-primary transition-colors mb-4 group/link"
|
| 253 |
-
>
|
| 254 |
-
<Github className="w-3.5 h-3.5" />
|
| 255 |
-
<span>{skill.repo}</span>
|
| 256 |
-
<span className="opacity-0 group-hover/link:opacity-100 transition-opacity">→</span>
|
| 257 |
-
</a>
|
| 258 |
-
|
| 259 |
-
{/* Action buttons */}
|
| 260 |
-
<div className="flex items-center gap-2">
|
| 261 |
-
<button
|
| 262 |
-
onClick={(e) => {
|
| 263 |
-
e.stopPropagation();
|
| 264 |
-
onRunSkill(skill);
|
| 265 |
-
}}
|
| 266 |
-
className="flex-1 flex items-center justify-center gap-1.5 py-2 px-3 rounded-lg bg-primary text-primary-foreground text-sm font-medium hover:bg-primary-hover transition-all duration-200"
|
| 267 |
-
>
|
| 268 |
-
<Play className="w-3.5 h-3.5" />
|
| 269 |
-
Try Now
|
| 270 |
-
</button>
|
| 271 |
-
<button
|
| 272 |
-
onClick={(e) => {
|
| 273 |
-
e.stopPropagation();
|
| 274 |
-
handleLike(skill.id);
|
| 275 |
-
}}
|
| 276 |
-
className={`p-2 rounded-lg transition-all duration-200 ${
|
| 277 |
-
likedSkills.has(skill.id)
|
| 278 |
-
? 'bg-pink-500/10 text-pink-500'
|
| 279 |
-
: 'bg-secondary text-muted-foreground hover:bg-pink-500/10 hover:text-pink-500'
|
| 280 |
-
}`}
|
| 281 |
-
>
|
| 282 |
-
<Heart className={`w-4 h-4 ${likedSkills.has(skill.id) ? 'fill-current' : ''}`} />
|
| 283 |
-
</button>
|
| 284 |
-
<button
|
| 285 |
-
onClick={(e) => {
|
| 286 |
-
e.stopPropagation();
|
| 287 |
-
onToggleCart(skill.id);
|
| 288 |
-
}}
|
| 289 |
-
className={`p-2 rounded-lg transition-all duration-200 ${
|
| 290 |
-
cart.has(skill.id)
|
| 291 |
-
? 'bg-green-500/10 text-green-500'
|
| 292 |
-
: 'bg-secondary text-muted-foreground hover:bg-green-500/10 hover:text-green-500'
|
| 293 |
-
}`}
|
| 294 |
-
>
|
| 295 |
-
{cart.has(skill.id) ? (
|
| 296 |
-
<Check className="w-4 h-4" />
|
| 297 |
-
) : (
|
| 298 |
-
<ShoppingBag className="w-4 h-4" />
|
| 299 |
-
)}
|
| 300 |
-
</button>
|
| 301 |
-
</div>
|
| 302 |
-
</div>
|
| 303 |
-
</div>
|
| 304 |
-
);
|
| 305 |
-
})}
|
| 306 |
-
</div>
|
| 307 |
-
|
| 308 |
-
{/* Empty state */}
|
| 309 |
-
{filteredSkills.length === 0 && (
|
| 310 |
-
<div className="text-center py-16">
|
| 311 |
-
<div className="w-14 h-14 rounded-full bg-secondary flex items-center justify-center mx-auto mb-3">
|
| 312 |
-
<Search className="w-7 h-7 text-muted-foreground" />
|
| 313 |
-
</div>
|
| 314 |
-
<p className="text-muted-foreground text-base">
|
| 315 |
-
{t('skills.noResults') || 'No skills found'}
|
| 316 |
-
</p>
|
| 317 |
-
<p className="text-muted-foreground/60 text-sm mt-1.5">
|
| 318 |
-
Try adjusting your search or filters
|
| 319 |
-
</p>
|
| 320 |
-
</div>
|
| 321 |
-
)}
|
| 322 |
-
</div>
|
| 323 |
-
</section>
|
| 324 |
-
|
| 325 |
-
<SkillModal skill={selectedSkill} onClose={() => setSelectedSkill(null)} onRun={onRunSkill} />
|
| 326 |
-
</>
|
| 327 |
-
);
|
| 328 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/components/normal-mode/index.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
export { NormalLayout } from './Layout';
|
| 2 |
-
export { NormalHero } from './Hero';
|
| 3 |
-
export { NormalSkillsGrid } from './SkillsGrid';
|
|
|
|
|
|
|
|
|
|
|
|
src/components/skill-creator/MySkillsLibrary.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import { useState, useEffect } from 'react';
|
| 2 |
import { Search, Plus, Trash2, Play, Calendar, Filter, ArrowLeft, Package } from 'lucide-react';
|
| 3 |
import { storageUtils } from '../../utils/storage';
|
| 4 |
-
import { getCandyEmoji } from '../../utils/candy';
|
| 5 |
import type { Skill, SkillCategory } from '../../types/skill-creator';
|
| 6 |
import { SKILLS_DATA } from '../../data/skillsData';
|
| 7 |
|
|
@@ -328,7 +327,7 @@ export function MySkillsLibrary({ onCreateNew, onUseSkill, onBack }: MySkillsLib
|
|
| 328 |
{/* Content */}
|
| 329 |
<div className="p-5">
|
| 330 |
<div className="flex items-start gap-3 mb-3">
|
| 331 |
-
<div className="text-3xl animate-candy-float">{
|
| 332 |
<div className="flex-1 min-w-0">
|
| 333 |
<h3 className="text-lg font-bold text-foreground truncate">
|
| 334 |
{skill.name}
|
|
|
|
| 1 |
import { useState, useEffect } from 'react';
|
| 2 |
import { Search, Plus, Trash2, Play, Calendar, Filter, ArrowLeft, Package } from 'lucide-react';
|
| 3 |
import { storageUtils } from '../../utils/storage';
|
|
|
|
| 4 |
import type { Skill, SkillCategory } from '../../types/skill-creator';
|
| 5 |
import { SKILLS_DATA } from '../../data/skillsData';
|
| 6 |
|
|
|
|
| 327 |
{/* Content */}
|
| 328 |
<div className="p-5">
|
| 329 |
<div className="flex items-start gap-3 mb-3">
|
| 330 |
+
<div className="text-3xl animate-candy-float">{skill.icon || '🤖'}</div>
|
| 331 |
<div className="flex-1 min-w-0">
|
| 332 |
<h3 className="text-lg font-bold text-foreground truncate">
|
| 333 |
{skill.name}
|
src/components/skill-creator/SkillExecutor.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import { useState, useEffect, useCallback, useRef } from 'react';
|
| 2 |
import ReactMarkdown from 'react-markdown';
|
| 3 |
import remarkGfm from 'remark-gfm';
|
| 4 |
-
|
| 5 |
import {
|
| 6 |
X,
|
| 7 |
Send,
|
|
@@ -1712,8 +1712,8 @@ export function SkillExecutor({ skill, onClose }: SkillExecutorProps) {
|
|
| 1712 |
{/* ── Header ─────────────────────────────────────────────────── */}
|
| 1713 |
<div className="flex items-center justify-between px-5 py-3.5 border-b border-border/50 glass-strong shrink-0">
|
| 1714 |
<div className="flex items-center gap-3.5">
|
| 1715 |
-
<div className="w-10 h-10 rounded-xl bg-
|
| 1716 |
-
<span
|
| 1717 |
</div>
|
| 1718 |
<div>
|
| 1719 |
<div className="flex items-center gap-2">
|
|
|
|
| 1 |
import { useState, useEffect, useCallback, useRef } from 'react';
|
| 2 |
import ReactMarkdown from 'react-markdown';
|
| 3 |
import remarkGfm from 'remark-gfm';
|
| 4 |
+
|
| 5 |
import {
|
| 6 |
X,
|
| 7 |
Send,
|
|
|
|
| 1712 |
{/* ── Header ─────────────────────────────────────────────────── */}
|
| 1713 |
<div className="flex items-center justify-between px-5 py-3.5 border-b border-border/50 glass-strong shrink-0">
|
| 1714 |
<div className="flex items-center gap-3.5">
|
| 1715 |
+
<div className="w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center text-xl border border-primary/20">
|
| 1716 |
+
<span>{skill.icon || '🤖'}</span>
|
| 1717 |
</div>
|
| 1718 |
<div>
|
| 1719 |
<div className="flex items-center gap-2">
|
src/components/skill-creator/SkillPreviewEditor.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import { useState, useEffect } from 'react';
|
| 2 |
import { Save, X, Edit2, Sparkles, AlertCircle } from 'lucide-react';
|
| 3 |
import type { Skill, AnalysisResult, SkillCategory } from '../../types/skill-creator';
|
| 4 |
-
import { getCandyEmoji } from '../../utils/candy';
|
| 5 |
|
| 6 |
interface SkillPreviewEditorProps {
|
| 7 |
skill: Partial<Skill>;
|
|
@@ -155,7 +154,7 @@ export function SkillPreviewEditor({
|
|
| 155 |
{/* Footer */}
|
| 156 |
<div className="h-10 px-4 border-t border-gray-100 bg-[#FAFAFA] flex items-center justify-between text-xs font-mono text-gray-500">
|
| 157 |
<span>{CATEGORY_LABELS[skill.category as SkillCategory] || 'Category'}</span>
|
| 158 |
-
<span className="text-primary animate-candy-float inline-block">{
|
| 159 |
</div>
|
| 160 |
</div>
|
| 161 |
</div>
|
|
|
|
| 1 |
import { useState, useEffect } from 'react';
|
| 2 |
import { Save, X, Edit2, Sparkles, AlertCircle } from 'lucide-react';
|
| 3 |
import type { Skill, AnalysisResult, SkillCategory } from '../../types/skill-creator';
|
|
|
|
| 4 |
|
| 5 |
interface SkillPreviewEditorProps {
|
| 6 |
skill: Partial<Skill>;
|
|
|
|
| 154 |
{/* Footer */}
|
| 155 |
<div className="h-10 px-4 border-t border-gray-100 bg-[#FAFAFA] flex items-center justify-between text-xs font-mono text-gray-500">
|
| 156 |
<span>{CATEGORY_LABELS[skill.category as SkillCategory] || 'Category'}</span>
|
| 157 |
+
<span className="text-primary animate-candy-float inline-block">{skill.icon || '🤖'}</span>
|
| 158 |
</div>
|
| 159 |
</div>
|
| 160 |
</div>
|
src/contexts/LanguageContext.tsx
CHANGED
|
@@ -19,6 +19,10 @@ const translations: Record<Language, Record<string, string>> = {
|
|
| 19 |
'nav.man': 'man recipes',
|
| 20 |
'nav.create': 'create skills',
|
| 21 |
'nav.library': 'my skills',
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
'theme': 'Theme',
|
| 23 |
'chooseTheme': 'Choose Theme',
|
| 24 |
'cart': 'Cart',
|
|
@@ -102,8 +106,12 @@ const translations: Record<Language, Record<string, string>> = {
|
|
| 102 |
'nav.find.user': 'Browse',
|
| 103 |
'nav.cd.user': 'Categories',
|
| 104 |
'nav.man.user': 'Docs',
|
| 105 |
-
'nav.create.user': 'Create',
|
| 106 |
'nav.library.user': 'Library',
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
// External Resources
|
| 109 |
'external.title': 'Community Skills (External)',
|
|
@@ -142,6 +150,10 @@ const translations: Record<Language, Record<string, string>> = {
|
|
| 142 |
'nav.man': '使用指南',
|
| 143 |
'nav.create': '创建技能',
|
| 144 |
'nav.library': '我的技能',
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
'theme': '主题',
|
| 146 |
'chooseTheme': '选择主题',
|
| 147 |
'cart': '购物车',
|
|
@@ -225,8 +237,12 @@ const translations: Record<Language, Record<string, string>> = {
|
|
| 225 |
'nav.find.user': '浏览',
|
| 226 |
'nav.cd.user': '分类',
|
| 227 |
'nav.man.user': '文档',
|
| 228 |
-
'nav.create.user': '创建',
|
| 229 |
'nav.library.user': '技能库',
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
|
| 231 |
// External Resources
|
| 232 |
'external.title': '社区技能 (外部资源)',
|
|
|
|
| 19 |
'nav.man': 'man recipes',
|
| 20 |
'nav.create': 'create skills',
|
| 21 |
'nav.library': 'my skills',
|
| 22 |
+
'nav.candy': 'find --candy',
|
| 23 |
+
'nav.craving': 'find --craving',
|
| 24 |
+
'nav.postCraving': 'post --craving',
|
| 25 |
+
'nav.postCandy': 'post --candy',
|
| 26 |
'theme': 'Theme',
|
| 27 |
'chooseTheme': 'Choose Theme',
|
| 28 |
'cart': 'Cart',
|
|
|
|
| 106 |
'nav.find.user': 'Browse',
|
| 107 |
'nav.cd.user': 'Categories',
|
| 108 |
'nav.man.user': 'Docs',
|
| 109 |
+
'nav.create.user': 'Create Candy',
|
| 110 |
'nav.library.user': 'Library',
|
| 111 |
+
'nav.candy.user': 'Find Candy',
|
| 112 |
+
'nav.craving.user': 'Find Craving',
|
| 113 |
+
'nav.postCraving.user': 'Post Craving',
|
| 114 |
+
'nav.postCandy.user': 'Post Candy',
|
| 115 |
|
| 116 |
// External Resources
|
| 117 |
'external.title': 'Community Skills (External)',
|
|
|
|
| 150 |
'nav.man': '使用指南',
|
| 151 |
'nav.create': '创建技能',
|
| 152 |
'nav.library': '我的技能',
|
| 153 |
+
'nav.candy': '找糖果',
|
| 154 |
+
'nav.craving': '找渴望',
|
| 155 |
+
'nav.postCraving': '发布需求',
|
| 156 |
+
'nav.postCandy': '发布技能',
|
| 157 |
'theme': '主题',
|
| 158 |
'chooseTheme': '选择主题',
|
| 159 |
'cart': '购物车',
|
|
|
|
| 237 |
'nav.find.user': '浏览',
|
| 238 |
'nav.cd.user': '分类',
|
| 239 |
'nav.man.user': '文档',
|
| 240 |
+
'nav.create.user': '创建糖果',
|
| 241 |
'nav.library.user': '技能库',
|
| 242 |
+
'nav.candy.user': '找糖果',
|
| 243 |
+
'nav.craving.user': '找渴望',
|
| 244 |
+
'nav.postCraving.user': '发布需求',
|
| 245 |
+
'nav.postCandy.user': '发布糖果',
|
| 246 |
|
| 247 |
// External Resources
|
| 248 |
'external.title': '社区技能 (外部资源)',
|
src/data/cravingsData.ts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
export type CravingCategory =
|
| 3 |
+
| 'Development'
|
| 4 |
+
| 'Design'
|
| 5 |
+
| 'Marketing'
|
| 6 |
+
| 'Productivity'
|
| 7 |
+
| 'Tools'
|
| 8 |
+
| 'Research'
|
| 9 |
+
| 'Mobile'
|
| 10 |
+
| 'Writing';
|
| 11 |
+
|
| 12 |
+
export type CravingUrgency = 'low' | 'medium' | 'high';
|
| 13 |
+
export type CravingStatus = 'open' | 'in-progress' | 'fulfilled';
|
| 14 |
+
|
| 15 |
+
export interface Craving {
|
| 16 |
+
id: string;
|
| 17 |
+
title: string;
|
| 18 |
+
description: string;
|
| 19 |
+
category: CravingCategory;
|
| 20 |
+
tags: string[];
|
| 21 |
+
budget: string;
|
| 22 |
+
urgency: CravingUrgency;
|
| 23 |
+
postedBy: string;
|
| 24 |
+
postedAt: string; // ISO date string
|
| 25 |
+
matchCount: number; // How many candies could fulfill this
|
| 26 |
+
status: CravingStatus;
|
| 27 |
+
emoji: string;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
export const CRAVINGS_DATA: Craving[] = [
|
| 31 |
+
{
|
| 32 |
+
id: 'craving-code-review',
|
| 33 |
+
title: 'Automated code review for my React monorepo',
|
| 34 |
+
description:
|
| 35 |
+
'I need an AI agent that can review PRs across a 30-repo monorepo, flag security issues, check TypeScript types, and leave structured comments on GitHub. Bonus if it can suggest refactors.',
|
| 36 |
+
category: 'Development',
|
| 37 |
+
tags: ['React', 'TypeScript', 'GitHub', 'Security'],
|
| 38 |
+
budget: '$100–300',
|
| 39 |
+
urgency: 'high',
|
| 40 |
+
postedBy: 'devloper_x',
|
| 41 |
+
postedAt: '2026-03-01T10:30:00Z',
|
| 42 |
+
matchCount: 7,
|
| 43 |
+
status: 'open',
|
| 44 |
+
emoji: '🔍',
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
id: 'craving-social-content',
|
| 48 |
+
title: 'Generate a week of social media posts from blog articles',
|
| 49 |
+
description:
|
| 50 |
+
'Give me a tool that reads my blog RSS feed and outputs 5 platform-specific posts (Twitter/X, LinkedIn, Instagram caption, Threads, BlueSky) per article, adapted for each platform tone.',
|
| 51 |
+
category: 'Marketing',
|
| 52 |
+
tags: ['Social Media', 'Content', 'Automation'],
|
| 53 |
+
budget: '$50–150',
|
| 54 |
+
urgency: 'medium',
|
| 55 |
+
postedBy: 'marketingmaven',
|
| 56 |
+
postedAt: '2026-03-02T08:00:00Z',
|
| 57 |
+
matchCount: 4,
|
| 58 |
+
status: 'open',
|
| 59 |
+
emoji: '📱',
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
id: 'craving-ui-component',
|
| 63 |
+
title: 'Design system documentation generator',
|
| 64 |
+
description:
|
| 65 |
+
'Parse a Figma file or a React component library and auto-generate a living documentation site with usage examples, prop tables, and design tokens. Must support Storybook export.',
|
| 66 |
+
category: 'Design',
|
| 67 |
+
tags: ['Figma', 'React', 'Design System', 'Documentation'],
|
| 68 |
+
budget: '$200–500',
|
| 69 |
+
urgency: 'low',
|
| 70 |
+
postedBy: 'pixel_pusher',
|
| 71 |
+
postedAt: '2026-02-28T14:20:00Z',
|
| 72 |
+
matchCount: 3,
|
| 73 |
+
status: 'open',
|
| 74 |
+
emoji: '🎨',
|
| 75 |
+
},
|
| 76 |
+
{
|
| 77 |
+
id: 'craving-email-automation',
|
| 78 |
+
title: 'Smart email triage and draft reply agent',
|
| 79 |
+
description:
|
| 80 |
+
'Read my inbox, categorize emails by priority, draft context-aware replies in my writing style, and flag anything that needs immediate human attention. Gmail or Outlook integration.',
|
| 81 |
+
category: 'Productivity',
|
| 82 |
+
tags: ['Email', 'Automation', 'Gmail'],
|
| 83 |
+
budget: '$80–200',
|
| 84 |
+
urgency: 'high',
|
| 85 |
+
postedBy: 'inbox_zero_fan',
|
| 86 |
+
postedAt: '2026-03-03T09:15:00Z',
|
| 87 |
+
matchCount: 5,
|
| 88 |
+
status: 'open',
|
| 89 |
+
emoji: '📬',
|
| 90 |
+
},
|
| 91 |
+
{
|
| 92 |
+
id: 'craving-competitor-analysis',
|
| 93 |
+
title: 'Weekly competitor landscape report',
|
| 94 |
+
description:
|
| 95 |
+
'Monitor 10 competitor websites, their Twitter/X activity, and product changelogs. Summarize key moves, pricing changes, and new features into a weekly Slack digest.',
|
| 96 |
+
category: 'Research',
|
| 97 |
+
tags: ['Research', 'Competitive Analysis', 'Slack'],
|
| 98 |
+
budget: '$100–250',
|
| 99 |
+
urgency: 'medium',
|
| 100 |
+
postedBy: 'strategy_nerd',
|
| 101 |
+
postedAt: '2026-02-27T11:00:00Z',
|
| 102 |
+
matchCount: 6,
|
| 103 |
+
status: 'open',
|
| 104 |
+
emoji: '🔭',
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
id: 'craving-product-descriptions',
|
| 108 |
+
title: 'E-commerce product description writer',
|
| 109 |
+
description:
|
| 110 |
+
'Generate SEO-optimized product descriptions for 500+ SKUs from a CSV of specs. Each description should be unique, conversion-focused, and under 200 words. Support for 3 languages.',
|
| 111 |
+
category: 'Writing',
|
| 112 |
+
tags: ['SEO', 'E-commerce', 'Content', 'Multilingual'],
|
| 113 |
+
budget: '$150–400',
|
| 114 |
+
urgency: 'medium',
|
| 115 |
+
postedBy: 'shopify_seller_99',
|
| 116 |
+
postedAt: '2026-03-01T16:45:00Z',
|
| 117 |
+
matchCount: 8,
|
| 118 |
+
status: 'open',
|
| 119 |
+
emoji: '🛍️',
|
| 120 |
+
},
|
| 121 |
+
{
|
| 122 |
+
id: 'craving-app-testing',
|
| 123 |
+
title: 'Mobile app regression test generator',
|
| 124 |
+
description:
|
| 125 |
+
'Given a mobile app codebase (React Native), auto-generate Detox or Maestro test cases for critical user flows. Should cover login, checkout, and push notification flows.',
|
| 126 |
+
category: 'Mobile',
|
| 127 |
+
tags: ['React Native', 'Testing', 'Automation', 'Mobile'],
|
| 128 |
+
budget: '$200–600',
|
| 129 |
+
urgency: 'low',
|
| 130 |
+
postedBy: 'native_dev_101',
|
| 131 |
+
postedAt: '2026-02-25T13:30:00Z',
|
| 132 |
+
matchCount: 2,
|
| 133 |
+
status: 'open',
|
| 134 |
+
emoji: '📲',
|
| 135 |
+
},
|
| 136 |
+
{
|
| 137 |
+
id: 'craving-data-viz',
|
| 138 |
+
title: 'Dashboard generation from SQL queries',
|
| 139 |
+
description:
|
| 140 |
+
'Point at a PostgreSQL database, let me describe what I want to see in plain English, and generate an interactive Recharts/D3 dashboard component with auto-refreshing data.',
|
| 141 |
+
category: 'Tools',
|
| 142 |
+
tags: ['SQL', 'Data Visualization', 'React', 'Dashboard'],
|
| 143 |
+
budget: '$300–700',
|
| 144 |
+
urgency: 'high',
|
| 145 |
+
postedBy: 'data_is_life',
|
| 146 |
+
postedAt: '2026-03-04T07:00:00Z',
|
| 147 |
+
matchCount: 4,
|
| 148 |
+
status: 'open',
|
| 149 |
+
emoji: '📊',
|
| 150 |
+
},
|
| 151 |
+
{
|
| 152 |
+
id: 'craving-tech-docs',
|
| 153 |
+
title: 'API documentation writer from codebase',
|
| 154 |
+
description:
|
| 155 |
+
'Scan a Node.js/Express codebase, extract all API endpoints, types, and business logic, then produce OpenAPI 3.1 spec + beautiful Markdown docs automatically. Must stay in sync on each commit.',
|
| 156 |
+
category: 'Writing',
|
| 157 |
+
tags: ['Documentation', 'API', 'Node.js', 'OpenAPI'],
|
| 158 |
+
budget: '$100–300',
|
| 159 |
+
urgency: 'high',
|
| 160 |
+
postedBy: 'api_architect',
|
| 161 |
+
postedAt: '2026-03-03T12:00:00Z',
|
| 162 |
+
matchCount: 5,
|
| 163 |
+
status: 'in-progress',
|
| 164 |
+
emoji: '📝',
|
| 165 |
+
},
|
| 166 |
+
{
|
| 167 |
+
id: 'craving-seo-optimization',
|
| 168 |
+
title: 'Technical SEO audit and fix agent',
|
| 169 |
+
description:
|
| 170 |
+
'Crawl my Next.js site, identify technical SEO issues (Core Web Vitals, meta tags, structured data, broken links), and open GitHub issues with suggested fixes. Monthly recurring run.',
|
| 171 |
+
category: 'Marketing',
|
| 172 |
+
tags: ['SEO', 'Next.js', 'Performance', 'GitHub'],
|
| 173 |
+
budget: '$80–200',
|
| 174 |
+
urgency: 'medium',
|
| 175 |
+
postedBy: 'seo_growth_hacker',
|
| 176 |
+
postedAt: '2026-02-29T10:00:00Z',
|
| 177 |
+
matchCount: 3,
|
| 178 |
+
status: 'open',
|
| 179 |
+
emoji: '🚀',
|
| 180 |
+
},
|
| 181 |
+
{
|
| 182 |
+
id: 'craving-code-refactor',
|
| 183 |
+
title: 'Legacy JavaScript to TypeScript migration agent',
|
| 184 |
+
description:
|
| 185 |
+
'Migrate a 50k LOC JavaScript codebase to strict TypeScript incrementally. Should infer types, add JSDoc where inference fails, and ensure zero regressions by running tests after each file.',
|
| 186 |
+
category: 'Development',
|
| 187 |
+
tags: ['TypeScript', 'Refactoring', 'JavaScript', 'Migration'],
|
| 188 |
+
budget: '$500–1500',
|
| 189 |
+
urgency: 'low',
|
| 190 |
+
postedBy: 'type_safety_enjoyer',
|
| 191 |
+
postedAt: '2026-02-26T15:00:00Z',
|
| 192 |
+
matchCount: 6,
|
| 193 |
+
status: 'open',
|
| 194 |
+
emoji: '🔧',
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
id: 'craving-customer-support',
|
| 198 |
+
title: 'Tier-1 customer support chatbot with escalation',
|
| 199 |
+
description:
|
| 200 |
+
'Build a support bot trained on our Notion knowledge base and Zendesk ticket history. Handle 80% of L1 tickets autonomously, escalate complex issues to humans with full context.',
|
| 201 |
+
category: 'Tools',
|
| 202 |
+
tags: ['Customer Support', 'Chatbot', 'Zendesk', 'Notion'],
|
| 203 |
+
budget: '$400–1000',
|
| 204 |
+
urgency: 'high',
|
| 205 |
+
postedBy: 'cx_team_lead',
|
| 206 |
+
postedAt: '2026-03-04T09:30:00Z',
|
| 207 |
+
matchCount: 9,
|
| 208 |
+
status: 'open',
|
| 209 |
+
emoji: '🎧',
|
| 210 |
+
},
|
| 211 |
+
];
|
src/index.css
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
@import '@fontsource/quicksand/400.css';
|
| 2 |
@import '@fontsource/quicksand/500.css';
|
| 3 |
@import '@fontsource/quicksand/600.css';
|
|
|
|
| 1 |
+
@import '@fontsource/inter/400.css';
|
| 2 |
+
@import '@fontsource/inter/500.css';
|
| 3 |
+
@import '@fontsource/inter/600.css';
|
| 4 |
+
@import '@fontsource/inter/700.css';
|
| 5 |
+
@import '@fontsource/inter/800.css';
|
| 6 |
@import '@fontsource/quicksand/400.css';
|
| 7 |
@import '@fontsource/quicksand/500.css';
|
| 8 |
@import '@fontsource/quicksand/600.css';
|
src/utils/storage.ts
CHANGED
|
@@ -184,4 +184,40 @@ export const storageUtils = {
|
|
| 184 |
console.error('Failed to save cart:', error);
|
| 185 |
}
|
| 186 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
};
|
|
|
|
| 184 |
console.error('Failed to save cart:', error);
|
| 185 |
}
|
| 186 |
},
|
| 187 |
+
|
| 188 |
+
// ── User-posted marketplace items ──────────────────────────────────────────
|
| 189 |
+
|
| 190 |
+
getUserCravings: (): import('../data/cravingsData').Craving[] => {
|
| 191 |
+
try {
|
| 192 |
+
return getSetting('user_market_cravings', []) as import('../data/cravingsData').Craving[];
|
| 193 |
+
} catch {
|
| 194 |
+
return [];
|
| 195 |
+
}
|
| 196 |
+
},
|
| 197 |
+
|
| 198 |
+
saveUserCraving: (craving: import('../data/cravingsData').Craving): void => {
|
| 199 |
+
try {
|
| 200 |
+
const existing = storageUtils.getUserCravings();
|
| 201 |
+
setSetting('user_market_cravings', [craving, ...existing]);
|
| 202 |
+
} catch (error) {
|
| 203 |
+
console.error('Failed to save craving:', error);
|
| 204 |
+
}
|
| 205 |
+
},
|
| 206 |
+
|
| 207 |
+
getUserCandies: (): import('../data/skillsData').Skill[] => {
|
| 208 |
+
try {
|
| 209 |
+
return getSetting('user_market_candies', []) as import('../data/skillsData').Skill[];
|
| 210 |
+
} catch {
|
| 211 |
+
return [];
|
| 212 |
+
}
|
| 213 |
+
},
|
| 214 |
+
|
| 215 |
+
saveUserCandy: (candy: import('../data/skillsData').Skill): void => {
|
| 216 |
+
try {
|
| 217 |
+
const existing = storageUtils.getUserCandies();
|
| 218 |
+
setSetting('user_market_candies', [candy, ...existing]);
|
| 219 |
+
} catch (error) {
|
| 220 |
+
console.error('Failed to save candy:', error);
|
| 221 |
+
}
|
| 222 |
+
},
|
| 223 |
};
|
vite.config.ts
CHANGED
|
@@ -9,7 +9,10 @@ export default defineConfig({
|
|
| 9 |
clearScreen: false,
|
| 10 |
server: {
|
| 11 |
port: 5173,
|
| 12 |
-
strictPort:
|
|
|
|
|
|
|
|
|
|
| 13 |
host: process.env.TAURI_DEV_HOST || 'localhost',
|
| 14 |
watch: {
|
| 15 |
ignored: ['**/src-tauri/**'],
|
|
|
|
| 9 |
clearScreen: false,
|
| 10 |
server: {
|
| 11 |
port: 5173,
|
| 12 |
+
strictPort: false,
|
| 13 |
+
// Disable HMR to prevent React Fast Refresh state corruption (black screens)
|
| 14 |
+
// Forces clean full-page reload on every file change (~200ms)
|
| 15 |
+
hmr: false,
|
| 16 |
host: process.env.TAURI_DEV_HOST || 'localhost',
|
| 17 |
watch: {
|
| 18 |
ignored: ['**/src-tauri/**'],
|