From d3194d6c81aa09329fb7284ebfd3d297f4033d2a Mon Sep 17 00:00:00 2001 From: Ahmed Farouk <93868173+ahmedfarouk2000@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:47:56 +0100 Subject: [PATCH] feat: Skeleton for Country Insights in Country View on mobile (#147) --- .../Accordions/AccordionModalSkeleton.tsx | 17 +++++++++++++ src/components/Map/FcsChoropleth.tsx | 14 +++++++---- src/components/Map/IpcMap/IpcChoropleth.tsx | 24 +++++++++++-------- src/components/Map/NutritionChoropleth.tsx | 14 +++++++---- tailwind.config.js | 1 + 5 files changed, 50 insertions(+), 20 deletions(-) create mode 100644 src/components/Accordions/AccordionModalSkeleton.tsx diff --git a/src/components/Accordions/AccordionModalSkeleton.tsx b/src/components/Accordions/AccordionModalSkeleton.tsx new file mode 100644 index 00000000..75bdae98 --- /dev/null +++ b/src/components/Accordions/AccordionModalSkeleton.tsx @@ -0,0 +1,17 @@ +import { Skeleton } from '@nextui-org/skeleton'; + +export default function AccordionModalSkeleton() { + return ( +
+ {/* For screens smaller than 450px */} +
+ +
+ + {/* For screens between 450px and 700px */} +
+ +
+
+ ); +} diff --git a/src/components/Map/FcsChoropleth.tsx b/src/components/Map/FcsChoropleth.tsx index 827d9aad..0f49d268 100644 --- a/src/components/Map/FcsChoropleth.tsx +++ b/src/components/Map/FcsChoropleth.tsx @@ -11,6 +11,7 @@ import FcsChoroplethProps from '@/domain/props/FcsChoroplethProps'; import FcsChoroplethOperations from '@/operations/map/FcsChoroplethOperations'; import { MapOperations } from '@/operations/map/MapOperations'; +import AccordionModalSkeleton from '../Accordions/AccordionModalSkeleton'; import CountryLoadingLayer from './CountryLoading'; import FscCountryChoropleth from './FcsCountryChoropleth'; @@ -65,11 +66,14 @@ export default function FcsChoropleth({ )} {/* Animated GeoJSON layer for the selected country */} {selectedCountryId && (!regionData || !regionLabelData) && ( - + <> + + + )} {regionData && countryId === selectedCountryId && regionLabelData && ( )} {!ipcRegionData && selectedCountryId && ( - feature?.properties?.adm0_id === selectedCountryId), - } as FeatureCollection - } - selectedCountryId={selectedCountryId} - color="hsl(var(--nextui-ipcAnimation))" - /> + <> + feature?.properties?.adm0_id === selectedCountryId), + } as FeatureCollection + } + selectedCountryId={selectedCountryId} + color="hsl(var(--nextui-ipcAnimation))" + /> + + )} {ipcRegionData && ( diff --git a/src/components/Map/NutritionChoropleth.tsx b/src/components/Map/NutritionChoropleth.tsx index 0ceb41d5..f74563f9 100644 --- a/src/components/Map/NutritionChoropleth.tsx +++ b/src/components/Map/NutritionChoropleth.tsx @@ -12,6 +12,7 @@ import NutritionChoroplethProps from '@/domain/props/NutritionChoroplethProps'; import { MapOperations } from '@/operations/map/MapOperations'; import NutritionChoroplethOperations from '@/operations/map/NutritionChoroplethOperations'; +import AccordionModalSkeleton from '../Accordions/AccordionModalSkeleton'; import CountryLoadingLayer from './CountryLoading'; import NutritionStateChoropleth from './NutritionStateChoropleth'; @@ -69,11 +70,14 @@ export default function NutritionChoropleth({ )} {/* Animated GeoJSON layer for the selected country */} {selectedCountryId && (!regionNutritionData || !regionLabelData) && ( - + <> + + + )} { // if this country ('countryId') is selected and data is loaded ('regionNutritionData') show Choropleth for all states diff --git a/tailwind.config.js b/tailwind.config.js index b4288115..8d50e4d2 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -64,6 +64,7 @@ const config = { }, screens: { sm700: '700px', + sm450: '450px', }, width: { '215px': '215px',