Skip to content

Commit

Permalink
feat: add status selector
Browse files Browse the repository at this point in the history
  • Loading branch information
Melichka authored and the-homeless-god committed Aug 31, 2024
1 parent 54d6786 commit 1cc2665
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Box } from "@mui/material"
import { styled } from "@mui/system"

export const StatusCircle = styled(Box)({
width: 14,
height: 14,
borderRadius: "50%",
display: "inline-block",
marginRight: 8,
})

export const StyledFormControl = styled("div")({
width: "80px",
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from "react"

import { MenuItem, Select } from "@mui/material"

import { StatusCircle, StyledFormControl } from "./StatusSelector.styled"

interface StatusSelectorProps {
value: string
onChange: (value: string) => void
}

export const StatusSelector: React.FC<StatusSelectorProps> = ({ value, onChange }) => {
const statusOptions = [
{ value: "Error", color: "red" },
{ value: "Warning", color: "orange" },
{ value: "Success", color: "green" },
{ value: "None", color: "gray" },
]

return (
<StyledFormControl>
<Select
value={value}
onChange={(e) => onChange(e.target.value as string)}
displayEmpty
variant="outlined"
inputProps={{ "aria-label": "Status Selector" }}
>
{statusOptions.map((option) => (
<MenuItem key={option.value} value={option.value}>
<StatusCircle sx={{ backgroundColor: option.color }} />
</MenuItem>
))}
</Select>
</StyledFormControl>
)
}

export default StatusSelector
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { StatusSelector } from "./StatusSelector"

0 comments on commit 1cc2665

Please sign in to comment.