-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app-menu): adds the user card to the app menu
Adds a the user avatar and name to the app menu closes #105
- Loading branch information
Showing
9 changed files
with
159 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/components/navigation/NavMenuUser/NavMenuUser.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Story } from '@storybook/react'; | ||
import NavMenuUser, { NavMenuUserProps } from './NavMenuUser'; | ||
|
||
export default { | ||
title: 'components/navigation/NavMenuUser', | ||
component: NavMenuUser, | ||
}; | ||
|
||
const Template: Story<NavMenuUserProps> = (args) => { | ||
return <NavMenuUser {...args} />; | ||
}; | ||
|
||
export const Default = Template.bind({}); | ||
|
||
Default.args = { | ||
image: 'https://picsum.photos/id/237/200/300', | ||
firstName: 'John', | ||
lastName: 'Doe', | ||
}; |
29 changes: 29 additions & 0 deletions
29
src/components/navigation/NavMenuUser/NavMenuUser.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import NavMenuUser from './NavMenuUser'; | ||
|
||
describe('<NavMenuUser />', () => { | ||
const setupNavMenuUser = (props) => { | ||
return render(<NavMenuUser {...props} />); | ||
}; | ||
|
||
it('should render', () => { | ||
expect.assertions(1); | ||
const { container } = setupNavMenuUser(); | ||
expect(container).toBeTruthy(); | ||
}); | ||
|
||
it('should render the first name and last initial', () => { | ||
expect.assertions(1); | ||
|
||
const firstName = 'John'; | ||
const lastName = 'Doe'; | ||
|
||
const { getByText } = setupNavMenuUser({ | ||
firstName, | ||
lastName, | ||
}); | ||
|
||
expect(getByText(`${firstName} ${lastName[0]}.`)).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Grid, GridItem, Heading, Avatar } from '@chakra-ui/react'; | ||
|
||
export interface NavMenuUserProps { | ||
image?: string; | ||
firstName: string; | ||
lastName?: string; | ||
} | ||
|
||
function NavMenuUser({ image, firstName, lastName }: NavMenuUserProps) { | ||
let name = firstName; | ||
|
||
if (lastName) { | ||
name = `${name} ${lastName[0]}.`; | ||
} | ||
|
||
return ( | ||
<Grid | ||
gap={2} | ||
templateRows="auto" | ||
templateColumns="repeat(2, auto)" | ||
alignItems="center" | ||
justifyContent="start" | ||
px={2} | ||
py={1} | ||
> | ||
<Avatar src={image} data-testid="avatar" size="xs" name={name} /> | ||
<GridItem area="info"> | ||
<Heading as="p" size="xs"> | ||
{name} | ||
</Heading> | ||
</GridItem> | ||
</Grid> | ||
); | ||
} | ||
|
||
export default NavMenuUser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import NavMenuUser from './NavMenuUser'; | ||
|
||
export * from './NavMenuUser'; | ||
|
||
export default NavMenuUser; |
1551a43
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.
Successfully deployed to the following URLs:
pokermans – ./
pokermans.vercel.app
pokermans-git-main-anguspiv.vercel.app
www.pokermans.com
pokermans.com
pokermans-anguspiv.vercel.app