mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 10:18:48 +00:00
Modularize code and added NavBar component
This commit is contained in:
parent
e961379e3f
commit
5caea0871e
@ -1,11 +1,14 @@
|
||||
/* eslint-disable */
|
||||
import React, { Component } from 'react';
|
||||
import logo from './images/twistter-logo.png';
|
||||
import { BrowserRouter as Router } from 'react-router-dom';
|
||||
import Route from 'react-router-dom/Route';
|
||||
import { BrowserRouter as Router, Route, Switch} from 'react-router-dom';
|
||||
import './App.css';
|
||||
|
||||
//TODO: reorganize imports
|
||||
|
||||
//components
|
||||
import Navbar from './components/layout/NavBar';
|
||||
|
||||
// pages
|
||||
import user from './pages/user';
|
||||
|
||||
@ -95,10 +98,9 @@ class App extends Component {
|
||||
render() {
|
||||
return (
|
||||
<Router>
|
||||
<div className="app">
|
||||
|
||||
|
||||
|
||||
<Navbar />
|
||||
<div className='container'>
|
||||
<Switch>
|
||||
|
||||
|
||||
<Route path="/" exact render={
|
||||
@ -167,8 +169,8 @@ class App extends Component {
|
||||
}
|
||||
}/>
|
||||
|
||||
<Route exact path="/user" component={user} />
|
||||
|
||||
<Route path="/user" exact component={user} />
|
||||
</Switch>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,52 +0,0 @@
|
||||
import React from 'react';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import Chip from '@material-ui/core/Chip';
|
||||
import Paper from '@material-ui/core/Paper';
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
root: {
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
flexWrap: 'wrap',
|
||||
padding: theme.spacing(0.5),
|
||||
},
|
||||
chip: {
|
||||
margin: theme.spacing(0.5),
|
||||
},
|
||||
}));
|
||||
|
||||
export default function ChipsArray() {
|
||||
const classes = useStyles();
|
||||
const [chipData, setChipData] = React.useState([
|
||||
{ key: 0, label: 'Angular' },
|
||||
{ key: 1, label: 'jQuery' },
|
||||
{ key: 2, label: 'Polymer' },
|
||||
{ key: 3, label: 'React' },
|
||||
{ key: 4, label: 'Vue.js' },
|
||||
]);
|
||||
|
||||
const handleDelete = chipToDelete => () => {
|
||||
if (chipToDelete.label === 'React') {
|
||||
alert('Why would you want to delete React?! :)');
|
||||
return;
|
||||
}
|
||||
|
||||
setChipData(chips => chips.filter(chip => chip.key !== chipToDelete.key));
|
||||
};
|
||||
|
||||
return (
|
||||
<Paper className={classes.root}>
|
||||
{chipData.map(data => {
|
||||
|
||||
return (
|
||||
<Chip
|
||||
key={data.key}
|
||||
label={data.label}
|
||||
onDelete={handleDelete(data)}
|
||||
className={classes.chip}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</Paper>
|
||||
);
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
import React, { Component } from 'react';
|
||||
|
||||
import AppBar from '@material-ui/core/AppBar';
|
||||
import ToolBar from '@material-ui/core/Toolbar';
|
||||
import Button from '@material-ui/core/Button';
|
||||
|
||||
export class Navbar extends Component {
|
||||
render() {
|
||||
return (
|
||||
<AppBar>
|
||||
<ToolBar>
|
||||
<Button>Home</Button>
|
||||
</ToolBar>
|
||||
</AppBar>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default Navbar;
|
||||
@ -1,21 +1,40 @@
|
||||
/* eslint-disable */
|
||||
import React, { Component } from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import NavBar from '../components/NavBar';
|
||||
import ChipsArray from '../components/ChipsArray';
|
||||
import PropTypes from 'prop-types';
|
||||
import StaticProfile from '../components/profile/StaticProfile';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
|
||||
import PostSkeleton from '../util/PostSkeleton';
|
||||
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
|
||||
class user extends Component {
|
||||
render() {
|
||||
return (
|
||||
<div className="container">
|
||||
<NavBar>
|
||||
const postMarkup = PostSkeleton;
|
||||
|
||||
</NavBar>
|
||||
</div>
|
||||
return (
|
||||
<b>User page</b>
|
||||
// <Grid container spacing={16}>
|
||||
// <Grid item sm={8} xs={12}>
|
||||
// <b>postMarkup</b>
|
||||
// {postMarkup}
|
||||
// </Grid>
|
||||
// {/* <Grid item sm={4} xs={12}>
|
||||
// <StaticProfile profile={this.state.profile} />
|
||||
// </Grid> */}
|
||||
// </Grid>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
//ReactDOM.render(<user />, node);
|
||||
ReactDOM.render(<ChipsArray />, document.querySelector('#root'));
|
||||
user.propTypes = {
|
||||
// getUserData: PropTypes.func.isRequired,
|
||||
//data: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
export default user
|
||||
const mapStateToProps = (state) => ({
|
||||
data: state.data
|
||||
});
|
||||
|
||||
export default connect(user);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/* eslint-disable */
|
||||
import React, { Fragment } from 'react';
|
||||
import NoImg from '../images/no-img.png';
|
||||
import PropTypes from 'prop-types';
|
||||
@ -71,3 +72,6 @@ const PostSkeleton = (props) => {
|
||||
PostSkeleton.propTypes = {
|
||||
classes: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
export default withStyles(styles)(PostSkeleton);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user