import new design from Jeremie's repo

pull/82/head
nicgirault 2 years ago
parent 4c2759d8c9
commit 341bf89b28

@ -0,0 +1,166 @@
import React from 'react';
import plotly from 'plotly.js/dist/plotly';
import createPlotComponent from 'react-plotly.js/factory';
import LoadingScreen from "./LoadingScreen";
function Bulles (props) {
// récupération des résultats de l'élection et stockage en tableau
const votesBrut = (Object.values(props))[0];
// déclaration et initialisation des mentions et couleurs
const mentionsBrut = ['Passable', 'Assez bien', 'Bien', 'Très bien', 'Excellent'];
const couleursBrut = ['#BB9C42', '#AABA44', '#DCDF44', '#B3D849', '#61AD45'];
//----------- Traitement des données -----------//
// fonction d'inversement des éléments de tableau
function inverse(obj){
var retobj = {};
for(var key in obj){
retobj[obj[key]] = key;
}
return retobj;
}
// fonction de réduction d'amplitude permettant de conserver une représentation ordinale du nombre de votes sans décalage visuel trop important
/*
Pattern de calcul :
Soient Ai, Bi, Ci, Di, Ei les nombres de votes initiaux fournis dans le tableau classé par ordre mélioratif de mention (de Passable à Excellent). Il vient :
A = 1
B = <{[1 + (Bi/Ai)] / 40} * A>
C = <{[1 + (Ci/Bi)] / 40} * B>
D = <{[1 + (Di/Ci)] / 40} * C>
E = <{[1 + (Ei/Di)] / 40} * D>
*/
function redAmpli(tab) {
var nvTab = [];
nvTab[0] = 100;
for(i = 1; i < tab.length; i++) {
nvTab[i] = ( (1 + ((tab[i]/tab[(i-1)]) / 40 ) ) * nvTab[(i-1)]);
}
return nvTab;
}
// déclaration de l'objet votes-mention et votes-couleur
var votesMentionNonOrdonnes = {};
var votesCouleurNonOrdonnes = {};
// initialisation votes-mention ordonnés croissants
for (var i = 0; i < mentionsBrut.length; i++) {
votesMentionNonOrdonnes[votesBrut[i]] = mentionsBrut[i];
votesCouleurNonOrdonnes[votesBrut[i]] = couleursBrut[i];
}
// déclaration des mentions-votes par ordre croissant
var votesMentionOrdonnes = inverse(votesMentionNonOrdonnes);
var votesCouleurOrdonnes = inverse(votesCouleurNonOrdonnes);
// vérification du nombre de votes classés par ordre croissant et passés initialement en propriétés au composant
console.log("Les données transmises au composant concernant le nombre de votes par mention sont : ");
console.log(votesBrut);
// vérification des mentions destinées à être associées aux votes et ordonnées initialement par ordre mélioratif
console.log("Les mentions des votes sont classées initialement par ordre mélioratif de la façon suivante :");
console.log(mentionsBrut);
// vérification du nombre de votes classés par ordre croissant
console.log("Les mentions-votes classées par ordre croissant de votes sont : ");
console.log(votesMentionOrdonnes);
// séparation des mentions et des votes
const mentions = Object.keys(votesMentionOrdonnes);
const votes = Object.values(votesMentionOrdonnes);
const couleurs = Object.keys(votesCouleurOrdonnes);
// vérification des mentions et des votes prêts à être traités pour la représentation graphique
console.log('La liste des mentions issue du classement par ordre croissant de votes est :');
console.log(mentions);
console.log('La liste du nombre de votes correspondant, classée par ordre croissant, est :');
console.log(votes);
// déclaration et initialisation des rayons de bulle pour la représentation graphique
var rayons = [];
rayons = redAmpli(votes)
// vérification des rayons
console.log('La liste des rayons à représenter graphiquement est la suivante :');
console.log(rayons);
// déclaration et initialisation des textes des bulles
const texteBulle1 = (mentions[0] + "<br>" + votes[0] + " votes").toString();
const texteBulle2 = (mentions[1] + "<br>" + votes[1] + " votes").toString();
const texteBulle3 = (mentions[2] + "<br>" + votes[2] + " votes").toString();
const texteBulle4 = (mentions[3] + "<br>" + votes[3] + " votes").toString();
const texteBulle5 = (mentions[4] + "<br>" + votes[4] + " votes").toString();
// déclaration et initialisation d'une instance de graphique en bulles
// const Plot = createPlotComponent(plotly);
const Plot = require('react-plotly.js').default;
//---------------------------------------------//
//----------- Affichage des données -----------//
const [loading, setLoading] = React.useState(true);
React.useEffect(() =>{
setTimeout(() => setLoading(false), 3000);
})
return (
// <div>
// {!loading ? (
// <React.Fragment>
<Plot
data={[
{
x: [0.7, 0.6, 0.5, 0.6, 0.7],
y: [0.3, 0.4, 0.5, 0.6, 0.5],
hovertemplate:
'<b>%{text}</b>' +
'<extra></extra>',
text: [texteBulle1, texteBulle2, texteBulle3, texteBulle4, texteBulle5],
showlegend: false,
mode: 'markers',
marker: {
color: [couleurs[0], couleurs[1], couleurs[2], couleurs[3], couleurs[4]],
size: rayons
}
}
]}
layout={ {
width: 600,
height: 600,
title: 'Nombre de voix par candidat',
xaxis: {
showgrid: false,
showticklabels: false,
showline: false,
zeroline: false,
range: [0, 1]
},
yaxis: {
showgrid: false,
showticklabels: false,
showline: false,
zeroline: false,
range: [0, 1]
}
} }
config={{
displayModeBar: false // this is the line that hides the bar.
}}
/>
// </React.Fragment>
// ) : (
// <LoadingScreen />
// )}
// </div>
)
}
export default Bulles;

