Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit 470c5c0

Browse files
committed
Merge branch 'staging' into feature/149-card
2 parents 1dfa856 + 54a5c7a commit 470c5c0

File tree

20 files changed

+247
-224
lines changed

20 files changed

+247
-224
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import Link from 'next/link'
2+
import PropTypes from 'prop-types'
3+
import styles from './Breadcrumbs.module.css'
4+
5+
/**
6+
* Render the Breadcrumbs component.
7+
*
8+
* @author WebDevStudios
9+
* @param {object} props The component attributes as props.
10+
* @param {Array} props.breadcrumbs The breadcrumb array.
11+
* @return {Element} The Breadcrumbs component.
12+
*/
13+
export default function Breadcrumbs({breadcrumbs}) {
14+
return (
15+
<>
16+
{!!breadcrumbs?.length && (
17+
<ul className={styles.breadcrumbs}>
18+
{breadcrumbs.map((breadcrumb, index) => (
19+
<li key={index}>
20+
<Link href={breadcrumb?.url}>
21+
<a>{breadcrumb?.text}</a>
22+
</Link>
23+
{index < breadcrumbs.length - 1 && (
24+
<span className={styles.sep}> &raquo; </span>
25+
)}
26+
</li>
27+
))}
28+
</ul>
29+
)}
30+
</>
31+
)
32+
}
33+
34+
Breadcrumbs.propTypes = {
35+
breadcrumbs: PropTypes.array.isRequired
36+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
ul.breadcrumbs {
2+
@apply mb-8 flex;
3+
4+
& li {
5+
@apply text-sm font-semibold;
6+
7+
& .sep {
8+
@apply px-2 opacity-50 font-normal;
9+
}
10+
}
11+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import {Meta, Story, Canvas} from '@storybook/addon-docs/blocks'
2+
3+
import Breadcrumbs from '.'
4+
5+
export const crumbs = [
6+
{
7+
text: 'Home',
8+
url: '/'
9+
},
10+
{
11+
text: 'About',
12+
url: '/about'
13+
},
14+
{
15+
text: 'Our Team',
16+
url: '/about/team'
17+
}
18+
]
19+
20+
<Meta title="Components/Atoms/Breadcrumbs" component={Breadcrumbs} />
21+
22+
# Breadcrumbs
23+
24+
Use this component to display site breadcrumbs.
25+
26+
<Canvas>
27+
<Story name="Component">
28+
<Breadcrumbs breadcrumbs={crumbs} />
29+
</Story>
30+
</Canvas>

components/atoms/Breadcrumbs/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {default} from './Breadcrumbs'
Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,38 @@
11
import PropTypes from 'prop-types'
22
import React from 'react'
33
import styles from './Container.module.css'
4+
import cn from 'classnames'
45

56
/**
67
* Render the Container component.
78
*
8-
* @param {object} props Container component props.
9-
* @param {Element} props.children Container children.
10-
* @return {Element} The Container component.
9+
* @param {object} props Container component props.
10+
* @param {object} props.children Container children.
11+
* @param {boolean} props.paddingTop Should container render top padding.
12+
* @param {boolean} props.paddingBtm Should container render bottom padding.
13+
* @return {Element} The Container component.
1114
*/
12-
export default function Container({children}) {
13-
return <div className={styles.containerW}>{children && children}</div>
15+
export default function Container({children, paddingTop, paddingBtm}) {
16+
return (
17+
<div
18+
className={cn(
19+
styles.containerW,
20+
paddingTop && styles.paddingTop,
21+
paddingBtm && styles.paddingBtm
22+
)}
23+
>
24+
{children && children}
25+
</div>
26+
)
1427
}
1528

1629
Container.propTypes = {
17-
children: PropTypes.element
30+
children: PropTypes.node,
31+
paddingTop: PropTypes.bool,
32+
paddingBtm: PropTypes.bool
33+
}
34+
35+
Container.defaultProps = {
36+
paddingTop: true,
37+
paddingBtm: true
1838
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
.containerW {
22
@apply container;
3+
4+
&.paddingTop {
5+
@apply pt-12;
6+
}
7+
8+
&.paddingBtm {
9+
@apply pb-12;
10+
}
311
}

components/atoms/Separator/Separator.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import cn from 'classnames'
22
import PropTypes from 'prop-types'
33
import React from 'react'
4-
import Container from '../Container'
54
import styles from './Separator.module.css'
65

76
/**
@@ -19,9 +18,7 @@ export default function Separator({className, fullWidth}) {
1918
{fullWidth ? (
2019
<hr className={cn(styles.separator, className)} />
2120
) : (
22-
<Container>
23-
<hr className={cn(styles.separator, className)} />
24-
</Container>
21+
<hr className={cn(styles.separator, className)} />
2522
)}
2623
</>
2724
)

components/common/Layout.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ export default function Layout({children, seo, hasJsonLd}) {
2828
}
2929
]
3030

31-
// Extract breadcrumbs from SEO.
32-
const breadcrumbs = seo?.breadcrumbs
33-
3431
return (
3532
<>
3633
<NextSeo
@@ -58,21 +55,7 @@ export default function Layout({children, seo, hasJsonLd}) {
5855
)}
5956
<Meta />
6057
<Header />
61-
<main>
62-
{/* TODO: extract breadcrumbs to component and make pretty. */}
63-
{!!breadcrumbs && !!breadcrumbs.length && (
64-
<div>
65-
{breadcrumbs.map((breadcrumb, index) => (
66-
<span key={index}>
67-
<a href={breadcrumb?.url}>{breadcrumb?.text}</a>
68-
{index < breadcrumbs.length - 1 && <span> &raquo; </span>}
69-
</span>
70-
))}
71-
</div>
72-
)}
73-
74-
{children}
75-
</main>
58+
<main>{children}</main>
7659
<Footer social={seo?.social} siteTitle={seo?.siteTitle} />
7760
</>
7861
)

components/molecules/AlgoliaResults/AlgoliaResults.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {searchResultsClient} from '@/api/algolia/connector'
22
import {AlgoliaContext} from '@/components/common/AlgoliaProvider'
3-
import cn from 'classnames'
43
import PropTypes from 'prop-types'
54
import React, {useContext} from 'react'
65
import {Configure, InstantSearch} from 'react-instantsearch-dom'
@@ -21,7 +20,7 @@ import SearchResults from './templates/SearchResults'
2120
export default function AlgoliaResults({config}) {
2221
const {indexName} = useContext(AlgoliaContext)
2322
return (
24-
<section className={cn('container', styles.algoliaResults)}>
23+
<div className={styles.algoliaResults}>
2524
{config.query !== '' && (
2625
<InstantSearch
2726
searchClient={config.query !== '' ? searchResultsClient : ''}
@@ -32,7 +31,7 @@ export default function AlgoliaResults({config}) {
3231
</InstantSearch>
3332
)}
3433
{config.query === '' && <NoResults query={config.query} />}
35-
</section>
34+
</div>
3635
)
3736
}
3837

components/molecules/AlgoliaResults/AlgoliaResults.module.css

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
.algoliaResults {
2-
@apply pt-20 pb-40;
3-
4-
& h1 {
5-
@apply mb-8;
6-
7-
font-size: 30px;
8-
}
9-
102
/* Results Header */
113
& .resultsHeader {
12-
@apply flex justify-between items-center;
13-
@apply mb-32;
4+
@apply flex justify-between items-center mb-12;
145

156
& .total {
167
& span {
@@ -44,24 +35,20 @@
4435
@apply text-center;
4536

4637
& > ul {
47-
@apply grid gap-12 grid-cols-1 text-left;
38+
@apply grid gap-4 grid-cols-1 text-left;
4839
}
4940

5041
/* Hit */
5142
& .hit {
52-
@apply p-20 border;
53-
54-
& h3 {
55-
@apply font-semibold;
56-
}
43+
@apply p-8 border;
5744

5845
& .date {
59-
@apply italic mb-8;
46+
@apply italic mb-4;
6047
}
6148
}
6249

6350
& > button {
64-
@apply inline-block m-auto mt-44 border rounded px-24 py-8 transition-colors duration-200 ease-in-out;
51+
@apply inline-block m-auto mt-8 border rounded p-4 transition-colors duration-200 ease-in-out;
6552

6653
&[disabled] {
6754
@apply opacity-25 cursor-not-allowed;

0 commit comments

Comments
 (0)