fix banner button

This commit is contained in:
gbrochar 2020-12-01 19:03:51 +01:00
parent ac3957fa13
commit a997db2b42
4 changed files with 57 additions and 23 deletions

View File

@ -2,7 +2,7 @@ import React from 'react';
import Link from './Link'; import Link from './Link';
interface Link { interface Link {
to: string; status: string;
text: string; text: string;
} }
@ -10,14 +10,15 @@ interface BannerProps {
title: string; title: string;
description: string; description: string;
links: Array<Link>; links: Array<Link>;
image: string; image: string;
setStatus: any;
} }
/** /**
* @return {jsx} The root component * @return {jsx} The root component
*/ */
export default function Banner( export default function Banner(
{title, description, links, image}: BannerProps) { {setStatus, title, description, links, image}: BannerProps) {
let imgUrl; let imgUrl;
if (image.startsWith('/static/images/')) { if (image.startsWith('/static/images/')) {
imgUrl = image; imgUrl = image;
@ -61,11 +62,11 @@ export default function Banner(
<br /> <br />
{links.map((elem, index) => {links.map((elem, index) =>
<p key={index} className='lead mt-2'> <p key={index} className='lead mt-2'>
<Link <button
className='btn btn-info btn-lg className='btn btn-info btn-lg
font-weight-bold' font-weight-bold'
to={elem.to} onClick={() => setStatus(elem.status)}>
text={elem.text} /> {elem.text}</button>
</p>)} </p>)}
</div> </div>
</div> </div>

View File

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import Banner from './Banner'; import Footer from './Footer';
/** /**
* @return {jsx} The homepage component * @return {jsx} The homepage component
@ -7,20 +7,48 @@ import Banner from './Banner';
export default function Blog() { export default function Blog() {
return ( return (
<React.Fragment> <React.Fragment>
<Banner <Footer
title={`Un voyage à travers l'Europe`} elements={[
description={`
On vous raconte nos aventures à travers l'Europe.\n
Nous voyageons en stop et sans argent.\n
On loge chez l'habitant ou dehors dans des hamacs.`}
links={[
{ {
to: '/blog', title: 'À propos',
text: 'Notre carnet de voyage', description: `Nous sommes deux jeunes de 23 ans à la
recherche d'aventures et de réponses à travers
l'Europe`,
links: [
{
to: '/about',
text: 'Plus de détails',
},
],
}, {
title: 'Nous contacter',
description:
<ul>
<li>curious.roamers@gmail.com</li>
<li>06 37 11 28 22</li>
</ul>,
links: [
{
to: '/contact',
text: `Autres façons de nous contacter`,
},
],
}, {
title: 'Donation',
description: `Si vous voulez contribuer à financer nos
futurs voyages ou simplement nous aider financièrement
:)`,
links: [
{
to: 'https://paypal.me/ygarrot',
text: 'Paypal',
}, {
to: 'https://tipeee.com/curious-roamers',
text: 'Tipeee',
},
],
}, },
]} ]}/>
image={'map.jpeg'}
/>
</React.Fragment> </React.Fragment>
); );
} }

View File

@ -4,13 +4,18 @@ import Quote from './Quote';
import Footer from './Footer'; import Footer from './Footer';
import ImagesWithDescription from './ImagesWithDescription'; import ImagesWithDescription from './ImagesWithDescription';
interface HomeProps {
setStatus: any;
}
/** /**
* @return {jsx} The homepage component * @return {jsx} The homepage component
*/ */
export default function Home() { export default function Home({setStatus}: HomeProps) {
return ( return (
<React.Fragment> <React.Fragment>
<Banner <Banner
setStatus={setStatus}
title={`Un voyage à travers l'Europe`} title={`Un voyage à travers l'Europe`}
description={` description={`
On vous raconte nos aventures à travers l'Europe.\n On vous raconte nos aventures à travers l'Europe.\n
@ -18,7 +23,7 @@ export default function Home() {
On loge chez l'habitant ou dehors dans des hamacs.`} On loge chez l'habitant ou dehors dans des hamacs.`}
links={[ links={[
{ {
to: '/blog', status: 'Blog',
text: 'Notre carnet de voyage', text: 'Notre carnet de voyage',
}, },
]} ]}

View File

@ -9,12 +9,12 @@ import Contact from './Contact';
* @return {jsx} The root component * @return {jsx} The root component
*/ */
export default function Root() { export default function Root() {
const [page, setPage] = useState(<Home />);
const [navbarStatus, setNavbarStatus] = useState('Home'); const [navbarStatus, setNavbarStatus] = useState('Home');
const [page, setPage] = useState(<Home setStatus={setNavbarStatus} />);
useEffect(() => { useEffect(() => {
if (navbarStatus == 'Home') { if (navbarStatus == 'Home') {
setPage(<Home />); setPage(<Home setStatus={setNavbarStatus} />);
} else if (navbarStatus == 'Blog') { } else if (navbarStatus == 'Blog') {
setPage(<Blog />); setPage(<Blog />);
} else if (navbarStatus == 'About') { } else if (navbarStatus == 'About') {