@ -0,0 +1,41 @@
import * as React from "react";
import * as d3 from "d3";
function drawChart(svgRef: React.RefObject<SVGSVGElement>) {
const data = [12, 5, 6, 6, 9, 10];
const h = 120;
const w = 250;
const svg = d3.select(svgRef.current);
svg
.attr("width", w)
.attr("height", h)
.style("margin-top", 50)
.style("margin-left", 50);
svg
.selectAll("rect")
.data(data)
.enter()
.append("rect")
.attr("x", (d, i) => i * 40)
.attr("y", (d, i) => h - 10 * d)
.attr("width", 20)
.attr("height", (d, i) => d * 10)
.attr("fill", "steelblue");
}
const Chart: React.FunctionComponent = () => {
const svg = React.useRef<SVGSVGElement>(null);
React.useEffect(() => {
drawChart(svg);
}, [svg]);
return (
<div id="chart">
<svg ref={svg} />
</div>
);
};
export default Chart;

@ -0,0 +1,21 @@
import React, { useRef, useState, useEffect } from 'react';
import D3Chart from './D3Chart';
const ChartWrapper = () => {
const chartArea = useRef(null);
const [chart, setChart] = useState(null);
useEffect(() => {
if (!chart) {
setChart(new D3Chart(chartArea.current));
}
}, [chart]);
return (
<div ref={chartArea}></div>
);
}
export default ChartWrapper;

@ -0,0 +1,38 @@
import * as d3 from 'd3';
const url = "https://udemy-react-d3.firebaseio.com/tallest_men.json";
const WIDTH = 800;
const HEIGHT = 500;
export default class D3Chart {
constructor(element) {
const svg = d3.select(element)
.append("svg")
.attr("width", 800)
.attr("height", 500)
d3.json(url).then(data => {
const max = d3.max(data, d => d.height)
const y = d3.scaleLinear()
.domain([0, max])
.range([0, HEIGHT])
const x = d3.scaleBand()
.domain(data.map(d => d.name))
.range([0, WIDTH])
.padding(0.4)
const rects = svg.selectAll("rect")
.data(data)
rects.enter()
.append("rect")
.attr("x", d => x(d.name))
.attr("y", d => HEIGHT - y(d.height))
.attr("width", x.bandwidth)
.attr("height", d => y(d.height))
.attr("fill", "grey")
})
}
}

@ -0,0 +1,75 @@
import React from "react"
import styled from "styled-components"
const Screen = styled.div`
position: relative;
opacity: 0;
animation: fade 0.4s ease-in forwards;
background: black;
@keyframes fade {
0% {
opacity: 0.4;
}
50% {
opacity: 0.8;
}
100% {
opacity: 1;
}
}
`;
const Balls = styled.div`
display: flex;
.ball {
height: 20px;
width: 20px;
border-radius: 50%;
background: red;
margin: 0 6px 0 0;
animation: oscillate 0.7s ease-in forwards infinite;
}
.one {
animation-delay: 0.5s;
}
.two {
animation-delay: 1s;
}
.three {
animation-delay: 2s;
}
@keyframes oscillate {
0% {
transform: translateY(0);
}
50% {
transform: translateY(20px);
}
100% {
transform: translateY(0);
}
}
`;
const LoadingScreen = () => {
return (
<Screen>
<Balls>
<div className="ball one"></div>
<div className="ball two"></div>
<div className="ball three"></div>
</Balls>
</Screen>
);
};
export default LoadingScreen;

