Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Active and Completed campaigns on Homepage #1416

Merged
merged 10 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,27 @@ import { campaignListPictureUrl } from 'common/util/campaignImageUrls'
import { CampaignState } from 'components/client/campaigns/helpers/campaign.enums'

import { CampaignTitle, Content, SupportNowButton } from './ActiveCampaignCard.styled'
import { moneyPublic } from 'common/util/money'
import {
MoneyWrapper,
MoneyWrapperFlex,
MoneyUnit,
MoneyFraction,
MoneyText,
} from '../../CompletedCampaignsSection/CompletedCampaignsSection.styled'

type Props = { campaign: CampaignResponse; index: number }

export default function ActiveCampaignCard({ campaign, index }: Props) {
const { t } = useTranslation('campaigns')
const { state: campaignState, allowDonationOnComplete, slug, title } = campaign
const campaignImagesUrl = campaignListPictureUrl(campaign)
const reachedMoneyUnit = moneyPublic(campaign.summary.reachedAmount).split(',')[0]
const reachedMoneyFraction = moneyPublic(campaign.summary.reachedAmount)
.split(',')[1]
.substring(0, 2)
const targetMoneyUnit = moneyPublic(campaign.targetAmount).split(',')[0]
const targetMoneyFraction = moneyPublic(campaign.targetAmount).split(',')[1].substring(0, 2)

return (
<CardActionArea
Expand All @@ -41,6 +55,16 @@ export default function ActiveCampaignCard({ campaign, index }: Props) {
},
},
}}>
<MoneyWrapper>
<MoneyWrapperFlex>
<MoneyText>{t('campaign.reached')}</MoneyText>
<MoneyUnit>{reachedMoneyUnit}</MoneyUnit>
<MoneyFraction>{reachedMoneyFraction}</MoneyFraction>
<MoneyText>{t('campaign.from')}</MoneyText>
<MoneyUnit>{targetMoneyUnit}</MoneyUnit>
<MoneyFraction>{targetMoneyFraction}</MoneyFraction>
</MoneyWrapperFlex>
</MoneyWrapper>
<Content>
<CampaignTitle>{title}</CampaignTitle>
<Grid textAlign="center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { styled } from '@mui/material/styles'
import theme from 'common/theme'

export const Root = styled(Grid)(() => ({
marginTop: theme.spacing(3.875),
marginTop: theme.spacing(7),
display: 'grid',
gridTemplateRows: 'repeat(5, 1fr)',

Expand Down Expand Up @@ -32,7 +32,7 @@ export const Root = styled(Grid)(() => ({

[theme.breakpoints.up(2000)]: {
maxWidth: theme.spacing(165),
margin: `${theme.spacing(4)} auto`,
margin: `${theme.spacing(7)} auto ${theme.spacing(4)} auto`,
},
}))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Slider from 'react-slick'
import styled from '@emotion/styled'

import theme from 'common/theme'
import { Typography, Link, Grid } from '@mui/material'
import { Typography, Link, Grid, Stack } from '@mui/material'

export const CarouselWrapper = styled(Slider)(() => ({
margin: '0 auto',
Expand All @@ -30,12 +30,11 @@ export const CampaignTitle = styled('h6')(() => ({
color: theme.palette.secondary.light,
}))

export const ReachedMoneyWrapper = styled(Grid)(() => ({
export const MoneyWrapper = styled(Grid)(() => ({
display: 'flex',
flexDirection: 'column',
paddingTop: theme.spacing(0.6),
padding: theme.spacing(0.6, 0),
minWidth: theme.spacing(17.5),
minHeight: theme.spacing(7.5),
background: '#323232',
borderRadius: theme.spacing(0, 0, 0, 2),
color: '#B0E5FF',
Expand All @@ -45,14 +44,29 @@ export const ReachedMoneyWrapper = styled(Grid)(() => ({
alignItems: 'center',
}))

export const ReachedMoney = styled(Typography)(() => ({
export const MoneyUnit = styled('span')(() => ({
fontWeight: 700,
fontSize: theme.typography.pxToRem(17),
}))

export const ReachedText = styled(Typography)(() => ({
export const MoneyFraction = styled('span')(() => ({
fontWeight: 700,
fontSize: theme.typography.pxToRem(10),
marginTop: theme.spacing(0.5),

[theme.breakpoints.up(1270)]: {
marginTop: theme.spacing(0.3),
},
}))

export const MoneyWrapperFlex = styled(Stack)(() => ({
flexDirection: 'row',
}))

export const MoneyText = styled(Typography)(() => ({
color: theme.palette.common.white,
fontFamily: 'Lato, sans-serif',
fontWeight: 700,
fontSize: theme.typography.pxToRem(17),
padding: theme.spacing(0, 1),
}))
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ import { campaignListPictureUrl } from 'common/util/campaignImageUrls'
import theme from 'common/theme'
import { CampaignState } from 'components/client/campaigns/helpers/campaign.enums'
import { routes } from 'common/routes'
import { settings } from './helpers/CaroucelSettings'
import { settings } from './helpers/CompletedCampaignsCaroucelSettings'
import { moneyPublic } from 'common/util/money'

import { Heading } from '../../IndexPage.styled'
import {
CarouselWrapper,
ReachedMoney,
ReachedText,
MoneyUnit,
MoneyFraction,
MoneyWrapper,
MoneyText,
CampaignTitle,
ReachedMoneyWrapper,
CompletedCampaignLink,
MoneyWrapperFlex,
} from './CompletedCampaignsSection.styled'

export default function CompletedCampaignsSection() {
Expand Down Expand Up @@ -51,16 +53,19 @@ export default function CompletedCampaignsSection() {
onMouseDown={onLinkMouseDown}
href={routes.campaigns.viewCampaignBySlug(campaign.slug)}
sx={{
background: `url(${campaignListPictureUrl(campaign)})`,
background: `linear-gradient(180deg, rgba(81, 81, 81, 0) 50%, rgba(0, 0, 0, 0.78) 80%, #000000 100%), url(${campaignListPictureUrl(
campaign,
)})`,
}}>
<ReachedMoneyWrapper>
<Grid>
<ReachedMoney>
{moneyPublic(campaign.summary.reachedAmount, campaign.currency)}
</ReachedMoney>
<ReachedText>{t('campaign.reached')}</ReachedText>
</Grid>
</ReachedMoneyWrapper>
<MoneyWrapper>
<MoneyWrapperFlex>
<MoneyUnit>{moneyPublic(campaign.summary.reachedAmount).split(',')[0]}</MoneyUnit>
<MoneyFraction>
{moneyPublic(campaign.summary.reachedAmount).split(',')[1].substring(0, 2)}
</MoneyFraction>
</MoneyWrapperFlex>
<MoneyText>{t('campaign.reached')}</MoneyText>
</MoneyWrapper>
<CampaignTitle>{campaign.title}</CampaignTitle>
</CompletedCampaignLink>
</Grid>
Expand Down