@ -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,43 @@
|
|||||||
|
import {useTranslation} from "next-i18next";
|
||||||
|
import {useRouter} from "next/router"
|
||||||
|
import {faPaypal} from "@fortawesome/free-brands-svg-icons";
|
||||||
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||||
|
|
||||||
|
const PaypalNoLogo = () => {
|
||||||
|
const {t} = useTranslation();
|
||||||
|
|
||||||
|
// FIXME generate a xx_XX string for locale version
|
||||||
|
const {locale} = useRouter();
|
||||||
|
let localeShort = locale.substring(0, 2);
|
||||||
|
let localeComplete =
|
||||||
|
localeShort.toLowerCase() + "_" + localeShort.toUpperCase();
|
||||||
|
if (localeComplete === "en_EN") {
|
||||||
|
localeComplete = "en_US";
|
||||||
|
}
|
||||||
|
const pixelLink =
|
||||||
|
`https://www.paypal.com/${localeComplete}/i/scr/pixel.gif`;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="d-inline-block m-auto">
|
||||||
|
<form
|
||||||
|
action="https://www.paypal.com/cgi-bin/webscr"
|
||||||
|
method="post"
|
||||||
|
target="_top"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="addButton"
|
||||||
|
title={t("PayPal - The safer, easier way to pay online!")}
|
||||||
|
>
|
||||||
|
{t("Support us !")}
|
||||||
|
<img src="/arrow-blue.svg" className="mr-2" />
|
||||||
|
</button>
|
||||||
|
<input type="hidden" name="cmd" value="_s-xclick" />
|
||||||
|
<input type="hidden" name="hosted_button_id" value="KB2Z7L9KARS7C" />
|
||||||
|
<img alt="" border="0" src={pixelLink} width="1" height="1" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PaypalNoLogo;
|
@ -0,0 +1,29 @@
|
|||||||
|
/* eslint react/prop-types: 0 */
|
||||||
|
import React from "react";
|
||||||
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
|
import { faFacebookSquare } from "@fortawesome/free-brands-svg-icons";
|
||||||
|
|
||||||
|
const Twitter = props => {
|
||||||
|
const handleClick = () => {
|
||||||
|
const url =
|
||||||
|
"https://twitter.com/intent/tweet?text=" +
|
||||||
|
|
||||||
|
props.title +
|
||||||
|
"&t=" +
|
||||||
|
props.url;
|
||||||
|
window.open(
|
||||||
|
url,
|
||||||
|
"",
|
||||||
|
"menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=500,width=700"
|
||||||
|
);
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
|
||||||
|
<img src="/twitter.svg" onClick={handleClick} className="cursorPointer mr-2" />
|
||||||
|
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Twitter;
|
||||||
|
|
||||||
|
//i
|
@ -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;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export const DotButton = ({ selected, onClick, value }) => (
|
||||||
|
<button
|
||||||
|
className={`embla__dot ${selected ? "is-selected" : ""}`}
|
||||||
|
type="button"
|
||||||
|
onClick={onClick}
|
||||||
|
>{value}</button>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const PrevButton = ({ enabled, onClick }) => (
|
||||||
|
<button
|
||||||
|
className="embla__button embla__button--prev"
|
||||||
|
onClick={onClick}
|
||||||
|
disabled={!enabled}
|
||||||
|
>
|
||||||
|
<svg className="embla__button__svg" viewBox="137.718 -1.001 366.563 644">
|
||||||
|
<path d="M428.36 12.5c16.67-16.67 43.76-16.67 60.42 0 16.67 16.67 16.67 43.76 0 60.42L241.7 320c148.25 148.24 230.61 230.6 247.08 247.08 16.67 16.66 16.67 43.75 0 60.42-16.67 16.66-43.76 16.67-60.42 0-27.72-27.71-249.45-249.37-277.16-277.08a42.308 42.308 0 0 1-12.48-30.34c0-11.1 4.1-22.05 12.48-30.42C206.63 234.23 400.64 40.21 428.36 12.5z" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const NextButton = ({ enabled, onClick }) => (
|
||||||
|
<button
|
||||||
|
className="embla__button embla__button--next"
|
||||||
|
onClick={onClick}
|
||||||
|
disabled={!enabled}
|
||||||
|
>
|
||||||
|
<svg className="embla__button__svg" viewBox="0 0 238.003 238.003">
|
||||||
|
<path d="M181.776 107.719L78.705 4.648c-6.198-6.198-16.273-6.198-22.47 0s-6.198 16.273 0 22.47l91.883 91.883-91.883 91.883c-6.198 6.198-6.198 16.273 0 22.47s16.273 6.198 22.47 0l103.071-103.039a15.741 15.741 0 0 0 4.64-11.283c0-4.13-1.526-8.199-4.64-11.313z" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
);
|
@ -0,0 +1,53 @@
|
|||||||
|
import {useState} from "react";
|
||||||
|
import {
|
||||||
|
faTrashAlt,
|
||||||
|
} from "@fortawesome/free-solid-svg-icons";
|
||||||
|
import {Button, Modal, ModalHeader, ModalBody, ModalFooter} from "reactstrap";
|
||||||
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||||
|
import {useTranslation} from "next-i18next";
|
||||||
|
|
||||||
|
const TrashButton = ({className, label, onDelete}) => {
|
||||||
|
const [visibled, setVisibility] = useState(false);
|
||||||
|
const {t} = useTranslation();
|
||||||
|
|
||||||
|
const toggle = () => setVisibility(!visibled)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="input-group-append cancelButton">
|
||||||
|
<FontAwesomeIcon onClick={toggle} icon={faTrashAlt} className="mr-2 cursorPointer" />
|
||||||
|
<Modal
|
||||||
|
isOpen={visibled}
|
||||||
|
toggle={toggle}
|
||||||
|
className="modal-dialog-centered cancelForm"
|
||||||
|
>
|
||||||
|
<ModalHeader><FontAwesomeIcon icon={faTrashAlt} /></ModalHeader>
|
||||||
|
<ModalBody>
|
||||||
|
{t("Are you sure to delete")}{<br />}
|
||||||
|
{label && label !== "" ? (
|
||||||
|
<b>{label}</b>
|
||||||
|
) : (
|
||||||
|
<>{t("the row")}</>
|
||||||
|
)}
|
||||||
|
</ModalBody>
|
||||||
|
<ModalFooter>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
className={className}
|
||||||
|
onClick={toggle}>
|
||||||
|
<div className="annuler"><img src="/arrow-dark-left.svg" /> {t("No")}</div>
|
||||||
|
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
className="new-btn-confirm"
|
||||||
|
onClick={() => {toggle(); onDelete();}}
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon icon={faTrashAlt} className="mr-2"/>
|
||||||
|
{t("Yes")}
|
||||||
|
</Button>
|
||||||
|
</ModalFooter>
|
||||||
|
</Modal>
|
||||||
|
</div >
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TrashButton;
|
@ -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;
|
@ -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,45 +1,6 @@
|
|||||||
const { i18n } = require("./next-i18next.config");
|
const {i18n} = require("./next-i18next.config");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
i18n,
|
|
||||||
// See https://github.com/netlify/netlify-plugin-nextjs/issues/223
|
|
||||||
unstableNetlifyFunctionsSupport: {
|
|
||||||
"pages/index.jsx": {
|
|
||||||
includeDirs: ["public"],
|
|
||||||
},
|
|
||||||
"pages/faq.jsx": {
|
|
||||||
includeDirs: ["public"],
|
|
||||||
},
|
|
||||||
"pages/legal-notices.jsx": {
|
|
||||||
includeDirs: ["public"],
|
|
||||||
},
|
|
||||||
"pages/new/confirm/[pid].jsx": {
|
|
||||||
includeDirs: ["public"],
|
|
||||||
},
|
|
||||||
"pages/new.jsx": {
|
|
||||||
includeDirs: ["public"],
|
|
||||||
},
|
|
||||||
"pages/result/[pid]/[[...tid]].jsx": {
|
|
||||||
includeDirs: ["public"],
|
|
||||||
},
|
|
||||||
"pages/vote/[pid]/[[...tid]].jsx": {
|
|
||||||
includeDirs: ["public"],
|
|
||||||
},
|
|
||||||
"pages/vote/[pid]/confirm.jsx": {
|
|
||||||
includeDirs: ["public"],
|
|
||||||
},
|
|
||||||
"pages/privacy-policy.jsx": {
|
|
||||||
includeDirs: ["public"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
pageExtensions: ["mdx", "jsx", "js", "ts", "tsx"],
|
|
||||||
webpack(config) {
|
|
||||||
config.module.rules.push({
|
|
||||||
test: /\.svg$/,
|
|
||||||
use: ["@svgr/webpack"],
|
|
||||||
});
|
|
||||||
|
|
||||||
return config;
|
i18n,
|
||||||
},
|
|
||||||
target: "experimental-serverless-trace",
|
|
||||||
};
|
};
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
import dynamic from 'next/dynamic';
|
||||||
|
import plotly from 'plotly.js/dist/plotly';
|
||||||
|
import createPlotComponent from 'react-plotly.js/factory';
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
//import Plot from 'react-plotly.js';
|
||||||
|
|
||||||
|
class BarChart extends Component {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Plot
|
||||||
|
data={[
|
||||||
|
{
|
||||||
|
type: 'bar',
|
||||||
|
x: ['Taubira', 'Hidalgo', 'Mélenchon'],
|
||||||
|
y: [29,150,85]
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
layout={ { width: 1000, height: 500, title: 'Nombre de voix par candidat' } }
|
||||||
|
config={{
|
||||||
|
displayModeBar: false // this is the line that hides the bar.
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default BarChart;
|
After Width: | Height: | Size: 165 B |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 525 B |
After Width: | Height: | Size: 521 B |
After Width: | Height: | Size: 375 B |
After Width: | Height: | Size: 297 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 607 B |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 240 B |
After Width: | Height: | Size: 765 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 512 B |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 406 B |
After Width: | Height: | Size: 386 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 646 B |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 403 B |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 489 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 69 KiB |
After Width: | Height: | Size: 95 KiB |
@ -1,29 +1,40 @@
|
|||||||
const colors = [
|
const colors = [
|
||||||
"#015411",
|
"#F2F0FF",
|
||||||
"#019812",
|
"#C23D13",
|
||||||
"#6bca24",
|
"#C27C13",
|
||||||
"#ffb200",
|
"#C2B113",
|
||||||
"#ff5d00",
|
"#D3D715",
|
||||||
"#b20616",
|
"#A0CF1C",
|
||||||
"#6f0214"
|
"#3A9918"
|
||||||
];
|
];
|
||||||
|
|
||||||
const gradeNames = [
|
const gradeNames = [
|
||||||
"Excellent",
|
"To reject",
|
||||||
"Very good",
|
|
||||||
"Good",
|
|
||||||
"Fair",
|
|
||||||
"Passable",
|
|
||||||
"Insufficient",
|
"Insufficient",
|
||||||
"To reject"
|
"Passable",
|
||||||
|
"Fair",
|
||||||
|
"Good",
|
||||||
|
"Very good",
|
||||||
|
"Excellent"
|
||||||
|
];
|
||||||
|
|
||||||
|
const gradeClass = [
|
||||||
|
"to-reject",
|
||||||
|
"insufficient",
|
||||||
|
"passable",
|
||||||
|
"fair",
|
||||||
|
"good",
|
||||||
|
"very-good",
|
||||||
|
"excellent"
|
||||||
];
|
];
|
||||||
|
|
||||||
const gradeValues = [6, 5, 4, 3, 2, 1, 0];
|
const gradeValues = [0, 1, 2, 3, 4, 5, 6, 7];
|
||||||
|
|
||||||
export const translateGrades = (t) => {
|
export const translateGrades = (t) => {
|
||||||
return gradeNames.map((name, i) => ({
|
return gradeNames.map((name, i) => ({
|
||||||
label: t(name),
|
label: t(name),
|
||||||
color: colors[i],
|
color: colors[i],
|
||||||
value: gradeValues[i]
|
value: gradeValues[i],
|
||||||
|
class: gradeClass[i]
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|