From 1b3aef9906f8912839f3136e723e1f569a385c28 Mon Sep 17 00:00:00 2001 From: AT Date: Fri, 5 Aug 2022 21:37:40 +0200 Subject: [PATCH] useLayer Hook --- dependencygraph.svg | 271 ++ package-lock.json | 33 - package.json | 5 +- src/Components/Map/AddButton.tsx | 11 +- src/Components/Map/Layer.tsx | 14 +- src/Components/Map/NewItemPopup.tsx | 26 +- src/Components/Map/UtopiaMap.stories.tsx | 13 +- src/Components/Map/UtopiaMap.tsx | 114 +- src/Components/Map/data.ts | 3652 +++++++++++++++++ src/Components/Map/useItems.tsx | 73 - src/Components/Map/useLayers.tsx | 94 + src/Utils/MarkerIconFactory.ts | 4 +- .../Map/UtopiaMap.css => index.css} | 30 + src/types.ts | 8 +- 14 files changed, 4138 insertions(+), 210 deletions(-) create mode 100644 dependencygraph.svg create mode 100644 src/Components/Map/data.ts delete mode 100644 src/Components/Map/useItems.tsx create mode 100644 src/Components/Map/useLayers.tsx rename src/{Components/Map/UtopiaMap.css => index.css} (74%) diff --git a/dependencygraph.svg b/dependencygraph.svg new file mode 100644 index 00000000..57da55e9 --- /dev/null +++ b/dependencygraph.svg @@ -0,0 +1,271 @@ + + + + + + +dependency-cruiser output + + +cluster_src + +src + + +cluster_src/Components + +Components + + +cluster_src/Components/Map + +Map + + +cluster_src/Utils + +Utils + + + +src/Components/Map/AddButton.tsx + + +AddButton.tsx + + + + + +src/Utils/DynamicHeroIcon.tsx + + +DynamicHeroIcon.tsx + + + + + +src/Components/Map/AddButton.tsx->src/Utils/DynamicHeroIcon.tsx + + + + + +src/Components/Map/Layer.tsx + + +Layer.tsx + + + + + +src/Utils/MarkerIconFactory.ts + + +MarkerIconFactory.ts + + + + + +src/Components/Map/Layer.tsx->src/Utils/MarkerIconFactory.ts + + + + + +src/Components/Map/Popup.tsx + + +Popup.tsx + + + + + +src/Components/Map/Layer.tsx->src/Components/Map/Popup.tsx + + + + + +src/Components/Map/useItems.tsx + + +useItems.tsx + + + + + +src/Components/Map/Layer.tsx->src/Components/Map/useItems.tsx + + + + + +src/Utils/ReplaceURLs.ts + + +ReplaceURLs.ts + + + + + +src/Components/Map/Popup.tsx->src/Utils/ReplaceURLs.ts + + + + + +src/Components/Map/NewItemPopup.tsx + + +NewItemPopup.tsx + + + + + +src/Components/Map/NewItemPopup.tsx->src/Components/Map/useItems.tsx + + + + + +src/types.ts + + +types.ts + + + + + +src/Components/Map/NewItemPopup.tsx->src/types.ts + + + + + +src/Components/Map/UtopiaMap.tsx + + +UtopiaMap.tsx + + + + + +src/Components/Map/NewItemPopup.tsx->src/Components/Map/UtopiaMap.tsx + + + + + + + +src/Components/Map/UtopiaMap.tsx->src/Components/Map/AddButton.tsx + + + + + +src/Components/Map/UtopiaMap.tsx->src/Components/Map/useItems.tsx + + + + + +src/Components/Map/UtopiaMap.tsx->src/Components/Map/NewItemPopup.tsx + + + + + + + +src/Components/Map/UtopiaMap.tsx->src/types.ts + + + + + +src/index.css + + +index.css + + + + + +src/Components/Map/UtopiaMap.tsx->src/index.css + + + + + +src/Components/Map/UtopiaMap.stories.tsx + + +UtopiaMap.stories.tsx + + + + + +src/Components/Map/UtopiaMap.stories.tsx->src/Components/Map/Layer.tsx + + + + + +src/Components/Map/UtopiaMap.stories.tsx->src/Components/Map/UtopiaMap.tsx + + + + + +src/Components/Map/index.tsx + + +index.tsx + + + + + +src/Components/Map/index.tsx->src/Components/Map/UtopiaMap.tsx + + + + + +src/index.tsx + + +index.tsx + + + + + +src/index.tsx->src/Components/Map/Layer.tsx + + + + + +src/index.tsx->src/Components/Map/index.tsx + + + + + diff --git a/package-lock.json b/package-lock.json index a7e717f4..a05b93b5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,6 @@ "babel-loader": "^7.1.5", "babel-runtime": "^6.26.0", "daisyui": "^2.19.0", - "glob-parent": ">=5.1.2", "postcss": "^8.4.14", "react": "^17.0.2", "react-dom": "^17.0.2", @@ -41,8 +40,6 @@ "rollup-plugin-postcss": "^4.0.2", "rollup-plugin-typescript2": "^0.32.1", "tailwindcss": "^3.1.5", - "trim": ">=0.0.3", - "trim-newlines": ">=3.0.1", "typescript": "^4.7.4" }, "peerDependencies": { @@ -24544,24 +24541,6 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "dev": true }, - "node_modules/trim": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/trim/-/trim-1.0.1.tgz", - "integrity": "sha512-3JVP2YVqITUisXblCDq/Bi4P9457G/sdEamInkyvCsjbTcXLXIiG7XCb4kGMFWh6JGXesS3TKxOPtrncN/xe8w==", - "dev": true - }, - "node_modules/trim-newlines": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-4.0.2.tgz", - "integrity": "sha512-GJtWyq9InR/2HRiLZgpIKv+ufIKrVrvjQWEj7PxAXNc5dwbNJkqhAUoAGgzRmULAnoOM5EIpveYd3J2VeSAIew==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/trim-right": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", @@ -44943,18 +44922,6 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "dev": true }, - "trim": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/trim/-/trim-1.0.1.tgz", - "integrity": "sha512-3JVP2YVqITUisXblCDq/Bi4P9457G/sdEamInkyvCsjbTcXLXIiG7XCb4kGMFWh6JGXesS3TKxOPtrncN/xe8w==", - "dev": true - }, - "trim-newlines": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-4.0.2.tgz", - "integrity": "sha512-GJtWyq9InR/2HRiLZgpIKv+ufIKrVrvjQWEj7PxAXNc5dwbNJkqhAUoAGgzRmULAnoOM5EIpveYd3J2VeSAIew==", - "dev": true - }, "trim-right": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", diff --git a/package.json b/package.json index 35aea4bc..ffa2b53b 100644 --- a/package.json +++ b/package.json @@ -43,10 +43,7 @@ "rollup-plugin-postcss": "^4.0.2", "rollup-plugin-typescript2": "^0.32.1", "tailwindcss": "^3.1.5", - "typescript": "^4.7.4", - "trim-newlines": ">=3.0.1", - "glob-parent": ">=5.1.2", - "trim": ">=0.0.3" + "typescript": "^4.7.4" }, "peerDependencies": { "react": "^17.0.2", diff --git a/src/Components/Map/AddButton.tsx b/src/Components/Map/AddButton.tsx index 732ad5c9..8c4c9010 100644 --- a/src/Components/Map/AddButton.tsx +++ b/src/Components/Map/AddButton.tsx @@ -1,14 +1,15 @@ import * as React from 'react' -import { Layer } from '../../types' import DynamicHeroIcon from '../../Utils/DynamicHeroIcon' +import { useLayers } from './useLayers' + export interface AddButtonProps { - layers: Layer[], setSelectMode: React.Dispatch> } export default function AddButton(props: AddButtonProps) { + const layers = useLayers(); return (
- {props.layers && + {layers &&