Skip to content

Commit

Permalink
add tooltips (electricitymaps#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Killendahl authored Dec 29, 2022
1 parent 75a9147 commit 3344f40
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion web/src/features/map-controls/MapControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ function WeatherButton({ type }: { type: 'wind' | 'solar' }) {
const [isLoadingLayer, setIsLoadingLayer] = useAtom(weatherButtonMap[type].loadingAtom);
const isEnabled = enabled === ToggleOptions.ON;
const Icon = weatherButtonMap[type].icon;
const tooltipTexts = {
wind: isEnabled ? __('tooltips.hideWindLayer') : __('tooltips.showWindLayer'),
solar: isEnabled ? __('tooltips.hideSolarLayer') : __('tooltips.showSolarLayer'),
};

const onToggle = () => {
if (!isEnabled) {
Expand All @@ -58,7 +62,7 @@ function WeatherButton({ type }: { type: 'wind' | 'solar' }) {
<Icon size={weatherButtonMap[type].iconSize} color={isEnabled ? '' : 'gray'} />
)
}
tooltipText={__(`tooltips.${type}}`)}
tooltipText={tooltipTexts[type]}
dataTestId={`${type}-layer-button`}
className={`${isLoadingLayer ? 'cursor-default' : 'cursor-pointer'}`}
onClick={!isLoadingLayer ? onToggle : () => {}}
Expand Down

0 comments on commit 3344f40

Please sign in to comment.