feat(sidebar): add floating category hover tooltip popup and upgrade to professional studio icons

This commit is contained in:
2026-11-13 11:01:31 +05:30
parent d3d35eaa85
commit b50d28781f
+112 -29
View File
@@ -11,14 +11,12 @@ import {
Smartphone, Smartphone,
ChevronRight, ChevronRight,
RotateCcw, RotateCcw,
LayoutGrid,
ScanFace,
Wand2,
Scissors,
Palette,
} from 'lucide-react'; } from 'lucide-react';
import {
FlaticonPortraitIcon,
FlaticonRestorationIcon,
FlaticonCutoutIcon,
FlaticonArtIcon,
FlaticonAllToolsIcon,
} from '@/components/icons/Flaticons';
import { ToolItem, CategoryItem, AppItem, resolveLocalised } from '@/types'; import { ToolItem, CategoryItem, AppItem, resolveLocalised } from '@/types';
import { KineticText } from '@/components/magicui/kinetic-text'; import { KineticText } from '@/components/magicui/kinetic-text';
import { AnimatedShinyText } from '@/components/magicui/animated-shiny-text'; import { AnimatedShinyText } from '@/components/magicui/animated-shiny-text';
@@ -353,39 +351,49 @@ const TOOL_MODEL_SPECS: Record<string, string> = {
'hair-style-changer': 'FLUX.1-Fill Hairstyle Refiner', 'hair-style-changer': 'FLUX.1-Fill Hairstyle Refiner',
}; };
// Category visual themes aligned to Porcelain Light theme with Flaticons // Category visual themes aligned to Porcelain Light theme with Professional Icons
const CATEGORY_THEMES: Record< const CATEGORY_THEMES: Record<
string, string,
{ {
icon: React.ReactNode; icon: React.ReactNode;
selectedIcon: React.ReactNode;
largeIcon: React.ReactNode; largeIcon: React.ReactNode;
color: string; color: string;
badgeBg: string; badgeBg: string;
iconBg: string;
} }
> = { > = {
'portrait-retouch': { 'portrait-retouch': {
icon: <FlaticonPortraitIcon className="w-4.5 h-4.5" />, icon: <ScanFace className="w-3.5 h-3.5 text-rose-500" />,
largeIcon: <FlaticonPortraitIcon className="w-7 h-7" />, selectedIcon: <ScanFace className="w-3.5 h-3.5 text-white" />,
largeIcon: <ScanFace className="w-6 h-6 text-rose-500" />,
color: 'text-rose-600', color: 'text-rose-600',
badgeBg: 'bg-rose-500/10 text-rose-700 border-rose-500/20', badgeBg: 'bg-rose-500/10 text-rose-700 border-rose-500/20',
iconBg: 'bg-rose-50',
}, },
'restoration': { 'restoration': {
icon: <FlaticonRestorationIcon className="w-4.5 h-4.5" />, icon: <Wand2 className="w-3.5 h-3.5 text-indigo-500" />,
largeIcon: <FlaticonRestorationIcon className="w-7 h-7" />, selectedIcon: <Wand2 className="w-3.5 h-3.5 text-white" />,
largeIcon: <Wand2 className="w-6 h-6 text-indigo-500" />,
color: 'text-indigo-600', color: 'text-indigo-600',
badgeBg: 'bg-indigo-500/10 text-indigo-700 border-indigo-500/20', badgeBg: 'bg-indigo-500/10 text-indigo-700 border-indigo-500/20',
iconBg: 'bg-indigo-50',
}, },
'background-cutout': { 'background-cutout': {
icon: <FlaticonCutoutIcon className="w-4.5 h-4.5" />, icon: <Scissors className="w-3.5 h-3.5 text-emerald-500" />,
largeIcon: <FlaticonCutoutIcon className="w-7 h-7" />, selectedIcon: <Scissors className="w-3.5 h-3.5 text-white" />,
largeIcon: <Scissors className="w-6 h-6 text-emerald-500" />,
color: 'text-emerald-600', color: 'text-emerald-600',
badgeBg: 'bg-emerald-500/10 text-emerald-700 border-emerald-500/20', badgeBg: 'bg-emerald-500/10 text-emerald-700 border-emerald-500/20',
iconBg: 'bg-emerald-50',
}, },
'creative-art': { 'creative-art': {
icon: <FlaticonArtIcon className="w-4.5 h-4.5" />, icon: <Palette className="w-3.5 h-3.5 text-amber-500" />,
largeIcon: <FlaticonArtIcon className="w-7 h-7" />, selectedIcon: <Palette className="w-3.5 h-3.5 text-white" />,
largeIcon: <Palette className="w-6 h-6 text-amber-500" />,
color: 'text-amber-600', color: 'text-amber-600',
badgeBg: 'bg-amber-500/10 text-amber-700 border-amber-500/20', badgeBg: 'bg-amber-500/10 text-amber-700 border-amber-500/20',
iconBg: 'bg-amber-50',
}, },
}; };
@@ -655,6 +663,13 @@ export function ToolGridSection({
}: ToolGridSectionProps) { }: ToolGridSectionProps) {
const [selectedCategory, setSelectedCategory] = useState<string>('all'); const [selectedCategory, setSelectedCategory] = useState<string>('all');
const [searchQuery, setSearchQuery] = useState<string>(''); const [searchQuery, setSearchQuery] = useState<string>('');
const [hoveredCategory, setHoveredCategory] = useState<{
id: string;
name: string;
count: number;
top: number;
left: number;
} | null>(null);
// Group all tools by category // Group all tools by category
const categorizedTools = useMemo(() => { const categorizedTools = useMemo(() => {
@@ -794,7 +809,11 @@ export function ToolGridSection({
LEFT SIDEBAR: DOCKED DIRECTLY TO VIEWPORT EDGE (STICKY DESKTOP) LEFT SIDEBAR: DOCKED DIRECTLY TO VIEWPORT EDGE (STICKY DESKTOP)
High-contrast, clearly legible font with dedicated active category states High-contrast, clearly legible font with dedicated active category states
========================================================================= */} ========================================================================= */}
<aside className="hidden lg:flex flex-col justify-between w-56 xl:w-60 shrink-0 border-r border-rule bg-paper-hi sticky top-[73px] h-[calc(100vh-73px)] overflow-y-auto no-scrollbar p-3.5 xl:p-4 z-20"> <aside
onScroll={() => setHoveredCategory(null)}
onMouseLeave={() => setHoveredCategory(null)}
className="hidden lg:flex flex-col justify-between w-56 xl:w-60 shrink-0 border-r border-rule bg-paper-hi sticky top-[73px] h-[calc(100vh-73px)] overflow-y-auto no-scrollbar p-3.5 xl:p-4 z-20"
>
{/* Top: Header, Search, Categories Nav */} {/* Top: Header, Search, Categories Nav */}
<div className="space-y-4"> <div className="space-y-4">
@@ -843,6 +862,7 @@ export function ToolGridSection({
onClick={() => { onClick={() => {
handleSelectCategory('all'); handleSelectCategory('all');
setSearchQuery(''); setSearchQuery('');
setHoveredCategory(null);
}} }}
className="inline-flex items-center gap-1 text-[11px] font-semibold text-accent hover:underline cursor-pointer lowercase" className="inline-flex items-center gap-1 text-[11px] font-semibold text-accent hover:underline cursor-pointer lowercase"
> >
@@ -856,7 +876,21 @@ export function ToolGridSection({
{/* All Studio Tools */} {/* All Studio Tools */}
<button <button
type="button" type="button"
onClick={() => handleSelectCategory('all')} onClick={() => {
handleSelectCategory('all');
setHoveredCategory(null);
}}
onMouseEnter={(e) => {
const rect = e.currentTarget.getBoundingClientRect();
setHoveredCategory({
id: 'all',
name: 'All Studio Tools',
count: tools.length,
top: rect.top + rect.height / 2,
left: rect.right + 10,
});
}}
onMouseLeave={() => setHoveredCategory(null)}
className={`w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-xs font-sans transition-all duration-150 cursor-pointer ${ className={`w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-xs font-sans transition-all duration-150 cursor-pointer ${
selectedCategory === 'all' && !searchQuery selectedCategory === 'all' && !searchQuery
? 'bg-slate-900 text-white shadow-xs font-semibold' ? 'bg-slate-900 text-white shadow-xs font-semibold'
@@ -866,10 +900,14 @@ export function ToolGridSection({
<div className="flex items-center gap-2 min-w-0"> <div className="flex items-center gap-2 min-w-0">
<div className={`w-5 h-5 rounded-md flex items-center justify-center shrink-0 ${ <div className={`w-5 h-5 rounded-md flex items-center justify-center shrink-0 ${
selectedCategory === 'all' && !searchQuery selectedCategory === 'all' && !searchQuery
? 'bg-white/20' ? 'bg-white/20 text-white'
: 'bg-slate-100' : 'bg-slate-100 text-slate-600'
}`}> }`}>
<FlaticonAllToolsIcon className="w-3.5 h-3.5" /> {selectedCategory === 'all' && !searchQuery ? (
<LayoutGrid className="w-3.5 h-3.5 text-white" />
) : (
<LayoutGrid className="w-3.5 h-3.5 text-slate-600" />
)}
</div> </div>
<span className="truncate">All Studio Tools</span> <span className="truncate">All Studio Tools</span>
</div> </div>
@@ -896,7 +934,21 @@ export function ToolGridSection({
<button <button
key={group.id} key={group.id}
type="button" type="button"
onClick={() => handleSelectCategory(group.id)} onClick={() => {
handleSelectCategory(group.id);
setHoveredCategory(null);
}}
onMouseEnter={(e) => {
const rect = e.currentTarget.getBoundingClientRect();
setHoveredCategory({
id: group.id,
name: catName,
count: group.tools.length,
top: rect.top + rect.height / 2,
left: rect.right + 10,
});
}}
onMouseLeave={() => setHoveredCategory(null)}
className={`w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-xs font-sans transition-all duration-150 cursor-pointer ${ className={`w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-xs font-sans transition-all duration-150 cursor-pointer ${
isSelected isSelected
? 'bg-slate-900 text-white shadow-xs font-semibold' ? 'bg-slate-900 text-white shadow-xs font-semibold'
@@ -906,10 +958,12 @@ export function ToolGridSection({
<div className="flex items-center gap-2 min-w-0"> <div className="flex items-center gap-2 min-w-0">
<div className={`w-5 h-5 rounded-md flex items-center justify-center shrink-0 ${ <div className={`w-5 h-5 rounded-md flex items-center justify-center shrink-0 ${
isSelected isSelected
? 'bg-white/20' ? 'bg-white/20 text-white'
: 'bg-slate-100' : theme?.iconBg || 'bg-slate-100'
}`}> }`}>
{theme?.icon || <FlaticonAllToolsIcon className="w-3.5 h-3.5" />} {isSelected
? theme?.selectedIcon || <LayoutGrid className="w-3.5 h-3.5 text-white" />
: theme?.icon || <LayoutGrid className="w-3.5 h-3.5 text-slate-600" />}
</div> </div>
<span className="truncate">{catName}</span> <span className="truncate">{catName}</span>
</div> </div>
@@ -946,6 +1000,31 @@ export function ToolGridSection({
</aside> </aside>
{/* =========================================================================
FLOATING CATEGORY TOOLTIP POPUP (TRIGGERED ON SIDEBAR HOVER)
Displays the complete unabbreviated category name & count
========================================================================= */}
{hoveredCategory && (
<div
className="fixed z-50 pointer-events-none px-3 py-1.5 rounded-lg bg-slate-900/95 backdrop-blur-md text-white text-xs font-sans font-medium shadow-xl border border-slate-700/80 flex items-center gap-2.5 transition-opacity duration-150 animate-in fade-in-0 zoom-in-95"
style={{
top: `${hoveredCategory.top}px`,
left: `${hoveredCategory.left}px`,
transform: 'translateY(-50%)',
}}
role="tooltip"
>
{/* Subtle pointer arrow pointing left toward the sidebar category */}
<div className="absolute -left-1.5 top-1/2 -translate-y-1/2 w-2.5 h-2.5 bg-slate-900 rotate-45 border-l border-b border-slate-700/80" />
<span className="font-semibold tracking-tight text-white whitespace-nowrap">
{hoveredCategory.name}
</span>
<span className="text-[10px] font-mono text-slate-300 bg-slate-800 px-1.5 py-0.5 rounded font-bold border border-slate-700/60 whitespace-nowrap">
{hoveredCategory.count} {hoveredCategory.count === 1 ? 'tool' : 'tools'}
</span>
</div>
)}
{/* ========================================================================= {/* =========================================================================
RIGHT MAIN STUDIO WORKSPACE (SPACIOUS 4-COLUMN CARDS GALLERY) RIGHT MAIN STUDIO WORKSPACE (SPACIOUS 4-COLUMN CARDS GALLERY)
========================================================================= */} ========================================================================= */}
@@ -994,7 +1073,7 @@ export function ToolGridSection({
: 'bg-white text-slate-800 border border-slate-200 hover:text-slate-950' : 'bg-white text-slate-800 border border-slate-200 hover:text-slate-950'
}`} }`}
> >
<FlaticonAllToolsIcon className="w-3.5 h-3.5" /> <LayoutGrid className="w-3.5 h-3.5" />
<span>All tools ({tools.length})</span> <span>All tools ({tools.length})</span>
</button> </button>
{categorizedTools.map((group) => { {categorizedTools.map((group) => {
@@ -1015,7 +1094,11 @@ export function ToolGridSection({
: 'bg-white text-slate-800 border border-slate-200 hover:text-slate-950' : 'bg-white text-slate-800 border border-slate-200 hover:text-slate-950'
}`} }`}
> >
<span className="shrink-0">{theme?.icon || <FlaticonAllToolsIcon className="w-3.5 h-3.5" />}</span> <span className="shrink-0">
{isSelected
? theme?.selectedIcon || <LayoutGrid className="w-3.5 h-3.5 text-white" />
: theme?.icon || <LayoutGrid className="w-3.5 h-3.5 text-slate-600" />}
</span>
<span>{catName}</span> <span>{catName}</span>
<span className="text-[10px] opacity-70">({group.tools.length})</span> <span className="text-[10px] opacity-70">({group.tools.length})</span>
</button> </button>
@@ -1056,7 +1139,7 @@ export function ToolGridSection({
<div className="flex flex-col sm:flex-row sm:items-start justify-between gap-4 pt-1"> <div className="flex flex-col sm:flex-row sm:items-start justify-between gap-4 pt-1">
<div className="flex items-center gap-3.5"> <div className="flex items-center gap-3.5">
<div className="w-12 h-12 rounded-2xl flex items-center justify-center bg-paper-hi shadow-xs border border-rule shrink-0"> <div className="w-12 h-12 rounded-2xl flex items-center justify-center bg-paper-hi shadow-xs border border-rule shrink-0">
{CATEGORY_THEMES[activeCategoryItem.id]?.largeIcon || <FlaticonAllToolsIcon className="w-7 h-7" />} {CATEGORY_THEMES[activeCategoryItem.id]?.largeIcon || <LayoutGrid className="w-6 h-6 text-slate-700" />}
</div> </div>
<div> <div>
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
@@ -1177,7 +1260,7 @@ export function ToolGridSection({
<div className="flex flex-col sm:flex-row sm:items-end justify-between gap-3 pb-4 border-b border-rule"> <div className="flex flex-col sm:flex-row sm:items-end justify-between gap-3 pb-4 border-b border-rule">
<div className="flex items-center gap-3.5"> <div className="flex items-center gap-3.5">
<div className="w-11 h-11 rounded-2xl flex items-center justify-center bg-paper-hi shadow-xs border border-rule shrink-0"> <div className="w-11 h-11 rounded-2xl flex items-center justify-center bg-paper-hi shadow-xs border border-rule shrink-0">
{theme?.largeIcon || theme?.icon || <FlaticonAllToolsIcon className="w-6 h-6" />} {theme?.largeIcon || theme?.icon || <LayoutGrid className="w-6 h-6 text-slate-700" />}
</div> </div>
<div> <div>
<div className="flex items-center gap-2.5"> <div className="flex items-center gap-2.5">