-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #263 from Vizzuality/SKY30-372-fe-add-geography-fi…
…lter-to-the-conservation-builder [SKY30-372] Add the location selector to the modelling tool + functionality enhancements
- Loading branch information
Showing
27 changed files
with
168 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
export const PAGES = { | ||
homepage: '/', | ||
progressTracker: '/progress-tracker', | ||
conservationBuilder: '/conservation-builder', | ||
homepage: '/', | ||
knowledgeHub: '/knowledge-hub', | ||
contact: '/contact', | ||
about: '/about', | ||
}; | ||
} as const; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 0 additions & 53 deletions
53
...end/src/containers/map/sidebar/main-panel/details/location-selector/type-toggle/index.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
69 changes: 69 additions & 0 deletions
69
frontend/src/containers/map/sidebar/main-panel/location-selector/type-toggle/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import * as ToggleGroup from '@radix-ui/react-toggle-group'; | ||
import { VariantProps, cva } from 'class-variance-authority'; | ||
|
||
import { cn } from '@/lib/classnames'; | ||
|
||
import { FILTERS } from '../index'; | ||
|
||
const toggleVariants = cva( | ||
'focus-visible:ring-slate-950 data-[state=on]:text-slate-950 dark:ring-offset-slate-950 dark:data-[state=on]:bg-slate-950 justify-center whitespace-nowrap ring-offset-white transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:shadow-sm dark:focus-visible:ring-slate-300 dark:data-[state=on]:text-slate-50 group flex flex-1 items-center space-x-1 rounded-none border-r last:border-r-0 border-black py-2 whitespace-pre-line font-mono text-xs font-bold uppercase leading-none text-black last:border-l-0 h-full', | ||
{ | ||
variants: { | ||
theme: { | ||
orange: 'data-[state=on]:bg-orange', | ||
blue: 'data-[state=on]:bg-blue', | ||
}, | ||
}, | ||
defaultVariants: { | ||
theme: 'orange', | ||
}, | ||
} | ||
); | ||
|
||
type LocationTypeToggleProps = VariantProps<typeof toggleVariants> & { | ||
className?: HTMLDivElement['className']; | ||
defaultValue: keyof typeof FILTERS; | ||
value: keyof typeof FILTERS; | ||
onChange: (value: keyof typeof FILTERS) => void; | ||
}; | ||
|
||
const LocationTypeToggle: React.FC<LocationTypeToggleProps> = ({ | ||
className, | ||
theme, | ||
defaultValue, | ||
value, | ||
onChange, | ||
}) => { | ||
return ( | ||
<ToggleGroup.Root | ||
className={cn( | ||
className, | ||
'grid w-full grid-cols-3 items-center justify-center border border-black' | ||
)} | ||
type="single" | ||
defaultValue={defaultValue} | ||
aria-label="Locations filter" | ||
value={value} | ||
onValueChange={(value: keyof typeof FILTERS) => { | ||
if (!value) return; | ||
onChange(value); | ||
}} | ||
> | ||
<ToggleGroup.Item className={toggleVariants({ theme })} value="all" aria-label="All"> | ||
All | ||
</ToggleGroup.Item> | ||
<ToggleGroup.Item | ||
className={toggleVariants({ theme })} | ||
value="countryHighseas" | ||
aria-label="Countries & High Seas" | ||
> | ||
Countries & High Seas | ||
</ToggleGroup.Item> | ||
<ToggleGroup.Item className={toggleVariants({ theme })} value="regions" aria-label="Regions"> | ||
Regions | ||
</ToggleGroup.Item> | ||
</ToggleGroup.Root> | ||
); | ||
}; | ||
|
||
export default LocationTypeToggle; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions
12
...ntainers/map/sidebar/main-panel/index.tsx → ...s/map/sidebar/main-panel/panels/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
53 changes: 53 additions & 0 deletions
53
frontend/src/pages/conservation-builder/[locationCode].tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { QueryClient, dehydrate } from '@tanstack/react-query'; | ||
import type { GetServerSideProps } from 'next'; | ||
|
||
import MapLayout from '@/layouts/map'; | ||
import { getGetLocationsQueryKey, getGetLocationsQueryOptions } from '@/types/generated/location'; | ||
import { LocationListResponse } from '@/types/generated/strapi.schemas'; | ||
|
||
export const getServerSideProps: GetServerSideProps = async (context) => { | ||
const { query } = context; | ||
const { locationCode = 'GLOB' } = query; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
await queryClient.prefetchQuery({ | ||
...getGetLocationsQueryOptions({ | ||
filters: { | ||
code: locationCode, | ||
}, | ||
}), | ||
}); | ||
|
||
const locationsData = queryClient.getQueryData<LocationListResponse>( | ||
getGetLocationsQueryKey({ | ||
filters: { | ||
code: locationCode, | ||
}, | ||
}) | ||
); | ||
|
||
if (!locationsData || !locationsData.data) return { notFound: true }; | ||
|
||
return { | ||
props: { | ||
location: locationsData.data[0].attributes || { | ||
code: 'GLOB', | ||
name: 'Global', | ||
}, | ||
dehydratedState: dehydrate(queryClient), | ||
}, | ||
}; | ||
}; | ||
|
||
export default function ConservationBuilderPage() { | ||
return null; | ||
} | ||
|
||
ConservationBuilderPage.layout = { | ||
Component: MapLayout, | ||
props: { | ||
title: 'Conservation builder', | ||
type: 'conservation-builder', | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.