1 | // @mui
|
---|
2 | import { alpha } from '@mui/material/styles';
|
---|
3 | import Box from '@mui/material/Box';
|
---|
4 | import ListItemText from '@mui/material/ListItemText';
|
---|
5 | import ListItemButton from '@mui/material/ListItemButton';
|
---|
6 | // components
|
---|
7 | import Label from 'src/components/label';
|
---|
8 |
|
---|
9 | // ----------------------------------------------------------------------
|
---|
10 |
|
---|
11 | type Props = {
|
---|
12 | title: {
|
---|
13 | text: string;
|
---|
14 | highlight: boolean;
|
---|
15 | }[];
|
---|
16 | path: {
|
---|
17 | text: string;
|
---|
18 | highlight: boolean;
|
---|
19 | }[];
|
---|
20 | groupLabel: string;
|
---|
21 | onClickItem: VoidFunction;
|
---|
22 | };
|
---|
23 |
|
---|
24 | export default function ResultItem({ title, path, groupLabel, onClickItem }: Props) {
|
---|
25 | return (
|
---|
26 | <ListItemButton
|
---|
27 | onClick={onClickItem}
|
---|
28 | sx={{
|
---|
29 | borderWidth: 1,
|
---|
30 | borderStyle: 'dashed',
|
---|
31 | borderColor: 'transparent',
|
---|
32 | borderBottomColor: (theme) => theme.palette.divider,
|
---|
33 | '&:hover': {
|
---|
34 | borderRadius: 1,
|
---|
35 | borderColor: (theme) => theme.palette.primary.main,
|
---|
36 | backgroundColor: (theme) =>
|
---|
37 | alpha(theme.palette.primary.main, theme.palette.action.hoverOpacity),
|
---|
38 | },
|
---|
39 | }}
|
---|
40 | >
|
---|
41 | <ListItemText
|
---|
42 | primaryTypographyProps={{
|
---|
43 | typography: 'subtitle2',
|
---|
44 | sx: { textTransform: 'capitalize' },
|
---|
45 | }}
|
---|
46 | secondaryTypographyProps={{ typography: 'caption' }}
|
---|
47 | primary={title.map((part, index) => (
|
---|
48 | <Box
|
---|
49 | key={index}
|
---|
50 | component="span"
|
---|
51 | sx={{
|
---|
52 | color: part.highlight ? 'primary.main' : 'text.primary',
|
---|
53 | }}
|
---|
54 | >
|
---|
55 | {part.text}
|
---|
56 | </Box>
|
---|
57 | ))}
|
---|
58 | secondary={path.map((part, index) => (
|
---|
59 | <Box
|
---|
60 | key={index}
|
---|
61 | component="span"
|
---|
62 | sx={{
|
---|
63 | color: part.highlight ? 'primary.main' : 'text.secondary',
|
---|
64 | }}
|
---|
65 | >
|
---|
66 | {part.text}
|
---|
67 | </Box>
|
---|
68 | ))}
|
---|
69 | />
|
---|
70 |
|
---|
71 | {groupLabel && <Label color="info">{groupLabel}</Label>}
|
---|
72 | </ListItemButton>
|
---|
73 | );
|
---|
74 | }
|
---|