Jeremie Pardou-Piquemal před 2 roky
rodič
revize
4af63ed864

+ 1 - 1
src/components/ItemLibrary.jsx

@@ -7,7 +7,7 @@ import { debounce } from "lodash";
 
 import { useItems } from "../components/board/Items";
 import useToggle from "./hooks/useToggle";
-import { search } from "../utils";
+import { search } from "./utils";
 
 import Chevron from "./ui/Chevron";
 import { PanZoomRotateAtom } from "./board";

+ 1 - 1
src/components/MainView.jsx

@@ -11,7 +11,7 @@ import { MediaLibraryProvider } from "./mediaLibrary";
 import ImageDropNPaste from "./ImageDropNPaste";
 import AddItemButton from "./AddItemButton";
 import { MessageButton } from "./message";
-import { insideClass } from "../utils";
+import { insideClass } from "./utils";
 
 const StyledBoardView = styled.div`
   width: 100vw;

+ 1 - 2
src/components/SelectedItemsPane.jsx

@@ -5,8 +5,7 @@ import { useRecoilValue, useRecoilCallback } from "recoil";
 import debounce from "lodash.debounce";
 import { useTranslation } from "react-i18next";
 
-import { insideClass, hasClass } from "../utils";
-
+import { insideClass, hasClass } from "./utils";
 import SidePanel from "./ui/SidePanel";
 import { useItemActions } from "./board/Items/useItemActions";
 import {

+ 1 - 1
src/components/board/ActionPane.jsx

@@ -8,7 +8,7 @@ import {
 } from "./";
 import { useItems } from "./Items";
 import { useSetRecoilState, useRecoilCallback } from "recoil";
-import { insideClass, hasClass } from "../../utils";
+import { insideClass, hasClass } from "../utils";
 
 import Gesture from "./Gesture";
 

+ 4 - 1
src/components/board/Gesture.jsx

@@ -1,6 +1,9 @@
 import React from "react";
+import platform from "platform";
 
-import { isMacOS } from "../../utils/deviceInfos";
+export const isMacOS = () => {
+  return platform.os.family === "OS X";
+};
 
 // From https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
 const getScrollLineHeight = () => {

+ 1 - 1
src/components/board/PanZoomRotate.jsx

@@ -12,7 +12,7 @@ import {
   PanZoomRotateAtom,
   SelectedItemsAtom,
 } from "./";
-import { insideClass } from "../../utils/";
+import { insideClass } from "../utils";
 
 import usePrevious from "../hooks/usePrevious";
 

+ 4 - 4
src/components/board/Selector.jsx

@@ -1,7 +1,9 @@
 import React from "react";
-
-import { useRecoilValue, useSetRecoilState, useRecoilCallback } from "recoil";
+import throttle from "lodash.throttle";
 import styled from "styled-components";
+import { useRecoilValue, useSetRecoilState, useRecoilCallback } from "recoil";
+
+import { insideClass, isItemInsideElement } from "../utils";
 
 import {
   PanZoomRotateAtom,
@@ -10,8 +12,6 @@ import {
   BoardStateAtom,
   SelectedItemsAtom,
 } from "./";
-import { insideClass, isItemInsideElement } from "../../utils";
-import throttle from "lodash.throttle";
 
 import Gesture from "./Gesture";
 

+ 0 - 18
src/utils/index.js → src/components/utils.js

@@ -49,24 +49,6 @@ export const shuffle = (a) => {
   return a;
 };
 
-/**
- * Extract coordinates from mouse/touch event.
- * @param {event} e the event.
- */
-export const getPointerState = (e) => {
-  if (e.touches) {
-    return {
-      clientX: e.touches[0].clientX,
-      clientY: e.touches[0].clientY,
-    };
-  } else {
-    return {
-      clientX: e.clientX,
-      clientY: e.clientY,
-    };
-  }
-};
-
 export const randInt = (min, max) => {
   return Math.floor(Math.random() * (max - min + 1)) + min;
 };

+ 1 - 1
src/gameComponents/Zone.jsx

@@ -1,7 +1,7 @@
 import React from "react";
 import { memo } from "react";
 import styled, { css } from "styled-components";
-import { isItemInsideElement } from "../utils";
+import { isItemInsideElement } from "../components/utils";
 import useItemInteraction from "../components/board/Items/useItemInteraction";
 import useGameItemActionMap from "./useGameItemActionMap";
 

+ 1 - 1
src/gameComponents/useGameItemActionMap.jsx

@@ -9,7 +9,7 @@ import { SelectedItemsAtom } from "../components/board";
 import { useUsers } from "../components/users";
 import { ItemMapAtom } from "../components/board";
 
-import { shuffle as shuffleArray, randInt } from "../utils";
+import { shuffle as shuffleArray, randInt } from "../components/utils";
 
 import deleteIcon from "../images/delete.svg";
 import stackToCenterIcon from "../images/stackToCenter.svg";

+ 0 - 5
src/utils/deviceInfos.js

@@ -1,5 +0,0 @@
-import platform from "platform";
-
-export const isMacOS = () => {
-  return platform.os.family === "OS X";
-};

+ 5 - 5
src/views/GameListView.jsx

@@ -11,7 +11,7 @@ import languageSVG from "../images/language.svg";
 import clockSVG from "../images/clock.svg";
 
 import { getGames } from "../utils/api";
-import { search } from "../utils";
+import { search } from "../components/utils";
 
 import GameListItem from "./GameListItem";
 import { StyledGameList } from "./StyledGameList";
@@ -204,14 +204,14 @@ const GameListView = () => {
   const filteredGameList = React.useMemo(() => {
     return gameList
       ? gameList.filter((game) => {
-          return (
-          (filterCriteria.searchTerm === NULL_SEARCH_TERM ||
+        return (
+            (filterCriteria.searchTerm === NULL_SEARCH_TERM ||
               search(filterCriteria.searchTerm, game.defaultName)) &&
             hasRequestedValues(filterCriteria.nbOfPlayers, game.playerCount) &&
             hasRequestedValues(filterCriteria.durations, game.duration) &&
             hasAllowedMaterialLanguage(filterCriteria, game)
-        );
-        })
+          );
+      })
       : [];
   }, [gameList, filterCriteria]);