feat(static-pages) : hide/show tack(dash) on footer

pull/73/head
Clement G 4 years ago
parent ad33191a4d
commit d835448206

@ -1,25 +1,33 @@
/* eslint react/prop-types: 0 */
import React, { Component } from "react";
import React from "react";
import { withTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import Paypal from "../banner/Paypal";
import {useBbox} from "./useBbox";
import "./footer.css";
class Footer extends Component {
constructor(props) {
super(props);
this.state = {};
}
render() {
const Footer = props => {
const linkStyle = { whiteSpace: "nowrap" };
const { t } = this.props;
const { t } = props;
const [bboxLink1, link1] = useBbox();
const [bboxLink2, link2] = useBbox();
const [bboxLink3, link3] = useBbox();
const [bboxLink4, link4] = useBbox();
const [bboxLink5, link5] = useBbox();
const [bboxLink6, link6] = useBbox();
return (
<footer className="text-center">
<div>
<Link to="/" style={linkStyle}>
<ul className="tacky">
<li ref={link1} className={(bboxLink1.top===bboxLink2.top)?"":"no-tack"}>
<Link to="/" style={linkStyle} >
{t("Homepage")}
</Link>
<span className="m-2">-</span>
</li>
<li ref={link2} className={(bboxLink2.top===bboxLink3.top)?"":"no-tack"}>
{" "}
<a
href="https://github.com/MieuxVoter"
target="_blank"
@ -28,7 +36,8 @@ class Footer extends Component {
>
{t("Source code")}
</a>
<span className="m-2">-</span>
</li>
<li ref={link3} className={(bboxLink3.top===bboxLink4.top)?"":"no-tack"}>
<a
href="https://mieuxvoter.fr/"
target="_blank"
@ -37,24 +46,28 @@ class Footer extends Component {
>
{t("Who are we?")}
</a>
</div>
<span className="m-2">-</span>
<Link to="/legal-notices" style={linkStyle}>
{t('Legal notices')}
</Link>
<span className="m-2">-</span>
</li>
<li ref={link4} className={(bboxLink4.top===bboxLink5.top)?"":"no-tack"}>
<Link to="/privacy-policy" style={linkStyle}>
{t('Privacy policy')}
{t("Privacy policy")}
</Link>
</li>
<li ref={link5} className={(bboxLink5.top===bboxLink6.top)?"":"no-tack"}>
<Link to="/legal-notices" style={linkStyle}>
{t("Legal notices")}
</Link>
<span className="m-2">-</span>
</li>
<li ref={link6}>
<Link to="/faq" style={linkStyle}>
{t('faq')}
{t("FAQ")}
</Link>
</li>
</ul>
</div>
<div className="mt-3">
<Paypal btnColor="btn-primary" />
</div>
</footer>
);
}
}
};
export default withTranslation()(Footer);

@ -0,0 +1,25 @@
.tacky {
margin: 0;
padding: 0;
list-style-type: none;
}
.tacky li {
display: inline-block;
}
.tacky li:after {
content: "-";
margin: 0 5px;
}
.tacky li:last-of-type:after {
content: "";
margin: 0;
}
.tacky li.no-tack:after {
content: "";
margin: 0;
display: none;
}

@ -0,0 +1,20 @@
/* eslint react/prop-types: 0 */
import { useState } from 'react';
import { useRef } from 'react';
import { useEffect } from 'react';
export const useBbox = () => {
const ref = useRef();
const [bbox, setBbox] = useState({});
const set = () =>
setBbox(ref && ref.current ? ref.current.getBoundingClientRect() : {});
useEffect(() => {
set();
window.addEventListener('resize', set);
return () => window.removeEventListener('resize', set);
}, []);
return [bbox, ref];
};
Loading…
Cancel
Save