Skip to content

Commit

Permalink
[TITAN-293] feat: ✨ Added Promo section component to the Front Page (#14
Browse files Browse the repository at this point in the history
)

* feat: ✨ Added Promo section component to the Front Page

* feat: ✨ Added CTA to the PromoSection component

Also removed unused React import and refactored the CSS

* refactor: 💄 Refactored button styling to the global scope

* refactor: ♻️ Using showCta flag instead of two props to display CTA component

Also made some updates regarding styling

* style: ♻️ Using the section style from the global scss

* refactor: ♻️ Extracted CtaButton component into its own module

* refactor: ♻️ Moved showCta into the props of CtaButton

* refactor: ♻️ Lifted CtaButton state to PromoSection

* feat: ✨ Added Promo section component to the Front Page

* feat: ✨ Added CTA to the PromoSection component

Also removed unused React import and refactored the CSS

* refactor: 💄 Refactored button styling to the global scope

* refactor: ♻️ Using showCta flag instead of two props to display CTA component

Also made some updates regarding styling

* style: ♻️ Using the section style from the global scss

* refactor: ♻️ Extracted CtaButton component into its own module

* refactor: ♻️ Moved showCta into the props of CtaButton

* refactor: ♻️ Lifted CtaButton state to PromoSection
  • Loading branch information
alvarocavalcanti committed Apr 11, 2023
1 parent b976438 commit 16d406b
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 33 deletions.
13 changes: 13 additions & 0 deletions components/CtaButton/CtaButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Link from 'next/link';

const CtaButton = ({ctaLink = null, ctaLabel = null }) => {
return (
<div className='buttonContainer'>
<Link href={ctaLink}>
<a className='button'>{ctaLabel}</a>
</Link>
</div>
);
};

export default CtaButton;
1 change: 1 addition & 0 deletions components/CtaButton/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as CtaButton } from './CtaButton.js';
4 changes: 2 additions & 2 deletions components/ProductCard/ProductCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ const ProductCard = ({ product }) => {
)}
</span>
</div>
<div className={styles.buttonContainer}>
<div className='buttonContainer'>
<Link href={productHref}>
<a className={styles.button}>View product</a>
<a className='button'>View product</a>
</Link>
</div>
</div>
Expand Down
16 changes: 0 additions & 16 deletions components/ProductCard/ProductCard.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,5 @@
font-weight: 700;
margin-bottom: 1rem;
}

.buttonContainer {
.button {
margin: 0px 0.5rem;
background-color: var(--wpe--color--green);
text-decoration: none;
font-weight: 500;
padding: 1rem;
display: inline-block;
color: var(--wpe--color--white);
transition: all 0.5s;
&:hover {
background-color: var(--wpe--color--green);
}
}
}
}
}
9 changes: 3 additions & 6 deletions components/ProductSection/ProductSection.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import classNames from 'classnames';
import styles from './ProductSection.module.scss';
import { ProductCard } from '../ProductCard';
import { Container } from '../Container';

const cx = classNames.bind(styles);

const ProductSection = ({ products, heading }) => {
return (
<div className={cx(['section', styles.component])}>
<div className={`section ${styles.component}`}>
<Container>
<h1>{heading}</h1>
<div className={cx(styles.section)}>
<h2>{heading}</h2>
<div className='section'>
{products?.map?.((product) => {
return <ProductCard key={product.id} product={product} />;
})}
Expand Down
23 changes: 23 additions & 0 deletions components/PromoSection/PromoSection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Container } from '../Container';
import { CtaButton } from '../CtaButton';
import styles from './PromoSection.module.scss';

const PromoSection = ({
showCta = false,
ctaLink = null,
ctaLabel = null,
title = null,
description = null
}) => {
return (
<div className={`section ${styles.component}`}>
<Container>
<h1 className={styles.title}>{title}</h1>
<div className={styles.description}>{description}</div>
{ showCta && <CtaButton ctaLink={ctaLink} ctaLabel={ctaLabel} /> }
</Container>
</div>
);
};

export default PromoSection;
22 changes: 22 additions & 0 deletions components/PromoSection/PromoSection.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.component {
@import 'styles/css-variables';

background-color: var(--wpe--color--grey);

h2 {
padding: 2em;
}

.title {
text-align: center;
font-size: 50px;
padding: 1em 0 0 0;
}

.description {
padding: 1rem 0;
text-align: center;
margin-top: auto;
width: 100%;
}
}
1 change: 1 addition & 0 deletions components/PromoSection/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as PromoSection } from './PromoSection.js';
8 changes: 3 additions & 5 deletions components/TestimonialsSection/TestimonialsSection.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import TestimonialCard from './TestimonialCard';
import { Container } from '../Container';
import classNames from 'classnames';
import styles from './TestimonialsSection.module.scss';

const cx = classNames.bind(styles);

const TestimonialsSection = () => {
return (
<div className={cx(['section', styles.component])}>
<div className={`section ${styles.component}`}>
<Container>
<h1>Customer Testimonials</h1>
<div className={cx(styles.section)}>
<h2>Customer Testimonials</h2>
<div className='section'>
<TestimonialCard
image='https://demo.studiopress.com/page-builder/spend/eso_spend_customer_testimonial_1.jpg'
blurb='I can sync all my BigCommerce products into WordPress and catch all updates automatically. Now I can create content in WordPress with BigCommerce products!'
Expand Down
1 change: 1 addition & 0 deletions components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export { SearchInput } from './SearchInput';
export { SearchRecommendations } from './SearchRecommendations';
export { SearchResults } from './SearchResults';
export { SearchSection } from './SearchSection';
export { PromoSection } from './PromoSection';
export { SkipNavigationLink } from './SkipNavigationLink';
export { TestimonialsSection } from './TestimonialsSection';
export { Hero } from './Hero';
Expand Down
46 changes: 45 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@
margin: 0 auto;
text-align: center;
padding-bottom: 4em;
display: flex;
}

.buttonContainer {
.button {
margin: 0px 0.5rem;
background-color: var(--wpe--color--green);
text-decoration: none;
font-weight: 500;
padding: 1rem;
display: inline-block;
color: var(--wpe--color--white);
transition: all 0.5s;
&:hover {
background-color: var(--wpe--color--green);
}
}
}

.shop-grid {
Expand Down
10 changes: 7 additions & 3 deletions wp-templates/front-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
SEO,
ContentWrapper,
ProductSection,
PromoSection,
TestimonialsSection,
} from '../components';
import productsStub from '../data/stubs/products';
Expand Down Expand Up @@ -40,9 +41,12 @@ export default function Component(props) {
<ProductSection heading='Latest Products' products={latestProducts} />
<TestimonialsSection />
<ProductSection heading='On Sale' products={saleProducts} />
{/*
<div>promo banner</div>
*/}
<PromoSection
showCta
ctaLink='/about'
ctaLabel='About'
title='Promo Banners'
description='You can use this component to promote articles or specific products. And optionally add a CTA below.' />
</Main>
<Footer title={siteTitle} menuItems={footerMenu} />
</>
Expand Down

0 comments on commit 16d406b

Please sign in to comment.