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>
+4 -1
View File
@@ -75,7 +75,10 @@ const FrontPageView: React.FC<FrontPageViewProps> = ({ events, feed }) => (
start_time={event.start_time}
text={event.description_fi}
link={`/events/${event.id}`}
image={event.image || event.tags[0].icon}
image={{
src: event.image || event.tags[0].icon,
alt: event.title_fi,
}}
buttonOnClick={noop}
data-e2e="event-card"
/>
@@ -201,7 +201,10 @@ const InEnglishPageView: React.FC<InEnglishPageViewProps> = ({ events, feed }) =
start_time={event.start_time}
text={event.description_en}
link={`/events/${event.id}`}
image={event.image || event.tags[0].icon}
image={{
src: event.image || event.tags[0].icon,
alt: event.title_en,
}}
buttonOnClick={noop}
data-e2e="event-card"
/>