Skip to content

Commit

Permalink
feature: add Previous button to steps
Browse files Browse the repository at this point in the history
  • Loading branch information
pauloiankoski committed Jul 15, 2024
1 parent 412ca6e commit f1d92ed
Show file tree
Hide file tree
Showing 15 changed files with 149 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { setAddons } from '../../store/actions';
import Card from '../../../components/card';
import CardInput from '../../../components/card-input';
import ContinueButton from '../../../components/continue-button';
import PreviousButton from '../../../components/previous-button';
import RecurringDonationsIcon from '../../../components/icons/recurring-donations';
import DonorsCoverFeesIcon from '../../../components/icons/donors-cover-fees';
import PDFReceiptsIcon from '../../../components/icons/pdf-receipts';
Expand Down Expand Up @@ -59,7 +60,10 @@ const Addons = () => {
<p>{__('Allow donors to dedicate their donation to someone special.', 'give')}</p>
</Card>
</CardInput>
<ContinueButton testId="addons-continue-button" />
<footer className="give-obw-footer">
<ContinueButton testId="addons-continue-button" />
<PreviousButton testId="addons-previous-button" />
</footer>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,4 @@
text-align: center;
}
}

> .give-obw-button {
margin-top: 52px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {__} from '@wordpress/i18n';

// Import components
import ContinueButton from '../../../components/continue-button';
import PreviousButton from '../../../components/previous-button';
import DonationFormComponent from '../../../components/donation-form';
import Bullet from '../../../components/icons/bullet';

Expand Down Expand Up @@ -39,7 +40,10 @@ const DonationForm = () => {
{__('Extend functionality with add-ons and more', 'give')}
</li>
</ul>
<ContinueButton testId="preview-continue-button" />
<footer className="give-obw-footer">
<ContinueButton testId="preview-continue-button" />
<PreviousButton testId="preview-previous-button" />
</footer>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { setFeatures } from '../../store/actions';
import Card from '../../../components/card';
import CardInput from '../../../components/card-input';
import ContinueButton from '../../../components/continue-button';
import PreviousButton from '../../../components/previous-button';
import OfflineDonationsIcon from '../../../components/icons/offline-donations';
import DonationGoalIcon from '../../../components/icons/donation-goal';
import DonationCommentsIcon from '../../../components/icons/donation-comments';
Expand Down Expand Up @@ -59,9 +60,12 @@ const Features = () => {
<p>{__('Donors can donate via their company.', 'give')}</p>
</Card>
</CardInput>
<ContinueButton testId="features-continue-button" />
</div>
);
<footer className="give-obw-footer">
<ContinueButton testId="features-continue-button" />
<PreviousButton testId="features-previous-button" />
</footer>
</div>
);
};

export default Features;
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,4 @@
text-align: center;
}
}

> .give-obw-button {
margin-top: 52px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { setCountry, setState, setCurrency, fetchStateList } from '../../store/a
// Import components
import Card from '../../../components/card';
import ContinueButton from '../../../components/continue-button';
import PreviousButton from '../../../components/previous-button';
import SelectInput from '../../../components/select-input';
import BackgroundImage from './background';

Expand Down Expand Up @@ -38,7 +39,10 @@ const Location = () => {
<SelectInput testId="state-select" label={ __( 'State / Province', 'give' ) } value={ state } onChange={ ( value ) => dispatch( setState( value ) ) } options={ statesList } isLoading={ fetchingStatesList } />
<SelectInput testId="currency-select" label={ __( 'Currency', 'give' ) } value={ currency } onChange={ ( value ) => dispatch( setCurrency( value ) ) } options={ currenciesList } />
</Card>
<ContinueButton testId="location-continue-button" />
<footer className="give-obw-footer">
<ContinueButton testId="location-continue-button" />
<PreviousButton testId="location-previous-button" />
</footer>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@

.give-obw-card {
padding: 40px;
margin-bottom: 85px;
margin-bottom: 24px;
box-sizing: border-box;
width: 445px;
}

.give-obw-select-input {
Expand All @@ -39,4 +41,8 @@
margin-bottom: 0;
}
}

.give-obw-footer {
width: 445px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import CardInput from '../../../components/card-input';
import Card from '../../../components/card';
import SelectInput from '../../../components/select-input';
import ContinueButton from '../../../components/continue-button';
import PreviousButton from '../../../components/previous-button';
import IndividualIcon from '../../../components/icons/individual';
import OrganizationIcon from '../../../components/icons/organization';
import OtherIcon from '../../../components/icons/other';
import SkipLink from '../../../components/skip-optin-link';

// Import styles
import './style.scss';
Expand Down Expand Up @@ -66,10 +66,12 @@ const YourCause = () => {
subscribeToNewsletter( configuration );
}} />

<SkipLink />

<footer className="give-obw-footer">
<ContinueButton testId="cause-continue-button" />
</footer>
</div>
);
};

