Skip to content

Commit

Permalink
refactor: lift filtering state into context
Browse files Browse the repository at this point in the history
  • Loading branch information
steveoh committed Nov 19, 2024
1 parent b3a879b commit ae67556
Show file tree
Hide file tree
Showing 12 changed files with 736 additions and 124 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"Geospatial",
"gnis",
"hostingchannels",
"Immer",
"lods",
"lucide",
"noopener",
Expand Down
200 changes: 199 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@ugrc/layer-selector": "^6.2.9",
"@ugrc/utah-design-system": "^1.15.1",
"firebase": "^11.0.2",
"immer": "^10.1.1",
"ky": "^1.7.2",
"lodash.startcase": "^4.4.0",
"react": "^18.3.1",
Expand All @@ -44,7 +45,8 @@
"react-error-boundary": "^4.1.2",
"react-fast-compare": "^3.2.2",
"react-stately": "^3.33.0",
"tailwind-variants": "^0.3.0"
"tailwind-variants": "^0.3.0",
"use-immer": "^0.10.0"
},
"devDependencies": {
"@chromatic-com/storybook": "^3.2.2",
Expand All @@ -62,6 +64,7 @@
"@types/react-dom": "^18.3.1",
"@typescript-eslint/eslint-plugin": "^8.14.0",
"@vitejs/plugin-react": "^4.3.3",
"@vitest/coverage-v8": "^2.1.5",
"autoprefixer": "^10.4.20",
"cpy-cli": "^5.0.0",
"eslint": "^9.14.0",
Expand Down
37 changes: 16 additions & 21 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
ReferenceLayer,
TagGroupLoader,
} from './components';
import { FilterProvider } from './components/contexts';
import { featureTypes, projectStatus } from './components/data/filters.js';
import { useMap } from './components/hooks';
import config from './config.js';
Expand Down Expand Up @@ -64,27 +65,21 @@ export default function App() {
<h5 className="dark:text-zinc-200">Search tool</h5>
</ErrorBoundary>
</div>
<div className="flex flex-col gap-4 rounded border border-zinc-200 p-3 dark:border-zinc-700">
<ErrorBoundary FallbackComponent={ErrorFallback}>
<h5 className="dark:text-zinc-200">Project Status</h5>
{featureLayers.length > 0 ? (
<ProjectStatus layers={featureLayers} status={projectStatus} />
) : (
<TagGroupLoader />
)}
{featureLayers.length > 0 && <CentroidToggle />}
</ErrorBoundary>
</div>
<div className="flex flex-col gap-4 rounded border border-zinc-200 p-3 dark:border-zinc-700">
<ErrorBoundary FallbackComponent={ErrorFallback}>
<h5 className="dark:text-zinc-200">Feature Type</h5>
{featureLayers.length > 0 ? (
<FeatureData layers={featureLayers} featureTypes={featureTypes} />
) : (
<TagGroupLoader />
)}
</ErrorBoundary>
</div>
<FilterProvider featureLayers={featureLayers}>
<div className="flex flex-col gap-4 rounded border border-zinc-200 p-3 dark:border-zinc-700">
<ErrorBoundary FallbackComponent={ErrorFallback}>
<h5 className="dark:text-zinc-200">Project Status</h5>
{featureLayers.length > 0 ? <ProjectStatus status={projectStatus} /> : <TagGroupLoader />}
{featureLayers.length > 0 && <CentroidToggle />}
</ErrorBoundary>
</div>
<div className="flex flex-col gap-4 rounded border border-zinc-200 p-3 dark:border-zinc-700">
<ErrorBoundary FallbackComponent={ErrorFallback}>
<h5 className="dark:text-zinc-200">Feature Type</h5>
{featureLayers.length > 0 ? <FeatureData featureTypes={featureTypes} /> : <TagGroupLoader />}
</ErrorBoundary>
</div>
</FilterProvider>
<div className="flex flex-col gap-4 rounded border border-zinc-200 p-3 dark:border-zinc-700">
<ErrorBoundary FallbackComponent={ErrorFallback}>
<h5 className="dark:text-zinc-200">Map Reference data</h5>
Expand Down
Loading

0 comments on commit ae67556

Please sign in to comment.