Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
samwisekind committed Jun 27, 2024
1 parent 630dee7 commit 558b896
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 160 deletions.
1 change: 1 addition & 0 deletions public/images/icons/star.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 0 additions & 15 deletions src/components/Catalogue/Catalogue.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,3 @@
line-height: 14px;
}
}

.image {
z-index: 0;
position: relative;
display: block;
width: 100%;
height: 100%;
object-fit: cover;
transition: all 0.6s $global-transition-ease-out-expo;
}

.card:hover > .image {
transform: scale(1.1);
filter: blur(4px);
}
35 changes: 9 additions & 26 deletions src/components/Catalogue/Catalogue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,15 @@ const Catalogue = ({
title,
subtitle,
link,
image,
}: Props) => {
const cardClasses = [styles.card];
if (!image) {
cardClasses.push(styles['no-image']);
}

return (
<Link href={link} className={cardClasses.join(' ')}>
<span className={styles.text}>
{subtitle && <span className={styles.subtitle}>{subtitle}</span>}
<span className={styles.title}>
<span>{title}</span>
</span>
}: Props) => (
<Link href={link} className={[styles.card, styles['no-image']].join(' ')}>
<span className={styles.text}>
{subtitle && <span className={styles.subtitle}>{subtitle}</span>}
<span className={styles.title}>
<span>{title}</span>
</span>
{image && (
<Image
src={image.url}
width={300}
height={150}
alt=""
className={styles.image}
/>
)}
</Link>
);
};
</span>
</Link>
);