@ -0,0 +1,62 @@
import React, { useEffect, useRef, useState } from "react";
import ReactDOM from "react-dom";
import styled from "styled-components";
const Modal = ({ show, onClose, children, title }) => {
const handleCloseClick = (e) => {
e.preventDefault();
onClose();
};
const modalContent = show ? (
<StyledModalOverlay>
<StyledModal>
<StyledModalHeader>
<a href="#" onClick={handleCloseClick}>
x
</a>
</StyledModalHeader>
{title && <StyledModalTitle>{title}</StyledModalTitle>}
<StyledModalBody>{children}</StyledModalBody>
</StyledModal>
</StyledModalOverlay>
) : null;
return (
modalContent
);
};
const StyledModalBody = styled.div`
padding-top: 10px;
`;
const StyledModalHeader = styled.div`
display: flex;
justify-content: flex-end;
font-size: 25px;
`;
const StyledModal = styled.div`
background: white;
width: 500px;
height: 600px;
border-radius: 15px;
padding: 15px;
`;
const StyledModalOverlay = styled.div`
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: rgba(0, 0, 0, 0.5);
`;
export default Modal;

@ -0,0 +1,37 @@
import React, {Fragment} from 'react';
import Head from 'next/head';
import dynamic from 'next/dynamic';
const Bulles = dynamic(import('./Bulles'), {
ssr: false
})
const nbVotesPassables = 15;
const nbVotesAssezBien = 200;
const nbVotesBien = 389;
const nbVotesTresBien = 12;
const nbVotesExcellent = 2;
const resultats = [nbVotesPassables, nbVotesAssezBien, nbVotesBien, nbVotesTresBien, nbVotesExcellent];
var totalVotes = 0;
for(var i = 0; i < resultats.length; i++) {
totalVotes += resultats[i];
}
function SystemeVote() {
return (
<Fragment>
<Bulles donnees={resultats} />
<p style={{color: '#000000'}}>Le total des votes est de {totalVotes}.</p>
</Fragment>
);
}
export default SystemeVote;

@ -0,0 +1,37 @@
import { useState } from "react";
export default function AddPicture(props) {
const [image, setImage] = useState(null);
const [createObjectURL, setCreateObjectURL] = useState(null);
const uploadToClient = (event) => {
if (event.target.files && event.target.files[0]) {
const i = event.target.files[0];
setImage(i);
setCreateObjectURL(URL.createObjectURL(i));
}
};
return (
<div className="ajout-avatar">
<div>
<div className="avatar-placeholer">
<img src={createObjectURL} />
</div>
</div>
<div className="avatar-text">
<h4>Photo <span> (facultatif)</span></h4>
<p>Importer une photo.<br />format : jpg, png, pdf</p>
<div className="btn-ajout-avatar">
<input type="file" name="myImage" id="myImage" onChange={uploadToClient} />
<label className="inputfile" for="myImage">Importer une photo</label>
</div>
</div>
</div>
);
}

@ -0,0 +1,24 @@
import { useState } from 'react'
import { Alert, Button } from 'react-bootstrap';
import { faTimes, faExclamationCircle } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
export default function AlertDismissibleExample() {
const [show, setShow] = useState(true);
if (show) {
return (
<Alert className="preventWarning">
<Alert.Heading>
<div>
<FontAwesomeIcon icon={faExclamationCircle} className="mr-2" />
<span>2 candidats minimum</span>
</div>
<FontAwesomeIcon onClick={() => setShow(false)} icon={faTimes} className="mr-2" />
</Alert.Heading>
</Alert>
);
}
return null;
}

