feat: add payment option image to donation forms (#37938)

This commit is contained in:
Ahmad Abdolsaheb
2019-12-23 15:31:10 +03:00
committed by mrugesh
parent 19352442ce
commit d08a87bcd6
9 changed files with 191 additions and 76 deletions

View File

@ -0,0 +1,50 @@
/* eslint-disable max-len */
import React, { Fragment } from 'react';
const propTypes = {};
function Paypal(props) {
return (
<Fragment>
<span className='sr-only'>Paypal</span>
<svg
height={33}
version='1.1'
viewBox='0 0 124 33'
width={124}
xmlns='http://www.w3.org/2000/svg'
{...props}
>
<path
d='M46.211 6.749h-6.839a.95.95 0 0 0-.939.802l-2.766 17.537a.57.57 0 0 0 .564.658h3.265a.95.95 0 0 0 .939-.803l.746-4.73a.95.95 0 0 1 .938-.803h2.165c4.505 0 7.105-2.18 7.784-6.5.306-1.89.013-3.375-.872-4.415-.972-1.142-2.696-1.746-4.985-1.746zM47 13.154c-.374 2.454-2.249 2.454-4.062 2.454h-1.032l.724-4.583a.57.57 0 0 1 .563-.481h.473c1.235 0 2.4 0 3.002.704.359.42.469 1.044.332 1.906zM66.654 13.075h-3.275a.57.57 0 0 0-.563.481l-.145.916-.229-.332c-.709-1.029-2.29-1.373-3.868-1.373-3.619 0-6.71 2.741-7.312 6.586-.313 1.918.132 3.752 1.22 5.031.998 1.176 2.426 1.666 4.125 1.666 2.916 0 4.533-1.875 4.533-1.875l-.146.91a.57.57 0 0 0 .562.66h2.95a.95.95 0 0 0 .939-.803l1.77-11.209a.568.568 0 0 0-.561-.658zm-4.565 6.374c-.316 1.871-1.801 3.127-3.695 3.127-.951 0-1.711-.305-2.199-.883-.484-.574-.668-1.391-.514-2.301.295-1.855 1.805-3.152 3.67-3.152.93 0 1.686.309 2.184.892.499.589.697 1.411.554 2.317zM84.096 13.075h-3.291a.954.954 0 0 0-.787.417l-4.539 6.686-1.924-6.425a.953.953 0 0 0-.912-.678h-3.234a.57.57 0 0 0-.541.754l3.625 10.638-3.408 4.811a.57.57 0 0 0 .465.9h3.287a.949.949 0 0 0 .781-.408l10.946-15.8a.57.57 0 0 0-.468-.895z'
fill='#253B80'
/>
<path
d='M94.992 6.749h-6.84a.95.95 0 0 0-.938.802l-2.766 17.537a.569.569 0 0 0 .562.658h3.51a.665.665 0 0 0 .656-.562l.785-4.971a.95.95 0 0 1 .938-.803h2.164c4.506 0 7.105-2.18 7.785-6.5.307-1.89.012-3.375-.873-4.415-.971-1.142-2.694-1.746-4.983-1.746zm.789 6.405c-.373 2.454-2.248 2.454-4.062 2.454h-1.031l.725-4.583a.568.568 0 0 1 .562-.481h.473c1.234 0 2.4 0 3.002.704.359.42.468 1.044.331 1.906zM115.434 13.075h-3.273a.567.567 0 0 0-.562.481l-.145.916-.23-.332c-.709-1.029-2.289-1.373-3.867-1.373-3.619 0-6.709 2.741-7.311 6.586-.312 1.918.131 3.752 1.219 5.031 1 1.176 2.426 1.666 4.125 1.666 2.916 0 4.533-1.875 4.533-1.875l-.146.91a.57.57 0 0 0 .564.66h2.949a.95.95 0 0 0 .938-.803l1.771-11.209a.571.571 0 0 0-.565-.658zm-4.565 6.374c-.314 1.871-1.801 3.127-3.695 3.127-.949 0-1.711-.305-2.199-.883-.484-.574-.666-1.391-.514-2.301.297-1.855 1.805-3.152 3.67-3.152.93 0 1.686.309 2.184.892.501.589.699 1.411.554 2.317zM119.295 7.23l-2.807 17.858a.569.569 0 0 0 .562.658h2.822c.469 0 .867-.34.939-.803l2.768-17.536a.57.57 0 0 0-.562-.659h-3.16a.571.571 0 0 0-.562.482z'
fill='#179BD7'
/>
<path
d='M7.266 29.154l.523-3.322-1.165-.027H1.061L4.927 1.292a.316.316 0 0 1 .314-.268h9.38c3.114 0 5.263.648 6.385 1.927.526.6.861 1.227 1.023 1.917.17.724.173 1.589.007 2.644l-.012.077v.676l.526.298a3.69 3.69 0 0 1 1.065.812c.45.513.741 1.165.864 1.938.127.795.085 1.741-.123 2.812-.24 1.232-.628 2.305-1.152 3.183a6.547 6.547 0 0 1-1.825 2c-.696.494-1.523.869-2.458 1.109-.906.236-1.939.355-3.072.355h-.73c-.522 0-1.029.188-1.427.525a2.21 2.21 0 0 0-.744 1.328l-.055.299-.924 5.855-.042.215c-.011.068-.03.102-.058.125a.155.155 0 0 1-.096.035H7.266z'
fill='#253B80'
/>
<path
d='M23.048 7.667c-.028.179-.06.362-.096.55-1.237 6.351-5.469 8.545-10.874 8.545H9.326c-.661 0-1.218.48-1.321 1.132L6.596 26.83l-.399 2.533a.704.704 0 0 0 .695.814h4.881c.578 0 1.069-.42 1.16-.99l.048-.248.919-5.832.059-.32c.09-.572.582-.992 1.16-.992h.73c4.729 0 8.431-1.92 9.513-7.476.452-2.321.218-4.259-.978-5.622a4.667 4.667 0 0 0-1.336-1.03z'
fill='#179BD7'
/>
<path
d='M21.754 7.151a9.757 9.757 0 0 0-1.203-.267 15.284 15.284 0 0 0-2.426-.177h-7.352a1.172 1.172 0 0 0-1.159.992L8.05 17.605l-.045.289a1.336 1.336 0 0 1 1.321-1.132h2.752c5.405 0 9.637-2.195 10.874-8.545.037-.188.068-.371.096-.55a6.594 6.594 0 0 0-1.017-.429 9.045 9.045 0 0 0-.277-.087z'
fill='#222D65'
/>
<path
d='M9.614 7.699a1.169 1.169 0 0 1 1.159-.991h7.352c.871 0 1.684.057 2.426.177a9.757 9.757 0 0 1 1.481.353c.365.121.704.264 1.017.429.368-2.347-.003-3.945-1.272-5.392C20.378.682 17.853 0 14.622 0h-9.38c-.66 0-1.223.48-1.325 1.133L.01 25.898a.806.806 0 0 0 .795.932h5.791l1.454-9.225 1.564-9.906z'
fill='#253B80'
/>
</svg>
</Fragment>
);
}
Paypal.displayName = 'Paypal';
Paypal.propTypes = propTypes;
export default Paypal;

View File

@ -23,7 +23,7 @@ import standardErrorMessage from '../utils/standardErrorMessage';
import reallyWeirdErrorMessage from '../utils/reallyWeirdErrorMessage'; import reallyWeirdErrorMessage from '../utils/reallyWeirdErrorMessage';
import RedirectHome from '../components/RedirectHome'; import RedirectHome from '../components/RedirectHome';
import { Loader, Spacer } from '../components/helpers'; import { Loader } from '../components/helpers';
const propTypes = { const propTypes = {
cert: PropTypes.shape({ cert: PropTypes.shape({
@ -153,14 +153,13 @@ class ShowCertification extends Component {
const donationCloseBtn = ( const donationCloseBtn = (
<div> <div>
<Spacer />
<Button <Button
block={true} block={true}
bsSize='sm' bsSize='sm'
bsStyle='primary' bsStyle='primary'
onClick={this.hideDonationSection} onClick={this.hideDonationSection}
> >
Close. Close
</Button> </Button>
</div> </div>
); );
@ -173,23 +172,25 @@ class ShowCertification extends Component {
) { ) {
conditionalDonationSection = ( conditionalDonationSection = (
<Grid className='donation-section'> <Grid className='donation-section'>
<Row className='certification-donation'> {!closeBtn && (
<Col sm={10} smOffset={1} xs={12}> <Row>
<p> <Col sm={10} smOffset={1} xs={12}>
Only you can see this message. Congratulations on earning this <p>
certification. Its no easy task. Running freeCodeCamp isnt Only you can see this message. Congratulations on earning this
easy either. Nor is it cheap. Help us help you and many other certification. Its no easy task. Running freeCodeCamp isnt
people around the world. Make a tax-deductible supporting easy either. Nor is it cheap. Help us help you and many other
donation to our nonprofit today. people around the world. Make a tax-deductible supporting
</p> donation to our nonprofit today.
</Col> </p>
</Row> </Col>
</Row>
)}
<MinimalDonateForm <MinimalDonateForm
showCloseBtn={this.showDonationCloseBtn} showCloseBtn={this.showDonationCloseBtn}
defaultTheme='light' defaultTheme='light'
/> />
<Row className='certification-donation'> <Row>
<Col sm={10} smOffset={1} xs={12}> <Col sm={4} smOffset={4} xs={6} xsOffset={3}>
{closeBtn ? donationCloseBtn : ''} {closeBtn ? donationCloseBtn : ''}
</Col> </Col>
</Row> </Row>

View File

@ -46,9 +46,13 @@ function DonateCompletion({
{success && !yearEndGift && ( {success && !yearEndGift && (
<div> <div>
<p> <p>
Your donation will support free technology education for people Your donations will support free technology education for people
all over the world. all over the world.
</p> </p>
<p>
You can update your supporter status at any time from your
settings page.
</p>
</div> </div>
)} )}
{success && yearEndGift && ( {success && yearEndGift && (

View File

@ -176,14 +176,6 @@ li.disabled > a {
} }
} }
.donation-icon-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin: 40px;
}
.donation-icon { .donation-icon {
width: 150px; width: 150px;
height: auto; height: auto;
@ -205,33 +197,79 @@ li.disabled > a {
} }
} }
.donation-modal p {
text-align: center;
font-weight: 700;
font-size: 1.1rem;
}
.donation-modal .modal-title {
text-align: center;
font-weight: 700;
font-size: 1.5rem;
}
.donation-modal .btn-link:focus { .donation-modal .btn-link:focus {
outline-width: 1px; outline-width: 1px;
outline-style: solid; outline-style: solid;
} }
@media screen and (max-width: 991px) { .donation-modal .modal-title {
.donation-icon-container { text-align: center;
margin: 30px; font-weight: 600;
} font-size: 1.2rem;
.donation-modal p { }
font-weight: 400;
font-size: 1rem; .donation-modal p,
} .donation-modal b {
.donation-modal .modal-title { text-align: center;
font-weight: 600; font-size: 1rem;
font-size: 1.2rem; }
.donation-icon-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin: 30px;
}
.form-payments-wrapper {
height: auto;
display: flex;
align-items: center;
justify-content: flex-start;
margin-top: 15px;
height: auto;
}
.form-payment-methods {
height: 20px;
width: 200px;
}
@media screen and (min-width: 355px) {
.form-payment-methods {
height: 30px;
width: 300px;
}
}
@media screen and (min-width: 991px) {
.form-payments-wrapper {
justify-content: flex-end;
margin-top: 0;
height: 39px;
}
.donate-page-wrapper .form-payment-methods {
height: 22px;
width: 220px;
}
.donation-icon-container {
margin: 40px;
}
.donation-modal p {
font-size: 1.1rem;
}
.donation-modal .modal-title {
font-weight: 700;
font-size: 1.5rem;
}
}
@media screen and (min-width: 1200px) {
.donate-page-wrapper .form-payment-methods {
height: 25px;
width: 250px;
} }
} }

View File

@ -58,16 +58,25 @@ function DonateModal({ show, block, isBlockDonation, closeDonationModal }) {
if (show) { if (show) {
ga.modalview('/donation-modal'); ga.modalview('/donation-modal');
} }
const donationText = (
<b>
Become a supporter and help us create even more learning resources for
you.
</b>
);
const blockDonationText = ( const blockDonationText = (
<div className='block-modal-text'> <div className='block-modal-text'>
<div className='donation-icon-container'> <div className='donation-icon-container'>
<Cup className='donation-icon' /> <Cup className='donation-icon' />
</div> </div>
<Row> <Row>
<Col sm={10} smOffset={1} xs={12}> {!closeLabel && (
<p>Nicely done. You just completed {blockNameify(block)}.</p> <Col sm={10} smOffset={1} xs={12}>
<p>Help us create even more learning resources like this.</p> <b>Nicely done. You just completed {blockNameify(block)}.</b>
</Col> {donationText}
</Col>
)}
</Row> </Row>
</div> </div>
); );
@ -78,29 +87,24 @@ function DonateModal({ show, block, isBlockDonation, closeDonationModal }) {
<Heart className='donation-icon' /> <Heart className='donation-icon' />
</div> </div>
<Row> <Row>
<Col sm={10} smOffset={1} xs={12}> {!closeLabel && (
<p> <Col sm={10} smOffset={1} xs={12}>
Help us create even more learning resources for you and your family. {donationText}
</p> </Col>
</Col> )}
</Row> </Row>
</div> </div>
); );
return ( return (
<Modal bsSize='lg' className='donation-modal' show={show}> <Modal bsSize='lg' className='donation-modal' show={show}>
<Modal.Header className='fcc-modal'>
<Modal.Title className='modal-title text-center'>
<strong>Become a Supporter</strong>
</Modal.Title>
</Modal.Header>
<Modal.Body> <Modal.Body>
{isBlockDonation ? blockDonationText : progressDonationText} {isBlockDonation ? blockDonationText : progressDonationText}
<Spacer /> <Spacer />
<MinimalDonateForm showCloseBtn={showCloseBtn} /> <MinimalDonateForm showCloseBtn={showCloseBtn} />
<Spacer /> <Spacer />
<Row> <Row>
<Col sm={10} smOffset={1} xs={12}> <Col sm={4} smOffset={4} xs={8} xsOffset={2}>
<Button <Button
block={true} block={true}
bsSize='sm' bsSize='sm'
@ -109,7 +113,7 @@ function DonateModal({ show, block, isBlockDonation, closeDonationModal }) {
onClick={closeDonationModal} onClick={closeDonationModal}
tabIndex='0' tabIndex='0'
> >
{closeLabel ? 'Close.' : 'Ask me later.'} {closeLabel ? 'Close' : 'Ask me later'}
</Button> </Button>
</Col> </Col>
</Row> </Row>

View File

@ -1,7 +1,13 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { CardNumberElement, CardExpiryElement } from 'react-stripe-elements'; import { CardNumberElement, CardExpiryElement } from 'react-stripe-elements';
import { ControlLabel, FormGroup } from '@freecodecamp/react-bootstrap'; import {
Row,
Col,
ControlLabel,
FormGroup,
Image
} from '@freecodecamp/react-bootstrap';
const propTypes = { const propTypes = {
getValidationState: PropTypes.func.isRequired, getValidationState: PropTypes.func.isRequired,
@ -77,12 +83,26 @@ class StripeCardForm extends Component {
/> />
</FormGroup> </FormGroup>
<FormGroup> <FormGroup>
<ControlLabel>Your Card Expiration Month:</ControlLabel> <ControlLabel>Expiration Date:</ControlLabel>
<CardExpiryElement <Row>
className='form-control donate-input-element' <Col md={5} xs={12}>
onChange={this.handleInputChange} <CardExpiryElement
style={style} className='form-control donate-input-element'
/> onChange={this.handleInputChange}
style={style}
/>
</Col>
<Col className='form-payments-wrapper' md={7} xs={12}>
<Image
alt='payment options'
className='form-payment-methods'
src={
'https://cdn.freecodecamp.org' +
'/platform/universal/form-payments.png'
}
/>
</Col>
</Row>
</FormGroup> </FormGroup>
</div> </div>
); );

View File

@ -255,7 +255,6 @@ class YearEndDonationForm extends Component {
? this.renderCustomAmountInput() ? this.renderCustomAmountInput()
: this.renderOtherPaymentButton()} : this.renderOtherPaymentButton()}
</Col> </Col>
<Col sm={10} smOffset={1} xs={12}> <Col sm={10} smOffset={1} xs={12}>
{this.renderDonationOptions()} {this.renderDonationOptions()}
<Spacer /> <Spacer />
@ -267,7 +266,6 @@ class YearEndDonationForm extends Component {
{this.renderPayPalDonations()} {this.renderPayPalDonations()}
<Spacer /> <Spacer />
</Col> </Col>
<Col sm={10} smOffset={1} xs={12}> <Col sm={10} smOffset={1} xs={12}>
<b> <b>
If you need a receipt from your taxes, reply to Quincy's email he If you need a receipt from your taxes, reply to Quincy's email he

View File

@ -42,13 +42,13 @@
padding: 20px 0px; padding: 20px 0px;
} }
.certificate-outer-wrapper .certification-donation .btn { .certificate-outer-wrapper .btn {
background-color: var(--gray-15); background-color: var(--gray-15);
border-color: var(--gray-85); border-color: var(--gray-85);
color: var(--gray-85); color: var(--gray-85);
} }
.certificate-outer-wrapper .certification-donation .btn:hover { .certificate-outer-wrapper .btn:hover {
border-color: var(--gray-85); border-color: var(--gray-85);
background-color: var(--gray-85); background-color: var(--gray-85);
color: var(--gray-05); color: var(--gray-05);

View File

@ -76,7 +76,7 @@ export class DonatePage extends Component {
return ( return (
<Fragment> <Fragment>
<Helmet title='Support our nonprofit | freeCodeCamp.org' /> <Helmet title='Support our nonprofit | freeCodeCamp.org' />
<Grid> <Grid className='donate-page-wrapper'>
<Spacer /> <Spacer />
<Row> <Row>
<Col sm={10} smOffset={1} xs={12}> <Col sm={10} smOffset={1} xs={12}>