-
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 #34 from Vizzuality/SKY30-87-fe-navigation-to-the-…
…data-table [SKY30-87] FE - Navigation to the data table + design tweaks
- Loading branch information
Showing
9 changed files
with
173 additions
and
12 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
40 changes: 40 additions & 0 deletions
40
frontend/src/containers/data-tool/content/details/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,40 @@ | ||
import DashboardTable from '@/components/dashboard-table'; | ||
import { Button } from '@/components/ui/button'; | ||
import { useSyncDataToolContentSettings } from '@/containers/data-tool/sync-settings'; | ||
|
||
import { mockedData } from './mocked-data'; | ||
|
||
const DataToolDetails: React.FC = () => { | ||
const [, setSettings] = useSyncDataToolContentSettings(); | ||
|
||
const handleOnCloseClick = () => { | ||
setSettings((prevSettings) => ({ ...prevSettings, showDetails: false })); | ||
}; | ||
|
||
return ( | ||
<div className="absolute h-full w-full overflow-scroll bg-white px-4 py-4 md:px-6"> | ||
<div className="mb-8 flex gap-8 md:justify-between"> | ||
<span className="max-w-lg"> | ||
<h2 className="text-4xl font-extrabold"> | ||
Marine Conservation at National and Regional Levels | ||
</h2> | ||
</span> | ||
<Button variant="text-link" className="m-0 cursor-pointer p-0" onClick={handleOnCloseClick}> | ||
Close | ||
</Button> | ||
</div> | ||
<div className="overflow-scroll"> | ||
{/* NOTE: Div to test the horizontal overflow */} | ||
<div className="mt-4" style={{ width: '130%' }}> | ||
{/* | ||
NOTE: We don't need a separate table component, but it's easier | ||
to have one while using mocked data in order to keep this component clean | ||
*/} | ||
<DashboardTable data={mockedData} /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DataToolDetails; |
67 changes: 67 additions & 0 deletions
67
frontend/src/containers/data-tool/content/details/mocked-data.ts
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,67 @@ | ||
import { DashboardTableItem } from '@/components/dashboard-table'; | ||
|
||
export const mockedData: DashboardTableItem[] = [ | ||
{ | ||
location: 'United Kingdom', | ||
locationId: 'GB', | ||
type: 'country', | ||
signedInitiative: true, | ||
score: 0.6, | ||
ecosystems: ['Mangroves', 'Open ocean', 'Kelp forest'], | ||
updated: new Date('2023-08-01'), | ||
}, | ||
{ | ||
location: 'Mexico', | ||
locationId: 'MX', | ||
type: 'country', | ||
signedInitiative: false, | ||
score: undefined, | ||
ecosystems: [], | ||
updated: new Date('2023-07-01'), | ||
}, | ||
{ | ||
location: 'Spain', | ||
locationId: 'ES', | ||
type: 'country', | ||
signedInitiative: true, | ||
score: 3.0, | ||
ecosystems: ['Open ocean'], | ||
updated: new Date('2022-10-01'), | ||
}, | ||
{ | ||
location: 'Brazil', | ||
locationId: 'BR', | ||
type: 'country', | ||
signedInitiative: false, | ||
score: undefined, | ||
ecosystems: [], | ||
updated: new Date('2023-01-01'), | ||
}, | ||
{ | ||
location: 'France', | ||
locationId: 'FR', | ||
type: 'country', | ||
signedInitiative: true, | ||
score: 12.7, | ||
ecosystems: ['Mangroves'], | ||
updated: new Date('2021-12-01'), | ||
}, | ||
{ | ||
location: 'Netherlands', | ||
locationId: 'NL', | ||
type: 'country', | ||
signedInitiative: true, | ||
score: 1.6, | ||
ecosystems: ['Kelp forest', 'Open ocean'], | ||
updated: new Date('2022-02-01'), | ||
}, | ||
{ | ||
location: 'Worldwide', | ||
locationId: 'worldwide', | ||
type: 'region', | ||
signedInitiative: true, | ||
score: 1.6, | ||
ecosystems: ['Coral reefs', 'Kelp forest', 'Open ocean'], | ||
updated: new Date('2023-04-01'), | ||
}, | ||
]; |
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,17 @@ | ||
import { useSyncDataToolContentSettings } from '@/containers/data-tool/sync-settings'; | ||
|
||
import Details from './details'; | ||
import Map from './map'; | ||
// import Table from './table'; | ||
|
||
const DataToolContent: React.FC = () => { | ||
return <Map />; | ||
const [{ showDetails }] = useSyncDataToolContentSettings(); | ||
|
||
return ( | ||
<div className="relative h-full w-full"> | ||
<Map /> | ||
{showDetails && <Details />} | ||
</div> | ||
); | ||
}; | ||
|
||
export default DataToolContent; |
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 was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
frontend/src/containers/data-tool/sidebar/details-button/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,26 @@ | ||
import { ArrowRight } from 'lucide-react'; | ||
|
||
import { Button } from '@/components/ui/button'; | ||
import { useSyncDataToolContentSettings } from '@/containers/data-tool/sync-settings'; | ||
|
||
const DetailsButton: React.FC = () => { | ||
const [, setSettings] = useSyncDataToolContentSettings(); | ||
|
||
const handleButtonClick = () => { | ||
setSettings((prevSettings) => ({ ...prevSettings, showDetails: true })); | ||
}; | ||
|
||
return ( | ||
<Button | ||
className="flex justify-between" | ||
variant="sidebar-details" | ||
size="full" | ||
onClick={handleButtonClick} | ||
> | ||
<span className="pt-1">Marine Conservation Details</span> | ||
<ArrowRight aria-hidden /> | ||
</Button> | ||
); | ||
}; | ||
|
||
export default DetailsButton; |
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,15 @@ | ||
import { useQueryState } from 'next-usequerystate'; | ||
import { parseAsJson } from 'next-usequerystate/parsers'; | ||
|
||
const DEFAULT_SYNC_CONTENT_SETTINGS: { | ||
showDetails: boolean; | ||
} = { | ||
showDetails: false, | ||
}; | ||
|
||
export const useSyncDataToolContentSettings = () => { | ||
return useQueryState( | ||
'content', | ||
parseAsJson<typeof DEFAULT_SYNC_CONTENT_SETTINGS>().withDefault(DEFAULT_SYNC_CONTENT_SETTINGS) | ||
); | ||
}; |