-
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 #15 from Vizzuality/SS-48-contextual-layers
Contextual panel
- Loading branch information
Showing
55 changed files
with
17,097 additions
and
719 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# IDE | ||
.idea |
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,2 @@ | ||
cd ./cms && yarn config-sync export -y | ||
cd ../client && yarn types && yarn lint --fix && yarn check-types && git add src/types/generated/ |
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,3 +1,4 @@ | ||
/.next | ||
/node_modules | ||
/public | ||
/public | ||
/src/types/generated/ |
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 |
---|---|---|
|
@@ -34,3 +34,6 @@ yarn-error.log* | |
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
# IDE | ||
.idea |
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
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,43 @@ | ||
"use client"; | ||
|
||
// Since QueryClientProvider relies on useContext under the hood, we have to put 'use client' on top | ||
import { isServer, QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
import { PropsWithChildren } from "react"; | ||
|
||
function makeQueryClient() { | ||
return new QueryClient({ | ||
defaultOptions: { | ||
queries: { | ||
// With SSR, we usually want to set some default staleTime | ||
// above 0 to avoid refetching immediately on the client | ||
staleTime: 60 * 1000, | ||
}, | ||
}, | ||
}); | ||
} | ||
|
||
let browserQueryClient: QueryClient | undefined = undefined; | ||
|
||
function getQueryClient() { | ||
if (isServer) { | ||
// Server: always make a new query client | ||
return makeQueryClient(); | ||
} else { | ||
// Browser: make a new query client if we don't already have one | ||
// This is very important, so we don't re-make a new client if React | ||
// suspends during the initial render. This may not be needed if we | ||
// have a suspense boundary BELOW the creation of the query client | ||
if (!browserQueryClient) browserQueryClient = makeQueryClient(); | ||
return browserQueryClient; | ||
} | ||
} | ||
|
||
export default function ReactQueryProvider({ children }: PropsWithChildren) { | ||
// NOTE: Avoid useState when initializing the query client if you don't | ||
// have a suspense boundary between this and the code that may | ||
// suspend because React will throw away the client on the initial | ||
// render if it suspends and there is no boundary | ||
const queryClient = getQueryClient(); | ||
|
||
return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>; | ||
} |
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,26 @@ | ||
import ContextualLayersPanel from "@/components/panels/contextual-layers"; | ||
import { Button } from "@/components/ui/button"; | ||
import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet"; | ||
import LayersIcon from "@/svgs/layers.svg"; | ||
|
||
const ContextualLayersControls = () => { | ||
return ( | ||
<Sheet> | ||
<SheetTrigger asChild> | ||
<Button type="button" variant="yellow" className="w-8 font-sans xl:w-auto"> | ||
<LayersIcon aria-hidden className="xl:!size-5" /> | ||
<span className="sr-only xl:not-sr-only">Contextual layers</span> | ||
</Button> | ||
</SheetTrigger> | ||
<SheetContent | ||
side="right" | ||
variant="light" | ||
className="bottom-[68px] h-[calc(100%_-_68px)] xl:bottom-0 xl:h-full" | ||
> | ||
<ContextualLayersPanel /> | ||
</SheetContent> | ||
</Sheet> | ||
); | ||
}; | ||
|
||
export default ContextualLayersControls; |
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
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,81 @@ | ||
"use client"; | ||
|
||
import { Button, buttonVariants } from "@/components/ui/button"; | ||
import { SheetClose, SheetHeader, SheetTitle } from "@/components/ui/sheet"; | ||
import { Skeleton } from "@/components/ui/skeleton"; | ||
import useDatasetsBySubTopic from "@/hooks/use-datasets-by-sub-topic"; | ||
import XMarkIcon from "@/svgs/xmark.svg"; | ||
|
||
import Item from "./item"; | ||
|
||
const ContextualLayersPanel = () => { | ||
const { data, isLoading } = useDatasetsBySubTopic("contextual"); | ||
|
||
return ( | ||
<> | ||
<SheetHeader className="flex items-center justify-between"> | ||
<SheetTitle | ||
className={buttonVariants({ variant: "yellow", className: "text-base xl:sr-only" })} | ||
> | ||
Contextual layers | ||
</SheetTitle> | ||
<SheetClose asChild> | ||
<Button | ||
type="button" | ||
variant="yellow" | ||
className="w-8 font-sans text-base transition-transform duration-500 ease-out xl:relative xl:w-auto xl:gap-5 xl:pr-10 xl:group-data-[state=open]:-translate-x-12" | ||
> | ||
<XMarkIcon aria-hidden className="!size-5 xl:!size-6" /> | ||
<span className="sr-only">Close</span> | ||
<span aria-hidden className="hidden xl:inline"> | ||
Contextual layers | ||
</span> | ||
</Button> | ||
</SheetClose> | ||
</SheetHeader> | ||
|
||
<p className="mt-11"> | ||
Introduction lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit | ||
amet, consectetu elit. | ||
</p> | ||
|
||
{isLoading && ( | ||
<> | ||
<Skeleton className="mt-6 h-6 w-1/2" /> | ||
<Skeleton className="mt-2 h-6 w-1/3" /> | ||
<Skeleton className="mt-2 h-6 w-2/3" /> | ||
<Skeleton className="mt-6 h-6 w-1/2" /> | ||
<Skeleton className="mt-2 h-6 w-1/3" /> | ||
<Skeleton className="mt-2 h-6 w-2/3" /> | ||
<Skeleton className="mt-6 h-6 w-1/2" /> | ||
<Skeleton className="mt-2 h-6 w-1/3" /> | ||
<Skeleton className="mt-2 h-6 w-2/3" /> | ||
</> | ||
)} | ||
|
||
{!isLoading && data.length === 0 && ( | ||
<div className="py-11 text-center font-semibold">Data not available</div> | ||
)} | ||
|
||
{!isLoading && data.length > 0 && ( | ||
<div className="mt-6 flex flex-col gap-2"> | ||
{data.map(({ subTopic, datasets }) => ( | ||
<Item | ||
key={subTopic} | ||
name={subTopic} | ||
layers={datasets | ||
.filter((dataset) => dataset.layers.length > 0) | ||
.map((dataset) => ({ | ||
// Assuming the dataset has just one layer, which is currently the case | ||
id: dataset.layers[0].id!, | ||
name: dataset.layers[0].attributes!.name!, | ||
}))} | ||
/> | ||
))} | ||
</div> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default ContextualLayersPanel; |
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,23 @@ | ||
import { Dataset, Layer } from "@/types/generated/strapi.schemas"; | ||
|
||
interface ItemProps { | ||
name: Dataset["name"]; | ||
layers: { id: number; name: Layer["name"] }[]; | ||
} | ||
|
||
const Item = ({ name, layers }: ItemProps) => { | ||
return ( | ||
<div> | ||
<div className="border-b border-casper-blue-400/50 py-2 uppercase">{name}</div> | ||
<ul className="py-2"> | ||
{layers.map((layer) => ( | ||
<li key={layer.id} className="py-2"> | ||
<span className="text-xl">{layer.name}</span> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Item; |
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
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,7 @@ | ||
import { cn } from "@/lib/utils"; | ||
|
||
function Skeleton({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) { | ||
return <div className={cn("animate-pulse bg-casper-blue-50", className)} {...props} />; | ||
} | ||
|
||
export { Skeleton }; |
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
Oops, something went wrong.