flags local
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { Team } from "@/lib/types";
|
||||
|
||||
// Zeigt die Flagge/das Wappen eines Teams. Fällt auf ein neutrales Rund
|
||||
// zurück, wenn keine crest-URL vorliegt. SVG-Crests (football-data) skalieren
|
||||
// sauber; das Rendern als rundes Bild gibt den Flaggen-Look aus dem Screenshot.
|
||||
// zurück, wenn keine crest-URL vorliegt oder das Bild nicht geladen werden kann.
|
||||
export default function Flag({
|
||||
team, size = 22,
|
||||
}: { team?: Team; size?: number }) {
|
||||
const [imgFailed, setImgFailed] = useState(false);
|
||||
const style = { width: size, height: size } as const;
|
||||
if (team?.crest) {
|
||||
|
||||
if (team?.crest && !imgFailed) {
|
||||
return (
|
||||
<img
|
||||
src={team.crest}
|
||||
@@ -17,6 +19,7 @@ export default function Flag({
|
||||
className="flag"
|
||||
style={style}
|
||||
loading="lazy"
|
||||
onError={() => setImgFailed(true)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user