-
Notifications
You must be signed in to change notification settings - Fork 1
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 #20 from Vizzuality/AF-map-settings-styles
[FE](styles): fix map settings
- Loading branch information
Showing
4 changed files
with
64 additions
and
3 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
59 changes: 59 additions & 0 deletions
59
client/src/containers/map/settings/basemaps/item/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,59 @@ | ||
import { useCallback } from 'react'; | ||
|
||
import Image from 'next/image'; | ||
|
||
import { useAtomValue, useSetAtom } from 'jotai'; | ||
|
||
import { cn } from '@/lib/classnames'; | ||
|
||
import { mapSettingsAtom } from '@/store/index'; | ||
|
||
export interface BasemapItemProps { | ||
label: string; | ||
value: string; | ||
preview: string; | ||
} | ||
|
||
const BasemapItem = ({ label, value, preview }: BasemapItemProps) => { | ||
const { basemap } = useAtomValue(mapSettingsAtom); | ||
const setMapSettings = useSetAtom(mapSettingsAtom); | ||
|
||
const handleToggleBasemap = useCallback(() => { | ||
setMapSettings((prev) => ({ | ||
...prev, | ||
basemap: value, | ||
})); | ||
}, [value, setMapSettings]); | ||
|
||
return ( | ||
<div className="flex w-full items-center justify-between space-x-8"> | ||
<button className="group grow" type="button" onClick={handleToggleBasemap}> | ||
<div className="space-y-2"> | ||
<div | ||
className={cn({ | ||
'shrink-0 overflow-hidden rounded transition-opacity': true, | ||
'group-hover:opacity-75 group-active:outline group-active:outline-2 group-active:outline-slate-400': | ||
true, | ||
'outline outline-2 outline-slate-500 group-hover:opacity-100 group-active:outline-slate-500': | ||
value === basemap, | ||
})} | ||
> | ||
<Image src={preview} alt={label} width={96} height={64} className="w-full rounded" /> | ||
</div> | ||
|
||
<span | ||
className={cn({ | ||
'block text-sm font-light text-slate-500 transition-colors': true, | ||
'group-hover:text-slate-400': true, | ||
'group-hover:text-slate-500': value === basemap, | ||
})} | ||
> | ||
{label} | ||
</span> | ||
</div> | ||
</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default BasemapItem; |