diff --git a/src/About/About.js b/src/About/About.js index 0147bb5..2608e54 100644 --- a/src/About/About.js +++ b/src/About/About.js @@ -1,11 +1,11 @@ -import React from 'react' -import './About.scss' +import React from 'react'; +import './About.scss'; const About = props => (

About page

-) +); -export default About \ No newline at end of file +export default About; \ No newline at end of file diff --git a/src/About/index.js b/src/About/index.js new file mode 100644 index 0000000..f3c6d14 --- /dev/null +++ b/src/About/index.js @@ -0,0 +1 @@ +export { default } from './About'; \ No newline at end of file diff --git a/src/App.js b/src/App.js index 938dbd9..636bb75 100644 --- a/src/App.js +++ b/src/App.js @@ -1,9 +1,15 @@ -import React, { Component } from 'react' -import './App.scss' -import About from './About/About' -import Cars from './Cars/Cars' +import React, { Component } from 'react'; +import './App.scss'; +import { Route, NavLink, Switch, Redirect } from 'react-router-dom'; +import About from './About'; +import Cars from './Cars'; +import CarDetail from './CarDetail'; class App extends Component { + state = { + isLoggedIn: false, + } + render() { return ( @@ -11,21 +17,47 @@ class App extends Component { -
- +
+

Is logged in {this.state.isLoggedIn ? 'TRUE' : 'FALSE'}

+ +
+
+ +

Home Page

} /> + {this.state.isLoggedIn ? : null} + + + + {/*

404 not found

} /> */} +
- - + ); } -} +}; -export default App +export default App; diff --git a/src/App.scss b/src/App.scss index 75a754b..5b8cecb 100644 --- a/src/App.scss +++ b/src/App.scss @@ -26,5 +26,11 @@ li { margin-right: 15px; } + + a.active, + a.wfm-active { + font-weight: bold; + color: red; + } } } diff --git a/src/CarDetail/CarDetail.js b/src/CarDetail/CarDetail.js new file mode 100644 index 0000000..649331e --- /dev/null +++ b/src/CarDetail/CarDetail.js @@ -0,0 +1,15 @@ +import React, { Component } from 'react'; +import './CarDetail.scss'; + +class CarDetail extends Component { + + render() { + return ( +
+

{this.props.match.params.name}

+
+ ) + } +}; + +export default CarDetail; \ No newline at end of file diff --git a/src/CarDetail/CarDetail.scss b/src/CarDetail/CarDetail.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/CarDetail/index.js b/src/CarDetail/index.js new file mode 100644 index 0000000..13bfb25 --- /dev/null +++ b/src/CarDetail/index.js @@ -0,0 +1 @@ +export { default } from './CarDetail' \ No newline at end of file diff --git a/src/Cars/Car/Car.js b/src/Cars/Car/Car.js index 23bd85f..59da807 100644 --- a/src/Cars/Car/Car.js +++ b/src/Cars/Car/Car.js @@ -1,14 +1,17 @@ -import React from 'react' -import './Car.scss' - +import React from 'react'; +import './Car.scss'; +import { withRouter } from 'react-router-dom'; const Car = props => { return ( -
+
props.history.push('/cars/' + props.name.toLowerCase())} + >

Сar name: {props.name}

Year: {props.year}

-
+
) -} +}; -export default Car \ No newline at end of file +export default withRouter(Car); \ No newline at end of file diff --git a/src/Cars/Car/index.js b/src/Cars/Car/index.js new file mode 100644 index 0000000..2456c6a --- /dev/null +++ b/src/Cars/Car/index.js @@ -0,0 +1 @@ +export { default } from './Car'; \ No newline at end of file diff --git a/src/Cars/Cars.js b/src/Cars/Cars.js index d8024cd..926cfe8 100644 --- a/src/Cars/Cars.js +++ b/src/Cars/Cars.js @@ -1,32 +1,43 @@ -import React, {Component} from 'react' -import Car from './Car/Car' +import React, { Component } from 'react'; +import Car from './Car'; -export default class Cars extends Component { - state = { - cars: [ - {name: 'Ford', year: 2018}, - {name: 'Audi', year: 2016}, - {name: 'Mazda', year: 2010} - ] - } +class Cars extends Component { + state = { + cars: [ + { name: 'Ford', year: 2018 }, + { name: 'Audi', year: 2016 }, + { name: 'Mazda', year: 2010 } + ] + }; - render() { - return ( -
- {this.state.cars.map((car, index) => { - return ( - - ) - })} -
- ) - } -} \ No newline at end of file + goToHomePage = () => { + this.props.history.push({ + pathname: '/' + }) + }; + + render() { + return ( +
+ +
+ {this.state.cars.map((car, index) => { + return ( + + ) + })} +
+ ) + } +}; + +export default Cars; \ No newline at end of file diff --git a/src/Cars/index.js b/src/Cars/index.js new file mode 100644 index 0000000..62b9c98 --- /dev/null +++ b/src/Cars/index.js @@ -0,0 +1 @@ +export { default } from './Cars' \ No newline at end of file diff --git a/src/index.js b/src/index.js index 61c0632..38dacb4 100644 --- a/src/index.js +++ b/src/index.js @@ -2,15 +2,14 @@ import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import App from './App'; -import { BrowserRouter } from 'react-router-dom' +import { BrowserRouter } from 'react-router-dom'; import registerServiceWorker from './registerServiceWorker'; - const app = ( -) +); ReactDOM.render(app, document.getElementById('root')); registerServiceWorker();