-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202 from NYPL/feature/DR-3194/general-cleanup
DR-3194 general cleanup
- Loading branch information
Showing
14 changed files
with
715 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# DC Facelift Environment Variables | ||
|
||
## Table of Contents | ||
|
||
- [General Information](#general-information) | ||
- [Application Variables](#application-variables) | ||
|
||
## General Information | ||
|
||
Environment variables are used in this code repository to control how the application builds, how and where data is fetched for separate sections in the application, for rendering certain features, and for controlling data flow. | ||
|
||
General environment variables are declared in the `.env.example` file. A copy of this file should be made and saved as `.env.local` where real values should be added. | ||
|
||
Generally, environment variables are meant to be read through the `process.env` object _on the server_. Variables intended for use on the client side should be prefaced with NEXT*PUBLIC* per Next's [docs](https://nextjs.org/docs/app/building-your-application/configuring/environment-variables). | ||
|
||
If an environment variable is updated, make sure to restart the server for the application to pick up the new value. | ||
|
||
## Application Variables | ||
|
||
These environment variables control how certain elements on the page render and where to fetch data. | ||
|
||
| Variable | Type | Value Example | Description | | ||
| ---------------------------- | ------ | ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | | ||
| `APP_ENV` | string | "development" | App environment key used to determine various environment-specific app settings. | | ||
| `DC_URL` | string | "" or "https://qa-digitalcollections.nypl.org" or https://digitalcollections.nypl.org | The base URL of the DC url, either points locally or externally to legacy DC. | | ||
| `API_URL` | string | "https://api.repo.nypl.org" or "https://qa.api.repo.nypl.org" | base url for Repo API calls. | | ||
| `AUTH_TOKEN` | string | "" | Auth token for Repo API. | | ||
| `ADOBE_EMBED_URL` | string | "" | Url endpoint used for Adobe Analytics event tracking. | | ||
| `GOOGLE_SHEETS_CLIENT_EMAIL` | string | "" | | | ||
| `GOOGLE_SHEETS_PRIVATE_KEY` | string | "" | | | ||
| `SPREADSHEET_ID` | string | "" | | | ||
| `NEW_RELIC_LICENSE_KEY` | string | "true" | | |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import React from "react"; | ||
import { Metadata } from "next"; | ||
import { CollectionsPage } from "../src/components/pages/collectionsPage/collectionsPage"; | ||
import { mockCollectionCards } from "__tests__/__mocks__/data/mockCollectionCards"; | ||
|
||
export const metadata: Metadata = { | ||
title: "Collections - NYPL Digital Collections", | ||
}; | ||
|
||
export default function Collections() { | ||
return <CollectionsPage />; | ||
export default async function Collections() { | ||
return <CollectionsPage data={mockCollectionCards} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,29 @@ | ||
"use client"; | ||
|
||
import { useSearchParams, usePathname, useRouter } from "next/navigation"; | ||
import { Heading, Pagination } from "@nypl/design-system-react-components"; | ||
import React from "react"; | ||
import { CollectionCardModel } from "../../models/collectionCard"; | ||
import useBreakpoints from "../../hooks/useBreakpoints"; | ||
import CollectionDataType from "../../types/CollectionDataType"; | ||
import React, { useRef, useState } from "react"; | ||
import { totalNumPages } from "../../utils/utils"; | ||
import { SimpleGrid as DCSimpleGrid } from "../simpleGrid/simpleGrid"; | ||
import { Card as DCCard } from "../card/card"; | ||
import { useTooltipOffset } from "@/src/hooks/useTooltipOffset"; | ||
|
||
export const CollectionsGrid = ({ data }: any) => { | ||
const pathname = usePathname(); | ||
const queryParams = useSearchParams(); | ||
const headingRef = useRef<HTMLHeadingElement>(null); | ||
|
||
const [currentPage, setCurrentPage] = useState( | ||
Number(queryParams.get("page")) || 1 | ||
); | ||
|
||
const { replace } = useRouter(); | ||
|
||
export const CollectionsGrid = ({ collections }: any) => { | ||
const { isLargerThanLargeTablet } = useBreakpoints(); | ||
|
||
const totalPages = totalNumPages(data.numFound, data.perPage); | ||
|
||
const updatePageURL = async (pageNumber: number) => { | ||
const params = new URLSearchParams(); | ||
params.set("page", pageNumber.toString()); | ||
setCurrentPage(pageNumber); | ||
const url = `${pathname}?${params.toString()}#${data.slug}`; | ||
replace(url); | ||
headingRef.current?.focus; | ||
}; | ||
|
||
const cardRef = useRef<HTMLDivElement>(null); | ||
const tooltipOffset = useTooltipOffset(cardRef); | ||
|
||
return ( | ||
<> | ||
<Heading | ||
ref={headingRef} | ||
tabIndex={-1} | ||
level="h2" | ||
id={data.slug} | ||
size="heading3" | ||
style={{ width: "fit-content" }} | ||
> | ||
{`Collections in the ${data.name}`} | ||
</Heading> | ||
<DCSimpleGrid> | ||
{data?.collections?.map((collection: CollectionDataType, index) => { | ||
const collectionModel = new CollectionCardModel(collection); | ||
return ( | ||
<DCCard | ||
key={index} | ||
ref={cardRef} | ||
tooltipOffset={tooltipOffset} | ||
id={index} | ||
slug={collectionModel.title} | ||
record={collectionModel} | ||
isLargerThanLargeTablet={isLargerThanLargeTablet} | ||
/> | ||
); | ||
})} | ||
</DCSimpleGrid> | ||
{totalPages > 1 && ( | ||
<> | ||
<Pagination | ||
id="pagination-id" | ||
initialPage={currentPage} | ||
currentPage={currentPage} | ||
pageCount={totalPages} | ||
onPageChange={updatePageURL} | ||
sx={{ | ||
display: "flex", | ||
justifyContent: "center", | ||
gap: "s", | ||
marginTop: "xxl", | ||
}} | ||
<DCSimpleGrid> | ||
{collections?.map((collection: CollectionDataType, index) => { | ||
const collectionModel = new CollectionCardModel(collection); | ||
return ( | ||
<DCCard | ||
key={index} | ||
id={index} | ||
slug={collectionModel.title} | ||
record={collectionModel} | ||
isLargerThanLargeTablet={isLargerThanLargeTablet} | ||
/> | ||
</> | ||
)} | ||
</> | ||
); | ||
})} | ||
</DCSimpleGrid> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"use client"; | ||
|
||
import useBreakpoints from "../../hooks/useBreakpoints"; | ||
import React from "react"; | ||
import { SimpleGrid as DCSimpleGrid } from "../simpleGrid/simpleGrid"; | ||
import { Card as DCCard } from "../card/card"; | ||
import ItemCardDataType from "@/src/types/ItemCardDataType"; | ||
import { ItemCardModel } from "@/src/models/itemCard"; | ||
|
||
export const ItemsGrid = ({ items }: any) => { | ||
console.log("items are: ", items); | ||
const { isLargerThanLargeTablet } = useBreakpoints(); | ||
|
||
return ( | ||
<DCSimpleGrid> | ||
{items?.map((item: ItemCardDataType, index) => { | ||
const itemModel = new ItemCardModel(item); | ||
return ( | ||
<DCCard | ||
key={index} | ||
id={index} | ||
record={itemModel} | ||
isLargerThanLargeTablet={isLargerThanLargeTablet} | ||
/> | ||
); | ||
})} | ||
</DCSimpleGrid> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.