Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 51046c2

Browse files
committed
fix: search card mobile layout
1 parent 0972bc1 commit 51046c2

1 file changed

Lines changed: 32 additions & 41 deletions

File tree

apps/ui/components/single-search/ReservationUnitCard.tsx

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import Link from "next/link";
55
import { useRouter } from "next/router";
66
import NextImage from "next/image";
77
import styled from "styled-components";
8-
import { H5, Strongish } from "common/src/common/typography";
8+
import { H5 } from "common/src/common/typography";
99
import { breakpoints } from "common/src/common/style";
1010
import { ReservationUnitType } from "common/types/gql-types";
1111
import { format, isToday, isTomorrow } from "date-fns";
1212
import { toUIDate } from "common/src/common/util";
13-
import { getAddressAlt, getMainImage, getTranslation } from "@/modules/util";
13+
import { getMainImage, getTranslation } from "@/modules/util";
1414
import IconWithText from "../common/IconWithText";
1515
import { MediumButton, pixel, truncatedText } from "@/styles/util";
1616
import {
@@ -38,6 +38,7 @@ const Container = styled.div`
3838

3939
const MainContent = styled.div`
4040
display: grid;
41+
gap: var(--spacing-s);
4142
margin: var(--spacing-s);
4243
position: relative;
4344
@@ -61,7 +62,6 @@ const Description = styled.span`
6162
font-family: var(--font-regular);
6263
font-size: var(--fontsize-body-m);
6364
flex-grow: 1;
64-
height: 40px;
6565
6666
@media (min-width: ${breakpoints.m}) {
6767
height: unset;
@@ -148,21 +148,24 @@ const StyledIconWithText = styled(IconWithText)`
148148
}
149149
`;
150150

151-
const StyledTag = styled(Tag)`
152-
position: absolute;
153-
top: 0;
154-
right: 0;
155-
z-index: 1;
156-
157-
&.available {
158-
background: var(--color-success-light);
159-
}
160-
&.no-times {
161-
background: var(--color-error-light);
162-
}
163-
&.closed {
164-
background: var(--tag-background);
151+
const StyledTag = styled(Tag)<{ $status: "available" | "no-times" | "closed" }>`
152+
@media (min-width: ${breakpoints.s}) {
153+
position: absolute;
154+
top: 0;
155+
right: 0;
156+
z-index: 1;
165157
}
158+
159+
background: ${({ $status }) => {
160+
switch ($status) {
161+
case "available":
162+
return "var(--color-success-light)";
163+
case "no-times":
164+
return "var(--color-error-light)";
165+
case "closed":
166+
return "var(--tag-background)";
167+
}
168+
}};
166169
`;
167170

168171
const StatusTag = (ru: {
@@ -173,15 +176,13 @@ const StatusTag = (ru: {
173176

174177
if (closed) {
175178
return (
176-
<StyledTag className="closed">
177-
{t("reservationUnitCard:closed")}
178-
</StyledTag>
179+
<StyledTag $status="closed">{t("reservationUnitCard:closed")}</StyledTag>
179180
);
180181
}
181182

182183
if (!availableAt) {
183184
return (
184-
<StyledTag className="no-times">
185+
<StyledTag $status="no-times">
185186
{t("reservationUnitCard:noTimes")}
186187
</StyledTag>
187188
);
@@ -195,9 +196,7 @@ const StatusTag = (ru: {
195196
dayText = `${t("common:tomorrow")}`;
196197
} else dayText = `${toUIDate(new Date(availableAt))} `;
197198

198-
return (
199-
<StyledTag className="available">{`${dayText} ${timeText}`}</StyledTag>
200-
);
199+
return <StyledTag $status="available">{`${dayText} ${timeText}`}</StyledTag>;
201200
};
202201

203202
const ReservationUnitCard = ({ reservationUnit }: PropsT): JSX.Element => {
@@ -207,8 +206,6 @@ const ReservationUnitCard = ({ reservationUnit }: PropsT): JSX.Element => {
207206

208207
const name = getReservationUnitName(reservationUnit);
209208

210-
const addressString = getAddressAlt(reservationUnit);
211-
212209
const link = `${reservationUnitPrefix}/${reservationUnit.pk}`;
213210

214211
const unitName = getUnitName(reservationUnit.unit ?? undefined);
@@ -233,21 +230,15 @@ const ReservationUnitCard = ({ reservationUnit }: PropsT): JSX.Element => {
233230
<Name>
234231
<StyledInlineLink href={link}>{name}</StyledInlineLink>
235232
</Name>
236-
<StatusTag
237-
data={{
238-
closed: reservationUnit.isClosed ?? false,
239-
availableAt: reservationUnit.firstReservableDatetime ?? "",
240-
}}
241-
/>
242-
<Description>
243-
{unitName}
244-
{addressString && (
245-
<>
246-
{", "}
247-
<Strongish>{addressString}</Strongish>
248-
</>
249-
)}
250-
</Description>
233+
<Description>{unitName}</Description>
234+
<div>
235+
<StatusTag
236+
data={{
237+
closed: reservationUnit.isClosed ?? false,
238+
availableAt: reservationUnit.firstReservableDatetime ?? "",
239+
}}
240+
/>
241+
</div>
251242
<Bottom>
252243
<Props>
253244
{reservationUnitTypeName && (

0 commit comments

Comments
 (0)