Skip to content

Commit

Permalink
fix: sanitized content styling
Browse files Browse the repository at this point in the history
  • Loading branch information
joonatank committed Nov 14, 2024
1 parent 7848634 commit ac78065
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 58 deletions.
4 changes: 2 additions & 2 deletions apps/ui/components/common/Sanitize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ type Props = {
};

const StyledContent = styled.div`
p {
margin-block: 0;
p:empty {
display: none;
}
a {
text-decoration: underline;
Expand Down
1 change: 1 addition & 0 deletions apps/ui/components/reservation-unit/EquipmentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const EquipmentContainer = styled(ShowAllContainer)`
list-style: none;
gap: var(--spacing-2-xs) var(--spacing-m);
padding: 0;
margin: 0;
display: grid;
grid-template-columns: 1fr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { type ReservationInfoContainerFragment } from "@gql/gql-types";
import { Trans, useTranslation } from "next-i18next";
import { daysByMonths } from "@/modules/const";
import { formatDate } from "@/modules/util";
import { Content } from "./ReservationUnitStyles";
import { H4 } from "common/src/common/typography";
import styled from "styled-components";

Expand Down Expand Up @@ -69,7 +68,7 @@ export function ReservationInfoContainer({

// TODO this should be a list
return (
<Content data-testid="reservation-unit__reservation-info">
<div data-testid="reservation-unit__reservation-info">
<Subheading $noMargin>
{t("reservationCalendar:reservationInfo")}
</Subheading>
Expand All @@ -81,7 +80,7 @@ export function ReservationInfoContainer({
{reservationUnitIsReservable && (
<ReservationMaxReservationsPerUser {...reservationUnit} />
)}
</Content>
</div>
);
}

Expand Down
11 changes: 0 additions & 11 deletions apps/ui/components/reservation-unit/ReservationUnitStyles.tsx

This file was deleted.

14 changes: 6 additions & 8 deletions apps/ui/components/reservation/ReservationInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
} from "@/modules/util";
import { getImageSource } from "common/src/helpers";
import { getReservationUnitPath } from "@/modules/urls";
import { Flex } from "common/styles/util";

type Type = "pending" | "confirmed" | "complete";

Expand Down Expand Up @@ -69,13 +70,15 @@ const MainImage = styled.img`
object-fit: cover;
`;

const Content = styled.div`
const Content = styled(Flex).attrs({
$gap: "xs",
})`
padding: 1px var(--spacing-m) var(--spacing-xs);
`;

const Heading = styled(H4).attrs({ as: "h3" })`
margin-top: var(--spacing-m);
margin-bottom: var(--spacing-xs);
margin-bottom: 0;
`;

const StyledLink = styled(Link)`
Expand All @@ -84,15 +87,10 @@ const StyledLink = styled(Link)`
text-underline-offset: 4px;
`;

const Value = styled.div`
margin-bottom: var(--spacing-s);
line-height: var(--lineheight-l);
`;
const Value = styled.div``;

const Subheading = styled(Value)`
font-size: var(--fontsize-body-l);
line-height: var(--lineheight-xl);
margin-bottom: var(--spacing-xs);
`;

type Props = {
Expand Down
13 changes: 5 additions & 8 deletions apps/ui/pages/reservation-unit/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ import {
} from "@/modules/reservable";
import SubventionSuffix from "@/components/reservation/SubventionSuffix";
import InfoDialog from "@/components/common/InfoDialog";
import { Content } from "@/components/reservation-unit/ReservationUnitStyles";
import { QuickReservation } from "@/components/reservation-unit/QuickReservation";
import { ReservationInfoContainer } from "@/components/reservation-unit/ReservationInfoContainer";
import {
Expand Down Expand Up @@ -649,17 +648,15 @@ function ReservationUnit({
</JustForDesktop>
</div>
<PageContentWrapper>
<Content data-testid="reservation-unit__description">
<div data-testid="reservation-unit__description">
<H4 as="h3">{t("reservationUnit:description")}</H4>
<Sanitize html={getTranslation(reservationUnit, "description")} />
</Content>
</div>
{equipment?.length > 0 && (
<Content data-testid="reservation-unit__equipment">
<H4 as="h3" $noMargin>
{t("reservationUnit:equipment")}
</H4>
<div data-testid="reservation-unit__equipment">
<H4 as="h3">{t("reservationUnit:equipment")}</H4>
<EquipmentList equipment={equipment} />
</Content>
</div>
)}
{reservationUnitIsReservable && (
<div data-testid="reservation-unit__calendar--wrapper">
Expand Down
35 changes: 9 additions & 26 deletions apps/ui/pages/reservations/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ const SecondaryActions = styled(Flex)`
margin-top: var(--spacing-l);
`;

const AccordionContent = styled.div`
margin-bottom: var(--spacing-s);
padding-top: var(--spacing-m);
`;

function ReserveeBusinessInfo({
reservation,
supportedFields,
Expand Down Expand Up @@ -530,15 +525,9 @@ function Reservation({
theme="thin"
data-testid="reservation__payment-and-cancellation-terms"
>
{paymentTermsContent && (
<AccordionContent>
<Sanitize html={paymentTermsContent} />
</AccordionContent>
)}
{paymentTermsContent && <Sanitize html={paymentTermsContent} />}
{cancellationTermsContent && (
<AccordionContent>
<Sanitize html={cancellationTermsContent} />
</AccordionContent>
<Sanitize html={cancellationTermsContent} />
)}
</Accordion>
)}
Expand All @@ -548,9 +537,7 @@ function Reservation({
theme="thin"
data-testid="reservation__pricing-terms"
>
<AccordionContent>
<Sanitize html={pricingTermsContent} />
</AccordionContent>
<Sanitize html={pricingTermsContent} />
</Accordion>
)}
<Accordion
Expand All @@ -559,17 +546,13 @@ function Reservation({
data-testid="reservation__terms-of-use"
>
{serviceSpecificTermsContent && (
<AccordionContent>
<Sanitize html={serviceSpecificTermsContent} />
</AccordionContent>
<Sanitize html={serviceSpecificTermsContent} />
)}
{termsOfUse?.genericTerms != null && (
<Sanitize
html={getTranslation(termsOfUse.genericTerms, "text")}
/>
)}
<AccordionContent>
{termsOfUse?.genericTerms != null && (
<Sanitize
html={getTranslation(termsOfUse.genericTerms, "text")}
/>
)}
</AccordionContent>
</Accordion>
</div>
<AddressSection reservationUnit={reservationUnit} />
Expand Down

0 comments on commit ac78065

Please sign in to comment.