Skip to content

Commit

Permalink
#103 move ListItemButton to shared components.
Browse files Browse the repository at this point in the history
  • Loading branch information
artzub committed Mar 9, 2023
1 parent 2e987d5 commit e05b567
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
24 changes: 16 additions & 8 deletions src/components/Header/components/BranchStep/Body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import { FixedSizeList } from 'react-window';
import debounce from 'lodash.debounce';
import styled from 'styled-components';

import { Avatar, ListItem as ListItemOrigin, ListItemAvatar, ListSubheader, TextField } from '@mui/material';
import {
Avatar,
ListItem as ListItemOrigin,
ListItemAvatar,
ListSubheader,
TextField,
} from '@mui/material';
import List from '@mui/material/List';
import ListItemText from '@mui/material/ListItemText';

Expand All @@ -18,12 +24,12 @@ import slice from '@/redux/modules/branches';
import repositoriesSlice from '@/redux/modules/repositories';

import Highlight from '@/shared/components/Highlight';
import ListItemButton from '@/shared/components/ListItemButton';
import LoadingOverlay from '@/shared/components/LoadingOverlay';
import { ScrollBarMixin } from '@/shared/components/ScrollBar';
import { useUIProperty } from '@/shared/hooks';
import { useRedirectTo } from '@/shared/hooks/useRedirectTo';

import ListItemButton from '../shared/ListItemButton';
import Marker from '../shared/Marker';

import Secondary from './Secondary';
Expand Down Expand Up @@ -83,14 +89,13 @@ const Body = () => {
const { isFetching, items } = useSelector(slice.selectors.getState);
const [bodyOpen, setBodyOpen] = useUIProperty('bodyOpen');
const [filtered, setFiltered] = useState(items);
const { selected: repository } = useSelector(repositoriesSlice.selectors.getState);
const { selected: repository } = useSelector(
repositoriesSlice.selectors.getState,
);
const { defaultBranch } = repository || {};

const changeSearch = useMemo(
() => debounce(
(value) => setSearch(value),
300,
),
() => debounce((value) => setSearch(value), 300),
[],
);

Expand Down Expand Up @@ -142,7 +147,10 @@ const Body = () => {
primary={(
<Primary>
{isDefault && <Marker>default</Marker>}
<Highlight search={search} text={item.name} />
<Highlight
search={search}
text={item.name}
/>
</Primary>
)}
secondary={<Secondary item={item} />}
Expand Down
28 changes: 22 additions & 6 deletions src/components/Header/components/ProfileStep/Body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import { useDebounce } from 'react-use';

import styled from 'styled-components';

import { Avatar, ListItem as ListItemOrigin, ListItemAvatar, ListSubheader, TextField } from '@mui/material';
import {
Avatar,
ListItem as ListItemOrigin,
ListItemAvatar,
ListSubheader,
TextField,
} from '@mui/material';
import List from '@mui/material/List';
import ListItemText from '@mui/material/ListItemText';

Expand All @@ -13,13 +19,12 @@ import { UrlPratTypes } from '@/models/UrlPartTypes';
import slice from '@/redux/modules/profiles';

import Highlight from '@/shared/components/Highlight';
import ListItemButton from '@/shared/components/ListItemButton';
import LoadingOverlay from '@/shared/components/LoadingOverlay';
import ScrollBar from '@/shared/components/ScrollBar';
import { useUIProperty } from '@/shared/hooks';
import { useRedirectTo } from '@/shared/hooks/useRedirectTo';

import ListItemButton from '../shared/ListItemButton';

const Container = styled.div`
min-height: 100px;
display: flex;
Expand Down Expand Up @@ -57,13 +62,19 @@ const NotData = styled(({ className }) => (
`;

const SearchHeader = (
<ListSubheader component="li" disableSticky>
<ListSubheader
component="li"
disableSticky
>
Search results
</ListSubheader>
);

const TopHeader = (
<ListSubheader component="li" disableSticky>
<ListSubheader
component="li"
disableSticky
>
Top profiles
</ListSubheader>
);
Expand Down Expand Up @@ -132,7 +143,12 @@ const Body = () => {
<Avatar src={profile.avatar} />
</ListItemAvatar>
<ListItemText
primary={<Highlight search={search} text={profile.login} />}
primary={(
<Highlight
search={search}
text={profile.login}
/>
)}
secondary={profile.type}
/>
</ListItem>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/components/RepositoryStep/Body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import { UrlPratTypes } from '@/models/UrlPartTypes';
import slice from '@/redux/modules/repositories';

import Highlight from '@/shared/components/Highlight';
import ListItemButton from '@/shared/components/ListItemButton';
import LoadingOverlay from '@/shared/components/LoadingOverlay';
import { ScrollBarMixin } from '@/shared/components/ScrollBar';
import { useUIProperty } from '@/shared/hooks';
import { useRedirectTo } from '@/shared/hooks/useRedirectTo';

import ListItemButton from '../shared/ListItemButton';
import Marker from '../shared/Marker';

import Secondary from './Secondary';
Expand Down

0 comments on commit e05b567

Please sign in to comment.