-
Notifications
You must be signed in to change notification settings - Fork 16
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
carbon capture modal #1979
Open
sunilsabatp
wants to merge
14
commits into
develop
Choose a base branch
from
feature/carbon_capture_modal
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
carbon capture modal #1979
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b0c6ba7
carbon capture modal
sunilsabatp c99ca99
enable chromatic
sunilsabatp 811cff4
fix transalation issue
sunilsabatp b1ec8ec
see more button functionality
sunilsabatp dfaa4c0
bar graph
sunilsabatp 581eb28
refactor: carbon capture component
sunilsabatp 6d0c684
minor change in alignment of item
sunilsabatp b6b4e7f
Merge branch 'feature/redesign-explore-btn' into feature/carbon_captu…
sunilsabatp 1a499ec
remove hard code color and font-size
sunilsabatp a80ad2d
fix carbon capture UI break
sunilsabatp c2e49dc
remove duplicate svg
sunilsabatp 1642346
work on feedback
sunilsabatp 0509398
work on feedback
sunilsabatp ad0d272
refactor: merge base branch, resolve conflicts, and perform minor cod…
sunilsabatp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,3 +1,14 @@ | ||
{ | ||
"satelliteAnalysis": "Satellite Analysis" | ||
} | ||
"satelliteAnalysis": "Satellite Analysis", | ||
"beforeIntervention": "Before intervention", | ||
"co₂Quantity": "~{{quantity}}t", | ||
"before": "before {{date}}", | ||
"byProject": "By Project", | ||
"byProjectCO₂Quantity": "v{{quantity}}t", | ||
"since": "since {{date}}", | ||
"sitePotential": "Site Potential", | ||
"seeMore": "See More", | ||
"seeLess": "See Less", | ||
"totalCo2Captured": "Total CO₂ Captured", | ||
"tons": "tons" | ||
} |
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,102 @@ | ||
import style from './CarbonCapture.module.scss'; | ||
import { useTranslation } from 'next-i18next'; | ||
import { getFormattedNumber } from '../../utils/getFormattedNumber'; | ||
|
||
interface CO2BarGraphProps { | ||
beforeIntervation: number; | ||
byProject: number; | ||
sitePotential: number; | ||
} | ||
|
||
export const CO2BarGraph = ({ | ||
beforeIntervation, | ||
byProject, | ||
sitePotential, | ||
}: CO2BarGraphProps) => { | ||
const calculatePercentage = (value: number, sitePotential: number) => { | ||
return (value / sitePotential) * 100; | ||
}; | ||
|
||
const beforeIntervationPercentage = calculatePercentage( | ||
beforeIntervation, | ||
sitePotential | ||
); | ||
const byProjectPercentage = calculatePercentage(byProject, sitePotential); | ||
|
||
return ( | ||
<div className={style.carbonCaptureIndicator}> | ||
<div | ||
style={{ | ||
width: `${beforeIntervationPercentage}%`, | ||
}} | ||
className={style.beforeIntervationIndicator} | ||
/> | ||
|
||
<div | ||
style={{ | ||
width: `${byProjectPercentage}%`, | ||
}} | ||
className={style.byProjectIndicator} | ||
/> | ||
|
||
<div | ||
style={{ | ||
width: `${ | ||
100 - (beforeIntervationPercentage + byProjectPercentage) | ||
}%`, | ||
}} | ||
className={style.projectPotential} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export const CO2CaptureData = ({ | ||
beforeIntervation, | ||
byProject, | ||
sitePotential, | ||
}: CO2BarGraphProps) => { | ||
const { t, i18n } = useTranslation(['projectDetails']); | ||
return ( | ||
<div className={style.carbonCaptureDataContainerMain}> | ||
<div> | ||
<p className={style.beforeIntervationData}> | ||
{t('projectDetails:co₂Quantity', { | ||
quantity: getFormattedNumber(i18n.language, beforeIntervation), | ||
})} | ||
</p> | ||
<p className={style.beforeIntervationLabel}> | ||
{t('projectDetails:beforeIntervention')} | ||
</p> | ||
<p className={style.beforeIntervationDate}> | ||
{t('projectDetails:before', { | ||
date: 2018, | ||
})} | ||
</p> | ||
</div> | ||
<div> | ||
<p className={style.byProjectData}> | ||
{t('projectDetails:byProjectCO₂Quantity', { | ||
quantity: getFormattedNumber(i18n.language, byProject), | ||
})} | ||
</p> | ||
<p className={style.byProjectLabel}>{t('projectDetails:byProject')}</p> | ||
<p className={style.byProjectDate}> | ||
{t('projectDetails:since', { | ||
date: 2018, | ||
})} | ||
</p> | ||
</div> | ||
<div className={style.sitePotentialDataContainer}> | ||
<p className={style.sitePotentialData}> | ||
{t('projectDetails:co₂Quantity', { | ||
quantity: getFormattedNumber(i18n.language, sitePotential), | ||
})} | ||
</p> | ||
<p className={style.sitePotentialLabel}> | ||
{t('projectDetails:sitePotential')} | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
}; |
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,180 @@ | ||
@import '../../theme/theme'; | ||
|
||
.carbonCaptureMainContainer { | ||
width: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.carbonCaptureInfoContainer { | ||
display: flex; | ||
height: 111px; | ||
flex-direction: column; | ||
gap: 12px; | ||
padding-left: 15.5px; | ||
padding-right: 15.5px; | ||
} | ||
|
||
.carbonCaptureLabelMainContainer { | ||
font-size: $fontXXSmall; | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
|
||
.carbonCaptureLabelContainer { | ||
display: flex; | ||
align-items: center; | ||
> .carbonCapture { | ||
display: flex; | ||
font-weight: 700; | ||
gap: 2px; | ||
p { | ||
font-weight: 400; | ||
} | ||
} | ||
.unit { | ||
margin-left: 1px; | ||
} | ||
} | ||
|
||
.carbonCaptureDetailContainer { | ||
padding-left: 16px; | ||
padding-right: 16px; | ||
padding-top: 16px; | ||
border: 1px solid rgba(111, 207, 151, 0.02); | ||
background: linear-gradient( | ||
0deg, | ||
rgba(33, 150, 83, 0.1) 0%, | ||
rgba(33, 150, 83, 0.1) 100% | ||
), | ||
$light; | ||
|
||
height: 70px; | ||
border-radius: 12px; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 10px; | ||
} | ||
|
||
.carbonCaptureIndicator { | ||
max-width: 274px; | ||
height: 11px; | ||
display: flex; | ||
border-radius: 3px; | ||
|
||
.beforeIntervationIndicator { | ||
width: 100%; | ||
height: 100%; | ||
background: rgba(0, 122, 73, 1); | ||
border-top-left-radius: 3px; | ||
border-bottom-left-radius: 3px; | ||
} | ||
.byProjectIndicator { | ||
width: 100%; | ||
background: rgba(104, 176, 48, 1); | ||
height: 100%; | ||
} | ||
.projectPotential { | ||
width: 100%; | ||
background: $light; | ||
height: 100%; | ||
border-top-right-radius: 3px; | ||
border-bottom-right-radius: 3px; | ||
} | ||
} | ||
|
||
.carbonCaptureDataContainerMain { | ||
display: flex; | ||
width: 100%; | ||
justify-content: space-between; | ||
} | ||
.carbonCaptureDataContainer { | ||
display: flex; | ||
padding-left: 16px; | ||
padding-top: 4px; | ||
padding-right: 16px; | ||
} | ||
.beforeIntervationData { | ||
color: $primaryColorNew; | ||
font-size: $fontXXXSmallNew; | ||
font-weight: 700; | ||
} | ||
.beforeIntervationLabel { | ||
font-size: $fontXXXSmallNew; | ||
font-weight: 400; | ||
} | ||
.beforeIntervationDate { | ||
font-size: 6px; | ||
color: $nonDonatableProjectBackgroundColor; | ||
} | ||
.byProjectData { | ||
color: $primaryColor; | ||
font-size: $fontXXXSmallNew; | ||
font-weight: 700; | ||
} | ||
.byProjectLabel { | ||
font-size: $fontXXXSmallNew; | ||
font-weight: 400; | ||
} | ||
.byProjectDate { | ||
font-size: 6px; | ||
color: $nonDonatableProjectBackgroundColor; | ||
} | ||
.sitePotentialDataContainer { | ||
display: flex; | ||
align-items: flex-end; | ||
flex-direction: column; | ||
.sitePotentialData { | ||
color: #333; | ||
font-size: $fontXXXSmallNew; | ||
font-weight: bold; | ||
} | ||
.sitePotentialLabel { | ||
font-size: $fontXXXSmallNew; | ||
font-weight: 400; | ||
} | ||
} | ||
|
||
.carbonCaptureModal { | ||
max-width: 338px; | ||
border-radius: 16px; | ||
overflow: hidden; | ||
background-color: $light; | ||
} | ||
|
||
.infoIconContainer { | ||
cursor: pointer; | ||
} | ||
|
||
.seeMoreButton { | ||
background: linear-gradient(0deg, $primaryColorNew 0%, $primaryColorNew 100%), | ||
$light; | ||
width: 100%; | ||
height: 27px; | ||
margin-top: 24px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
cursor: pointer; | ||
} | ||
|
||
.seeMoreLabel { | ||
font-size: $fontXXXSmallNew; | ||
font-weight: 700; | ||
color: $light; | ||
} | ||
|
||
.downArrow { | ||
margin-left: 5px; | ||
margin-bottom: 5px; | ||
} | ||
|
||
.horizontalLine { | ||
position: relative; | ||
top: -8px; | ||
} | ||
|
||
.carbonCaptureValue { | ||
margin-left: 2px; | ||
font-weight: 400; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
LGTM with a minor optimization suggestion.
The
CO2BarGraph
component is well-implemented and correctly visualizes the carbon capture data. Consider this small optimization:You can optimize the percentage calculations by computing them once and reusing the results:
This change improves readability and avoids recalculating the remaining percentage.
📝 Committable suggestion