feat(sidebar): add floating category hover tooltip popup and upgrade to professional studio icons
This commit is contained in:
@@ -11,14 +11,12 @@ import {
|
||||
Smartphone,
|
||||
ChevronRight,
|
||||
RotateCcw,
|
||||
LayoutGrid,
|
||||
ScanFace,
|
||||
Wand2,
|
||||
Scissors,
|
||||
Palette,
|
||||
} from 'lucide-react';
|
||||
import {
|
||||
FlaticonPortraitIcon,
|
||||
FlaticonRestorationIcon,
|
||||
FlaticonCutoutIcon,
|
||||
FlaticonArtIcon,
|
||||
FlaticonAllToolsIcon,
|
||||
} from '@/components/icons/Flaticons';
|
||||
import { ToolItem, CategoryItem, AppItem, resolveLocalised } from '@/types';
|
||||
import { KineticText } from '@/components/magicui/kinetic-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',
|
||||
};
|
||||
|
||||
// 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<
|
||||
string,
|
||||
{
|
||||
icon: React.ReactNode;
|
||||
selectedIcon: React.ReactNode;
|
||||
largeIcon: React.ReactNode;
|
||||
color: string;
|
||||
badgeBg: string;
|
||||
iconBg: string;
|
||||
}
|
||||
> = {
|
||||
'portrait-retouch': {
|
||||
icon: <FlaticonPortraitIcon className="w-4.5 h-4.5" />,
|
||||
largeIcon: <FlaticonPortraitIcon className="w-7 h-7" />,
|
||||
icon: <ScanFace className="w-3.5 h-3.5 text-rose-500" />,
|
||||
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',
|
||||
badgeBg: 'bg-rose-500/10 text-rose-700 border-rose-500/20',
|
||||
iconBg: 'bg-rose-50',
|
||||
},
|
||||
'restoration': {
|
||||
icon: <FlaticonRestorationIcon className="w-4.5 h-4.5" />,
|
||||
largeIcon: <FlaticonRestorationIcon className="w-7 h-7" />,
|
||||
icon: <Wand2 className="w-3.5 h-3.5 text-indigo-500" />,
|
||||
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',
|
||||
badgeBg: 'bg-indigo-500/10 text-indigo-700 border-indigo-500/20',
|
||||
iconBg: 'bg-indigo-50',
|
||||
},
|
||||
'background-cutout': {
|
||||
icon: <FlaticonCutoutIcon className="w-4.5 h-4.5" />,
|
||||
largeIcon: <FlaticonCutoutIcon className="w-7 h-7" />,
|
||||
icon: <Scissors className="w-3.5 h-3.5 text-emerald-500" />,
|
||||
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',
|
||||
badgeBg: 'bg-emerald-500/10 text-emerald-700 border-emerald-500/20',
|
||||
iconBg: 'bg-emerald-50',
|
||||
},
|
||||
'creative-art': {
|
||||
icon: <FlaticonArtIcon className="w-4.5 h-4.5" />,
|
||||
largeIcon: <FlaticonArtIcon className="w-7 h-7" />,
|
||||
icon: <Palette className="w-3.5 h-3.5 text-amber-500" />,
|
||||
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',
|
||||
badgeBg: 'bg-amber-500/10 text-amber-700 border-amber-500/20',
|
||||
iconBg: 'bg-amber-50',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -655,6 +663,13 @@ export function ToolGridSection({
|
||||
}: ToolGridSectionProps) {
|
||||
const [selectedCategory, setSelectedCategory] = useState<string>('all');
|
||||
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
|
||||
const categorizedTools = useMemo(() => {
|
||||
@@ -794,7 +809,11 @@ export function ToolGridSection({
|
||||
LEFT SIDEBAR: DOCKED DIRECTLY TO VIEWPORT EDGE (STICKY DESKTOP)
|
||||
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 */}
|
||||
<div className="space-y-4">
|
||||
@@ -843,6 +862,7 @@ export function ToolGridSection({
|
||||
onClick={() => {
|
||||
handleSelectCategory('all');
|
||||
setSearchQuery('');
|
||||
setHoveredCategory(null);
|
||||
}}
|
||||
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 */}
|
||||
<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 ${
|
||||
selectedCategory === 'all' && !searchQuery
|
||||
? '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={`w-5 h-5 rounded-md flex items-center justify-center shrink-0 ${
|
||||
selectedCategory === 'all' && !searchQuery
|
||||
? 'bg-white/20'
|
||||
: 'bg-slate-100'
|
||||
? 'bg-white/20 text-white'
|
||||
: '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>
|
||||
<span className="truncate">All Studio Tools</span>
|
||||
</div>
|
||||
@@ -896,7 +934,21 @@ export function ToolGridSection({
|
||||
<button
|
||||
key={group.id}
|
||||
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 ${
|
||||
isSelected
|
||||
? '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={`w-5 h-5 rounded-md flex items-center justify-center shrink-0 ${
|
||||
isSelected
|
||||
? 'bg-white/20'
|
||||
: 'bg-slate-100'
|
||||
? 'bg-white/20 text-white'
|
||||
: 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>
|
||||
<span className="truncate">{catName}</span>
|
||||
</div>
|
||||
@@ -946,6 +1000,31 @@ export function ToolGridSection({
|
||||
|
||||
</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)
|
||||
========================================================================= */}
|
||||
@@ -994,7 +1073,7 @@ export function ToolGridSection({
|
||||
: '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>
|
||||
</button>
|
||||
{categorizedTools.map((group) => {
|
||||
@@ -1015,7 +1094,11 @@ export function ToolGridSection({
|
||||
: '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 className="text-[10px] opacity-70">({group.tools.length})</span>
|
||||
</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 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">
|
||||
{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 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 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">
|
||||
{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 className="flex items-center gap-2.5">
|
||||
|
||||
Reference in New Issue
Block a user