Add skills page with category grouping (Story 2.4)

- Enhance Skill model with getCurrentLevel() and ordered scope
- Update SkillController to group by category with translated labels
- Add level and project_count to SkillResource
- Create skill.ts types (Skill, SkillCategory, SkillsResponse)
- Create useFetchSkills composable
- Create SkillCard component with animated progress bar
- Implement competences.vue with:
  - Responsive grid (2/3/4 columns)
  - Category sections with icons
  - Stagger animations (respects prefers-reduced-motion)
  - Loading/error/empty states
  - Placeholder for vis.js skill tree (Epic 3)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-06 10:37:10 +01:00
parent 2269ecdb62
commit 4db96a0ded
11 changed files with 414 additions and 65 deletions

View File

@@ -10,13 +10,36 @@ class SkillController extends Controller
{ {
public function index() public function index()
{ {
$skills = Skill::ordered()->get()->groupBy('category'); $lang = app()->getLocale();
$skills = Skill::with('projects')->ordered()->get();
$grouped = $skills->groupBy('category');
$grouped = $skills->map(fn ($group) => SkillResource::collection($group)); $data = $grouped->map(function ($categorySkills, $category) use ($lang) {
return [
'category' => $category,
'category_label' => $this->getCategoryLabel($category, $lang),
'skills' => SkillResource::collection($categorySkills),
];
})->values();
return response()->json([ return response()->json([
'data' => $grouped, 'data' => $data,
'meta' => ['lang' => app()->getLocale()], 'meta' => [
'lang' => $lang,
'total' => $skills->count(),
],
]); ]);
} }
private function getCategoryLabel(string $category, string $lang): string
{
$labels = [
'frontend' => ['fr' => 'Frontend', 'en' => 'Frontend'],
'backend' => ['fr' => 'Backend', 'en' => 'Backend'],
'tools' => ['fr' => 'Outils', 'en' => 'Tools'],
'soft_skills' => ['fr' => 'Soft Skills', 'en' => 'Soft Skills'],
];
return $labels[strtolower($category)][$lang] ?? ucfirst($category);
}
} }

View File

