-
Notifications
You must be signed in to change notification settings - Fork 1
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 #22 from PotLock/feat/donation-modal
Feat/donation-modal
- Loading branch information
Showing
28 changed files
with
497 additions
and
435 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
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
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
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,61 @@ | ||
import { Container, HeroContainer, Line } from "./styles"; | ||
import DonationStats from "@app/pages/Projects/components/DonationStats/DonationStats"; | ||
import HomeBannerStyle from "@app/assets/svgs/HomeBannerBackground"; | ||
import { context, useContext, useMemo, useState } from "alem"; | ||
import { useDonationModal } from "@app/hooks/useDonationModal"; | ||
|
||
const NewHero = ({ projectsData }: any) => { | ||
const { allProjects, approvedProjects } = projectsData; | ||
|
||
const { setDonationModalProps } = useDonationModal(); | ||
|
||
const getRandomProject = () => { | ||
if (approvedProjects) { | ||
const randomIndex = Math.floor(Math.random() * approvedProjects.length); | ||
return approvedProjects[randomIndex]?.registrant_id; | ||
} | ||
}; | ||
|
||
const openDonateRandomlyModal = () => { | ||
setDonationModalProps({ | ||
projectId: getRandomProject(), | ||
}); | ||
}; | ||
|
||
const accountId = context.accountId; | ||
const isRegisteredProject = useMemo(() => { | ||
if (allProjects) { | ||
return allProjects.find((registration: any) => registration.registrant_id === accountId); | ||
} | ||
}, [allProjects]); | ||
|
||
return ( | ||
<Container> | ||
<HeroContainer | ||
style={{ | ||
...HomeBannerStyle, | ||
}} | ||
> | ||
<div className="content"> | ||
<h3 className="sub-title">Transforming Funding for Public Goods</h3> | ||
<h1 className="title"> | ||
Discover impact projects, donate directly, & <br className="line-break" /> participate in funding rounds. | ||
</h1> | ||
<div className="btns"> | ||
<button onClick={openDonateRandomlyModal} className="donate-btn"> | ||
Donate Randomly | ||
</button> | ||
|
||
<a href={isRegisteredProject ? `?tab=project&projectId=${accountId}` : "?tab=createproject"}> | ||
{isRegisteredProject ? "View Your Project" : "Register Your Project"} | ||
</a> | ||
</div> | ||
</div> | ||
</HeroContainer> | ||
<DonationStats /> | ||
<Line /> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default NewHero; |
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,108 @@ | ||
import styled from "styled-components"; | ||
|
||
export const Container = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
`; | ||
|
||
export const HeroContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
position: relative; | ||
width: 100%; | ||
justify-content: center; | ||
border: 1px solid #f8d3b0; | ||
border-radius: 12px; | ||
overflow: hidden; | ||
.background { | ||
position: absolute; | ||
pointer-events: none; | ||
left: 0px; | ||
width: 100%; | ||
top: 0px; | ||
min-height: 600px; | ||
} | ||
.content { | ||
position: relative; | ||
z-index: 1; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
padding: 64px 40px; | ||
} | ||
.sub-title { | ||
color: #dd3345; | ||
font-weight: 600; | ||
font-size: 16px; | ||
margin-top: 0; | ||
margin-bottom: 12px; | ||
} | ||
.title { | ||
letter-spacing: -0.4px; | ||
font-weight: 500; | ||
font-size: 40px; | ||
font-family: "Lora"; | ||
margin: 0; | ||
} | ||
.btns { | ||
display: flex; | ||
align-items: center; | ||
gap: 2rem; | ||
margin-top: 40px; | ||
font-size: 14px; | ||
a, | ||
button { | ||
padding: 12px 16px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
font-weight: 500; | ||
border-radius: 6px; | ||
box-shadow: 0px 0px 0px 1px #292929, 0px -2px 0px 0px #292929 inset; | ||
border: none; | ||
text-decoration: none; | ||
color: #292929; | ||
transition: all 300ms; | ||
&:hover { | ||
background: #292929; | ||
color: white; | ||
} | ||
} | ||
button { | ||
color: white; | ||
background: #dd3345; | ||
&:hover { | ||
} | ||
} | ||
} | ||
@media only screen and (max-width: 768px) { | ||
.content { | ||
padding: 48px 20px; | ||
} | ||
.title { | ||
font-size: 36px; | ||
} | ||
.btns { | ||
flex-direction: column; | ||
gap: 1rem; | ||
margin-top: 24px; | ||
} | ||
.line-break { | ||
display: none; | ||
} | ||
} | ||
@media only screen and (max-width: 480px) { | ||
.btns a, | ||
button { | ||
width: 100%; | ||
padding: 12px 0; | ||
} | ||
} | ||
`; | ||
|
||
export const Line = styled.div` | ||
width: 100%; | ||
height: 1px; | ||
background: #ebebeb; | ||
margin-top: 1rem; | ||
`; |
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,39 @@ | ||
// UserProvider.tsx | ||
import { createContext } from "alem"; | ||
|
||
// Interface | ||
export interface UserContextProps { | ||
setSuccessfulDonation: (newValue: any) => void; | ||
successfulDonation: any; | ||
donationModalProps: { | ||
projectId?: string; | ||
potId?: string; | ||
potDetail?: any; | ||
projects?: any; | ||
multiple?: boolean; | ||
} | null; | ||
setDonationModalProps: (newValue: any) => void; | ||
} | ||
|
||
const DonationModalProvider = () => { | ||
// Create a provider using a reference key | ||
const { setDefaultData, updateData, getSelf } = createContext<UserContextProps>("donation-modal"); | ||
|
||
setDefaultData({ | ||
successfulDonation: null, | ||
donationModalProps: null, | ||
setSuccessfulDonation: (successfulDonation: any) => { | ||
updateData({ | ||
successfulDonation, | ||
donationModalProps: null, | ||
}); | ||
}, | ||
setDonationModalProps: (donationModalProps: any) => { | ||
updateData({ | ||
donationModalProps, | ||
}); | ||
}, | ||
}); | ||
}; | ||
|
||
export default DonationModalProvider; |
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,4 @@ | ||
import { useContext } from "alem"; | ||
import { UserContextProps } from "@app/contexts/DonationModalProvider"; | ||
|
||
export const useDonationModal = () => useContext<UserContextProps>("donation-modal"); |
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.