From 105a1abc96421cd97eac53dd66df3f6d66fb20c6 Mon Sep 17 00:00:00 2001 From: rektdeckard Date: Wed, 29 Jul 2020 12:20:53 -0400 Subject: [PATCH] IconGrid: drop virtualization approach and bump to phosphor-react@0.1.8 --- package.json | 9 +- src/components/IconGrid/IconGridRL.tsx | 34 ------ src/components/IconGrid/IconGridStatic.tsx | 46 -------- src/components/IconGrid/IconGridUV.css | 20 ---- src/components/IconGrid/IconGridUV.tsx | 102 ------------------ .../IconGrid/IconGridVirtualized.tsx | 34 ------ 6 files changed, 5 insertions(+), 240 deletions(-) delete mode 100644 src/components/IconGrid/IconGridRL.tsx delete mode 100644 src/components/IconGrid/IconGridStatic.tsx delete mode 100644 src/components/IconGrid/IconGridUV.css delete mode 100644 src/components/IconGrid/IconGridUV.tsx delete mode 100644 src/components/IconGrid/IconGridVirtualized.tsx diff --git a/package.json b/package.json index 8539f99..94f2344 100644 --- a/package.json +++ b/package.json @@ -6,23 +6,24 @@ "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.2", "@testing-library/user-event": "^7.1.2", + "@types/file-saver": "^2.0.1", "@types/jest": "^24.0.0", "@types/node": "^12.0.0", "@types/react": "^16.9.43", "@types/react-dom": "^16.9.8", "@types/react-list": "^0.8.5", "@types/react-virtualized": "^9.21.10", + "@types/tinycolor2": "^1.4.2", + "file-saver": "^2.0.2", "framer-motion": "^2.1.0", - "phosphor-react": "^0.1.6", + "phosphor-react": "^0.1.8", "react": "^16.13.1", "react-dom": "^16.13.1", "react-dropdown-select": "^4.4.2", - "react-list": "^0.8.15", "react-scripts": "3.4.1", "react-use": "^15.3.2", - "react-virtual": "^2.2.1", - "react-virtualized": "^9.21.2", "recoil": "^0.0.10", + "tinycolor2": "^1.4.1", "typescript": "^3.9.6" }, "scripts": { diff --git a/src/components/IconGrid/IconGridRL.tsx b/src/components/IconGrid/IconGridRL.tsx deleted file mode 100644 index 584a8bf..0000000 --- a/src/components/IconGrid/IconGridRL.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import React from "react"; -import { useRecoilValue } from "recoil"; -import ReactList from "react-list"; - -import { filteredQueryResultsSelector } from "../../state/selectors"; -import "./IconGrid.css"; - -type IconGridProps = {}; - -const IconGridRL: React.FC = () => { - const filteredQueryResults = useRecoilValue(filteredQueryResultsSelector); - - const renderItem = (index: number, key: number | string) => { - const icon = filteredQueryResults[index]; - return ( -
- {/* {`${icon.name} */} -
{icon.name}
-
- ); - }; - - return ( -
- -
- ); -}; - -export default IconGridRL; diff --git a/src/components/IconGrid/IconGridStatic.tsx b/src/components/IconGrid/IconGridStatic.tsx deleted file mode 100644 index 5a26ecf..0000000 --- a/src/components/IconGrid/IconGridStatic.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import React from "react"; -import { useRecoilValue } from "recoil"; -import { motion } from "framer-motion"; - -import { filteredQueryResultsSelector } from "../../state/selectors"; -import { iconColorAtom, iconSizeAtom, styleQueryAtom } from "../../state/atoms"; -import "./IconGrid.css"; - -type IconGridProps = {}; - -// const variants = { -// open: { opacity: 1, x: 0 }, -// closed: { opacity: 0, x: "-100%" }, -// } - -const whileHover = { boxShadow: "0 0 0 2px rgb(0, 0, 0)" }; -const whileTap = { boxShadow: "0 0 0 4px rgb(139, 0, 139)" } - -const transition = { duration: 0.2 }; - -const IconGrid: React.FC = () => { - const weight = useRecoilValue(styleQueryAtom); - const color = useRecoilValue(iconColorAtom); - const size = useRecoilValue(iconSizeAtom); - const filteredQueryResults = useRecoilValue(filteredQueryResultsSelector); - - return ( - - {filteredQueryResults.map(({ name, Icon }) => ( - - -

{name}

-
- ))} -
- ); -}; - -export default IconGrid; diff --git a/src/components/IconGrid/IconGridUV.css b/src/components/IconGrid/IconGridUV.css deleted file mode 100644 index 1955de9..0000000 --- a/src/components/IconGrid/IconGridUV.css +++ /dev/null @@ -1,20 +0,0 @@ -.grid { - display: grid; - grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); -} - -.grid-item { - margin: 4px; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - background-color: aquamarine; - filter: grayscale(100%); - transition: filter 0.5s ease; -} - -.grid-item:hover { - filter: grayscale(0%); - transition: 0.5s ease; -} diff --git a/src/components/IconGrid/IconGridUV.tsx b/src/components/IconGrid/IconGridUV.tsx deleted file mode 100644 index 65bc094..0000000 --- a/src/components/IconGrid/IconGridUV.tsx +++ /dev/null @@ -1,102 +0,0 @@ -import React, { useRef, useCallback, useMemo } from "react"; -import { useRecoilValue } from "recoil"; -import { useVirtual } from "react-virtual"; - -import { filteredQueryResultsSelector } from "../../state/selectors"; -// import { iconColorAtom, iconSizeAtom } from "../../state/atoms"; -// import "./IconGridUV.css"; - -type IconGridProps = {}; - -const COLUMN_COUNT = 5; - -const IconGrid: React.FC = () => { - const parentRef = useRef(null); - // const color = useRecoilValue(iconColorAtom); - // const size = useRecoilValue(iconSizeAtom); - const filteredQueryResults = useRecoilValue(filteredQueryResultsSelector); - // const categorizedQueryResults = useRecoilValue(categorizedQueryResultsSelector); - // console.log(categorizedQueryResults); - - // const rowVirtualizer = useVirtual({ - // size: useMemo(() => Math.ceil(filteredQueryResults.length / COLUMN_COUNT), [ - // filteredQueryResults, - // ]), - // parentRef, - // estimateSize: useCallback(() => 220 * COLUMN_COUNT, []), - // }); - - const rowVirtualizer = useVirtual({ - size: useMemo(() => Math.ceil(filteredQueryResults.length / COLUMN_COUNT), [ - filteredQueryResults, - ]), - parentRef, - estimateSize: useCallback(() => 240, []), - overscan: 5, - }); - - const columnVirtualizer = useVirtual({ - horizontal: true, - size: COLUMN_COUNT, - parentRef, - estimateSize: useCallback(() => 160, []), - }); - - return ( - <> -
-
- {rowVirtualizer.virtualItems.map((virtualRow) => ( - - {columnVirtualizer.virtualItems.map((virtualColumn) => ( -
- {(function () { - const icon = - filteredQueryResults[ - virtualRow.index * COLUMN_COUNT + virtualColumn.index - ]; - if (!icon) return null; - return ( - <> - {/* {`${icon.name} */} -

{icon.name}

- - ); - })()} -
- ))} -
- ))} -
-
- - ); -}; - -export default IconGrid; diff --git a/src/components/IconGrid/IconGridVirtualized.tsx b/src/components/IconGrid/IconGridVirtualized.tsx deleted file mode 100644 index 7121f58..0000000 --- a/src/components/IconGrid/IconGridVirtualized.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import React from "react"; -import { useRecoilValue } from "recoil"; -import { Grid } from "react-virtualized"; - -import { filteredQueryResultsSelector } from "../../state/selectors"; -import "./IconGrid.css"; - -type IconGridProps = {}; - -const COLUMN_COUNT = 5; - -export default class IconGridVirtualized extends React.PureComponent { - constructor(props: IconGridProps) { - super(props); - } - - render() { - const filteredQueryResults = useRecoilValue(filteredQueryResultsSelector); - - const cellRenderer = () =>
- - return ( - - ) - } -}