Skip to content

Commit

Permalink
Merge pull request #223 from NYPL/release/0.1.16-alpha
Browse files Browse the repository at this point in the history
Release v0.1.16-alpha
  • Loading branch information
7emansell authored Nov 8, 2024
2 parents e8f414f + 65b03be commit fbf5f64
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 35 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [0.1.16-alpha] 2024-11-8

### Updated

- Updated cards to use Next Image (DR-3056)
Expand Down
33 changes: 10 additions & 23 deletions app/src/components/card/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import ItemCardDataType from "@/src/types/ItemCardDataType";
import { CollectionCardDataType } from "../../types/CollectionCardDataType";
import { Offset } from "@/src/hooks/useTooltipOffset";
import { stringToSlug } from "@/src/utils/utils";
import CardImage from "./cardImage";
export interface DCCardProps {
tooltipOffset?: Offset;
id: string;
isLargerThanLargeTablet: boolean;
slug?: string;
imageHeight: number;
record: CollectionCardDataType | ItemCardDataType;
}

Expand All @@ -29,7 +31,10 @@ export function isCollectionCardDataType(
}

export const Card = forwardRef<HTMLDivElement, DCCardProps>(
({ tooltipOffset, id, isLargerThanLargeTablet, slug, record }, ref) => {
(
{ tooltipOffset, id, isLargerThanLargeTablet, imageHeight, slug, record },
ref
) => {
const truncatedTitle = record.title.length > TRUNCATED_LENGTH;
const isCollection = isCollectionCardDataType(record);
const identifier = slug
Expand All @@ -38,30 +43,12 @@ export const Card = forwardRef<HTMLDivElement, DCCardProps>(
const card = (
<ChakraCard
ref={ref}
key={record.imageID}
id={`card-${identifier}`}
mainActionLink={record.url}
imageProps={
record.imageID
? {
alt: "",
id: `image-${identifier}`,
isLazy: true,
aspectRatio: "twoByOne",
fallbackSrc: "/noImage.png",
onError: (_event) =>
console.warn(
`Card image failed to load, fallback image loaded instead. ImageURL: ${record.imageURL}`
),
src: record.imageURL,
}
: {
alt: "",
id: `no-image-${identifier}`,
isLazy: true,
aspectRatio: "twoByOne",
src: "/noImage.png",
}
}
imageProps={{
component: <CardImage imageHeight={imageHeight} record={record} />,
}}
>
<CardContent>
{isCollection && record.containsOnSiteMaterials && (
Expand Down
18 changes: 12 additions & 6 deletions app/src/components/exploreFurther/exploreFurther.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import { ExploreFurtherDataType } from "../../types/ExploreFurtherDataType";
import exploreFurtherData from "../../data/exploreFurtherData";
import { headerBreakpoints } from "../../utils/breakpoints";
import Image from "next/image";

const ExploreFurther = () => {
const data: ExploreFurtherDataType[] = exploreFurtherData;
Expand Down Expand Up @@ -48,13 +49,18 @@ const ExploreFurther = () => {
data-testid={`test-id-${index}`}
mainActionLink={item.url}
imageProps={{
alt: "",
aspectRatio: "sixteenByNine",
component: undefined,
component: (
<Image
src={item.image}
alt={""}
sizes="(max-width: 600px) 100vw, 25vw"
style={{
width: "100%",
minHeight: "100%",
}}
/>
),
isAtEnd: false,
isLazy: true,
size: "default",
src: item.imageSrc,
}}
layout="row"
sx={{
Expand Down
4 changes: 4 additions & 0 deletions app/src/components/grids/cardsGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ItemCardModel } from "@/src/models/itemCard";
import { SimpleGrid as DCSimpleGrid } from "../simpleGrid/simpleGrid";
import { Card as DCCard } from "../card/card";
import { useTooltipOffset } from "@/src/hooks/useTooltipOffset";
import { useCardImageHeight } from "@/src/hooks/useCardImageHeight";

interface CardsGridProps {
records: CollectionDataType[] | ItemDataType[];
Expand All @@ -20,6 +21,7 @@ export const CardsGrid = ({ records }: CardsGridProps) => {
const isCollections = isCollectionType(records);
const cardRef = useRef<HTMLDivElement>(null);
const tooltipOffset = useTooltipOffset(cardRef);
const imageHeight = useCardImageHeight(cardRef);

return (
<DCSimpleGrid>
Expand All @@ -33,6 +35,7 @@ export const CardsGrid = ({ records }: CardsGridProps) => {
ref={cardRef}
tooltipOffset={tooltipOffset}
record={collectionCardModel}
imageHeight={imageHeight}
isLargerThanLargeTablet={isLargerThanLargeTablet}
/>
);
Expand All @@ -45,6 +48,7 @@ export const CardsGrid = ({ records }: CardsGridProps) => {
ref={cardRef}
tooltipOffset={tooltipOffset}
record={itemCardModel}
imageHeight={imageHeight}
isLargerThanLargeTablet={isLargerThanLargeTablet}
/>
);
Expand Down
4 changes: 4 additions & 0 deletions app/src/components/lane/lane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import ItemDataType from "@/src/types/ItemDataType";
import useBreakpoints from "@/src/hooks/useBreakpoints";
import { useTooltipOffset } from "@/src/hooks/useTooltipOffset";
import { isCollectionType } from "@/src/utils/utils";
import { useCardImageHeight } from "@/src/hooks/useCardImageHeight";

interface LaneProps {
seeMoreLink: string;
Expand All @@ -38,6 +39,7 @@ export const Lane = ({
const cardRef = useRef<HTMLDivElement>(null);
const tooltipOffset = useTooltipOffset(cardRef);
const isCollections = isCollectionType(records);
const imageHeight = useCardImageHeight(cardRef);

const laneContents = isCollections
? {
Expand Down Expand Up @@ -119,6 +121,7 @@ export const Lane = ({
id={`${index}`}
record={collectionCardModel}
isLargerThanLargeTablet={isLargerThanLargeTablet}
imageHeight={imageHeight}
ref={cardRef}
tooltipOffset={tooltipOffset}
/>
Expand All @@ -131,6 +134,7 @@ export const Lane = ({
id={`item-${index}-${record.title}`}
record={itemCardModel}
isLargerThanLargeTablet={isLargerThanLargeTablet}
imageHeight={imageHeight}
tooltipOffset={tooltipOffset}
ref={cardRef}
/>
Expand Down
5 changes: 0 additions & 5 deletions app/src/data/exploreFurtherData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const exploreFurtherData: ExploreFurtherDataType[] = [
url: "http://nypl.artehouse.com/perl/home.pl",
image: serviceArtehouse,
imgAlt: "Service Artehouse",
imageSrc: "/service-artehouse.jpg",
},
{
title: "NYPL Archives and Manuscripts",
Expand All @@ -22,7 +21,6 @@ const exploreFurtherData: ExploreFurtherDataType[] = [
url: "http://archives.nypl.org/",
image: serviceArchives,
imgAlt: "Service Archives",
imageSrc: "/service-archives.jpg",
},
{
title: "NYPL Research Catalog",
Expand All @@ -31,7 +29,6 @@ const exploreFurtherData: ExploreFurtherDataType[] = [
url: "https://www.nypl.org/research/research-catalog/ ",
image: researchCatalog,
imgAlt: "NYPL Research Catalog",
imageSrc: "/ResearchCatalogThumbnail_v2.jpg",
},
{
title: "NYPL Digital Collections API",
Expand All @@ -40,7 +37,6 @@ const exploreFurtherData: ExploreFurtherDataType[] = [
url: "https://api.repo.nypl.org/",
image: serviceApi,
imgAlt: "Service API",
imageSrc: "/service-api.jpg",
},
{
title: "Digital Public Library of America",
Expand All @@ -49,7 +45,6 @@ const exploreFurtherData: ExploreFurtherDataType[] = [
url: "http://dp.la/",
image: serviceDpla,
imgAlt: "Service Digital Public Library",
imageSrc: "/service-dpla.jpg",
},
];

Expand Down
1 change: 0 additions & 1 deletion app/src/types/ExploreFurtherDataType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ export interface ExploreFurtherDataType {
description: string;
imgAlt: string;
image: StaticImageData;
imageSrc: string;
}

0 comments on commit fbf5f64

Please sign in to comment.