Skip to content

Commit 2ee5fb7

Browse files
committed
[grid] Refining the search field for running sessions
1 parent 4b14cf7 commit 2ee5fb7

File tree

2 files changed

+59
-12
lines changed

2 files changed

+59
-12
lines changed

javascript/grid-ui/src/components/RunningSessions/RunningSessions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ function RunningSessions (props) {
174174
const [selected, setSelected] = useState<string[]>([])
175175
const [page, setPage] = useState(0)
176176
const [dense, setDense] = useState(false)
177-
const [rowsPerPage, setRowsPerPage] = useState(5)
177+
const [rowsPerPage, setRowsPerPage] = useState(10)
178178
const [searchFilter, setSearchFilter] = useState('')
179179
const [searchBarHelpOpen, setSearchBarHelpOpen] = useState(false)
180180

javascript/grid-ui/src/components/RunningSessions/RunningSessionsSearchBar.tsx

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ import DialogActions from '@mui/material/DialogActions'
3232
import DialogContent from '@mui/material/DialogContent'
3333
import Button from '@mui/material/Button'
3434
import Box from '@mui/material/Box'
35+
import { alpha, styled } from '@mui/material/styles'
36+
import InputBase from '@mui/material/InputBase'
37+
import SearchIcon from '@mui/icons-material/Search'
3538

3639
interface RunningSessionsSearchBarProps {
3740
searchFilter: string
@@ -40,6 +43,48 @@ interface RunningSessionsSearchBarProps {
4043
setSearchBarHelpOpen: (value: boolean) => void
4144
}
4245

46+
const Search = styled('div')(({ theme }) => ({
47+
position: 'relative',
48+
borderRadius: theme.shape.borderRadius,
49+
backgroundColor: alpha(theme.palette.common.white, 0.15),
50+
'&:hover': {
51+
backgroundColor: alpha(theme.palette.common.white, 0.25),
52+
},
53+
marginLeft: 0,
54+
width: '100%',
55+
[theme.breakpoints.up('sm')]: {
56+
marginLeft: theme.spacing(1),
57+
width: 'auto',
58+
},
59+
}));
60+
61+
const SearchIconWrapper = styled('div')(({ theme }) => ({
62+
padding: theme.spacing(0, 2),
63+
height: '100%',
64+
position: 'absolute',
65+
pointerEvents: 'none',
66+
display: 'flex',
67+
alignItems: 'center',
68+
justifyContent: 'center',
69+
}));
70+
71+
const StyledInputBase = styled(InputBase)(({ theme }) => ({
72+
color: 'inherit',
73+
'& .MuiInputBase-input': {
74+
padding: theme.spacing(1, 1, 1, 0),
75+
// vertical padding + font size from searchIcon
76+
paddingLeft: `calc(1em + ${theme.spacing(4)})`,
77+
transition: theme.transitions.create('width'),
78+
width: '100%',
79+
[theme.breakpoints.up('sm')]: {
80+
width: '12ch',
81+
'&:focus': {
82+
width: '20ch',
83+
},
84+
},
85+
},
86+
}));
87+
4388
function RunningSessionsSearchBar ({
4489
searchFilter,
4590
handleSearch,
@@ -52,17 +97,19 @@ function RunningSessionsSearchBar ({
5297
display='flex'
5398
justifyContent='flex-end'
5499
>
55-
<OutlinedInput
56-
id='search-query-tab-running'
57-
autoFocus
58-
margin='dense'
59-
type='text'
60-
value={searchFilter}
61-
placeholder='search sessions...'
62-
onChange={(e) => {
63-
handleSearch(e.target.value)
64-
}}
65-
/>
100+
<Search>
101+
<SearchIconWrapper>
102+
<SearchIcon />
103+
</SearchIconWrapper>
104+
<StyledInputBase
105+
id='search-query-tab-running'
106+
autoFocus
107+
value={searchFilter}
108+
onChange={(e) => handleSearch(e.target.value)}
109+
placeholder="Search…"
110+
inputProps={{ 'aria-label': 'search' }}
111+
/>
112+
</Search>
66113
<IconButton
67114
sx={{ padding: '1px' }}
68115
onClick={() => setSearchBarHelpOpen(true)}

0 commit comments

Comments
 (0)