Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | 520x 520x 59x 59x 59x 59x 59x 59x 59x 59x 59x 295x 59x 118x 177x 1x 1x 1x 174x 1x 334x 1x | import dayjs from "dayjs";
import { ReactElement } from "react";
import { useTranslation } from "react-i18next";
import { capitalize } from "remeda";
import styled from "styled-components";
import { ProgramItem } from "shared/types/models/programItem";
import { InfoText } from "client/components/InfoText";
import { InfoTextVariant } from "client/components/componentStyles";
import { TextWithLinks } from "client/markdown/components/TextWithLinks";
import { useTimeNow } from "client/utils/useTimeNow";
import { getFormattedInterval } from "client/views/program-item/programItemUtils";
const NBSP = "\u{A0}";
interface Props {
programItem: ProgramItem;
}
export const ProgramItemDetails = ({ programItem }: Props): ReactElement => {
const { t } = useTranslation();
const timeNow = useTimeNow();
const formatTime = (): string => {
const hours = Math.floor(programItem.mins / 60);
const minutes = Math.round((programItem.mins / 60 - hours) * 60);
const minutesDuration = minutes ? ` ${minutes}${NBSP}${t("minutes")}` : "";
// Include the date outside event week so the weekday isn't ambiguous
const interval = getFormattedInterval(
dayjs(programItem.startTime),
dayjs(programItem.endTime),
timeNow,
);
return `${capitalize(interval)} (${hours}${NBSP}${t("hours")}${minutesDuration})`;
};
return (
<DetailsContainer>
{programItem.revolvingDoor && (
<InfoText variant={InfoTextVariant.INFO}>
{t("programItemInfo.revolvingDoor", {
PROGRAM_TYPE: t(`programTypeSingular.${programItem.programType}`),
PROGRAM_TYPE2: t(`programTypeInessive.${programItem.programType}`),
})}
</InfoText>
)}
{!!programItem.mins && (
<TwoColumnRow>
<DetailTitle>{t("programItemInfo.runTime")}</DetailTitle>
{formatTime()}
</TwoColumnRow>
)}
{programItem.location && (
<TwoColumnRow>
<DetailTitle>{t("programItemInfo.location")}</DetailTitle>
{programItem.location}
</TwoColumnRow>
)}
{programItem.ageGroups.length > 0 && (
<TwoColumnRow>
<DetailTitle>{t("programItemInfo.ageGroups")}</DetailTitle>
{programItem.ageGroups
.map((ageGroup) => t(`ageGroup.${ageGroup}`))
.join(", ")}
</TwoColumnRow>
)}
{programItem.genres.length > 0 && (
<TwoColumnRow>
<DetailTitle>{t("programItemInfo.genres")}</DetailTitle>
{programItem.genres.map((genre) => t(`genre.${genre}`)).join(", ")}
</TwoColumnRow>
)}
{programItem.tags.length > 0 && (
<TwoColumnRow>
<DetailTitle>{t("programItemInfo.tags")}</DetailTitle>
{programItem.tags.map((tag) => t(`tags.${tag}`)).join(", ")}
</TwoColumnRow>
)}
{programItem.people && (
<TwoColumnRow>
<DetailTitle>{t("programItemInfo.organiser")}</DetailTitle>
{programItem.people}
</TwoColumnRow>
)}
<p>
<TextWithLinks>{programItem.description}</TextWithLinks>
</p>
{programItem.contentWarnings && programItem.contentWarnings !== "-" && (
<ResponsiveColumnRow>
<DetailTitle> {t("programItemInfo.contentWarnings")}</DetailTitle>
{programItem.contentWarnings}
</ResponsiveColumnRow>
)}
{programItem.accessibilityValues.length > 0 && (
<ResponsiveColumnRow>
<DetailTitle>{t("programItemInfo.inclusivity")}</DetailTitle>
<AccessibilityValues>
{programItem.accessibilityValues.map((a) => (
<span key={a}>{t(`accessibility.${a}`)}</span>
))}
</AccessibilityValues>
</ResponsiveColumnRow>
)}
{programItem.otherAccessibilityInformation && (
<ResponsiveColumnRow>
<DetailTitle>
{t("programItemInfo.otherAccessibilityInformation")}
</DetailTitle>
{programItem.otherAccessibilityInformation}
</ResponsiveColumnRow>
)}
{programItem.gameSystem && (
<ResponsiveColumnRow>
<DetailTitle>{t("programItemInfo.gameSystem")}</DetailTitle>
{programItem.gameSystem}
</ResponsiveColumnRow>
)}
{programItem.otherAuthor && (
<ResponsiveColumnRow>
<DetailTitle>{t("programItemInfo.otherAuthor")}</DetailTitle>
{programItem.otherAuthor}
</ResponsiveColumnRow>
)}
{programItem.styles.length > 0 && (
<ResponsiveColumnRow>
<DetailTitle>{t("programItemInfo.gamestyle")}</DetailTitle>
{programItem.styles.map((s) => t(`gamestyle.${s}`)).join(", ")}
</ResponsiveColumnRow>
)}
</DetailsContainer>
);
};
const DetailsContainer = styled.div`
overflow-wrap: break-word;
white-space: pre-line;
`;
const TwoColumnRow = styled.div`
display: flex;
flex-direction: row;
margin: 8px 0 0 0;
`;
const ResponsiveColumnRow = styled(TwoColumnRow)`
row-gap: 4px;
@media (max-width: ${(props) => props.theme.breakpointPhone}) {
flex-direction: column;
}
`;
const DetailTitle = styled.h4`
flex: 0 0 25%;
margin: 0;
@media (max-width: ${(props) => props.theme.breakpointPhone}) {
flex: 0 0 45%;
}
`;
const AccessibilityValues = styled.div`
display: flex;
flex-direction: column;
row-gap: 4px;
`;
|