change images, update readme

This commit is contained in:
Raymond
2018-07-05 16:41:28 +01:00
parent eeecbb54ec
commit 4f97c49d2f
19 changed files with 3861 additions and 2811 deletions

View File

@@ -2,7 +2,7 @@
Product comparison page build using **React** + **Redux** + **Bootstrap** + **SASS**
![Screenshot](http://i.imgur.com/0fTmInU.png)
![Screenshot](https://s8.postimg.cc/fdfsvumkl/Screen_Shot_2018-07-05_at_16.36.17.png)
It's build on top of [`create-react-app`](http://www.google.lt)
@@ -26,8 +26,3 @@ License
The MIT License (MIT). Please see License File for more information.
[![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](https://github.com/Rhymond/product-compare-react)
Todo
-
- [ ] Write tests
- [ ] Integrate CI

6537
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -8,9 +8,9 @@
"babel-eslint": "7.2.3",
"babel-jest": "20.0.3",
"babel-loader": "7.0.0",
"babel-preset-react-app": "^3.0.1",
"babel-preset-react-app": "^3.1.2",
"babel-runtime": "6.23.0",
"bootstrap": "^4.0.0-alpha.6",
"bootstrap": "^4.1.1",
"case-sensitive-paths-webpack-plugin": "2.1.1",
"chalk": "1.1.3",
"css-loader": "0.28.4",
@@ -28,25 +28,25 @@
"html-webpack-plugin": "2.29.0",
"jest": "20.0.4",
"node-sass-chokidar": "0.0.3",
"npm-run-all": "^4.1.1",
"npm-run-all": "^4.1.3",
"object-assign": "4.1.1",
"postcss-flexbugs-fixes": "3.0.0",
"postcss-loader": "2.0.6",
"promise": "7.1.1",
"react": "^15.6.1",
"react-addons-css-transition-group": "^15.6.0",
"react-addons-transition-group": "^15.6.0",
"react": "^15.6.2",
"react-addons-css-transition-group": "^15.6.2",
"react-addons-transition-group": "^15.6.2",
"react-dev-utils": "^3.0.2",
"react-dom": "^15.6.1",
"react-dom": "^15.6.2",
"react-error-overlay": "^1.0.9",
"react-redux": "^5.0.5",
"react-router": "^4.1.1",
"react-router-dom": "^4.1.1",
"react-scripts": "^1.0.10",
"react-select": "^1.0.0-rc.5",
"react-redux": "^5.0.7",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"react-scripts": "^1.1.4",
"react-select": "^1.2.1",
"redux": "^3.0.0",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.2.0",
"redux-thunk": "^2.3.0",
"style-loader": "0.18.2",
"sw-precache-webpack-plugin": "0.11.3",
"url-loader": "0.5.9",

BIN
public/images/Cherry.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 KiB

BIN
public/images/Nuts.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 KiB

BIN
public/images/Orange.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 KiB

View File

@@ -1,39 +1,39 @@
{
"products": [{
"id": "1",
"name": "Chair",
"image": "https://devitems.com/preview/furnish/img/product/1.jpg",
"price": "$39",
"name": "Cherry",
"image": "images/Cherry.png",
"price": "$1.99",
"colors": ["red", "green", "blue"],
"condition": "New",
"description": "Black chair"
"condition": "Fresh",
"description": "Two Cherries"
},
{
"id": "2",
"name": "Lamp",
"image": "https://devitems.com/preview/furnish/img/product/2.jpg",
"price": "$319",
"name": "Orange",
"image": "images/Orange.png",
"price": "$2.99",
"colors": ["green", "blue"],
"condition": "Used",
"description": "Amazing lamp"
"condition": "Frozen",
"description": "Giant Orange"
},
{
"id": "3",
"name": "Statue",
"image": "https://devitems.com/preview/furnish/img/product/3.jpg",
"price": "$239",
"name": "Nuts",
"image": "images/Nuts.png",
"price": "$1.00",
"colors": ["red"],
"condition": "Used",
"description": "Used Statue"
"condition": "Frozen",
"description": "Mixed Nuts"
},
{
"id": "4",
"name": "Seat",
"image": "https://devitems.com/preview/furnish/img/product/4.jpg",
"price": "$239",
"name": "Strawberry",
"image": "images/Strawberry.png",
"price": "$1.49",
"colors": ["blue"],
"condition": "New",
"description": "Large Seat"
"condition": "Fresh",
"description": "Just Strawberry"
}
]
}

View File

@@ -7,7 +7,7 @@ const Compare = ({products}) =>
<table className="table">
<thead className="thead-default">
<tr>
<th></th>
<th />
{products.map(product =>
<th key={product.id}>
{product.name}
@@ -27,7 +27,7 @@ const Compare = ({products}) =>
{products.map(product =>
<td key={product.id}>
{product.colors.map((color, index) =>
<span key={index} className={"bg-" + color}></span>
<span key={index} className={"bg-" + color} />
)}
</td>
)}
@@ -35,7 +35,7 @@ const Compare = ({products}) =>
<tr className="condition">
<th scope="row">Condition</th>
{products.map(product =>
<td key={product.id} className={product.condition === "Used" ? "bg-red" : "bg-green"}>
<td key={product.id} className={product.condition === "Frozen" ? "bg-red" : "bg-green"}>
{product.condition}
</td>
)}
@@ -43,6 +43,6 @@ const Compare = ({products}) =>
</tbody>
</table>
</div>
</div>
</div>;
export default Compare

View File

@@ -5,7 +5,7 @@
background-color: #fff;
border-radius: 5px;
overflow: hidden;
box-shadow: 0px 13px 21px -5px rgba(0, 0, 0, 0.05);
box-shadow: 0 13px 21px -5px rgba(0, 0, 0, 0.05);
border: 1px solid #eee;
font-size: 18px;
table-layout: fixed;

View File

@@ -5,7 +5,7 @@ const Product = ({product, compare}) =>
<div key={product.id} className="col-sm-6 col-md-3">
<div className={"product " + (product.compare ? "compare" : "")} >
<img src={product.image} alt={product.name} />
<div className="image_overlay"></div>
<div className="image_overlay"/>
<div className="view_details" onClick={() => compare(product)}>
{product.compare ? "Remove" : "Compare"}
</div>
@@ -17,6 +17,6 @@ const Product = ({product, compare}) =>
</div>
</div>
</div>
</div>
</div>;
export default Product

View File

@@ -10,8 +10,9 @@ $product-main-color: $green;
overflow: hidden;
transition: all 500ms ease-out;
margin-bottom: 30px;
border: 1px solid #ddd;
&:hover {
box-shadow: 0px 13px 21px -5px rgba(0, 0, 0, 0.2);
box-shadow: 0 13px 21px -5px rgba(0, 0, 0, 0.2);
.image_overlay {
opacity: $image-overlay-opacity;
}

View File

@@ -2,12 +2,10 @@ import React from 'react'
import {Product} from '../'
const ProductList = ({products, compare}) =>
<div>
<div className="row mt-3">
{products.map(product =>
<Product key={product.id} product={product} compare={compare} />
)}
</div>
</div>
<div className="row mt-3">
{products.map(product =>
<Product key={product.id} product={product} compare={compare} />
)}
</div>;
export default ProductList

View File

@@ -1,2 +1,2 @@
export const FETCH_PRODUCTS = 'FETCH_PRODUCTS'
export const COMPARE_PRODUCT = 'COMPARE_PRODUCT'
export const FETCH_PRODUCTS = 'FETCH_PRODUCTS';
export const COMPARE_PRODUCT = 'COMPARE_PRODUCT';

View File

@@ -10,11 +10,16 @@ class Home extends Component {
}
render() {
const {products, actions} = this.props
const compareProducts = products.filter(product => product.compare)
const {products, actions} = this.props;
const compareProducts = products.filter(product => product.compare);
return (
<div className="home mt-5">
<div className="row">
<div className="col-12">
<h2 className="mb-3">Compare Products</h2>
</div>
</div>
<ProductList products={products} compare={actions.compare}/>
{compareProducts.length >= 2 &&
<Compare products={compareProducts}/>

View File

@@ -12,7 +12,7 @@ import App from './containers/App'
import 'bootstrap/dist/css/bootstrap.css'
import './styles.css'
const loggerMiddleware = createLogger()
const loggerMiddleware = createLogger();
const store = createStore(
reducer,
@@ -20,7 +20,7 @@ const store = createStore(
thunkMiddleware,
loggerMiddleware
)
)
);
ReactDOM.render(
<Provider store={store}>
@@ -29,6 +29,6 @@ ReactDOM.render(
</BrowserRouter>
</Provider>,
document.getElementById('root')
)
);
registerServiceWorker()
registerServiceWorker();

View File

@@ -1,8 +1,8 @@
import { combineReducers } from 'redux'
import product from './product_reducer'
import product from './productReducer'
const compareApp = combineReducers({
product
})
});
export default compareApp

View File

@@ -2,7 +2,7 @@ import * as types from '../constants/types'
const INITIAL_STATE = {
products: []
}
};
export default function (state = INITIAL_STATE, action) {
switch (action.type) {
@@ -11,7 +11,7 @@ export default function (state = INITIAL_STATE, action) {
...state, products: action.payload.map(product =>
({...product, compare: false})
)
}
};
case types.COMPARE_PRODUCT:
return {
...state, products: state.products.map(product =>
@@ -19,7 +19,7 @@ export default function (state = INITIAL_STATE, action) {
({...product, compare: !product.compare}) :
product
)
}
};
default:
return state
}

View File

@@ -2,6 +2,6 @@ body {
margin: 0;
padding: 0;
font-family: sans-serif;
background: #eaebec;
background: #f6f7f8;
color: #393c45;
}