Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 56 additions & 13 deletions packages/gatsby-theme/src/components/LayoutFooter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,30 @@ import { ReactComponent as TwitterSVG } from '../SocialIcon/twitter.svg'

import * as styles from './styles.module.css'

declare global {
interface Window {
__ucCmp?: {
showSecondLayer?: () => void
}
}
}

interface IFooterLinkData {
href: string
text: string
icon?: JSX.Element
target?: '_blank'
}

interface IFooterButtonData {
text: string
icon?: JSX.Element
onClick: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void
}

interface IFooterListData {
header: string
links: Array<IFooterLinkData>
links: Array<IFooterLinkData | IFooterButtonData>
}

const footerListsData: Array<IFooterListData> = [
Expand Down Expand Up @@ -81,7 +95,22 @@ const footerListsData: Array<IFooterListData> = [
},
{
header: 'Legal',
links: [{ href: externalUrls.privacyPolicy, text: 'Privacy Policy' }]
links: [
{
href: externalUrls.privacyPolicy,
text: 'Privacy Policy'
},
{
text: 'Privacy Settings',
onClick: function () {
if (window.__ucCmp?.showSecondLayer) {
window.__ucCmp.showSecondLayer()
} else {
console.log('Privacy Settings not available')
}
}
}
]
}
]

Expand Down Expand Up @@ -114,17 +143,31 @@ const FooterLists: React.FC = () => (
<div className={styles.column} key={index}>
<h2 className={styles.heading}>{header}</h2>
<ul className={styles.links}>
{links.map(({ text, target, href, icon }, i) => (
<li
// className={styles.linkItem}
key={i}
>
<Link target={target} href={href} className={styles.link}>
{icon}
{text}
</Link>
</li>
))}
{links.map((link, i) => {
const isButton = 'onClick' in link && !('href' in link)
return (
<li
// className={styles.linkItem}
key={i}
>
{isButton ? (
<button className={styles.link} onClick={link.onClick}>
{link.icon}
{link.text}
</button>
) : (
<Link
target={link.target}
href={link.href}
className={styles.link}
>
{link.icon}
{link.text}
</Link>
)}
</li>
)
})}
</ul>
</div>
))}
Expand Down