Skip to content

Commit

Permalink
change image on reload
Browse files Browse the repository at this point in the history
  • Loading branch information
avertrees committed Oct 25, 2023
1 parent 3aadbfd commit 926689e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Created a campaign hero component and other child components for the featured item data. (DR-2464)

### Update

- Update version of NYPL Reservoir to 2.0.1
- Updated image in Hero Component to change on reload. (DR-2565)

### Added
- Added spider block script (DR-2518)
Expand Down
9 changes: 6 additions & 3 deletions src/components/hero/campaignHero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ import imageURL from "../../utils/utils";
import CampaignHeroSubText from "./campaignHeroSubText";
import CampaignHeroHeading from "./campaignHeroHeading";

const CampaignHero = () => {
const CampaignHero = ({ featuredItems }: any) => {
const randomIndex = Math.floor(Math.random() * featuredItems.images.length);
const imageID = featuredItems.images[randomIndex].split(".")[0];

return (
<Hero
backgroundImageSrc={imageURL("1269908")}
backgroundImageSrc={imageURL(imageID)}
backgroundColor="ui.bg.default"
heroType="campaign"
heading={<CampaignHeroHeading />}
imageProps={{
alt: "Momoyogusa = Flowers of a Hundred Generations.",
src: imageURL("1269908"),
src: imageURL(imageID),
}}
subHeaderText={<CampaignHeroSubText />}
/>
Expand Down
9 changes: 7 additions & 2 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import CampaignHero from "../components/hero/campaignHero";
import featuredItemsData from "../data/featureditems.json";

export default function Home() {
return <CampaignHero />;
export default function Home(props: any) {
return <CampaignHero featuredItems={props.featuredItemsData.featuredItems} />;
}

export async function getServerSideProps() {
return { props: { featuredItemsData } };
}

0 comments on commit 926689e

Please sign in to comment.