@ -13,13 +13,13 @@ const ButtonWithConfirm = ({className, label, onDelete}) => {
const toggle = () => setVisibility(!visibled)
return (
<div className="input-group-append">
<div className="input-group-append cancelButton">
<button
type="button"
className={className}
onClick={toggle}
>
<FontAwesomeIcon icon={faTrashAlt} />
<div className="annuler"><img src="/arrow-dark-left.svg" /><p>Annuler</p></div>
</button>
<Modal
isOpen={visibled}

@ -1,53 +1,141 @@
import {useState} from 'react'
import { useState } from 'react'
import ButtonWithConfirm from "./ButtonWithConfirm";
import {
Row,
Col,
Label,
Input,
InputGroup,
InputGroupAddon,
Button, Modal, ModalHeader, ModalBody, ModalFooter
} from "reactstrap";
import {useTranslation} from "react-i18next";
import { useTranslation } from "react-i18next";
import {
sortableHandle
} from "react-sortable-hoc";
import HelpButton from "@components/form/HelpButton";
const DragHandle = sortableHandle(({children}) => (
import AddPicture from "@components/form/AddPicture";
import {
faPlus, faCogs, faCheck
} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
const DragHandle = sortableHandle(({ children }) => (
<span className="input-group-text indexNumber">{children}</span>
));
const CandidateField = ({label, candIndex, onDelete, ...inputProps}) => {
const {t} = useTranslation();
const CandidateField = ({ label, description, candIndex, onDelete, onAdd, ...inputProps }) => {
const { t } = useTranslation();
const [visibled, setVisibility] = useState(false);
const toggle = () => setVisibility(!visibled)
const test = () => {
toggle();
onAdd();
}
const [image, setImage] = useState(null);
const [createObjectURL, setCreateObjectURL] = useState(null);
const uploadToClient = (event) => {
if (event.target.files && event.target.files[0]) {
const i = event.target.files[0];
setImage(i);
setCreateObjectURL(URL.createObjectURL(i));
}
};
return (
<Row>
<Col>
<InputGroup>
<InputGroupAddon addonType="prepend">
<DragHandle>
<span>{candIndex + 1}</span>
</DragHandle>
</InputGroupAddon>
<Input
type="text"
value={label}
{...inputProps}
placeholder={t("resource.candidatePlaceholder")}
tabIndex={candIndex + 1}
maxLength="250"
autoFocus
/>
<ButtonWithConfirm className="btn btn-primary border-light" label={label} onDelete={onDelete}>
</ButtonWithConfirm>
</InputGroup>
</Col>
<Col xs="auto" className="align-self-center pl-0">
<Row className="rowNoMargin">
<div className="candidateButton">
<div className="avatarThumb">
<img src={createObjectURL} alt="" />
<span className="ml-2">Ajouter un candidat</span>
</div>
<FontAwesomeIcon onClick={toggle} icon={faPlus} className="mr-2 cursorPointer" />
</div>
<Modal
isOpen={visibled}
toggle={toggle}
className="modal-dialog-centered"
>
<ModalHeader className='closeModalAddCandidate' toggle={toggle}>
</ModalHeader>
<ModalBody>
<Col className="addCandidateCard">
<InputGroup className="addCandidateForm">
<InputGroupAddon addonType="prepend" className="addCandidateHeader">
<DragHandle>
<h6>Ajouter un participant</h6>
<p>Ajoutez une photo, le nom et une description au candidat.</p>
<div className="ajout-avatar">
<div>
<div className="avatar-placeholer">
<img src={createObjectURL} />
</div>
</div>
<div className="avatar-text">
<h4>Photo <span> (facultatif)</span></h4>
<p>Importer une photo.<br />format : jpg, png, pdf</p>
<div className="btn-ajout-avatar">
<input type="file" name="myImage" id="myImage" onChange={uploadToClient} />
<label className="inputfile" for="myImage">Importer une photo</label>
</div>
</div>
</div>
<img src="/avatar.svg" />
</DragHandle>
</InputGroupAddon>
<Label className="addCandidateText">Nom et prenom</Label>
<Input
type="text"
value={label}
{...inputProps}
placeholder={t("resource.candidatePlaceholder")}
tabIndex={candIndex + 1}
maxLength="250"
autoFocus
className="addCandidateText"
/>
<Label className="sss">Description (Facultatif)</Label>
<Input
type="text"
value={description}
{...inputProps}
placeholder="Texte"
tabIndex={candIndex + 1}
maxLength="250"
autoFocus
className="sss"
/>
<Row className="removeAddButtons">
<ButtonWithConfirm className="removeButton" label={label} onDelete={onDelete, toggle}></ButtonWithConfirm>
<Button className="addButton" label={label} onClick={test}>
<FontAwesomeIcon icon={faPlus} />
<span>Ajouter</span>
</Button>
</Row>
</InputGroup>
</Col>
</ModalBody></Modal>
{/* <Col xs="auto" className="align-self-center pl-0">
<HelpButton>
{t(
"Enter the name of your candidate or proposal here (250 characters max.)"
)}
</HelpButton>
</Col>
</Col> */}
</Row>
);
}

@ -16,7 +16,7 @@ import {
} from "react-sortable-hoc";
import arrayMove from "array-move"
import CandidateField from './CandidateField'
import AlertDismissibleExample from './AlertButton'
// const SortableItem = sortableElement(({className, ...childProps}) => <li className={className}><CandidateField {...childProps} /></li>);
//
// const SortableContainer = sortableContainer(({children}) => {
@ -36,7 +36,7 @@ const CandidatesField = ({onChange}) => {
const addCandidate = () => {
if (candidates.length < 1000) {
candidates.push({label: "", fieldRef: createRef()});
candidates.push({label: "", description: "", fieldRef: createRef()});
setCandidates([...candidates]);
onChange(candidates)
} else {
@ -53,8 +53,8 @@ const CandidatesField = ({onChange}) => {
const removeCandidate = index => {
if (candidates.length === 1) {
const newCandidates = []
newCandidates.push({label: "", fieldRef: createRef()});
newCandidates.push({label: "", fieldRef: createRef()});
newCandidates.push({label: "", description: "", fieldRef: createRef()});
newCandidates.push({label: "", description: "", fieldRef: createRef()});
setCandidates(newCandidates);
onChange(newCandidates)
}
@ -65,8 +65,9 @@ const CandidatesField = ({onChange}) => {
}
};
const editCandidate = (index, label) => {
const editCandidate = (index, label, description) => {
candidates[index].label = label
candidates[index].description = description
setCandidates([...candidates]);
onChange(candidates);
};
@ -88,7 +89,10 @@ const CandidatesField = ({onChange}) => {
};
return (
<>
<div className="sectionAjouterCandidat">
<div className="ajouterCandidat">
<h4>Saisissez ici le nom de vos candidats.</h4>
<AlertDismissibleExample />
<SortableContainer onSortEnd={onSortEnd}>
{candidates.map((candidate, index) => {
const className = "sortable"
@ -99,26 +103,18 @@ const CandidatesField = ({onChange}) => {
index={index}
candIndex={index}
label={candidate.label}
description={candidate.description}
onDelete={() => removeCandidate(index)}
onChange={(e) => editCandidate(index, e.target.value)}
onKeyPress={(e) => handleKeyPress(e, index)}
onAdd={addCandidate}
innerRef={candidate.fieldRef}
/>
)
})}
</SortableContainer>
<Button
color="secondary"
className="btn-block mt-2"
tabIndex={candidates.length + 2}
type="button"
onClick={addCandidate}
>
<FontAwesomeIcon icon={faPlus} className="mr-2" />
{t("Add a proposal")}
</Button>
</>
</div>
</div>
);
}

@ -2,6 +2,8 @@ import Link from "next/link";
import { useTranslation } from "next-i18next";
import Paypal from "../banner/Paypal";
import { useBbox } from "./useBbox";
import { Button, Row, Col } from "reactstrap";
import LanguageSelector from "./LanguageSelector";
const Footer = () => {
const linkStyle = { whiteSpace: "nowrap" };
@ -12,81 +14,68 @@ const Footer = () => {
const [bboxLink3, link3] = useBbox();
const [bboxLink4, link4] = useBbox();
const [bboxLink5, link5] = useBbox();
const [bboxLink6, link6] = useBbox();
const [bboxLink7, link7] = useBbox();
return (
<footer className="text-center">
<div>
<ul className="tacky">
<li
ref={link1}
className={bboxLink1.top === bboxLink2.top ? "" : "no-tack"}
>
<Link href="/" style={linkStyle}>
{t("Homepage")}
</Link>
</li>
<li
ref={link2}
className={bboxLink2.top === bboxLink3.top ? "" : "no-tack"}
>
<Link href="/faq" style={linkStyle}>
{t("FAQ")}
</Link>
</li>
<li
ref={link3}
className={bboxLink3.top === bboxLink4.top ? "" : "no-tack"}
>
<a href="mailto:app@mieuxvoter.fr?subject=[HELP]" style={linkStyle}>
{t("resource.help")}
<Row className="tacky">
<Col className="col-md-10 col-sm-10">
<Row className="footerRow">
<Col className="col-md-1 footerLogo">
<img src="/logos/logo-footer.svg" alt="logo of Mieux Voter" />
</Col>
<Col ref={link1}
className={bboxLink1.top === bboxLink2.top ? "" : "no-tack"}
>
<Link href="/" style={linkStyle}>
Le jugement majoritaire
</Link>
</Col>
<Col ref={link2}
className={bboxLink2.top === bboxLink3.top ? "" : "no-tack"}
>
<Link
href="https://mieuxvoter.fr/"
target="_blank"
rel="noopener noreferrer"
style={linkStyle}
>
{t("Who are we?")}
</Link>
</Col>
<Col ref={link3}
className={bboxLink3.top === bboxLink4.top ? "" : "no-tack"}
>
<Link href="/faq" style={linkStyle}>
{t("FAQ")}
</Link>
</Col>
<Col ref={link4}
className={bboxLink4.top === bboxLink5.top ? "" : "no-tack"}
>
<Link href="/" style={linkStyle}>
Actualités
</Link>
</Col>
<Col ref={link5}>
<a href="mailto:app@mieuxvoter.fr?subject=[HELP]" style={linkStyle}>
Nous contacter
</a>
</li>
<li
ref={link4}
className={bboxLink4.top === bboxLink5.top ? "" : "no-tack"}
>
<a
href="https://mieuxvoter.fr/"
target="_blank"
rel="noopener noreferrer"
style={linkStyle}
>
{t("Who are we?")}
</a>
</li>
<li
ref={link5}
className={bboxLink5.top === bboxLink6.top ? "" : "no-tack"}
>
<Link href="/privacy-policy" style={linkStyle}>
{t("Privacy policy")}
</Link>
</li>
<li
ref={link6}
className={bboxLink6.top === bboxLink7.top ? "" : "no-tack"}
>
<Link href="/legal-notices" style={linkStyle}>
{t("resource.legalNotices")}
</Link>
</li>
<li ref={link7}>
{" "}
<a
href="https://github.com/MieuxVoter"
target="_blank"
rel="noopener noreferrer"
style={linkStyle}
>
{t("Source code")}
</a>
</li>
</ul>
</div>
<div className="mt-3">
<Paypal btnColor="btn-primary" />
</Col>
<Col><LanguageSelector /></Col>
</Row>
</Col>
<Col className="footerButton">
<Col className="col-xl-10 col-md-12 offset-xl-2">
<Button className="btn-primary btn-footer">
<a href="/">
Soutenez-nous
</a>
</Button>
</Col>
</Col>
</Row>
</div>
</footer>
);

@ -1,61 +1,125 @@
/* eslint react/prop-types: 0 */
import {useState} from "react";
import {Collapse, Navbar, NavbarToggler, Nav, NavItem} from "reactstrap";
import { useState } from "react";
import {
Collapse,
Navbar,
NavbarToggler,
Nav,
NavItem,
Button,
} from "reactstrap";
import Link from "next/link";
import Head from "next/head";
import {useTranslation} from 'next-i18next'
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
import {faRocket} from "@fortawesome/free-solid-svg-icons";
import { useTranslation } from "next-i18next";
import LanguageSelector from "./LanguageSelector";
import Accordion from "react-bootstrap/Accordion";
const Header = () => {
const [isOpen, setOpen] = useState(false)
const [isOpen, setOpen] = useState(false);
const toggle = () => setOpen(!isOpen);
const {t} = useTranslation()
const { t } = useTranslation("common");
return (
<>
<Head><title>{t("title")}</title></Head>
<header>
<Navbar color="light" light expand="md">
<Link href="/">
<a className="navbar-brand">
<div className="d-flex flex-row">
<div className="align-self-center">
<img src="/logos/logo-color.svg" alt="logo" height="32" />
</div>
<div className="align-self-center ml-2">
<div className="logo-text">
<h1>
{t("Voting platform")}
<small>{t("Majority Judgment")}</small>
</h1>
</div>
</div>
</div>
</a>
</Link>
<NavbarToggler onClick={toggle} />
<Collapse isOpen={isOpen} navbar>
<Nav className="ml-auto" navbar>
<header className="mobile-header">
<Navbar light className="nav-mobile" expand="lg">
<div className="navbar-header">
<Button onClick={toggle} className="navbar-toggle">
<img src="/open-menu-icon.svg" alt="" height="50" />
</Button>
</div>
<Collapse isOpen={isOpen} navbar>
<Nav className="ml-auto navbar-nav-scroll" navbar>
<div className="d-flex flex-row justify-content-between nav-logo">
<Link href="/">
<a className="navbar-brand navbar-brand-mobile">
<img src="/logos/logo.svg" alt="logo" height="80" />
</a>
</Link>
<Button onClick={toggle} className="navbar-toggle navbar-close-button">
<img height="20" src="/close-menu-icon.svg" alt="logo" />
</Button>
</div>
<div>
<NavItem>
<Link href="/new/">
<a className="text-primary nav-link"> <FontAwesomeIcon icon={faRocket} className="mr-2" />
{t("Start an election")}
<Link href="/">
<a onClick={toggle} className="navbar-my-link nav-link">
Le jugement majoritaire
</a>
</Link>
</NavItem>
<NavItem style={{width: "80px"}}>
<LanguageSelector />
<NavItem>
<Link href="/">
<a onClick={toggle} className="navbar-my-link nav-link">
Qui sommes-nous ?
</a>
</Link>
</NavItem>
<NavItem>
<Link href="/">
<a onClick={toggle} className="navbar-my-link nav-link">
Foire aux questions
</a>
</Link>
</NavItem>
</Nav>
</Collapse>
</Navbar>
</header>
</>
<NavItem>
<Link href="/">
<a onClick={toggle} className="navbar-my-link nav-link">
On parle de nous
</a>
</Link>
</NavItem>
<NavItem>
<Link href="/">
<a onClick={toggle} className="navbar-my-link nav-link">
Nous contactez
</a>
</Link>
</NavItem>
<NavItem>
<LanguageSelector style={{ width: "80px" }} />
</NavItem>
</div>
<NavItem className="navbar-credits-container">
<Button className="btn-primary btn-nav">
<a href="/">
Soutenez-nous
</a>
</Button>
<hr />
<div className="navbar-credits sharing sharing-mobile">
<p>Partagez lapplication Mieux voter</p>
<Link href="https://www.facebook.com/mieuxvoter.fr/"><img src="/facebook.svg" className="mr-2" /></Link>
<Link href="https://twitter.com/mieux_voter"><img src="/twitter.svg" className="mr-2" /></Link>
</div>
<div className="d-flex">
<Link href="https://jimmys-box.com/">
<a onClick={toggle} className="navbar-jimmy-link">
développé parJIMMY
</a>
</Link>
</div>
</NavItem>
</Nav>
</Collapse>
</Navbar>
</header>
);
}
};
export default Header;

@ -0,0 +1,61 @@
/* eslint react/prop-types: 0 */
import {useState} from "react";
import {Collapse, Navbar, NavbarToggler, Nav, NavItem} from "reactstrap";
import Link from "next/link";
import Head from "next/head";
import {useTranslation} from 'next-i18next'
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
import {faRocket} from "@fortawesome/free-solid-svg-icons";
import LanguageSelector from "./LanguageSelector";
const Header = () => {
const [isOpen, setOpen] = useState(false)
const toggle = () => setOpen(!isOpen);
const {t} = useTranslation()
return (
<>
<Head><title>{t("title")}</title></Head>
<header>
<Navbar color="light" light expand="md">
<Link href="/">
<a className="navbar-brand">
<div className="d-flex flex-row">
<div className="align-self-center">
<img src="/logos/logo-color.svg" alt="logo" height="32" />
</div>
<div className="align-self-center ml-2">
<div className="logo-text">
<h1>
{t("Voting platform")}
<small>{t("Majority Judgment")}</small>
</h1>
</div>
</div>
</div>
</a>
</Link>
<NavbarToggler onClick={toggle} />
<Collapse isOpen={isOpen} navbar>
<Nav className="ml-auto" navbar>
<NavItem>
<Link href="/new/">
<a className="text-primary nav-link"> <FontAwesomeIcon icon={faRocket} className="mr-2" />
{t("Start an election")}
</a>
</Link>
</NavItem>
<NavItem style={{width: "80px"}}>
<LanguageSelector />
</NavItem>
</Nav>
</Collapse>
</Navbar>
</header>
</>
);
}
export default Header;

@ -25,6 +25,7 @@ const LanguageSelector = () => {
optionsSize={22}
showSelectedLabel={false}
showSecondaryOptionLabel={false}
className="menu-flags"
/>
);
};

@ -0,0 +1,47 @@
/* eslint react/prop-types: 0 */
import { useState } from "react";
import { Container, Row, Col, Nav, NavItem } from "reactstrap";
import Link from "next/link";
import Head from "next/head";
import { useTranslation } from 'next-i18next'
export default function HeaderResultResult() {
;
return (
<Container className="sectionHeaderResult">
<Row>
<Col className="col-md-3">
<Row>
<Col className="sectionHeaderResultSideCol">
<img src="/calendar.svg" />
<p>Clos il y a 2 jours</p></Col>
</Row>
<Row>
<Col className="sectionHeaderResultSideCol"><img src="/avatarBlue.svg" />
<p>14 votants</p></Col>
</Row>
</Col>
<Col className="sectionHeaderResultMiddleCol col-md-6">
<h3>Quel est le meilleur candidat pour les éléctions présidentielle ?</h3>
</Col>
<Col className="col-md-3">
<Row>
<Col className="sectionHeaderResultSideCol"><img src="/arrowUpload.svg" /><p>Télécharger les résultats</p></Col>
</Row>
<Row>
<Col className="sectionHeaderResultSideCol"><img src="/arrowL.svg" /><p>Partagez les résultats</p></Col>
</Row>
</Col>
</Row>
</Container>
);
}

@ -0,0 +1,38 @@
/* eslint react/prop-types: 0 */
import { useState } from "react";
import { Container, Row, Col, Nav, NavItem } from "reactstrap";
import Link from "next/link";
import Head from "next/head";
import { useTranslation } from 'next-i18next'
export default function HeaderMobileResult() {
;
return (
<Container className="sectionHeaderResult">
<Row className="sectionHeaderResultMiddleCol">
<h3>Quel est le meilleur candidat pour les éléctions présidentielle ?</h3>
</Row>
<Row>
<Col className="sectionHeaderResultSideCol">
<img src="/calendar.svg" />
<p>Clos il y a 2 jours</p>
</Col>
<Col className="sectionHeaderResultSideCol">
<img src="/avatarBlue.svg" />
<p>14 votants</p>
</Col>
</Row>
</Container >
);
}

@ -0,0 +1,14 @@
import React from 'react';
import HeaderDesktopResult from './HeaderDesktopResult';
import HeaderMobileResult from './HeaderMobileResult';
import { useMediaQuery } from "react-responsive";
export default function HeaderResult() {
const isMobile = useMediaQuery({ query: "(max-width: 800px)" });
if (isMobile) return <HeaderMobileResult />;
else return <HeaderDesktopResult />;
}

@ -0,0 +1,18 @@
import React from 'react';
import plotly from 'plotly.js/dist/plotly';
import createPlotComponent from 'react-plotly.js/factory';
// const Plot = createPlotComponent(plotly);
const Plot = require('react-plotly.js').default;
export default () => (
<Plot
data={[
{
type: 'bar',
x: ['Taubira', 'Hidalgo', 'Mélenchon'],
y: [29,150,85]
}
]}
layout={ { width: 1000, height: 500, title: 'Nombre de voix par candidat' } }
/>
)

@ -1,6 +1,7 @@
const { i18n } = require("./next-i18next.config");
module.exports = {
i18n,
// See https://github.com/netlify/netlify-plugin-nextjs/issues/223
unstableNetlifyFunctionsSupport: {

4779
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -4,7 +4,7 @@
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"build": "next build && next export",
"start": "next start",
"export": "next export"
},
@ -15,14 +15,20 @@
"@fortawesome/free-solid-svg-icons": "^5.15.3",
"@fortawesome/react-fontawesome": "^0.1.14",
"@svgr/webpack": "^5.5.0",
"@weknow/react-bubble-chart-d3": "^1.0.12",
"array-move": "^3.0.1",
"bootstrap": "^4.6.0",
"bootstrap-scss": "^4.6.0",
"d3": "^7.3.0",
"d3-require": "^1.2.4",
"domexception": "^2.0.1",
"dotenv": "^8.6.0",
"form-data": "^4.0.0",
"gsap": "^3.9.1",
"handlebars": "^4.7.7",
"handlebars-i18next": "^1.0.1",
"highcharts": "^9.3.2",
"highcharts-react-official": "^3.1.0",
"i18next": "^20.2.2",
"i18next-chained-backend": "^2.1.0",
"i18next-fs-backend": "^1.1.1",