Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign vegetation change data box #1966

Draft
wants to merge 24 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b89689d
add icons
prachigarg19 Jan 29, 2024
1d74e68
feat: add dropdown
prachigarg19 Jan 29, 2024
a217aee
feat: add slider
prachigarg19 Jan 30, 2024
80f8621
style: fix slider
prachigarg19 Jan 30, 2024
352ce37
feat: add new info icon
prachigarg19 Jan 30, 2024
172a6a8
feat: combine all components to form databox
prachigarg19 Jan 30, 2024
76fd138
add chromatic workflow
prachigarg19 Jan 30, 2024
4f6a2d2
refactor: resolve ts errors
prachigarg19 Jan 30, 2024
9f5cd37
fix: add static width to dropdown
prachigarg19 Jan 30, 2024
470ed95
style: add responsiveness
prachigarg19 Jan 30, 2024
60fd8a0
style: restyle thumb
prachigarg19 Jan 30, 2024
840da77
remove dropdown story
prachigarg19 Feb 2, 2024
18269de
fix styles issues
prachigarg19 Feb 2, 2024
d5b011e
Merge branch 'feature/redesign-explore-btn' into feature/design-veget…
prachigarg19 Feb 12, 2024
ec7cf49
add translations
prachigarg19 Feb 12, 2024
e30e5b9
feat: add coming soon label
prachigarg19 Mar 15, 2024
04b08a4
style: improve responsiveness
prachigarg19 Mar 15, 2024
17dc0c0
style: fix dropdown icon shift
prachigarg19 Mar 15, 2024
bae1f2d
style: change cursor property
prachigarg19 Mar 15, 2024
983079b
Merge branch 'feature/redesign-explore-btn' into feature/design-veget…
prachigarg19 Mar 26, 2024
b91ee17
feat: add icons for dropdown
prachigarg19 Mar 26, 2024
ce5b9cc
style: fix slider labels and dropdown icons
prachigarg19 Mar 26, 2024
d886f9f
Merge branch 'feature/redesign-explore-btn' into feature/design-veget…
prachigarg19 Apr 12, 2024
6694c01
feat: add popup
prachigarg19 Apr 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- feature/storybook-update
- develop
- feature/redesign-explore-btn
- feature/design-vegetation-data-box
# List of jobs
jobs:
chromatic-deployment:
Expand Down
12 changes: 11 additions & 1 deletion public/static/locales/en/projectDetails.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
{
"satelliteAnalysis": "Satellite Analysis"
"satelliteAnalysis": "Satellite Analysis",
"biomassChange": "Biomass Change",
"potentialBiomass": "Potential Biomass",
"treeCover": "Tree Cover",
"fireRisk": "Fire Risk",
"floodingRisk": "Flooding Risk",
"speciesDensity": "Species Density",
"projectBegin": "Since project begin",
"avg": "Average",
"tons": "tons",
"comingSoon": "coming soon"
}
266 changes: 266 additions & 0 deletions src/temp/VegetationChangeDatabox/Databox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
import React, { useState } from 'react';
import styles from './VegetationChangeDatabox.module.scss';
import BiomassChangeIcon from '../icons/BiomassChangeIcon';
import VegetationSlider from './VegetationSlider';
import NewInfoIcon from '../icons/NewInfoIcon';
import { useTranslation } from 'next-i18next';
import CloseIcon from '../icons/CloseIcon';
import PotentialBiomassIcon from '../icons/PotentialBiomassIcon';
import TreeCoverIcon from '../icons/TreeCoverIcon';
import FireIcon from '../icons/FireIcon';
import SpeciesDensityIcon from '../icons/SpeciesDensityIcon';
import FloodingRiskIcon from '../icons/FloodingRiskIcon';
import DropdownDownArrow from '../icons/DropdownDownArrow';
import DropdownUpArrow from '../icons/DropdownUpArrow';

interface DataboxProps {
startYear: number;
}
interface PopupContent {
[key: string]: { heading: string; content: string }[];
}