export default Catalogue;
3 changes: 1 addition & 2 deletions src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ const Tooltip = ({
>
<button
type="button"
title="Tooltip"
className={buttonClasses.join(' ')}
onKeyDown={() => {}}
title="Tooltip"
aria-label="Tooltip"
aria-expanded={open}
tabIndex={0}
/>
Expand Down
31 changes: 14 additions & 17 deletions src/helpers/getBottlenoseDolphinCatalogue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const mockedEntries = [{
id: 'mocked-id-2',
name: 'mocked name 2',
slug: 'mocked-slug-2',
images: ['mocked image 2'],
otherImages: ['mocked image 2'],
},
}];

Expand Down Expand Up @@ -60,12 +60,10 @@ describe('getCatalogueList', () => {
id: 'mocked-id-1',
name: 'mocked name 1',
slug: 'mocked-slug-1',
image: null,
}, {
id: 'mocked-id-2',
name: 'mocked name 2',
slug: 'mocked-slug-2',
image: 'mocked image 2',
}],
});
});
Expand Down Expand Up @@ -95,6 +93,7 @@ describe('getCatalogueItem', () => {
items: [{
sys: {
id: 'mocked-entry-id',
updatedAt: 'mocked-updated-at',
},
fields: {
id: 'mocked-id',
Expand Down Expand Up @@ -130,9 +129,10 @@ describe('getCatalogueItem', () => {
birthYear: null,
age: null,
sex: null,
dorsalEdgeMarkings: null,
otherFeatures: null,
images: [],
leftDorsalFin: null,
rightDorsalFin: null,
otherImages: [],
lastUpdated: 'mocked-updated-at',
},
mother: null,
calves: [],
Expand All @@ -144,6 +144,7 @@ describe('getCatalogueItem', () => {
items: [{
sys: {
id: 'mocked-entry-id',
updatedAt: 'mocked-updated-at',
},
fields: {
id: 'mocked-id',
Expand All @@ -154,17 +155,16 @@ describe('getCatalogueItem', () => {
birthYear: 'mocked birth year',
age: 'mocked age',
sex: 'mocked sex',
dorsalEdgeMarkings: 'mocked doral edge markings',
otherFeatures: 'mocked other features',
leftDorsalFin: 'mocked-left-dorsal-fin',
rightDorsalFin: 'mocked-right-dorsal-fin',
otherImages: ['mocked-other-image-1'],
mother: {
fields: {
id: 'mocked-mother-id-1',
name: 'mocked-mother-name-1',
slug: 'mocked-mother-slug-1',
images: ['mocked-mother-image-1'],
},
},
images: ['mocked-image'],
},
}],
}));
Expand All @@ -175,7 +175,6 @@ describe('getCatalogueItem', () => {
id: 'mocked-calf-id-1',
name: 'mocked-calf-name-1',
slug: 'mocked-calf-slug-1',
images: ['mocked-calf-image-1'],
},
}, {
fields: {
Expand All @@ -197,26 +196,24 @@ describe('getCatalogueItem', () => {
birthYear: 'mocked birth year',
age: 'mocked age',
sex: 'mocked sex',
dorsalEdgeMarkings: 'mocked doral edge markings',
otherFeatures: 'mocked other features',
images: ['mocked-image'],
leftDorsalFin: 'mocked-left-dorsal-fin',
rightDorsalFin: 'mocked-right-dorsal-fin',
otherImages: ['mocked-other-image-1'],
lastUpdated: 'mocked-updated-at',
},
mother: {
id: 'mocked-mother-id-1',
name: 'mocked-mother-name-1',
slug: 'mocked-mother-slug-1',
image: 'mocked-mother-image-1',
},
calves: [{
id: 'mocked-calf-id-1',
name: 'mocked-calf-name-1',
slug: 'mocked-calf-slug-1',
image: 'mocked-calf-image-1',
}, {
id: 'mocked-calf-id-2',
name: null,
slug: 'mocked-calf-slug-2',
image: null,
}],
});
});
Expand Down
25 changes: 9 additions & 16 deletions src/helpers/getBottlenoseDolphinCatalogue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,11 @@ import { flattenImageAssetFields } from './flattenAssetFields';
*/
const reduceCatalogueItem = (
entry: Entry<ContentTypeCatalogueBottlenoseDolphin>,
): CatalogueBottlenoseDolphinBasicInfo => {
let image = null;
if (entry.fields?.images && Array.isArray(entry.fields.images)) {
image = flattenImageAssetFields(entry.fields?.images[0] as Asset);
}

return {
id: String(entry.fields.id),
name: entry.fields?.name ? String(entry.fields.name) : null,
slug: String(entry.fields.slug),
image,
};
};
): CatalogueBottlenoseDolphinBasicInfo => ({
id: String(entry.fields.id),
name: entry.fields?.name ? String(entry.fields.name) : null,
slug: String(entry.fields.slug),
});

interface GetCatalogueListOptions {
page: number,
Expand Down Expand Up @@ -127,9 +119,10 @@ const getCatalogueItem = async (
birthYear: entry.fields?.birthYear ?? null,
age: entry.fields.age ?? null,
sex: entry.fields.sex ?? null,
dorsalEdgeMarkings: entry.fields.dorsalEdgeMarkings ?? null,
otherFeatures: entry.fields.otherFeatures ?? null,
images: entry.fields.images?.map((item) => flattenImageAssetFields(item as Asset)) ?? [],
leftDorsalFin: entry.fields?.leftDorsalFin ? flattenImageAssetFields(entry.fields.leftDorsalFin) : null,
rightDorsalFin: entry.fields?.rightDorsalFin ? flattenImageAssetFields(entry.fields.rightDorsalFin) : null,
otherImages: entry.fields.otherImages?.map((item) => flattenImageAssetFields(item as Asset)) ?? [],
lastUpdated: entry.sys.updatedAt,
},
mother: entry.fields.mother ? reduceCatalogueItem(entry.fields.mother) : null,
calves,
Expand Down
14 changes: 7 additions & 7 deletions src/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export type CatalogueBottlenoseDolphinBasicInfo = {
id: string,
name: string | null,
slug: string,
image: FlattenedImage | null,
};

export type CatalogueBottlenoseDolphinListAPIResponse = {
Expand All @@ -90,9 +89,10 @@ export type CatalogueBottlenoseDolphin = {
birthYear: string | null,
age: number | null,
sex: 'Unknown' | 'Female' | 'Male',
dorsalEdgeMarkings: string | null,
otherFeatures: string | null,
images: Array<FlattenedImage> | [],
leftDorsalFin: FlattenedImage | null,
rightDorsalFin: FlattenedImage | null,
otherImages: Array<FlattenedImage> | [],
lastUpdated: string,
},
mother: CatalogueBottlenoseDolphinBasicInfo | null,
calves: Array<CatalogueBottlenoseDolphinBasicInfo> | [],
Expand Down Expand Up @@ -235,9 +235,9 @@ export type ContentTypeCatalogueBottlenoseDolphin = {
birthYear?: EntryFieldTypes.Date,
age?: EntryFieldTypes.Integer,
sex: EntryFieldTypes.Symbol<'Unknown' | 'Female' | 'Male'>,
dorsalEdgeMarkings?: EntryFieldTypes.Symbol,
otherFeatures?: EntryFieldTypes.Symbol,
mother?: EntryFieldTypes.EntryLink<ContentTypeCatalogueBottlenoseDolphin>,
images?: EntryFieldTypes.Array<EntryFieldTypes.AssetLink>,
leftDorsalFin?: EntryFieldTypes.AssetLink,
rightDorsalFin?: EntryFieldTypes.AssetLink,
otherImages?: EntryFieldTypes.Array<EntryFieldTypes.AssetLink>,
},
};
Loading

0 comments on commit 558b896

Please sign in to comment.