Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create component for link #95 #96

Merged
merged 3 commits into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes
File renamed without changes
46 changes: 14 additions & 32 deletions client/src/components/Navbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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';

Expand All @@ -11,11 +11,11 @@ import Box from '@mui/material/Box';
import Modal from '@mui/material/Modal';
import Fade from '@mui/material/Fade';
import Login from '../login';
import Logo from '../../asstes/logo.png';
import PresonImg from '../../asstes/avatar.png';
import Logo from '../../assets/logo.png';
import PresonImg from '../../assets/avatar.png';
import LinkComponent from '../common/LinkComponent';

function NavBar() {
const [logged, setLogged] = useState(false);
const [open, setOpen] = useState(false);
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);
Expand Down Expand Up @@ -44,27 +44,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 @@ -76,13 +60,11 @@ function NavBar() {
<Button onClick={handleOpen} style={{ color: '#fff', textTransform: 'none' }}>Login</Button>

</Button>
{logged ? (
<Link to="/">
<Avatar src={PresonImg} />
</Link>
) : (
''
)}

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

</div>

</nav>
Expand All @@ -99,7 +81,7 @@ function NavBar() {
>
<Fade in={open}>
<Box sx={style}>
<Login setLogged={setLogged} handleClose={handleClose} />
<Login handleClose={handleClose} />
</Box>
</Fade>
</Modal>
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;