Added icon to filter by status dropdown.

This commit is contained in:
M M committed 2024-07-02 21:07:15 -07:00
1 parent 8453542777
commit f7e8e69168
1 file changed
+25 -10
+25 -10
View File
@@ -11,6 +11,7 @@ import TableRow from '@mui/material/TableRow';
import Paper from '@mui/material/Paper'; import Paper from '@mui/material/Paper';
import Box from '@mui/material/Box'; import Box from '@mui/material/Box';
import { StatusLabel } from "../../Components/Label/"; import { StatusLabel } from "../../Components/Label/";
import TuneIcon from '@mui/icons-material/Tune'; // Import TuneIcon
const StyledTableCell = styled(TableCell)(({ theme }) => ({ const StyledTableCell = styled(TableCell)(({ theme }) => ({
[`&.${tableCellClasses.head}`]: { [`&.${tableCellClasses.head}`]: {
@@ -39,10 +40,10 @@ const filterOptions = createFilterOptions({
stringify: (option) => option.title, stringify: (option) => option.title,
}); });
const top100Films = [ const titles = [
{ title: 'The Shawshank Redemption', year: 1994 }, { title: 'Down' },
{ title: 'The Dark Knight', year: 2008 }, { title: 'Cannot resolve'},
{ title: '12 Angry Men', year: 1957 }, { title: 'Clear / show all'},
]; ];
function createData(name, date, message) { function createData(name, date, message) {
@@ -72,7 +73,7 @@ export default function CustomizedTables() {
}, },
}} }}
> >
<Box sx={{ display: 'flex', justifyContent: 'flex-end', marginBottom: theme.spacing(2) }}> <Box sx={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center', marginBottom: theme.spacing(2) }}>
<Filter /> <Filter />
</Box> </Box>
<TableContainer component={Paper}> <TableContainer component={Paper}>
@@ -105,16 +106,30 @@ function Filter() {
return ( return (
<Autocomplete <Autocomplete
id="filter-demo" id="filter-demo"
options={top100Films} options={titles}
getOptionLabel={(option) => option.title} getOptionLabel={(option) => option.title}
filterOptions={filterOptions} filterOptions={filterOptions}
sx={{ width: 300 }} sx={{
disableClearable // This disables the clearable (x) button width: 170, // Adjust width as needed
'& .MuiAutocomplete-inputRoot': {
height: '50px', // Adjust the height of the input field
},
'& .MuiAutocomplete-listbox': {
maxHeight: '200px', // Adjust the max height of the dropdown list
},
}}
disableClearable
renderInput={(params) => ( renderInput={(params) => (
<TextField <TextField
{...params} {...params}
label="Filter by Status" size="small"
InputProps={{ ...params.InputProps, endAdornment: null }} // Hides the end adornment (arrow icon) label={
<React.Fragment>
<TuneIcon sx={{ marginRight: '0.5rem', position: 'relative', top: '6px' }} />
Filter by status
</React.Fragment>
}
InputProps={{ ...params.InputProps, endAdornment: null }}
/> />
)} )}
/> />