Skip to content

Commit

Permalink
Setup social icons
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Fusco <[email protected]>
  • Loading branch information
josephfusco committed Oct 19, 2023
1 parent e5a7819 commit 94ad529
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 11 deletions.
39 changes: 39 additions & 0 deletions components/FooterNavigation.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { gql } from '@apollo/client'
import clsx from 'clsx'
import Link from 'next/link'
import * as React from 'react'
import styles from '@/styles/footer-navigation.module.css';

export function FooterNavigation({ navigation }) {
return (
<>
{navigation.map((item) => (
<Link
className={clsx(
styles.socialIconLink,
'gap-4',
)}
href={item.href}
key={item.id}
target={item.target}>
{item.label}
</Link>
))}
</>
)
}

FooterNavigation.fragment = gql`
fragment FooterNavigationFragment on RootQuery {
footerMenuItems: menuItems(first: 100, where: { location: FOOTER }) {
nodes {
id
label
title: label
href: uri
parentId
target
}
}
}
`
14 changes: 14 additions & 0 deletions components/Layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ import { useCallback, useEffect, useState } from 'react'

import { DocsSidebarNavigation } from '@/components/DocsSidebarNavigation'
import { PrimaryNavigation } from '@/components/PrimaryNavigation'
import { FooterNavigation } from '@/components/FooterNavigation'
import { Prose } from '@/components/Prose'
import { SiteHeader } from '@/components/SiteHeader'
import { SiteFooter } from '@/components/SiteFooter'
import { collectHeadings } from '@/lib/utils'

Layout.fragment = gql`
fragment LayoutFragment on RootQuery {
...PrimaryNavigationFragment
...DocsSidebarNavigationFragment
...FooterNavigationFragment
}
${PrimaryNavigation.fragment}
${DocsSidebarNavigation.fragment}
${FooterNavigation.fragment}
`

