From a5536b07908a4016092a7cbaab467c70d97bd91b Mon Sep 17 00:00:00 2001 From: Valeriy Date: Fri, 30 Aug 2019 20:19:26 +0300 Subject: [PATCH] fix(client): refactor footer and fix internal links (#36726) --- client/src/components/Footer/FooterCol.js | 37 +-- .../Footer/__snapshots__/Footer.test.js.snap | 10 +- client/src/components/Footer/footer.css | 33 +-- client/src/components/Footer/footerLinks.json | 248 ++++++++++-------- client/src/components/Footer/index.js | 14 +- 5 files changed, 169 insertions(+), 173 deletions(-) diff --git a/client/src/components/Footer/FooterCol.js b/client/src/components/Footer/FooterCol.js index d8bc329ea2..aebccef50c 100644 --- a/client/src/components/Footer/FooterCol.js +++ b/client/src/components/Footer/FooterCol.js @@ -2,37 +2,28 @@ import React from 'react'; import PropTypes from 'prop-types'; import Link from '../helpers/Link'; -import { footerLinks } from './footerLinks'; -import './footer.css'; - -function FooterCol({ colNum, title }) { - // if the column number is not applicable return an empty div - if (colNum < 1 || colNum > footerLinks + 1) return
; - - let linksRow = footerLinks[colNum - 1].map(function(item, i) { - if (item.interal) - return ( - - {item.text} - - ); - return ( - - {item.text} - - ); - }); +function FooterCol({ title, links }) { return ( -
+
{title}
- {linksRow} + {links.map(({ to, text, internal }, i) => ( + + {text} + + ))}
); } const propTypes = { - colNum: PropTypes.number, + links: PropTypes.arrayOf( + PropTypes.shape({ + to: PropTypes.string.isRequired, + text: PropTypes.string, + internal: PropTypes.bool + }) + ).isRequired, title: PropTypes.string }; diff --git a/client/src/components/Footer/__snapshots__/Footer.test.js.snap b/client/src/components/Footer/__snapshots__/Footer.test.js.snap index 5ad6567488..e3ad6c2354 100644 --- a/client/src/components/Footer/__snapshots__/Footer.test.js.snap +++ b/client/src/components/Footer/__snapshots__/Footer.test.js.snap @@ -31,7 +31,7 @@ exports[`
renders to the DOM 1`] = `

renders to the DOM 1`] = ` Donate @@ -124,7 +122,7 @@ exports[`
renders to the DOM 1`] = `
renders to the DOM 1`] = `
renders to the DOM 1`] = `
- - - - + {footerLinks.map(({ title, links }, index) => ( + + ))}