Skip to content

Commit

Permalink
fix: image sizes + course grid (#1261)
Browse files Browse the repository at this point in the history
  • Loading branch information
annarhughes authored Jan 13, 2025
1 parent f38454f commit 135f723
Show file tree
Hide file tree
Showing 41 changed files with 182 additions and 128 deletions.
3 changes: 2 additions & 1 deletion components/banner/MaintenanceBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Box, Container, Typography } from '@mui/material';
import { useTranslations } from 'next-intl';
import Image from 'next/image';
import illustrationChange from '../../public/illustration_change_peach.svg';
import { getImageSizes } from '../../utils/imageSizes';

const containerStyle = {
textAlign: 'center',
Expand All @@ -25,7 +26,7 @@ export const MaintenanceBanner = () => {
alt={t('alt.personTea')}
src={illustrationChange}
fill
sizes="100vw"
sizes={getImageSizes(imageContainerStyle.width)}
style={{
objectFit: 'contain',
}}
Expand Down
16 changes: 10 additions & 6 deletions components/cards/CourseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Image from 'next/image';
import { useState } from 'react';
import { PROGRESS_STATUS } from '../../constants/enums';
import { iconTextRowStyle, rowStyle } from '../../styles/common';
import { getImageSizes } from '../../utils/imageSizes';
import Link from '../common/Link';
import ProgressStatus from '../common/ProgressStatus';

Expand Down Expand Up @@ -54,8 +55,10 @@ const collapseContentStyle = {
} as const;

const cardActionsStyle = {
paddingLeft: 4,
paddingTop: 0,
alignItems: 'end',
justifyContent: 'flex-end',
alignItems: 'center',
} as const;

const statusRowStyle = {
Expand Down Expand Up @@ -96,7 +99,7 @@ const CourseCard = (props: CourseCardProps) => {
alt={course.content.image_with_background.alt}
src={course.content.image_with_background.filename}
fill
sizes="100vw"
sizes={getImageSizes(imageContainerStyle.width)}
style={{
objectFit: 'contain',
}}
Expand All @@ -106,9 +109,6 @@ const CourseCard = (props: CourseCardProps) => {
<Typography component="h3" variant="h3">
{course.content.name}
</Typography>
{!!courseProgress && courseProgress !== PROGRESS_STATUS.NOT_STARTED && (
<ProgressStatus status={courseProgress} />
)}
</Box>
</CardContent>
</CardActionArea>
Expand All @@ -119,7 +119,7 @@ const CourseCard = (props: CourseCardProps) => {
alt={course.content.image.alt}
src={course.content.image.filename}
fill
sizes="100vw"
sizes={getImageSizes(imageContainerStyle.width)}
style={{
objectFit: 'contain',
}}
Expand All @@ -143,6 +143,10 @@ const CourseCard = (props: CourseCardProps) => {
</Box>
)}

{!!courseProgress && courseProgress !== PROGRESS_STATUS.NOT_STARTED && (
<ProgressStatus status={courseProgress} />
)}

<IconButton
sx={{ marginLeft: 'auto' }}
aria-label={`${t('expandSummary')} ${course.content.name}`}
Expand Down
7 changes: 4 additions & 3 deletions components/cards/RelatedContentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { RELATED_CONTENT_CATEGORIES } from '../../constants/enums';
const cardStyle = {
mt: 0,
width: '100%',
height: '100%',
mb: { xs: '1rem', sm: '1.5rem' },
backgroundColor: 'paleSecondaryLight',
} as const;
Expand Down Expand Up @@ -39,7 +38,7 @@ export const RelatedContentCard = (props: RelatedContentProps) => {
return (
<Card sx={cardStyle}>
<CardActionArea href={href}>
<CardContent>
<CardContent sx={{ minHeight: 238 }}>
<Box position="relative" width="100%" paddingRight={3}>
<Box>
<Typography sx={categoryStyle}>
Expand All @@ -48,7 +47,9 @@ export const RelatedContentCard = (props: RelatedContentProps) => {
<span className="before-dot">{` ${duration} ${t('minuteLabel')}`}</span>
)}
</Typography>
<Typography variant="h3">{title}</Typography>
<Typography variant="h3" mb={0}>
{title}
</Typography>
</Box>
<ArrowForwardIos
color="error"
Expand Down
9 changes: 6 additions & 3 deletions components/cards/ShortsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import Link from '../common/Link';
const cardStyle = {
mt: 0,
width: '250px',
height: '100%',
mb: { xs: '1rem', sm: '1.5rem' },
backgroundColor: 'paleSecondaryLight',
flex: 0,
} as const;

interface ShortsCardProps {
Expand Down Expand Up @@ -40,9 +40,12 @@ export const ShortsCard = (props: ShortsCardProps) => {

return (
<Card sx={cardStyle}>
<CardActionArea component={Link} href={`/${href}`}>
<CardActionArea component={Link} href={`/${href}`} sx={{ height: '100%' }}>
<CardContent
sx={{ padding: '0 !important', display: 'flex', flexDirection: 'column', gap: '1' }}
sx={{
minHeight: 335,
padding: '0 !important',
}}
>
<Box height="130px" position="relative" width="100%" overflow="hidden">
<Image
Expand Down
3 changes: 2 additions & 1 deletion components/common/ContentUnavailable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Image from 'next/image';
import illustrationPerson4Peach from '../../public/illustration_person4_peach.svg';
import { columnStyle } from '../../styles/common';
import { TextNode } from '../../utils/helper-types/translations';
import { getImageSizes } from '../../utils/imageSizes';

const accessContainerStyle = {
...columnStyle,
Expand Down Expand Up @@ -32,7 +33,7 @@ export const ContentUnavailable = ({ title, message }: ContentUnavailableProps)
alt={t('alt.personTea')}
src={illustrationPerson4Peach}
fill
sizes="100vw"
sizes={getImageSizes(imageContainerStyle.width)}
style={{
objectFit: 'contain',
}}
Expand Down
5 changes: 3 additions & 2 deletions components/common/ImageTextColumn.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Box, Typography } from '@mui/material';
import { useTranslations } from 'next-intl';
import Image, { StaticImageData } from 'next/image';
import { getImageSizes } from '../../utils/imageSizes';

export interface ImageTextItem {
text: string;
Expand Down Expand Up @@ -28,7 +29,7 @@ const itemContainerStyle = {
} as const;

const imageContainerStyle = {
position: 'relative', // needed for next/image to fill the container
position: 'relative',
width: 100,
height: 100,
paddingX: 5,
Expand All @@ -55,7 +56,7 @@ const ImageTextColumn = (props: ImageTextGridProps) => {
alt={tS(item.illustrationAlt)}
src={item.illustrationSrc}
fill
sizes="100vw"
sizes={getImageSizes(imageContainerStyle.width)}
style={{
objectFit: 'contain',
}}
Expand Down
3 changes: 2 additions & 1 deletion components/common/ImageTextGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Box, Typography } from '@mui/material';
import { useTranslations } from 'next-intl';
import Image, { StaticImageData } from 'next/image';
import { richtextContentStyle, rowStyle } from '../../styles/common';
import { getImageSizes } from '../../utils/imageSizes';

export interface ImageTextItem {
text: string;
Expand Down Expand Up @@ -52,7 +53,7 @@ const ImageTextGrid = (props: ImageTextGridProps) => {
alt={tS(item.illustrationAlt)}
src={item.illustrationSrc}
fill
sizes="100vw"
sizes={getImageSizes(imageContainerStyle.width)}
style={{
objectFit: 'contain',
}}
Expand Down
4 changes: 2 additions & 2 deletions components/common/ProgressStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ const ProgressStatus = (props: ProgressStatusProps) => {

if (status === PROGRESS_STATUS.STARTED) {
return (
<Box sx={iconTextRowStyle}>
<Box sx={{ ...iconTextRowStyle, marginTop: '0 !important' }}>
<DonutLargeIcon color="error" />
<Typography>{tS('started')}</Typography>
</Box>
);
}
if (status === PROGRESS_STATUS.COMPLETED) {
return (
<Box sx={iconTextRowStyle}>
<Box sx={{ ...iconTextRowStyle, marginTop: '0 !important' }}>
<CheckCircleIcon color="error" />
<Typography>{tS('completed')}</Typography>
</Box>
Expand Down
3 changes: 2 additions & 1 deletion components/forms/ResourceFeedbackForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import illustrationPerson4Peach from '../../public/illustration_person4_peach.sv
import { useCreateResourceFeedbackMutation } from '../../store/api';
import { ResourceFeedback } from '../../store/resourcesSlice';
import { staticFieldLabelStyle } from '../../styles/common';
import { getImageSizes } from '../../utils/imageSizes';

const fieldBoxStyle: SxProps<Theme> = {
...staticFieldLabelStyle,
Expand Down Expand Up @@ -102,7 +103,7 @@ const ResourceFeedbackForm = (props: ResourceFeedbackFormProps) => {
alt={tS('alt.personTea')}
src={illustrationPerson4Peach}
fill
sizes="100vw"
sizes={getImageSizes(imageContainerStyle.width)}
style={{
objectFit: 'contain',
}}
Expand Down
3 changes: 2 additions & 1 deletion components/forms/SessionFeedbackForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import illustrationPerson4Peach from '../../public/illustration_person4_peach.sv
import { useCreateSessionFeedbackMutation } from '../../store/api';
import { SessionFeedback } from '../../store/coursesSlice';
import { staticFieldLabelStyle } from '../../styles/common';
import { getImageSizes } from '../../utils/imageSizes';

const fieldBoxStyle: SxProps<Theme> = {
...staticFieldLabelStyle,
Expand Down Expand Up @@ -99,7 +100,7 @@ const SessionFeedbackForm = (props: SessionFeedbackFormProps) => {
alt={tS('alt.personTea')}
src={illustrationPerson4Peach}
fill
sizes="100vw"
sizes={getImageSizes(imageContainerStyle.width)}
style={{
objectFit: 'contain',
}}
Expand Down
3 changes: 2 additions & 1 deletion components/layout/Consent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { COOKIES_ACCEPTED, COOKIES_REJECTED } from '../../constants/events';
import { useAppDispatch, useTypedSelector } from '../../hooks/store';
import IllustrationCookieCat from '../../public/illustration_cookie_cat.svg';
import { setCookiesAccepted } from '../../store/userSlice';
import { getImageSizes } from '../../utils/imageSizes';
import logEvent, { getEventUserData } from '../../utils/logEvent';
import Link from '../common/Link';

Expand Down Expand Up @@ -111,7 +112,7 @@ const Consent = (props: {}) => {
<Image
alt={tS('alt.cookieCat')}
src={IllustrationCookieCat}
sizes="100vw"
sizes={getImageSizes(70)}
style={{
width: '100%',
height: 'auto',
Expand Down
38 changes: 5 additions & 33 deletions components/layout/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import tiktokLogo from '../../public/tiktok.svg';

import Cookies from 'js-cookie';
import { rowStyle } from '../../styles/common';
import { getImageSizes } from '../../utils/imageSizes';
import logEvent, { getEventUserData } from '../../utils/logEvent';
import Link from '../common/Link';

Expand Down Expand Up @@ -142,16 +143,7 @@ const Footer = () => {
<>
<Container sx={footerContainerStyle} component="footer">
<Box width="100%" mb={3}>
<Image
alt={tS('alt.bloomLogo')}
src={bloomLogo}
width={140}
height={60}
style={{
maxWidth: '100%',
height: 'auto',
}}
/>
<Image alt={tS('alt.bloomLogo')} src={bloomLogo} width={140} height={60} />
</Box>
<Box sx={footerContentRowStyle}>
<Box sx={getDescriptionContainerStyle(partners.length)}>
Expand Down Expand Up @@ -190,7 +182,7 @@ const Footer = () => {
alt={tS(partner.logoAlt)}
src={partner.logo}
fill
sizes="300px"
sizes={getImageSizes(logoContainerStyle.width)}
style={{
objectFit: 'contain',
objectPosition: 'left',
Expand Down Expand Up @@ -272,14 +264,7 @@ const Footer = () => {
})
}
>
<Image
alt={tS('alt.tiktokLogo')}
src={tiktokLogo}
style={{
maxWidth: '100%',
height: 'auto',
}}
/>
<Image alt={tS('alt.tiktokLogo')} src={tiktokLogo} width={24} height={24} />
</IconButton>
)}
{partner.github && (
Expand Down Expand Up @@ -310,27 +295,14 @@ const Footer = () => {
</Typography>
<Box sx={fundingLogosContainerStyle}>
<Link href="https://www.comicrelief.com/" position="relative" target="_blank">
<Image
alt={tS('alt.comicReliefLogo')}
src={comicReliefLogo}
width={88}
height={64}
style={{
maxWidth: '100%',
height: 'auto',
}}
/>
<Image alt={tS('alt.comicReliefLogo')} src={comicReliefLogo} width={88} height={64} />
</Link>
<Link href="https://www.tnlcommunityfund.org.uk/" position="relative" target="_blank">
<Image
alt={tS('alt.communityFundLogo')}
src={communityFundLogo}
width={170}
height={50}
style={{
maxWidth: '100%',
height: 'auto',
}}
/>
</Link>
</Box>
Expand Down
4 changes: 3 additions & 1 deletion components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { render } from 'storyblok-rich-text-react-renderer';
import { PROGRESS_STATUS } from '../../constants/enums';
import { columnStyle, rowStyle } from '../../styles/common';
import { TextNode } from '../../utils/helper-types/translations';
import { getImageSizes } from '../../utils/imageSizes';
import { RichTextOptions } from '../../utils/richText';
import UserResearchBanner from '../banner/UserResearchBanner';
import ProgressStatus from '../common/ProgressStatus';
Expand Down Expand Up @@ -58,6 +59,7 @@ const childrenContentStyle = {

const textContentStyle = {
marginTop: 'auto',
mb: 2,
} as const;

const backButtonStyle = {
Expand Down Expand Up @@ -127,7 +129,7 @@ const Header = (props: HeaderProps) => {
alt={imageAltText}
src={imageSrc}
fill
sizes="100vw"
sizes={getImageSizes(imageContainerStyle.width)}
style={{
objectFit: 'contain',
}}
Expand Down
3 changes: 2 additions & 1 deletion components/layout/HomeHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as React from 'react';
import { render } from 'storyblok-rich-text-react-renderer';
import { columnStyle, rowStyle } from '../../styles/common';
import theme from '../../styles/theme';
import { getImageSizes } from '../../utils/imageSizes';
import { RichTextOptions } from '../../utils/richText';
import UserResearchBanner from '../banner/UserResearchBanner';

Expand Down Expand Up @@ -87,7 +88,7 @@ const Header = (props: HeaderProps) => {
alt={imageAltText}
src={imageSrc}
fill
sizes="100vw"
sizes={getImageSizes(imageContainerStyle.width)}
style={{
objectFit: 'contain',
}}
Expand Down
2 changes: 2 additions & 0 deletions components/layout/PartnerAdminHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Container, Typography } from '@mui/material';
import { useTranslations } from 'next-intl';
import Image, { StaticImageData } from 'next/image';
import * as React from 'react';
import { getImageSizes } from '../../utils/imageSizes';

const headerContainerStyles = {
backgroundColor: 'common.white',
Expand Down Expand Up @@ -36,6 +37,7 @@ const PartnerAdminHeader = (props: PartnerAdminHeaderProps) => {
alt={tS(partnerLogoAlt)}
src={partnerLogoSrc}
width={200}
sizes={getImageSizes(200)}
style={{
maxWidth: '100%',
height: 'auto',
Expand Down
Loading

0 comments on commit 135f723

Please sign in to comment.