-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bai 1544 show entry kind for all results in top right search #1778
Changes from 7 commits
04d5558
631fae1
e5ac83a
0166aaa
e4d796a
050c324
0899fc6
2884a39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import SearchIcon from '@mui/icons-material/Search' | ||
import { Box, InputBase, List, ListItemButton, ListItemText, Popover, Stack } from '@mui/material' | ||
import { Box, Chip, InputBase, List, ListItem, ListItemButton, ListItemText, Popover, Stack } from '@mui/material' | ||
import { alpha, styled, useTheme } from '@mui/material/styles' | ||
import { useListModels } from 'actions/model' | ||
import { ChangeEvent, useMemo, useState } from 'react' | ||
|
@@ -8,6 +8,8 @@ import Loading from 'src/common/Loading' | |
import useDebounce from 'src/hooks/useDebounce' | ||
import Link from 'src/Link' | ||
import MessageAlert from 'src/MessageAlert' | ||
import { EntryKindLabel } from 'types/types' | ||
import { toTitleCase } from 'utils/stringUtils' | ||
|
||
const Search = styled('div')(({ theme }) => ({ | ||
borderRadius: theme.shape.borderRadius, | ||
|
@@ -53,28 +55,34 @@ export default function EntrySearch() { | |
const modelList = useMemo( | ||
() => | ||
entries.map((entry) => ( | ||
<Box key={entry.id} sx={{ maxWidth: '300px' }}> | ||
<Box key={entry.id} sx={{ maxWidth: '400px' }}> | ||
<Link href={`/${entry.kind}/${entry.id}`} noLinkStyle> | ||
<ListItemButton> | ||
<ListItemText | ||
primary={entry.name} | ||
secondary={entry.description} | ||
slotProps={{ | ||
primary: { | ||
style: { | ||
whiteSpace: 'nowrap', | ||
textOverflow: 'ellipsis', | ||
overflow: 'hidden', | ||
color: theme.palette.primary.main, | ||
<ListItem | ||
disablePadding | ||
secondaryAction={<Chip label={toTitleCase(EntryKindLabel[entry.kind])} size='small' />} | ||
> | ||
<ListItemButton> | ||
<ListItemText | ||
primary={entry.name} | ||
secondary={entry.description} | ||
slotProps={{ | ||
primary: { | ||
style: { | ||
whiteSpace: 'nowrap', | ||
textOverflow: 'ellipsis', | ||
overflow: 'hidden', | ||
color: theme.palette.primary.main, | ||
maxWidth: '400px', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because this is set to the same width as the surrounding box, really long names will appear under the entry kind chip. I'd suggest instead of settings this to a specific amount of pixels, giving it a |
||
}, | ||
}, | ||
}, | ||
|
||
secondary: { | ||
style: { whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden' }, | ||
}, | ||
}} | ||
/> | ||
</ListItemButton> | ||
secondary: { | ||
style: { whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden', maxWidth: '400px' }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, see my other comment about changing the |
||
}, | ||
}} | ||
/> | ||
</ListItemButton> | ||
</ListItem> | ||
</Link> | ||
</Box> | ||
)), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use
sx
here instead ofstyle
.