Skip to content

Commit

Permalink
create component for link #95
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammedsalah7 committed Nov 9, 2021
1 parent 0d068f0 commit c447e6a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 29 deletions.
40 changes: 11 additions & 29 deletions client/src/components/Navbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import React, { useState } from 'react';
import { Link } from 'react-router-dom';
import {
ListItem, ListItemText, Button, Avatar, Container, List,
ListItemText, Button, Avatar, Container, List,
} from '@mui/material';
import './style.css';

import Logo from '../../asstes/logo.png';
import PresonImg from '../../asstes/avatar.png';
import LinkComponent from '../common/LinkComponent';

function NavBar() {
const [logged, setLogged] = useState(true);
return (
<Container maxWidth="xl">
<nav className="container">
Expand All @@ -25,27 +25,11 @@ function NavBar() {
marginRight: '150px', alignSelf: 'center', color: '#797B7D',
}}
>
<Link to="/" style={{ color: '#797B7D', textDecoration: 'none' }}>
<ListItem button style={{ textDecoration: 'none' }}>
<ListItemText primary="Home" />
</ListItem>
</Link>
<LinkComponent to="/" name="Home" />
<LinkComponent to="/about" name="About" />
<LinkComponent to="/buy" name="Buy" />
<LinkComponent to="/rent" name="Rent" />

<Link to="/signup" style={{ color: '#797B7D', textDecoration: 'none' }}>
<ListItem button>
<ListItemText primary="About" />
</ListItem>
</Link>
<Link to="/" style={{ color: '#797B7D', textDecoration: 'none' }}>
<ListItem button>
<ListItemText primary="Buy" />
</ListItem>
</Link>
<Link to="/" style={{ color: '#797B7D', textDecoration: 'none' }}>
<ListItem button>
<ListItemText primary="Rent" />
</ListItem>
</Link>
</List>

<div className="agent">
Expand All @@ -58,13 +42,11 @@ function NavBar() {
<ListItemText primary="Host my House" style={{ color: '#fff' }} />
</Link>
</Button>
{logged ? (
<Link to="/">
<Avatar src={PresonImg} />
</Link>
) : (
''
)}

<Link to="/">
<Avatar src={PresonImg} />
</Link>

</div>

</nav>
Expand Down
22 changes: 22 additions & 0 deletions client/src/components/common/LinkComponent/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Link } from 'react-router-dom';
import { ListItem, ListItemText } from '@mui/material';
import PropTypes from 'prop-types';

const LinkComponent = ({
to, styleList, name,
}) => (
<div>
<Link to={to} style={{ color: '#797B7D', textDecoration: 'none' }}>
<ListItem button style={styleList}>
<ListItemText primary={name} />
</ListItem>
</Link>
</div>
);
LinkComponent.propTypes = {
name: PropTypes.string.isRequired,
to: PropTypes.string.isRequired,
styleList: PropTypes.objectOf.isRequired,
};

export default LinkComponent;

0 comments on commit c447e6a

Please sign in to comment.