Skip to content

Commit

Permalink
add shuffling to menu
Browse files Browse the repository at this point in the history
  • Loading branch information
robindemourat committed Jul 31, 2024
1 parent 5714065 commit d51f812
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,41 @@
import { Link, } from "react-scroll";
import axios from 'axios';
import { csvParse } from 'd3-dsv';
import { useEffect, useState } from 'react';
import { useEffect, useMemo, useState } from 'react';
import Md from 'react-markdown';
import rehypeRaw from "rehype-raw";

import ImageGallery from "./components/ImagesGallery";
import Home from "./components/Home";
import Voyageurs from './components/Voyageurs';
import './App.scss';
import { menuData, metadata, datasets, textsList, images } from './metadata'
import { menuData as inputMenuData, metadata, datasets, textsList, images } from './metadata'
import Philippe from "./components/Philippe";

function shuffle(arr) {
const array = [...arr];
let currentIndex = array.length;
while (currentIndex !== 0) {
let randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex--;
[array[currentIndex], array[randomIndex]] = [
array[randomIndex], array[currentIndex]];
}
return array;
}

function App() {
const [menuOpen, setMenuOpen] = useState(false);
const [data, setData] = useState();
const [texts, setTexts] = useState();
const bottomMenuGroup = ['À propos'];
const menuData = useMemo(() => {
return [
inputMenuData[0],
...shuffle(inputMenuData.slice(1, inputMenuData.length - 1)),
inputMenuData[inputMenuData.length - 1],
]
}, []);
useEffect(() => {
textsList.reduce((cur, textName) => {
return cur.then((res) => {
Expand Down

0 comments on commit d51f812

Please sign in to comment.