const Databox = ({ startYear }: DataboxProps) => {
const { t } = useTranslation('projectDetails');
const [isPopupOpen, setIsPopupOpen] = useState(false);
const [selectedOption, setSelectedOption] = useState({
icon: <BiomassChangeIcon />,
title: t('biomassChange'),
name: `biomassChange`,
});
const [isMenuOpen, setIsMenuOpen] = useState(false);

const PopupContent: PopupContent = {
biomassChange: [
{
heading: ``,
content: `Areas where biomass has increased since the project begin appear in green. Areas where it has decreased substantially appear in red. No change appears white and mild decreases in grey.`,
},
{
heading: `Why the grey?`,
content: `This is because restoration projects routinely experience a small decrease in biomass at the beginning of the restoration work. This is not necessarily a bad thing.`,
},
{
heading: ``,
content: `For instance, when converting a degraded cattle ranch back to forest, a project might initially have to cut tall grass in order to plant small tree seedlings. It will take a few years before the biomass of the young trees exceeds the biomass of the removed grass.`,
},
{
heading: `Source`,
content: `The change is biomass is calculated by a Plant-for-the-Planet analysis model based on satellite data.`,
},
],
treeCover: [
{
heading: ``,
content: `Areas where biomass has increased since the project begin appear in green. Areas where it has decreased substantially appear in red. No change appears white and mild decreases in grey.`,
},
{
heading: `Why the grey?`,
content: `This is because restoration projects routinely experience a small decrease in biomass at the beginning of the restoration work. This is not necessarily a bad thing.`,
},
{
heading: ``,
content: `For instance, when converting a degraded cattle ranch back to forest, a project might initially have to cut tall grass in order to plant small tree seedlings. It will take a few years before the biomass of the young trees exceeds the biomass of the removed grass.`,
},
{
heading: `Source`,
content: `The change is biomass is calculated by a Plant-for-the-Planet analysis model based on satellite data.`,
},
],
potentialBiomass: [
{
heading: ``,
content: `Areas where biomass has increased since the project begin appear in green. Areas where it has decreased substantially appear in red. No change appears white and mild decreases in grey.`,
},
{
heading: `Why the grey?`,
content: `This is because restoration projects routinely experience a small decrease in biomass at the beginning of the restoration work. This is not necessarily a bad thing.`,
},
{
heading: ``,
content: `For instance, when converting a degraded cattle ranch back to forest, a project might initially have to cut tall grass in order to plant small tree seedlings. It will take a few years before the biomass of the young trees exceeds the biomass of the removed grass.`,
},
{
heading: `Source`,
content: `The change is biomass is calculated by a Plant-for-the-Planet analysis model based on satellite data.`,
},
],
fireRisk: [
{
heading: ``,
content: `Areas where biomass has increased since the project begin appear in green. Areas where it has decreased substantially appear in red. No change appears white and mild decreases in grey.`,
},
{
heading: `Why the grey?`,
content: `This is because restoration projects routinely experience a small decrease in biomass at the beginning of the restoration work. This is not necessarily a bad thing.`,
},
{
heading: ``,
content: `For instance, when converting a degraded cattle ranch back to forest, a project might initially have to cut tall grass in order to plant small tree seedlings. It will take a few years before the biomass of the young trees exceeds the biomass of the removed grass.`,
},
{
heading: `Source`,
content: `The change is biomass is calculated by a Plant-for-the-Planet analysis model based on satellite data.`,
},
],
floodingRisk: [
{
heading: ``,
content: `Areas where biomass has increased since the project begin appear in green. Areas where it has decreased substantially appear in red. No change appears white and mild decreases in grey.`,
},
{
heading: `Why the grey?`,
content: `This is because restoration projects routinely experience a small decrease in biomass at the beginning of the restoration work. This is not necessarily a bad thing.`,
},
{
heading: ``,
content: `For instance, when converting a degraded cattle ranch back to forest, a project might initially have to cut tall grass in order to plant small tree seedlings. It will take a few years before the biomass of the young trees exceeds the biomass of the removed grass.`,
},
{
heading: `Source`,
content: `The change is biomass is calculated by a Plant-for-the-Planet analysis model based on satellite data.`,
},
],
speciesDensity: [
{
heading: ``,
content: `Areas where biomass has increased since the project begin appear in green. Areas where it has decreased substantially appear in red. No change appears white and mild decreases in grey.`,
},
{
heading: `Why the grey?`,
content: `This is because restoration projects routinely experience a small decrease in biomass at the beginning of the restoration work. This is not necessarily a bad thing.`,
},
{
heading: ``,
content: `For instance, when converting a degraded cattle ranch back to forest, a project might initially have to cut tall grass in order to plant small tree seedlings. It will take a few years before the biomass of the young trees exceeds the biomass of the removed grass.`,
},
{
heading: `Source`,
content: `The change is biomass is calculated by a Plant-for-the-Planet analysis model based on satellite data.`,
},
],
};

const optionsList = [
{
icon: <BiomassChangeIcon />,
title: t('biomassChange'),
isFeaturePending: false,
name: `biomassChange`,
},
{
icon: <TreeCoverIcon />,
title: t('treeCover'),
isFeaturePending: false,
name: `treeCover`,
},
{
icon: <PotentialBiomassIcon />,
title: t('potentialBiomass'),
isFeaturePending: true,
name: `potentialBiomass`,
},
{
icon: <FireIcon />,
title: t('fireRisk'),
isFeaturePending: true,
name: `fireRisk`,
},
{
icon: <FloodingRiskIcon />,
title: t('floodingRisk'),
isFeaturePending: true,
name: `floodingRisk`,
},
{
icon: <SpeciesDensityIcon />,
title: t('speciesDensity'),
isFeaturePending: true,
name: `speciesDensity`,
},
];

return (
<div className={styles.databoxContainer}>
<div className={styles.dropdownInfoContainer}>
<div>
{isMenuOpen && (
<div className={styles.itemsContainer}>
<ul>
{optionsList?.map((option, index) => (
<li
key={index}
onClick={() => setSelectedOption(option)}
className={`${styles.menuItem} ${
option.title === selectedOption.title
? styles.selected
: ''
}`}
>
<div className={styles.optionIcon}>{option.icon}</div>
<div className={styles.optionLabel}>
<p>{option.title}</p>
{option.isFeaturePending && (
<span>{t('comingSoon')}</span>
)}
</div>
</li>
))}
</ul>
</div>
)}
<div
className={styles.menuButton}
onClick={() => setIsMenuOpen(!isMenuOpen)}
>
<div className={styles.label}>
{selectedOption.icon}
<p>{selectedOption.title}</p>
</div>
<div className={styles.dropdownIcon}>
{isMenuOpen ? (
<DropdownDownArrow width={10} />
) : (
<DropdownUpArrow width={8} />
)}
</div>
</div>
</div>
<p className={styles.startYearText}>
{t('projectBegin')} {startYear}
</p>
</div>
<div className={styles.divider}></div>
<div className={styles.sliderInfoContainer}>
<VegetationSlider position={5} />
<div
className={styles.infoIcon}
onMouseEnter={() => setIsPopupOpen(true)}
>
<NewInfoIcon width={10} color={`#BDBDBD`} />
</div>
</div>
{isPopupOpen && (
<div
className={styles.databoxPopup}
onMouseEnter={() => setIsPopupOpen(true)}
>
<div className={styles.popupHeading}>
<h6>Biomass Change Map</h6>
<button onClick={() => setIsPopupOpen(false)}>
<CloseIcon width={16} />
</button>
</div>
{PopupContent[selectedOption.name].map((item, index) => (
<div className={styles.popupItem} key={index}>
<h6>{item.heading}</h6>
<p>{item.content}</p>
</div>
))}
</div>
)}
</div>
);
};

export default Databox;
Loading