Enhance skill evaluation UI with category icons and URL state management

- Added category icons to the skill evaluation components for better visual representation.
- Implemented URL parameter handling in SkillEvaluation to maintain selected category state across navigation.
- Improved the HomePage layout with expandable skill categories and enhanced user interaction.
- Updated skill data files to include icon properties for each category.
This commit is contained in:
Julien Froidefond
2025-08-20 15:52:59 +02:00
parent 09d2c5cbe1
commit fe63f9592a
15 changed files with 202 additions and 54 deletions

View File

@@ -1,5 +1,6 @@
import { ChevronRight } from "lucide-react";
import { SkillCategory } from "@/lib/types";
import { getCategoryIcon } from "@/lib/category-icons";
interface CategoryTabsProps {
categories: SkillCategory[];
@@ -16,12 +17,13 @@ export function CategoryTabs({
<div className="flex flex-wrap gap-2 mb-8">
{categories.map((category) => {
const isActive = selectedCategory === category.category;
const CategoryIcon = getCategoryIcon(category.icon);
return (
<button
key={category.category}
onClick={() => onCategoryChange(category.category)}
className={`
relative px-6 py-3 rounded-xl font-medium transition-all duration-300 group
relative px-6 py-3 rounded-xl font-medium transition-all duration-300 group flex items-center gap-2
${
isActive
? "bg-blue-500 text-white shadow-lg shadow-blue-500/25"
@@ -29,6 +31,7 @@ export function CategoryTabs({
}
`}
>
<CategoryIcon className="w-4 h-4 relative z-10" />
<span className="relative z-10">{category.category}</span>
{isActive && (
<div className="absolute inset-0 rounded-xl bg-gradient-to-r from-blue-600/20 to-blue-400/20 animate-pulse" />

View File

@@ -94,35 +94,40 @@ export function SkillEvaluationCard({
</div>
{/* Level Selection */}
<div className="flex items-center gap-2 flex-shrink-0 ml-4">
<div className="flex items-center gap-3 flex-shrink-0 ml-4">
{Object.entries(SKILL_LEVELS).map(([value, label]) => {
const isSelected = currentLevel === value;
const levelValue = value as Exclude<SkillLevel, null>;
return (
<Tooltip key={value}>
<TooltipTrigger asChild>
<button
onClick={() => onUpdateSkill(skill.id, levelValue)}
className={`
relative w-5 h-5 rounded-md border-2 transition-all hover:scale-110
${
isSelected
? `${getLevelColor(levelValue)} ${getLevelColorBorder(
levelValue
)} shadow-lg`
: "bg-white/5 border-white/20 hover:border-white/30 hover:bg-white/10"
}
`}
>
{isSelected && (
<div className="absolute inset-0.5 bg-white rounded-sm"></div>
)}
</button>
</TooltipTrigger>
<TooltipContent>
<p className="text-sm font-medium">{label}</p>
</TooltipContent>
</Tooltip>
<div key={value} className="flex items-center gap-1.5">
<button
onClick={() => onUpdateSkill(skill.id, levelValue)}
className={`
relative w-4 h-4 rounded-md border-2 transition-all hover:scale-110
${
isSelected
? `${getLevelColor(levelValue)} ${getLevelColorBorder(
levelValue
)} shadow-lg`
: "bg-white/5 border-white/20 hover:border-white/30 hover:bg-white/10"
}
`}
>
{isSelected && (
<div className="absolute inset-0.5 bg-white rounded-sm"></div>
)}
</button>
<span
className={`text-xs font-medium transition-colors cursor-pointer ${
isSelected
? "text-white"
: "text-slate-400 hover:text-slate-300"
}`}
onClick={() => onUpdateSkill(skill.id, levelValue)}
>
{label}
</span>
</div>
);
})}

View File

@@ -37,7 +37,7 @@ export function SkillEvaluationGrid({
</div>
</div>
<div className="space-y-2">
<div className="space-y-3">
{currentEvaluation.selectedSkillIds.map((skillId) => {
const skill = currentCategory.skills.find((s) => s.id === skillId);
if (!skill) return null;

View File

@@ -1,6 +1,7 @@
"use client";
import { useState } from "react";
import { useState, useEffect } from "react";
import { useSearchParams, useRouter } from "next/navigation";
import { TooltipProvider } from "@/components/ui/tooltip";
import { SkillCategory, SkillLevel, CategoryEvaluation } from "@/lib/types";
import { SkillSelector } from "./skill-selector";
@@ -26,10 +27,31 @@ export function SkillEvaluation({
onAddSkill,
onRemoveSkill,
}: SkillEvaluationProps) {
const searchParams = useSearchParams();
const router = useRouter();
const categoryParam = searchParams.get("category");
const [selectedCategory, setSelectedCategory] = useState(
categories[0]?.category || ""
);
const handleCategoryChange = (category: string) => {
setSelectedCategory(category);
// Update URL without page reload
const newUrl = new URL(window.location.href);
newUrl.searchParams.set("category", category);
router.replace(newUrl.pathname + newUrl.search);
};
// Update selected category when URL param changes or categories load
useEffect(() => {
if (categoryParam && categories.some((c) => c.category === categoryParam)) {
setSelectedCategory(categoryParam);
} else if (categories.length > 0 && !selectedCategory) {
setSelectedCategory(categories[0].category);
}
}, [categoryParam, categories]); // Remove selectedCategory from deps to avoid loop
const currentCategory = categories.find(
(cat) => cat.category === selectedCategory
);
@@ -55,7 +77,7 @@ export function SkillEvaluation({
<CategoryTabs
categories={categories}
selectedCategory={selectedCategory}
onCategoryChange={setSelectedCategory}
onCategoryChange={handleCategoryChange}
/>
<div className="space-y-8">