Implemented select component and added styling
This commit is contained in:
1 parent
2147f14ff7
commit
dd4d5faf33
3 files changed
+96
-18
No files matched your search
@@ -0,0 +1,19 @@
|
||||
.select-component > .MuiSelect-select {
|
||||
height: 34px !important;
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
}
|
||||
.MuiInputBase-root:has(> .MuiSelect-select) {
|
||||
min-width: 150px;
|
||||
}
|
||||
.MuiInputBase-root:has(> .MuiSelect-select),
|
||||
.MuiMenu-List .MuiMenuItem-root {
|
||||
font-size: var(--env-var-font-size-medium);
|
||||
color: var(--env-var-color-5);
|
||||
}
|
||||
.MuiInputBase-root:has(> .MuiSelect-select) fieldset {
|
||||
border-color: var(--env-var-color-29);
|
||||
}
|
||||
.MuiInputBase-root:not(.Mui-focused):has(> .MuiSelect-select):hover fieldset {
|
||||
border-color: var(--env-var-color-29);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import { useTheme } from "@emotion/react";
|
||||
import { MenuItem, Select as MuiSelect } from "@mui/material";
|
||||
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
|
||||
|
||||
import "./index.css";
|
||||
|
||||
const Select = ({ id, placeholder, isHidden, value, items, onChange, sx }) => {
|
||||
const theme = useTheme();
|
||||
const itemStyles = {
|
||||
fontSize: "var(--env-var-font-size-medium)",
|
||||
color: theme.palette.otherColors.bluishGray,
|
||||
textTransform: "capitalize",
|
||||
borderRadius: `${theme.shape.borderRadius}px`,
|
||||
margin: theme.gap.xs,
|
||||
};
|
||||
|
||||
return (
|
||||
<MuiSelect
|
||||
id={id}
|
||||
className="select-component"
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
displayEmpty
|
||||
MenuProps={{
|
||||
PaperProps: {
|
||||
style: {
|
||||
marginTop: theme.gap.xs,
|
||||
},
|
||||
},
|
||||
MenuListProps: {
|
||||
style: { padding: 0 },
|
||||
},
|
||||
}}
|
||||
IconComponent={KeyboardArrowDownIcon}
|
||||
sx={{ ...sx }}
|
||||
>
|
||||
{placeholder && (
|
||||
<MenuItem
|
||||
className="select-placeholder"
|
||||
value="0"
|
||||
sx={{
|
||||
display: isHidden ? "none" : "flex",
|
||||
visibility: isHidden ? "none" : "visible",
|
||||
...itemStyles,
|
||||
}}
|
||||
>
|
||||
{placeholder}
|
||||
</MenuItem>
|
||||
)}
|
||||
{items.map((item) => (
|
||||
<MenuItem
|
||||
value={item._id}
|
||||
key={`${id}-${item._id}`}
|
||||
sx={{
|
||||
...itemStyles,
|
||||
}}
|
||||
>
|
||||
{item.name}
|
||||
</MenuItem>
|
||||
))}
|
||||
</MuiSelect>
|
||||
);
|
||||
};
|
||||
|
||||
export default Select;
|
||||
@@ -1,12 +1,6 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import { useSelector } from "react-redux";
|
||||
import {
|
||||
Select,
|
||||
MenuItem,
|
||||
Typography,
|
||||
ButtonGroup,
|
||||
Stack,
|
||||
} from "@mui/material";
|
||||
import { Typography, ButtonGroup, Stack } from "@mui/material";
|
||||
|
||||
import Button from "../../Components/Button";
|
||||
import axiosInstance from "../../Utils/axiosConfig";
|
||||
@@ -15,6 +9,7 @@ import { StatusLabel } from "../../Components/Label";
|
||||
import { useTheme } from "@emotion/react";
|
||||
|
||||
import "./index.css";
|
||||
import Select from "../../Components/Inputs/Select";
|
||||
|
||||
const Incidents = () => {
|
||||
const theme = useTheme();
|
||||
@@ -59,6 +54,7 @@ const Incidents = () => {
|
||||
fetchIncidents();
|
||||
}, [authState]);
|
||||
|
||||
console.log(monitors);
|
||||
const handleSelect = (event) => {
|
||||
setSelectedMonitor(event.target.value);
|
||||
};
|
||||
@@ -118,16 +114,14 @@ const Incidents = () => {
|
||||
>
|
||||
<Stack direction="row" alignItems="center" gap={theme.gap.medium}>
|
||||
<Typography component="h1">Incident history for: </Typography>
|
||||
<Select value={selectedMonitor} onChange={handleSelect}>
|
||||
<MenuItem value={"0"}>All servers</MenuItem>
|
||||
{Object.values(monitors).map((monitor) => {
|
||||
return (
|
||||
<MenuItem key={monitor._id} value={monitor._id}>
|
||||
{monitor.name}
|
||||
</MenuItem>
|
||||
);
|
||||
})}
|
||||
</Select>
|
||||
<Select
|
||||
id="incidents-select-monitor"
|
||||
placeholder="All servers"
|
||||
value={selectedMonitor}
|
||||
onChange={handleSelect}
|
||||
items={Object.values(monitors)}
|
||||
field="name"
|
||||
/>
|
||||
<ButtonGroup sx={{ ml: "auto" }}>
|
||||
<Button
|
||||
level="secondary"
|
||||
@@ -158,7 +152,7 @@ const Incidents = () => {
|
||||
/>
|
||||
</ButtonGroup>
|
||||
</Stack>
|
||||
<BasicTable data={data} paginated={true} rowsPerPage={12}/>
|
||||
<BasicTable data={data} paginated={true} rowsPerPage={12} />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user