fix event card image alt

This commit is contained in:
Aarni Halinen
2021-04-01 16:26:48 +03:00
parent b8ee0680a4
commit cffaf74cb2
3 changed files with 16 additions and 9 deletions
+8 -7
View File
@@ -10,8 +10,10 @@ interface WrappedCardProps {
start_time: string;
text: string;
link: string;
image?: string;
imageAlt?: string;
image?: {
src: string;
alt: string;
};
buttonOnClick?: () => void;
}
@@ -67,7 +69,7 @@ const StyledCard = styled.article`
`;
const WrappedCard: React.FC<WrappedCardProps> = ({
title, text, link, image, imageAlt, start_time, buttonOnClick, ...props
title, text, link, image, start_time, buttonOnClick, ...props
}) => {
const options: Intl.DateTimeFormatOptions = {
day: "numeric",
@@ -77,9 +79,6 @@ const WrappedCard: React.FC<WrappedCardProps> = ({
minute: "2-digit",
};
const datetime = new Date(start_time).toLocaleString("fi-FI", options);
const img = image ? (
<Image src={image} alt={imageAlt} layout="responsive" width={0} height={0} objectFit="scale-down" />
) : null;
const button = (
<Link to={link}>
@@ -91,7 +90,9 @@ const WrappedCard: React.FC<WrappedCardProps> = ({
return (
<StyledCard {...props}>
{img}
{image && (
<Image src={image.src} alt={image.alt} layout="responsive" width={0} height={0} objectFit="scale-down" />
)}
<p>{datetime}</p>
<h3>{title}</h3>
<p>{text}</p>