function useTableOfContents(tableOfContents) {
Expand Down Expand Up @@ -79,6 +83,14 @@ export function Layout({ data, children, toc, title }) {
parentKey: 'parentId',
})
: []
const footerMenuItems = data?.footerMenuItems ?? []
const footerNavigation = footerMenuItems?.nodes
? flatListToHierarchical(footerMenuItems.nodes, {
idKey: 'id',
childrenKey: 'links',
parentKey: 'parentId',
})
: []
const docsSidebarMenuItems = data?.docsSidebarMenuItems ?? []
const docsSidebarNavigation = docsSidebarMenuItems?.nodes
? flatListToHierarchical(docsSidebarMenuItems.nodes, {
Expand Down Expand Up @@ -231,6 +243,8 @@ export function Layout({ data, children, toc, title }) {
</nav>
</div>
</div>

<SiteFooter navigation={footerNavigation} />
</>
)
}
14 changes: 13 additions & 1 deletion components/LayoutArchive.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@ import { gql } from '@apollo/client'
import { flatListToHierarchical } from '@faustwp/core'

import { PrimaryNavigation } from './PrimaryNavigation'
import { FooterNavigation } from './FooterNavigation'

import { DocsSidebarNavigation } from '@/components/DocsSidebarNavigation'
import { Prose } from '@/components/Prose'
import { SiteHeader } from '@/components/SiteHeader'

import { SiteFooter } from '@/components/SiteFooter'

LayoutArchive.fragment = gql`
fragment LayoutArchiveFragment on RootQuery {
...PrimaryNavigationFragment
...DocsSidebarNavigationFragment
...FooterNavigationFragment
}
${PrimaryNavigation.fragment}
${DocsSidebarNavigation.fragment}
${FooterNavigation.fragment}
`

export function LayoutArchive({ data, children, title }) {
Expand All @@ -26,6 +29,14 @@ export function LayoutArchive({ data, children, title }) {
parentKey: 'parentId',
})
: []
const footerMenuItems = data?.footerMenuItems ?? []
const footerNavigation = footerMenuItems?.nodes
? flatListToHierarchical(footerMenuItems.nodes, {
idKey: 'id',
childrenKey: 'links',
parentKey: 'parentId',
})
: []
const docsSidebarMenuItems = data?.docsSidebarMenuItems ?? []
const docsSidebarNavigation = docsSidebarMenuItems?.nodes
? flatListToHierarchical(docsSidebarMenuItems.nodes, {
Expand Down Expand Up @@ -75,6 +86,7 @@ export function LayoutArchive({ data, children, title }) {
</article>
</div>
</div>
<SiteFooter navigation={footerNavigation} />
</>
)
}
16 changes: 15 additions & 1 deletion components/LayoutFrontPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ import { gql } from '@apollo/client'
import { flatListToHierarchical } from '@faustwp/core'

import { PrimaryNavigation } from '@/components/PrimaryNavigation'
import { FooterNavigation } from './FooterNavigation'

import { SiteHeader } from '@/components/SiteHeader'
import { SiteFooter } from './SiteFooter'

LayoutFrontPage.fragment = gql`
fragment LayoutFrontPageFragment on RootQuery {
...PrimaryNavigationFragment
...FooterNavigationFragment
}
${PrimaryNavigation.fragment}
${FooterNavigation.fragment}
`

export function LayoutFrontPage({ data, children }) {
Expand All @@ -20,10 +25,19 @@ export function LayoutFrontPage({ data, children }) {
parentKey: 'parentId',
})
: []
const footerMenuItems = data?.footerMenuItems ?? []
const footerNavigation = footerMenuItems?.nodes
? flatListToHierarchical(footerMenuItems.nodes, {
idKey: 'id',
childrenKey: 'links',
parentKey: 'parentId',
})
: []
return (
<>
<SiteHeader navigation={primaryNavigation} data={data} />
<>{children}</>
{children}
<SiteFooter navigation={footerNavigation} />
</>
)
}
22 changes: 13 additions & 9 deletions components/SiteFooter.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import clsx from 'clsx'
import { Container } from '@/components/Container'
import { FooterNavigation } from '@/components/FooterNavigation'

export function SiteFooter({ navigation }) {
// eslint-disable-next-line no-console
console.log({ navigation })
return (
<footer
className={clsx(
'flex flex-wrap items-center justify-between bg-white px-4 py-5 shadow-md shadow-slate-900/5 transition duration-500 dark:shadow-none sm:px-6 lg:px-8',
)}
>
<p>Footer</p>
<footer className="py-6 md:px-8 md:py-0">
<Container>
<div className="flex flex-col items-center justify-between gap-4 md:h-24 md:flex-row">
<p className="text-center text-sm leading-loose text-muted-foreground md:text-left">
&copy; 2023 WPGraphQL. All rights reserved. | Development sponsored by <a href="https://www.wpengine.com/atlas" target="_blank" rel="noreferrer" className="font-medium underline underline-offset-4">WP Engine</a>
</p>
<div className="text-muted-foreground flex flex-row gap-4">
<FooterNavigation navigation={navigation} />
</div>
</div>
</Container>
</footer>
)
}
1 change: 1 addition & 0 deletions public/social-icons/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/social-icons/slack.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/social-icons/twitter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/social-icons/wordpress.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/social-icons/youtube.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions styles/footer-navigation.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
.socialIconLink {
color: transparent;
display: inline-flex;
margin-left: 0.8rem;
overflow: hidden;
position: relative;
text-align: center;
text-decoration: none;
width: 24px;
height: 24px;
line-height: 24px;
}

.socialIconLink::after {
background-color: hsl(var(--muted-foreground));
content: "";
height: 100%;
left: 0;
opacity: 0.8;
position: absolute;
top: 0;
width: 24px;
height: 24px;
}

.socialIconLink:hover::after,
.socialIconLink:focus::after {
opacity: 1;
}

.socialIconLink[href*="github.com"]::after {
mask: url("/social-icons/github.svg");
}

.socialIconLink[href*="slack.com"]::after {
mask: url("/social-icons/slack.svg");
}

.socialIconLink[href*="twitter.com"]::after,
.socialIconLink[href*="x.com"]::after {
mask: url("/social-icons/twitter.svg");
}

.socialIconLink[href*="wordpress.org"]::after {
mask: url("/social-icons/wordpress.svg");
}

.socialIconLink[href*="youtube.com"]::after {
mask: url("/social-icons/youtube.svg");
}

0 comments on commit 94ad529

Please sign in to comment.