forked from electricitymaps/electricitymaps-contrib
-
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.
feat(web): add production source legends to data source accordion for…
… carbon and emission chart (electricitymaps#6728) * add production source legends to data sources for carbon and emission chart * add legends to bar-breakdown * fix: assumes is not shown in data sources * add power generation and emission factor to all charts * remove data sources when graph is disabled * fix source alignment * hide when no sources * fix: use not ! instead of == undefined | null * fix: based on tonys comments * fix: create hook useZoneDataSources * renameing * fix: remove productionSourceLegendList from breakdownChart when it is disabled * remove padding and move files around * fix: sort imports
- Loading branch information
1 parent
4829414
commit 64f2912
Showing
21 changed files
with
366 additions
and
217 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
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,51 @@ | ||
import { ElectricityModeType } from 'types'; | ||
|
||
import ProductionSourceLegend from './ProductionSourceLegend'; | ||
|
||
export function DataSources({ | ||
title, | ||
icon, | ||
sources, | ||
emissionFactorSourcesToProductionSources, | ||
}: { | ||
title: string; | ||
icon: React.ReactNode; | ||
sources: string[]; | ||
emissionFactorSourcesToProductionSources?: { [key: string]: string[] }; | ||
}) { | ||
const showDataSources = Boolean( | ||
(sources && sources?.length > 0) || emissionFactorSourcesToProductionSources | ||
); | ||
if (showDataSources == false) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className="flex flex-col py-2"> | ||
<div className="flex flex-row pb-2"> | ||
<div className="mr-1">{icon}</div> | ||
<div className="text-md font-semibold">{title}</div> | ||
</div> | ||
<div className="flex flex-col gap-2 pl-5"> | ||
{sources.sort().map((source, index) => ( | ||
<div key={index} className="text-sm"> | ||
{source} | ||
{emissionFactorSourcesToProductionSources && ( | ||
<span className="inline-flex translate-y-1 gap-1 pl-1.5"> | ||
{emissionFactorSourcesToProductionSources[source]?.map( | ||
(productionSource, index) => ( | ||
<span key={index} className="self-center object-center text-xs"> | ||
<ProductionSourceLegend | ||
electricityType={productionSource as ElectricityModeType} | ||
/> | ||
</span> | ||
) | ||
)} | ||
</span> | ||
)} | ||
</div> | ||
))} | ||
</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
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.
Oops, something went wrong.