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

Assignment of react beginners training submission by [Krishna Kumar]. Made ema-john app. #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ExpandedNodes": [
"",
"\\src"
],
"PreviewInSolutionExplorer": false
}
Binary file added .vs/ema-john/v15/.suo
Binary file not shown.
Binary file added .vs/slnx.sqlite
Binary file not shown.
6 changes: 0 additions & 6 deletions database.rules.json

This file was deleted.

8 changes: 0 additions & 8 deletions functions/index.js

This file was deleted.

9 changes: 0 additions & 9 deletions functions/package.json

This file was deleted.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"enzyme": "^2.9.1",
"font-awesome": "^4.7.0",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-rating": "^0.8.0",
"react-router-dom": "^4.1.1",
"react-scripts": "1.0.10",
"react-test-renderer": "^15.6.1"
"react-scripts": "1.0.10"
},
"scripts": {
"start": "react-scripts start",
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>ema-John</title>
</head>
<body>
<noscript>
Expand Down
37 changes: 22 additions & 15 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
.App {
text-align: center;
.container {
max-width: 1024px;
padding: 0 20px;
box-sizing: border-box;
margin: 0 auto 50px auto;
}

.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
.shop-items {
width: 75%;
border:1px solid #999;
}

.App-header {
background-color: #222;
height: 150px;
padding: 20px;
color: white;
.order-summary {
width: 25%;
border: 1px solid #999;
border-left: 0;
}

.App-intro {
font-size: large;
.shopping-page-section {
display: flex;
}

@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
.list-remove-defaults {
padding: 0;
list-style: none;
margin-bottom: 0;
}

.container.list-remove-defaults {
padding: 0 20px;
}
71 changes: 57 additions & 14 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,66 @@
import React, { Component } from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';

import './App.css';
import Home from './components/Home/Home';
import OrderReview from './components/OrderReview/OrderReview';
import NotFound from './components/NotFound/NotFound';
import Header from './components/Header/Header';
import Mocks from './mocks';
import ShopItem from './components/ShopItem/ShopItem';
import OrderSummary from './components/OrderSummary/OrderSummary';

class App extends Component {
constructor() {
super();
this.state = {
items:[],
orderSummaryDetails: {
noOfItems: 0,
itemsValue: 0,
shipping: 0,
totalBeforeTax: 0,
tax: 0,
orderTotal: 0
}
}
this.updateOrderSummary.bind(this);
}
componentDidMount() {
var firstTenItems = Mocks.slice(0,10);
this.setState({
items: firstTenItems
});
}
updateOrderSummary(item) {
var orderSummaryDetails = this.state.orderSummaryDetails;
var newNoOfItems = orderSummaryDetails.noOfItems + 1;
var newItemsValue = orderSummaryDetails.itemsValue + item.price;
var newShipping = orderSummaryDetails.shipping + item.shipping;
var newTotalBeforeTax = newItemsValue + newShipping;
var newTax = .10 * newTotalBeforeTax;
var newOrderTotal = newTotalBeforeTax + newTax;
this.setState({
orderSummaryDetails: {
noOfItems: newNoOfItems,
itemsValue: +newItemsValue.toFixed(2),
shipping: +newShipping.toFixed(2),
totalBeforeTax: +newTotalBeforeTax.toFixed(2),
tax: +newTax.toFixed(2),
orderTotal: +newOrderTotal.toFixed(2)
}
});
}
render() {
const items = this.state.items;
return (
<div className="App">
<Router>
<Switch>
<Route exact path="/" component={Home}></Route>
<Route path="/shop" component={Home}></Route>
<Route path="/review" component={OrderReview}></Route>
<Route path="*" component={NotFound}></Route>
</Switch>
</Router>
<div className="ema-john-app">
<Header></Header>
<div className="container shopping-page-section">
<section className="shop-items">
<ul className="list-remove-defaults">
{
items.map(item => <ShopItem key={item.key} item={item} updateOrderSummary={this.updateOrderSummary.bind(this)}></ShopItem>)
}
</ul>
</section>
<OrderSummary orderSummaryDetails={this.state.orderSummaryDetails}></OrderSummary>
</div>
</div>
);
}
Expand Down
18 changes: 0 additions & 18 deletions src/components/Cart/Cart.css

This file was deleted.

66 changes: 0 additions & 66 deletions src/components/Cart/Cart.js

This file was deleted.

25 changes: 0 additions & 25 deletions src/components/CartItem/CartItem.css

This file was deleted.

34 changes: 0 additions & 34 deletions src/components/CartItem/CartItem.js

This file was deleted.

42 changes: 22 additions & 20 deletions src/components/Header/Header.css
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
.header img{
height: 80px;
.logo-section {
text-align: center;
padding: 16px 0 0 0;
}

.header ul{
background-color: black;
height: 40px;
text-align: left;
margin-bottom: 0px;
.logo-section img {
height: 70px;
}

.header li{
list-style: none;
display: inline-block;
margin-right: 15px;
line-height: 30px;
padding: 5px;
.header ul li {
display: inline-block;
}

.header a{
text-decoration: none;
color: white;
.header ul a {
display: inline-block;
color: #fff;
text-decoration: none;
padding: 16px;
border-bottom: 2px solid transparent;
}

.header li:hover{
background-color: lightgray;
.header ul a.menu-selected {
color: red;
}

.header a:visited{
color: white;
.header ul a:hover {
/*background: #666;*/
border-bottom: 2px solid red;
}

.menu-section {
background: #000;
}
Loading