Created
November 6, 2024 16:05
-
-
Save aeischeid/91eba0be747aedcbc63fb85f43c086e3 to your computer and use it in GitHub Desktop.
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
import { Paper, ToggleButton, ToggleButtonGroup } from "@mui/material"; | |
import { useStore } from "@nanostores/react"; | |
import { atom } from "nanostores"; | |
export type EmissionsView = "Market-Based" | "Location-Based"; | |
const EMISSIONS_VIEWS: Array<EmissionsView> = [ | |
"Market-Based", | |
"Location-Based", | |
] as const; | |
export const selectedEmissionsView = atom<EmissionsView>(EMISSIONS_VIEWS[0]); | |
export default function EmissionsViewSelect() { | |
const $selectedEmissionsView = useStore(selectedEmissionsView); | |
return ( | |
<Paper | |
elevation={0} | |
variant="outlined" | |
sx={{ | |
display: "inline-block", | |
}} | |
> | |
<ToggleButtonGroup | |
value={$selectedEmissionsView} | |
exclusive | |
onChange={(e, value) => { | |
selectedEmissionsView.set(value); | |
}} | |
aria-label="emissions view toggle button" | |
sx={{ | |
"& .MuiToggleButtonGroup-grouped": { | |
margin: "calc(var(--mui-spacing) * .5)", | |
border: 0, | |
borderRadius: "calc(var(--mui-shape-borderRadius) - 2px)", | |
}, | |
"& .MuiToggleButtonGroup-lastButton": { | |
marginLeft: 0, | |
}, | |
}} | |
size="small" | |
> | |
<ToggleButton value="Market-Based">Market-Based</ToggleButton> | |
<ToggleButton value="Location-Based">Location-Based</ToggleButton> | |
</ToggleButtonGroup> | |
</Paper> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment