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 { useState, useEffect } from "react";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import {
|
import { Typography, ButtonGroup, Stack } from "@mui/material";
|
||||||
Select,
|
|
||||||
MenuItem,
|
|
||||||
Typography,
|
|
||||||
ButtonGroup,
|
|
||||||
Stack,
|
|
||||||
} from "@mui/material";
|
|
||||||
|
|
||||||
import Button from "../../Components/Button";
|
import Button from "../../Components/Button";
|
||||||
import axiosInstance from "../../Utils/axiosConfig";
|
import axiosInstance from "../../Utils/axiosConfig";
|
||||||
@@ -15,6 +9,7 @@ import { StatusLabel } from "../../Components/Label";
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
|
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
import Select from "../../Components/Inputs/Select";
|
||||||
|
|
||||||
const Incidents = () => {
|
const Incidents = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -59,6 +54,7 @@ const Incidents = () => {
|
|||||||
fetchIncidents();
|
fetchIncidents();
|
||||||
}, [authState]);
|
}, [authState]);
|
||||||
|
|
||||||
|
console.log(monitors);
|
||||||
const handleSelect = (event) => {
|
const handleSelect = (event) => {
|
||||||
setSelectedMonitor(event.target.value);
|
setSelectedMonitor(event.target.value);
|
||||||
};
|
};
|
||||||
@@ -118,16 +114,14 @@ const Incidents = () => {
|
|||||||
>
|
>
|
||||||
<Stack direction="row" alignItems="center" gap={theme.gap.medium}>
|
<Stack direction="row" alignItems="center" gap={theme.gap.medium}>
|
||||||
<Typography component="h1">Incident history for: </Typography>
|
<Typography component="h1">Incident history for: </Typography>
|
||||||
<Select value={selectedMonitor} onChange={handleSelect}>
|
<Select
|
||||||
<MenuItem value={"0"}>All servers</MenuItem>
|
id="incidents-select-monitor"
|
||||||
{Object.values(monitors).map((monitor) => {
|
placeholder="All servers"
|
||||||
return (
|
value={selectedMonitor}
|
||||||
<MenuItem key={monitor._id} value={monitor._id}>
|
onChange={handleSelect}
|
||||||
{monitor.name}
|
items={Object.values(monitors)}
|
||||||
</MenuItem>
|
field="name"
|
||||||
);
|
/>
|
||||||
})}
|
|
||||||
</Select>
|
|
||||||
<ButtonGroup sx={{ ml: "auto" }}>
|
<ButtonGroup sx={{ ml: "auto" }}>
|
||||||
<Button
|
<Button
|
||||||
level="secondary"
|
level="secondary"
|
||||||
@@ -158,7 +152,7 @@ const Incidents = () => {
|
|||||||
/>
|
/>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
</Stack>
|
</Stack>
|
||||||
<BasicTable data={data} paginated={true} rowsPerPage={12}/>
|
<BasicTable data={data} paginated={true} rowsPerPage={12} />
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user