feat(client): add secure donation border to donation form (#45637)

* feat: add secure donation border to donation form

* feat: add string to translations

* Apply suggestions from code review

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* feat: cleanup and reorder logic

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
Ahmad Abdolsaheb
2022-04-07 15:24:42 +03:00
committed by GitHub
parent 4005d65123
commit 4034c59ba2
5 changed files with 30 additions and 14 deletions

View File

@ -357,6 +357,7 @@
"try-again": "Please try again.", "try-again": "Please try again.",
"card-number": "Your Card Number:", "card-number": "Your Card Number:",
"expiration": "Expiration Date:", "expiration": "Expiration Date:",
"secure-donation": "Secure donation",
"faq": "Frequently asked questions", "faq": "Frequently asked questions",
"only-you": "Only you can see this message. Congratulations on earning this certification. It's no easy task. Running freeCodeCamp isn't easy either. Nor is it cheap. Help us help you and many other people around the world. Make a tax-deductible supporting donation to our nonprofit today.", "only-you": "Only you can see this message. Congratulations on earning this certification. It's no easy task. Running freeCodeCamp isn't easy either. Nor is it cheap. Help us help you and many other people around the world. Make a tax-deductible supporting donation to our nonprofit today.",
"get-help": "How can I get help with my donations?", "get-help": "How can I get help with my donations?",

View File

@ -335,11 +335,18 @@ class DonateForm extends Component<DonateFormProps, DonateFormComponentState> {
return ( return (
<> <>
<b className={isMinimalForm ? 'donation-label-modal' : ''}> <b className={isMinimalForm ? 'donation-label-modal' : ''}>
{isAVariant === false && <SecurityLockIcon />}
{this.getDonationButtonLabel()}: {this.getDonationButtonLabel()}:
</b> </b>
<Spacer /> <Spacer />
<div className={'donate-btn-group'}> <fieldset
className={`donate-btn-group ${isAVariant ? '' : 'test-btn-group'}`}
>
{!isAVariant && (
<legend>
<SecurityLockIcon />
{t('donate.secure-donation')}
</legend>
)}
{loading.stripe && loading.paypal && this.paymentButtonsLoader()} {loading.stripe && loading.paypal && this.paymentButtonsLoader()}
<WalletsWrapper <WalletsWrapper
amount={donationAmount} amount={donationAmount}
@ -374,11 +381,10 @@ class DonateForm extends Component<DonateFormProps, DonateFormComponentState> {
processing={processing} processing={processing}
t={t} t={t}
theme={priorityTheme} theme={priorityTheme}
isAVariant={isAVariant}
/> />
</> </>
)} )}
</div> </fieldset>
</> </>
); );
} }

View File

@ -334,10 +334,6 @@ li.disabled > a {
height: 22px; height: 22px;
} }
.confirm-donation-btn svg.svg-inline--fa.fa-lock {
margin-bottom: 2px;
}
@media screen and (min-width: 355px) { @media screen and (min-width: 355px) {
.form-payment-methods { .form-payment-methods {
height: 30px; height: 30px;
@ -541,3 +537,20 @@ a.patreon-button:hover {
font-size: 1em; font-size: 1em;
border-left-color: var(--quaternary-background); border-left-color: var(--quaternary-background);
} }
.test-btn-group {
padding: 10px;
border: 2px solid var(--quaternary-background);
border-radius: 4px;
}
.test-btn-group > legend {
width: fit-content;
font-size: 0.9em;
color: var(--quaternary-color);
border: none;
margin-bottom: 0;
padding: 0 4px;
left: 0;
margin-left: -2px;
}

View File

@ -17,7 +17,6 @@ import React, { useState } from 'react';
import envData from '../../../../config/env.json'; import envData from '../../../../config/env.json';
import { Themes } from '../settings/theme'; import { Themes } from '../settings/theme';
import { AddDonationData } from './paypal-button'; import { AddDonationData } from './paypal-button';
import SecurityLockIcon from './security-lock-icon';
const { stripePublicKey }: { stripePublicKey: string | null } = envData; const { stripePublicKey }: { stripePublicKey: string | null } = envData;
@ -35,7 +34,6 @@ interface FormPropTypes {
t: (label: string) => string; t: (label: string) => string;
theme: Themes; theme: Themes;
processing: boolean; processing: boolean;
isAVariant: boolean;
} }
interface Element { interface Element {
@ -51,8 +49,7 @@ const StripeCardForm = ({
t, t,
onDonationStateChange, onDonationStateChange,
postStripeCardDonation, postStripeCardDonation,
processing, processing
isAVariant
}: FormPropTypes): JSX.Element => { }: FormPropTypes): JSX.Element => {
const [isSubmissionValid, setSubmissionValidity] = useState(true); const [isSubmissionValid, setSubmissionValidity] = useState(true);
const [isTokenizing, setTokenizing] = useState(false); const [isTokenizing, setTokenizing] = useState(false);
@ -170,7 +167,6 @@ const StripeCardForm = ({
disabled={!stripe || !elements || isSubmitting} disabled={!stripe || !elements || isSubmitting}
type='submit' type='submit'
> >
{isAVariant === false && <SecurityLockIcon />}
{t('buttons.donate')} {t('buttons.donate')}
</Button> </Button>
</Form> </Form>

View File

@ -94,7 +94,7 @@ const patreonDefaultPledgeAmount = 500;
const aBTestConfig = { const aBTestConfig = {
isTesting: true, isTesting: true,
type: 'addSecurityLock' type: 'secureDonationBorder'
}; };
module.exports = { module.exports = {