export default YourCause;

27 changes: 15 additions & 12 deletions assets/src/js/admin/onboarding-wizard/components/button/index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
// Import vendor dependencies
import PropTypes from 'prop-types';
import cx from 'classnames';

// Import styles
import './style.scss';

const Button = ( { onClick, testId, children } ) => {
return (
<button className="give-obw-button" data-givewp-test={ testId } onClick={ onClick }>
{ children }
</button>
);
const Button = ({className, onClick, testId, children}) => {
return (
<button className={cx('give-obw-button', className)} data-givewp-test={testId} onClick={onClick}>
{children}
</button>
);
};

Button.propTypes = {
onClick: PropTypes.func,
testId: PropTypes.string,
children: PropTypes.node,
className: PropTypes.string,
onClick: PropTypes.func,
testId: PropTypes.string,
children: PropTypes.node,
};

Button.defaultProps = {
onClick: null,
testId: null,
children: null,
className: null,
onClick: null,
testId: null,
children: null,
};

export default Button;
20 changes: 20 additions & 0 deletions assets/src/js/admin/onboarding-wizard/components/button/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@
border-radius: 4px;
border: none;

&--reverse {
flex-direction: row-reverse;
}

&--secondary.give-obw-button {
background: #fff;
box-shadow: none;
color: #4fa651;
outline: 1px solid #4fa651;

&:focus {
outline: 1px solid #4fa651;
}

&:hover {
background: #f2fff3;
filter: none;
}
}

&:focus {
box-shadow: 0 0 0 2px #7ec980, 0 0 0 3px #4fa651;
outline: none;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const Chevron = () => {
return (
<svg width="8" height="13" viewBox="0 0 8 13" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.07257 7.21484C7.31866 6.96875 7.31866 6.55859 7.07257 6.3125L1.76788 0.980469C1.49445 0.734375 1.08429 0.734375 0.838196 0.980469L0.20929 1.60938C-0.0368042 1.85547 -0.0368042 2.26562 0.20929 2.53906L4.42023 6.75L0.20929 10.9883C-0.0368042 11.2617 -0.0368042 11.6719 0.20929 11.918L0.838196 12.5469C1.08429 12.793 1.49445 12.793 1.76788 12.5469L7.07257 7.21484Z" fill="white" />
</svg>
);
return (
<svg width="8" height="13" viewBox="0 0 8 13" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M7.07257 7.21484C7.31866 6.96875 7.31866 6.55859 7.07257 6.3125L1.76788 0.980469C1.49445 0.734375 1.08429 0.734375 0.838196 0.980469L0.20929 1.60938C-0.0368042 1.85547 -0.0368042 2.26562 0.20929 2.53906L4.42023 6.75L0.20929 10.9883C-0.0368042 11.2617 -0.0368042 11.6719 0.20929 11.918L0.838196 12.5469C1.08429 12.793 1.49445 12.793 1.76788 12.5469L7.07257 7.21484Z"
fill="currentColor"
/>
</svg>
);
};

export default Chevron;
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Import vendor dependencies
import PropTypes from 'prop-types';
import {__} from '@wordpress/i18n';

// Import store dependencies
import {useStoreValue} from '../../app/store';
import {goToStep} from '../../app/store/actions';

// Import utilities
// Import components
import Button from '../button';
import Chevron from '../icons/chevron';

// Import styles
import './style.scss';

const PreviousButton = ({label, testId, clickCallback}) => {
const [{currentStep}, dispatch] = useStoreValue();

if (currentStep === 0) {
return;
}

return (
<Button
className="give-obw-button--reverse give-obw-button--secondary"
testId={testId}
onClick={() => {
clickCallback();
dispatch(goToStep(currentStep - 1));
}}
>
{label}
<span className="give-obw-previous-button__icon">
<Chevron />
</span>
</Button>
);
};

PreviousButton.propTypes = {
label: PropTypes.string,
testId: PropTypes.string,
clickCallback: PropTypes.func,
};

PreviousButton.defaultProps = {
label: __('Previous', 'give'),
testId: null,
clickCallback: () => {},
};

export default PreviousButton;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.give-obw-button {
cursor: pointer;
transition: 200ms all ease;
}
.give-obw-previous-button__icon {
margin: 0 14px 0 0;
rotate: 180deg;
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@
font-weight: 400;
}
}

.givewp-select__control {
width: 100%;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,11 @@
line-height: 22px;

background: #e5e5e5;

&-footer {
display: flex;
flex-direction: row-reverse;
justify-content: space-between;
width: 100%;
}
}

0 comments on commit f1d92ed

Please sign in to comment.