Skip to content

Commit

Permalink
feat(player-list-item): migrates to material ui
Browse files Browse the repository at this point in the history
Migrates the component to use MaterialUI instead of
ChakraUI

re #144
  • Loading branch information
anguspiv committed Apr 6, 2023
1 parent b3c58ad commit 5dc6e54
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Story } from '@storybook/react';
import { PlayerListItem, PlayerListItemProps } from './PlayerListItem';

export default {
title: 'components/players/PlayerListItem',
title: 'Molecules/PlayerListItem',
component: PlayerListItem,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { render, screen } from '@testing-library/react';
import { PlayerListItem } from './PlayerListItem';

describe('<PlayerListItem />', () => {
const setupPlayerListItem = (props) => {
const setupPlayerListItem = (props = {}) => {
return render(<PlayerListItem {...props} />);
};

Expand All @@ -22,7 +22,7 @@ describe('<PlayerListItem />', () => {
firstName: 'John',
});

expect(screen.getByText('John')).toBeInTheDocument();
expect(screen.getByText(/John/)).toBeInTheDocument();
});

it('should render the users nickname', () => {
Expand Down
26 changes: 26 additions & 0 deletions src/components/molecules/PlayerListItem/PlayerListItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import NextLink from 'next/link';
import { Avatar, ListItem, ListItemAvatar, ListItemText } from '@mui/material';

export interface PlayerListItemProps extends Profile {
image?: string;
}

export function PlayerListItem({ id, firstName, nickname, lastName, image }: PlayerListItemProps) {
return (
<ListItem
button
component={NextLink}
href={`/players/${id}`}
alignItems="flex-start"
data-testid="player-list-item"
>
<ListItemAvatar>
<Avatar alt={`${firstName} ${lastName}`} src={image} />
</ListItemAvatar>
<ListItemText primary={`${firstName} ${lastName}`} secondary={nickname} />
</ListItem>
);
}

export default PlayerListItem;
2 changes: 1 addition & 1 deletion src/components/players/PlayerList/PlayerList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Stack, Divider, Center, Spinner } from '@chakra-ui/react';
import { PlayerListItem, PlayerListItemProps } from '../PlayerListItem';
import { PlayerListItem, PlayerListItemProps } from '@components/molecules/PlayerListItem';

export interface PlayerListProps {
players: PlayerListItemProps[];
Expand Down
28 changes: 0 additions & 28 deletions src/components/players/PlayerListItem/PlayerListItem.tsx

This file was deleted.

0 comments on commit 5dc6e54

Please sign in to comment.