feat(ui): add ViewCounter component and enhance accessibility annotations

Introduce a new `ViewCounter` component to manage view tracking for content. Add biome-ignore comments for accessibility standards in several UI components, enhance semantic element usage, and improve tag handling in `SearchSidebar`.
This commit is contained in:
Mathis HERRIOT
2026-01-14 22:18:50 +01:00
parent 0a1391674f
commit 0611ef715c
10 changed files with 55 additions and 17 deletions

View File

@@ -8,7 +8,8 @@ import { Input } from "@/components/ui/input";
import { ScrollArea } from "@/components/ui/scroll-area";
import { Separator } from "@/components/ui/separator";
import { CategoryService } from "@/services/category.service";
import type { Category } from "@/types/content";
import { TagService } from "@/services/tag.service";
import type { Category, Tag } from "@/types/content";
export function SearchSidebar() {
const router = useRouter();
@@ -16,10 +17,14 @@ export function SearchSidebar() {
const pathname = usePathname();
const [categories, setCategories] = React.useState<Category[]>([]);
const [popularTags, setPopularTags] = React.useState<Tag[]>([]);
const [query, setQuery] = React.useState(searchParams.get("query") || "");
React.useEffect(() => {
CategoryService.getAll().then(setCategories).catch(console.error);
TagService.getAll({ limit: 10, sort: "popular" })
.then(setPopularTags)
.catch(console.error);
}, []);
const updateSearch = React.useCallback(
@@ -116,19 +121,23 @@ export function SearchSidebar() {
<div>
<h3 className="text-sm font-medium mb-3">Tags populaires</h3>
<div className="flex flex-wrap gap-2">
{["funny", "coding", "cat", "dog", "work", "relatable", "gaming"].map(
(tag) => (
<Badge
key={tag}
variant={searchParams.get("tag") === tag ? "default" : "outline"}
className="cursor-pointer hover:bg-secondary"
onClick={() =>
updateSearch("tag", searchParams.get("tag") === tag ? null : tag)
}
>
#{tag}
</Badge>
),
{popularTags.map((tag) => (
<Badge
key={tag.id}
variant={searchParams.get("tag") === tag.name ? "default" : "outline"}
className="cursor-pointer hover:bg-secondary"
onClick={() =>
updateSearch(
"tag",
searchParams.get("tag") === tag.name ? null : tag.name,
)
}
>
#{tag.name}
</Badge>
))}
{popularTags.length === 0 && (
<p className="text-xs text-muted-foreground">Aucun tag trouvé.</p>
)}
</div>
</div>