@@ -16,7 +16,10 @@ class SkillResource extends JsonResource
'description' => $this->getTranslated('description_key'), 'description' => $this->getTranslated('description_key'),
'icon' => $this->icon, 'icon' => $this->icon,
'category' => $this->category, 'category' => $this->category,
'level' => $this->getCurrentLevel(),
'max_level' => $this->max_level, 'max_level' => $this->max_level,
'display_order' => $this->display_order,
'project_count' => $this->whenLoaded('projects', fn () => $this->projects->count()),
'pivot' => $this->when($this->pivot, fn () => [ 'pivot' => $this->when($this->pivot, fn () => [
'level_before' => $this->pivot->level_before, 'level_before' => $this->pivot->level_before,
'level_after' => $this->pivot->level_after, 'level_after' => $this->pivot->level_after,

View File

@@ -34,6 +34,13 @@ class Skill extends Model
public function scopeOrdered(Builder $query): Builder public function scopeOrdered(Builder $query): Builder
{ {
return $query->orderBy('display_order'); return $query->orderBy('category')->orderBy('display_order');
}
public function getCurrentLevel(): int
{
$maxLevelAfter = $this->projects()->max('skill_project.level_after');
return $maxLevelAfter ?? 1;
} }
} }

View File

@@ -1,6 +1,6 @@
# Story 2.4: Page Compétences - Affichage par catégories # Story 2.4: Page Compétences - Affichage par catégories
Status: ready-for-dev Status: review
## Story ## Story
@@ -21,61 +21,61 @@ so that je comprends son profil technique global.
## Tasks / Subtasks ## Tasks / Subtasks
- [ ] **Task 1: Créer l'endpoint API Laravel pour les skills** (AC: #3) - [x] **Task 1: Créer l'endpoint API Laravel pour les skills** (AC: #3)
- [ ] Créer `app/Http/Controllers/Api/SkillController.php` - [x] Créer `app/Http/Controllers/Api/SkillController.php`
- [ ] Créer la méthode `index()` pour lister toutes les compétences - [x] Créer la méthode `index()` pour lister toutes les compétences
- [ ] Grouper les compétences par catégorie - [x] Grouper les compétences par catégorie
- [ ] Joindre les traductions selon `Accept-Language` - [x] Joindre les traductions selon `Accept-Language`
- [ ] Créer `app/Http/Resources/SkillResource.php` - [x] Créer `app/Http/Resources/SkillResource.php`
- [ ] Ajouter la route `GET /api/skills` dans `routes/api.php` - [x] Ajouter la route `GET /api/skills` dans `routes/api.php`
- [ ] **Task 2: Créer le composable useFetchSkills** (AC: #3) - [x] **Task 2: Créer le composable useFetchSkills** (AC: #3)
- [ ] Créer `frontend/app/composables/useFetchSkills.ts` - [x] Créer `frontend/app/composables/useFetchSkills.ts`
- [ ] Gérer les états loading, error, data - [x] Gérer les états loading, error, data
- [ ] Typer la réponse avec interface Skill[] - [x] Typer la réponse avec interface Skill[]
- [ ] **Task 3: Créer le composant SkillCard** (AC: #2, #8) - [x] **Task 3: Créer le composant SkillCard** (AC: #2, #8)
- [ ] Créer `frontend/app/components/feature/SkillCard.vue` - [x] Créer `frontend/app/components/feature/SkillCard.vue`
- [ ] Props : skill (avec name, icon, level, maxLevel) - [x] Props : skill (avec name, icon, level, maxLevel)
- [ ] Afficher l'icône (si présente) ou un placeholder - [x] Afficher l'icône (si présente) ou un placeholder
- [ ] Afficher le nom traduit - [x] Afficher le nom traduit
- [ ] Afficher le niveau avec une barre de progression - [x] Afficher le niveau avec une barre de progression
- [ ] Style cliquable (hover effect, cursor pointer) - [x] Style cliquable (hover effect, cursor pointer)
- [ ] **Task 4: Créer la page competences.vue** (AC: #1, #6) - [x] **Task 4: Créer la page competences.vue** (AC: #1, #6)
- [ ] Créer `frontend/app/pages/competences.vue` - [x] Créer `frontend/app/pages/competences.vue`
- [ ] Charger les données avec `useFetchSkills()` - [x] Charger les données avec `useFetchSkills()`
- [ ] Grouper les skills par catégorie côté frontend - [x] Grouper les skills par catégorie côté frontend
- [ ] Afficher chaque catégorie comme une section avec titre - [x] Afficher chaque catégorie comme une section avec titre
- [ ] Grille de SkillCard dans chaque section - [x] Grille de SkillCard dans chaque section
- [ ] **Task 5: Implémenter l'animation d'entrée** (AC: #4) - [x] **Task 5: Implémenter l'animation d'entrée** (AC: #4)
- [ ] Animation stagger pour les SkillCards (comme ProjectCard) - [x] Animation stagger pour les SkillCards (comme ProjectCard)
- [ ] Animation fade-in pour les titres de catégories - [x] Animation fade-in pour les titres de catégories
- [ ] Respecter `prefers-reduced-motion` - [x] Respecter `prefers-reduced-motion`
- [ ] **Task 6: Design responsive** (AC: #5, #6) - [x] **Task 6: Design responsive** (AC: #5, #6)
- [ ] Mobile : 2 colonnes de SkillCards par catégorie - [x] Mobile : 2 colonnes de SkillCards par catégorie
- [ ] Desktop : 4 colonnes, espace réservé pour vis.js (Epic 3) - [x] Desktop : 4 colonnes, espace réservé pour vis.js (Epic 3)
- [ ] Catégories empilées verticalement - [x] Catégories empilées verticalement
- [ ] **Task 7: Représentation visuelle du niveau** (AC: #2) - [x] **Task 7: Représentation visuelle du niveau** (AC: #2)
- [ ] Créer une barre de progression stylisée (style RPG/XP) - [x] Créer une barre de progression stylisée (style RPG/XP)
- [ ] Utiliser `sky-accent` pour la partie remplie - [x] Utiliser `sky-accent` pour la partie remplie
- [ ] Afficher le ratio (ex: 4/5 ou 80%) - [x] Afficher le ratio (ex: 4/5 ou 80%)
- [ ] Animation subtile au chargement (remplissage progressif) - [x] Animation subtile au chargement (remplissage progressif)
- [ ] **Task 8: Meta tags SEO** (AC: #7) - [x] **Task 8: Meta tags SEO** (AC: #7)
- [ ] Titre dynamique : "Compétences | Skycel" - [x] Titre dynamique : "Compétences | Skycel"
- [ ] Description : compétences de Célian - [x] Description : compétences de Célian
- [ ] og:title et og:description - [x] og:title et og:description
- [ ] **Task 9: Tests et validation** - [x] **Task 9: Tests et validation**
- [ ] Tester en FR et EN - [x] Tester en FR et EN
- [ ] Vérifier le groupement par catégorie - [x] Vérifier le groupement par catégorie
- [ ] Valider les animations - [x] Valider les animations
- [ ] Tester le responsive - [x] Tester le responsive
- [ ] Vérifier que les skills sont cliquables (préparation Story 2.5) - [x] Vérifier que les skills sont cliquables (préparation Story 2.5)
## Dev Notes ## Dev Notes
@@ -552,16 +552,46 @@ frontend/i18n/en.json # AJOUTER clés skills.*
### Agent Model Used ### Agent Model Used
{{agent_model_name_version}} Claude Opus 4.5 (claude-opus-4-5-20251101)
### Debug Log References ### Debug Log References
- API SkillController et SkillResource existaient déjà, améliorés avec level, project_count et category_label
### Completion Notes List ### Completion Notes List
- Modèle Skill amélioré : getCurrentLevel() + scope ordered par category puis display_order
- SkillResource amélioré : ajout level, display_order, project_count
- SkillController amélioré : groupement par catégorie avec category_label traduit
- Type skill.ts créé avec Skill, SkillCategory, SkillsResponse
- Composable useFetchSkills créé
- SkillCard créé : icône, nom, barre de progression animée, niveau X/Y, hover effect
- Page compétences complète :
- Grille responsive 2/3/4 colonnes
- Sections par catégorie avec icônes (🎨 frontend, ⚙️ backend, 🛠️ tools, 💡 soft_skills)
- Animation stagger fadeInUp
- États loading (skeleton), error (retry), empty
- Placeholder vis.js (desktop only)
- prefers-reduced-motion respecté
- SEO via useSeo
- Store progression visitSection('competences')
- Traductions FR/EN ajoutées (skills.*)
### Change Log ### Change Log
| Date | Change | Author | | Date | Change | Author |
|------|--------|--------| |------|--------|--------|
| 2026-02-04 | Story créée avec contexte complet | SM Agent | | 2026-02-04 | Story créée avec contexte complet | SM Agent |
| 2026-02-06 | Tasks 1-9 implémentées et validées | Dev Agent (Claude Opus 4.5) |
### File List ### File List
- `api/app/Models/Skill.php` — MODIFIÉ (getCurrentLevel, scope ordered)
- `api/app/Http/Controllers/Api/SkillController.php` — MODIFIÉ (groupement, category_label)
- `api/app/Http/Resources/SkillResource.php` — MODIFIÉ (level, project_count)
- `frontend/app/types/skill.ts` — CRÉÉ
- `frontend/app/composables/useFetchSkills.ts` — CRÉÉ
- `frontend/app/components/feature/SkillCard.vue` — CRÉÉ
- `frontend/app/pages/competences.vue` — RÉÉCRIT
- `frontend/i18n/fr.json` — MODIFIÉ (ajout skills.*)
- `frontend/i18n/en.json` — MODIFIÉ (ajout skills.*)

View File

@@ -60,7 +60,7 @@ development_status:
2-1-composant-projectcard: review 2-1-composant-projectcard: review
2-2-page-projets-galerie: review 2-2-page-projets-galerie: review
2-3-page-projet-detail: review 2-3-page-projet-detail: review
2-4-page-competences-affichage-categories: ready-for-dev 2-4-page-competences-affichage-categories: review
2-5-competences-cliquables-projets-lies: ready-for-dev 2-5-competences-cliquables-projets-lies: ready-for-dev
2-6-page-temoignages-migrations-bdd: ready-for-dev 2-6-page-temoignages-migrations-bdd: ready-for-dev
2-7-composant-dialogue-pnj: ready-for-dev 2-7-composant-dialogue-pnj: ready-for-dev

View File

@@ -0,0 +1,83 @@
<template>
<button
type="button"
class="skill-card group w-full text-left bg-sky-text/5 rounded-xl p-4 hover:bg-sky-text/10 transition-colors cursor-pointer border border-sky-text/10"
@click="emit('click', skill)"
>
<div class="flex items-center gap-3 mb-3">
<!-- Icon -->
<div class="w-10 h-10 flex items-center justify-center bg-sky-dark/50 rounded-lg shrink-0">
<span v-if="skill.icon" class="text-2xl">{{ skill.icon }}</span>
<span v-else class="text-sky-text/40 text-lg">💻</span>
</div>
<!-- Name and project count -->
<div class="flex-1 min-w-0">
<h3 class="font-ui font-medium text-sky-text truncate group-hover:text-sky-accent transition-colors">
{{ skill.name }}
</h3>
<p v-if="skill.project_count" class="text-xs text-sky-text/50">
{{ skill.project_count }} {{ skill.project_count > 1 ? $t('skills.projects') : $t('skills.project') }}
</p>
</div>
</div>
<!-- Progress bar -->
<div class="relative h-2 bg-sky-dark/50 rounded-full overflow-hidden">
<div
class="skill-progress absolute left-0 top-0 h-full bg-gradient-to-r from-sky-accent to-sky-accent/80 rounded-full"
:style="{ '--target-width': `${progressPercent}%` }"
/>
</div>
<!-- Level display -->
<div class="flex justify-between items-center mt-2">
<span class="text-xs text-sky-text/40 font-ui">{{ $t('skills.level') }}</span>
<span class="text-sm font-ui font-medium text-sky-accent">
{{ skill.level }}/{{ skill.max_level }}
</span>
</div>
</button>
</template>
<script setup lang="ts">
import type { Skill } from '~/types/skill'
const props = defineProps<{
skill: Skill
}>()
const emit = defineEmits<{
click: [skill: Skill]
}>()
const progressPercent = computed(() =>
Math.round((props.skill.level / props.skill.max_level) * 100),
)
</script>
<style scoped>
.skill-card:focus-visible {
outline: 2px solid var(--color-sky-accent, #38bdf8);
outline-offset: 2px;
}
.skill-progress {
width: 0;
animation: fillProgress 0.8s ease-out forwards;
animation-delay: var(--animation-delay, 0ms);
}
@keyframes fillProgress {
to {
width: var(--target-width, 0%);
}
}
@media (prefers-reduced-motion: reduce) {
.skill-progress {
animation: none;
width: var(--target-width, 0%);
}
}
</style>

View File

@@ -0,0 +1,14 @@
import type { SkillsResponse } from '~/types/skill'
export function useFetchSkills() {
const config = useRuntimeConfig()
const { locale } = useI18n()
return useFetch<SkillsResponse>('/skills', {
baseURL: config.public.apiUrl as string,
headers: {
'X-API-Key': config.public.apiKey as string,
'Accept-Language': locale.value,
},
})
}

View File

@@ -1,16 +1,153 @@
<template> <template>
<div class="min-h-screen p-8"> <div class="max-w-7xl mx-auto px-4 py-8 md:py-12">
<h1 class="text-3xl font-narrative text-sky-text">{{ $t('pages.skills.title') }}</h1> <h1 class="text-3xl md:text-4xl font-ui font-bold text-sky-text mb-8">
<p class="mt-4 text-sky-text/70">{{ $t('pages.skills.description') }}</p> {{ $t('skills.title') }}
</h1>
<!-- Loading state -->
<div v-if="pending" class="space-y-10">
<div v-for="i in 4" :key="i">
<div class="bg-sky-text/5 h-7 rounded w-32 mb-4" />
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4">
<div v-for="j in 4" :key="j" class="bg-sky-text/5 rounded-xl h-28 animate-pulse" />
</div>
</div>
</div>
<!-- Error state -->
<div v-else-if="error" class="text-center py-16">
<p class="text-sky-text/60 font-narrative mb-6">
{{ $t('skills.load_error') }}
</p>
<button
class="px-6 py-3 bg-sky-accent text-sky-dark font-ui font-semibold rounded-lg hover:opacity-90 transition-opacity"
@click="refresh()"
>
{{ $t('common.retry') }}
</button>
</div>
<!-- Skills by category -->
<div v-else class="space-y-12">
<section
v-for="(category, categoryIndex) in categories"
:key="category.category"
class="category-section"
:style="{ '--category-delay': `${categoryIndex * 150}ms` }"
>
<h2 class="text-xl font-ui font-semibold text-sky-text mb-5 flex items-center gap-2">
<span class="text-sky-accent">{{ getCategoryIcon(category.category) }}</span>
{{ category.category_label }}
</h2>
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4">
<FeatureSkillCard
v-for="(skill, skillIndex) in category.skills"
:key="skill.id"
:skill="skill"
class="skill-card-animated"
:style="{ '--animation-delay': `${categoryIndex * 150 + skillIndex * 60}ms` }"
@click="handleSkillClick"
/>
</div>
</section>
<!-- Empty state -->
<div v-if="categories.length === 0" class="text-center py-16">
<p class="text-sky-text/60 font-narrative">
{{ $t('skills.no_skills') }}
</p>
</div>
<!-- Placeholder for vis.js skill tree (Epic 3) - Desktop only -->
<div class="hidden lg:block mt-12 p-8 border-2 border-dashed border-sky-text/10 rounded-xl text-center">
<p class="text-sky-text/40 font-narrative">
{{ $t('skills.skill_tree_placeholder') }}
</p>
</div>
</div>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
const { setPageMeta } = useSeo() import type { Skill } from '~/types/skill'
const { t } = useI18n() import { useProgressionStore } from '~/stores/progression'
const { t } = useI18n()
const { setPageMeta } = useSeo()
const store = useProgressionStore()
const { data, pending, error, refresh } = await useFetchSkills()
const categories = computed(() => data.value?.data ?? [])
// SEO
setPageMeta({ setPageMeta({
title: t('pages.skills.title'), title: t('skills.page_title'),
description: t('pages.skills.description'), description: t('skills.page_description'),
})
// Category icons
const categoryIcons: Record<string, string> = {
frontend: '🎨',
backend: '⚙️',
tools: '🛠️',
soft_skills: '💡',
}
function getCategoryIcon(category: string): string {
return categoryIcons[category.toLowerCase()] ?? '📚'
}
// Handle skill click (preparation for Story 2.5)
function handleSkillClick(skill: Skill) {
// Will be implemented in Story 2.5 - modal with related projects
console.log('Skill clicked:', skill.slug)
}
onMounted(() => {
store.visitSection('competences')
}) })
</script> </script>
<style scoped>
.category-section {
animation: fadeIn 0.5s ease-out forwards;
animation-delay: var(--category-delay, 0ms);
opacity: 0;
}
.skill-card-animated {
animation: fadeInUp 0.4s ease-out forwards;
animation-delay: var(--animation-delay, 0ms);
opacity: 0;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(12px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@media (prefers-reduced-motion: reduce) {
.category-section,
.skill-card-animated {
animation: none;
opacity: 1;
}
}
</style>

View File

@@ -0,0 +1,30 @@
export interface Skill {
id: number
slug: string
name: string
description: string | null
icon: string | null
category: string
level: number
max_level: number
display_order: number
project_count?: number
pivot?: {
level_before: number
level_after: number
}
}
export interface SkillCategory {
category: string
category_label: string
skills: Skill[]
}
export interface SkillsResponse {
data: SkillCategory[]
meta: {
lang: string
total: number
}
}

View File

@@ -94,6 +94,17 @@
"previous": "Previous project", "previous": "Previous project",
"next": "Next project" "next": "Next project"
}, },
"skills": {
"title": "My Skills",
"page_title": "Skills | Skycel",
"page_description": "Discover the technical skills and soft skills of C\u00e9lian, full-stack web developer.",
"load_error": "Unable to load skills...",
"no_skills": "No skills yet",
"skill_tree_placeholder": "Interactive skill tree (coming soon)",
"level": "Level",
"project": "project",
"projects": "projects"
},
"pages": { "pages": {
"projects": { "projects": {
"title": "Projects", "title": "Projects",

View File

@@ -94,14 +94,25 @@
"previous": "Projet pr\u00e9c\u00e9dent", "previous": "Projet pr\u00e9c\u00e9dent",
"next": "Projet suivant" "next": "Projet suivant"
}, },
"skills": {
"title": "Mes Comp\u00e9tences",
"page_title": "Comp\u00e9tences | Skycel",
"page_description": "D\u00e9couvrez les comp\u00e9tences techniques et soft skills de C\u00e9lian, d\u00e9veloppeur web full-stack.",
"load_error": "Impossible de charger les comp\u00e9tences...",
"no_skills": "Aucune comp\u00e9tence pour le moment",
"skill_tree_placeholder": "Arbre de comp\u00e9tences interactif (bient\u00f4t disponible)",
"level": "Niveau",
"project": "projet",
"projects": "projets"
},
"pages": { "pages": {
"projects": { "projects": {
"title": "Projets", "title": "Projets",
"description": "Découvrez mes projets et réalisations" "description": "D\u00e9couvrez mes projets et r\u00e9alisations"
}, },
"skills": { "skills": {
"title": "Compétences", "title": "Comp\u00e9tences",
"description": "Mes compétences techniques et humaines" "description": "Mes comp\u00e9tences techniques et humaines"
}, },
"testimonials": { "testimonials": {
"title": "Témoignages", "title": "Témoignages",