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

Commit 4767c8d

Browse files
committed
Doc blocks and logo component
1 parent 31b676b commit 4767c8d

File tree

7 files changed

+39
-39
lines changed

7 files changed

+39
-39
lines changed

api/wordpress/_global/getMenus.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import {gql} from '@apollo/client'
22
import {initializeWpApollo} from '../connector'
33
import filterByLocation from '@/api/wordpress/menus/filterByLocation'
44

5+
// TODO: Rebakah to look at the way this query is set up in terms of file structure
6+
57
/**
68
* Get menu data from WPGraphQL.
79
*

api/wordpress/menus/filterByLocation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import formatHeirarchialMenu from '@/api/wordpress/menus/formatHeirarchialMenu'
66
* @author WebDevStudios
77
* @param {Array} menus The array of WP menus to filter.
88
* @param {Array} locations The array of locations for filtering.
9-
* @return {object} An object containing the requested locations as individual objects.
9+
* @return {object} An object containing the requested locations as individual objects.
1010
*/
1111
export default function filterByLocation(menus, locations) {
1212
const data = {}

components/atoms/Logo/Logo.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Link from 'next/link'
2+
3+
export default function Logo() {
4+
return (
5+
<Link href="/">
6+
<a>
7+
<img
8+
src="/logo.svg"
9+
alt="site logo"
10+
loading="lazy"
11+
height="128"
12+
width="128"
13+
/>
14+
</a>
15+
</Link>
16+
)
17+
}

components/atoms/Logo/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {default} from './Logo.js'

components/common/ActiveLink.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
import Link from 'next/link'
12
import {useRouter} from 'next/router'
23
import PropTypes from 'prop-types'
3-
import Link from 'next/link'
44
import React, {Children} from 'react'
55

6-
export default function ActiveLink({children, activeClassName, ...props}) {
6+
/**
7+
* Component to set an active link.
8+
*
9+
* @author WebDevStudios
10+
* @see https://nextjs.org/docs/api-reference/next/link
11+
* @param {object} children Child objects for rendering.
12+
* @param {object} activeClass The classname for the active element.
13+
* @param {object} props.href The href to be added as a link.
14+
*/
15+
export default function ActiveLink({children, activeClass, ...props}) {
716
const {asPath} = useRouter()
817
const child = Children.only(children)
918
const childClassName = child.props.className || ''
@@ -23,7 +32,7 @@ export default function ActiveLink({children, activeClassName, ...props}) {
2332

2433
const className =
2534
asPath === stripTrailingSlash(props.href) || asPath === props.as
26-
? `${childClassName} ${activeClassName}`.trim()
35+
? `${childClassName} ${activeClass}`.trim()
2736
: childClassName
2837

2938
return (
@@ -37,6 +46,6 @@ export default function ActiveLink({children, activeClassName, ...props}) {
3746

3847
ActiveLink.propTypes = {
3948
children: PropTypes.object,
40-
activeClassName: PropTypes.string,
49+
activeClass: PropTypes.string,
4150
props: PropTypes.object
4251
}

components/molecules/Navigation/Navigation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import ActiveLink from '@/components/common/ActiveLink'
2-
import styles from './Navigation.module.css'
32
import cn from 'classnames'
3+
import styles from './Navigation.module.css'
44

55
/**
66
* @param props

components/organisms/Header/Header.js

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,14 @@
1-
import Link from 'next/link'
2-
import {useContext, useState} from 'react'
1+
import Logo from '@/components/atoms/Logo'
2+
import {MenuContext} from '@/components/common/MenuProvider'
33
import AlgoliaSearch from '@/components/molecules/AlgoliaSearch'
44
import Navigation from '@/components/molecules/Navigation'
5-
import styles from './Header.module.css'
6-
import Hamburger from 'hamburger-react'
7-
import {MenuContext} from '@/components/common/MenuProvider'
85
import cn from 'classnames'
6+
import {useContext, useState} from 'react'
7+
import styles from './Header.module.css'
98

109
// TODO: Create Storybook for this component.
11-
// TODO: Split Logo into component.
1210
// TODO: Create mobile menu.
1311

14-
function Logo() {
15-
return (
16-
<Link href="/">
17-
<a>
18-
<img
19-
src="/logo.svg"
20-
alt="site logo"
21-
loading="lazy"
22-
height="128"
23-
width="128"
24-
/>
25-
</a>
26-
</Link>
27-
)
28-
}
29-
30-
function Drawer({menu}) {
31-
return (
32-
<div className="bg-white dark:bg-gray-900 absolute w-56 h-screen py-12 px-4 top-0 right-0 flex flex-col shadow-md z-50">
33-
<Navigation menu={menu} styles={styles} className={styles.header} />
34-
</div>
35-
)
36-
}
37-
3812
/**
3913
* Render the header as a component.
4014
*/
@@ -59,9 +33,6 @@ export default function Header() {
5933
styles={styles}
6034
className={cn(styles.primaryMenu, isOpen && styles.open)}
6135
/>
62-
<span className="hidden">
63-
<Hamburger label="Show menu" toggled={isOpen} toggle={setOpen} />
64-
</span>
6536
</div>
6637
</header>
6738
)

0 commit comments

Comments
 (0)