Skip to content

Commit

Permalink
Add hover animation to eventList
Browse files Browse the repository at this point in the history
  • Loading branch information
Magnus Brecke committed Sep 25, 2024
1 parent e219524 commit 1435ca0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
24 changes: 15 additions & 9 deletions app/components/EventItem/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Flex, Icon, Image } from '@webkom/lego-bricks';
import { Button, Flex, Icon, Image, LinkButton } from '@webkom/lego-bricks';
import cx from 'classnames';
import {
AlarmClock,
Calendar,
Expand All @@ -18,6 +19,7 @@ import { eventAttendanceAbsolute } from 'app/utils/eventStatus';
import styles from './styles.css';
import type { ListEvent } from 'app/store/models/Event';
import type { ReactNode } from 'react';
import { useState } from 'react';

export type EventStyle = 'default' | 'extra-compact' | 'compact';

Expand Down Expand Up @@ -127,6 +129,7 @@ const EventItem = ({
showTags = true,
eventStyle,
}: EventItemProps): ReactNode => {
const [hover, setHover] = useState(false);
switch (eventStyle) {
case 'extra-compact':
return (
Expand Down Expand Up @@ -201,17 +204,18 @@ const EventItem = ({
case 'default':
default:
return (
<div
<Link
to={`/events/${event.slug}`}
onMouseEnter={() => setHover(true)}
onMouseLeave={() => setHover(false)}
style={{
borderColor: colorForEventType(event.eventType),
}}
className={styles.eventItem}
className={cx(styles.eventItem, hover && styles.eventItemHover)}
>
<div>
<Link to={`/events/${event.slug}`}>
<h3 className={styles.eventItemTitle}>{event.title}</h3>
{event.totalCapacity > 0 && <Attendance event={event} />}
</Link>
<h3 className={styles.eventItemTitle}>{event.title}</h3>
{event.totalCapacity > 0 && <Attendance event={event} />}
<TimeStartAndRegistration event={event} />
{showTags && (
<Flex wrap>
Expand All @@ -222,7 +226,9 @@ const EventItem = ({
)}
</div>

<Flex className={styles.companyLogo}>
<Flex
className={cx(styles.companyLogo, hover && styles.companyLogoHover)}
>
{event.cover && (
<Image
alt="Forsidebilde"
Expand All @@ -231,7 +237,7 @@ const EventItem = ({
/>
)}
</Flex>
</div>
</Link>
);
}
};
Expand Down
13 changes: 13 additions & 0 deletions app/components/EventItem/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
display: flex;
justify-content: space-between;
line-height: 1.3;
transition: var(--easing-fast);
}

.eventItemHover {
background-color: var(--additive-background);
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
}

.eventItemCompact {
Expand Down Expand Up @@ -48,6 +55,12 @@
max-height: 80px;
object-fit: contain;
background: white;
margin: 5px 10px 5px 0;
transition: var(--easing-fast);
}

.companyLogoHover img {
border-radius: 10px;
}

.companyLogoCompact img {
Expand Down

0 comments on commit 1435ca0

Please sign in to comment.