├── .gitignore ├── .idea ├── ecommerce.iml ├── inspectionProfiles │ └── Project_Default.xml ├── misc.xml ├── modules.xml ├── vcs.xml └── workspace.xml ├── README.md ├── ecm1-1.png ├── ecm2-2.png ├── ecm3.png ├── ecm4.png ├── ecm5.png ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── index.html └── manifest.json ├── src ├── App.js ├── App.scss ├── App.test.js ├── actions │ └── index.js ├── components │ ├── BrandFilter │ │ ├── BrandFilter.js │ │ └── BrandFilter.scss │ ├── CartItem │ │ ├── CartItem.js │ │ └── CartItem.scss │ ├── Footer │ │ └── Footer.js │ ├── Header │ │ └── Header.js │ ├── LayoutMode │ │ ├── LayoutMode.js │ │ └── LayoutMode.scss │ ├── OrderFilter │ │ ├── OrderFilter.js │ │ └── OrderFilter.scss │ ├── Pagination │ │ ├── Pagination.js │ │ └── Pagination.scss │ ├── Product │ │ ├── Product.js │ │ └── Product.scss │ ├── ProductDetail │ │ └── ProductDetail.js │ ├── ProductSlider │ │ ├── ProductSlider.js │ │ └── ProductSlider.scss │ └── SlideDots │ │ ├── SlideDots.js │ │ └── SlideDots.scss ├── containers │ ├── FilterBar │ │ └── FilterBar.js │ └── ProductList │ │ ├── ProductList.js │ │ └── ProductList.scss ├── data │ ├── brands.js │ ├── getData.js │ └── phones.js ├── index.js ├── index.scss ├── logo.svg ├── pages │ ├── Home │ │ └── Home.js │ ├── ProductDetail │ │ └── ProductDetail.js │ └── ShopingCart │ │ └── ShoppingCart.js ├── pipes │ ├── brandFilter.js │ ├── orderByFilter.js │ ├── paginationFilter.js │ ├── priceFormatter.js │ └── shortenTitle.js ├── reducers │ ├── brand.filter.reducer.js │ ├── index.js │ ├── orderByPrice.filter.reducer.js │ ├── pagination.reducer.js │ └── shop.reducer.js ├── serviceWorker.js └── utilities │ └── cumulativeOffset.js └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /.idea/ecommerce.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 179 | 180 | 181 | 183 | 184 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | true 241 | DEFINITION_ORDER 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 35 | 36 | 37 | 38 | ))} 39 | 40 | 41 | ); 42 | 43 | }; 44 | 45 | const mapStateToProps = (state) => { 46 | 47 | const brandItemsCount = {}; 48 | 49 | state.shop.products.forEach(p => { 50 | brandItemsCount[p.brand] = brandItemsCount[p.brand] + 1 || 1; 51 | }); 52 | 53 | 54 | return { 55 | brandItemsCount 56 | } 57 | 58 | }; 59 | 60 | export default connect(mapStateToProps)(BrandFilter); -------------------------------------------------------------------------------- /src/components/BrandFilter/BrandFilter.scss: -------------------------------------------------------------------------------- 1 | .custom-checkbox { 2 | display: block; 3 | position: relative; 4 | padding-left: 2rem; 5 | cursor: pointer; 6 | user-select: none; 7 | 8 | &__input { 9 | position: absolute; 10 | opacity: 0; 11 | height: 0; 12 | width: 0; 13 | 14 | 15 | } 16 | 17 | &__span { 18 | position: absolute; 19 | top: 50%; 20 | left: 0; 21 | transform: translateY(-50%); 22 | height: 1.2rem; 23 | width: 1.2rem; 24 | background-color: white; 25 | border: 2px solid gray; 26 | 27 | &::after { 28 | content: ""; 29 | opacity: 0; 30 | position: absolute; 31 | top: 50%; 32 | left: 50%; 33 | width: .6rem; 34 | height: .6rem; 35 | background-color: dodgerblue; 36 | transform: translate(-50%, -50%); 37 | } 38 | } 39 | 40 | &:hover &__span { 41 | background-color: #eeeeee; 42 | } 43 | 44 | &__input:checked + &__span::after { 45 | opacity: 1; 46 | } 47 | } 48 | 49 | .flex-50 { 50 | flex: 0 0 100%; 51 | } 52 | 53 | @media only screen and (max-width: 768px) { 54 | 55 | .flex-50 { 56 | flex: 0 0 50%; 57 | } 58 | } -------------------------------------------------------------------------------- /src/components/CartItem/CartItem.js: -------------------------------------------------------------------------------- 1 | import React, {useState} from 'react'; 2 | import {connect} from 'react-redux'; 3 | import {shortenTitle} from "../../pipes/shortenTitle"; 4 | import {formatMoney} from "../../pipes/priceFormatter"; 5 | import './CartItem.scss'; 6 | import {addProductToCart, decrementCartQuantity, incrementCartQuantity, removeProductToCart} from "../../actions"; 7 | 8 | const CartItem = ( 9 | { 10 | title, 11 | price, 12 | description, 13 | quantity, 14 | id, 15 | img, 16 | dispatch 17 | } 18 | ) => { 19 | 20 | console.log(id); 21 | const [itemQuantity, setItemQuantity] = useState(quantity); 22 | const removeItem = () => { 23 | dispatch(removeProductToCart(id)); 24 | }; 25 | 26 | const handleQuantityChange = (e) => { 27 | /* const value = e.target.value; 28 | console.log(value) 29 | 30 | if(value > 0 && value <= 10) { 31 | setItemQuantity(value); 32 | dispatch(addProductToCart(id)); 33 | } */ 34 | }; 35 | 36 | const incrementOrDecrement = (e, type) => { 37 | const value = itemQuantity; 38 | console.log(type, value); 39 | 40 | if(type === 'inc' && value < 10) { 41 | setItemQuantity(itemQuantity + 1); 42 | dispatch(incrementCartQuantity(id)); 43 | } 44 | 45 | 46 | if(type === 'desc' && value > 1) { 47 | setItemQuantity(itemQuantity - 1); 48 | dispatch(decrementCartQuantity(id)); 49 | } 50 | 51 | }; 52 | 53 | 54 | return ( 55 |
56 |
57 | {description} 59 |
60 |
61 |

{shortenTitle(title)}

62 |

63 | {description} 64 |

65 |
66 |
67 |
68 |
{formatMoney(price)}$ x
69 |
70 |
71 |
72 | {incrementOrDecrement(e, 'inc')}} 74 | type="button" value="+" className="plus" /> 75 | 80 | {incrementOrDecrement(e, 'desc')}} 82 | type="button" value="-" className="minus" /> 83 |
84 |
85 |
86 | 91 |
92 |
93 |
94 | ); 95 | }; 96 | 97 | export default connect()(CartItem); 98 | -------------------------------------------------------------------------------- /src/components/CartItem/CartItem.scss: -------------------------------------------------------------------------------- 1 | 2 | 3 | .quantity { 4 | float: left; 5 | margin-right: 15px; 6 | background-color: #eee; 7 | position: relative; 8 | width: 80px; 9 | overflow: hidden 10 | } 11 | 12 | .quantity input { 13 | margin: 0; 14 | text-align: center; 15 | width: 15px; 16 | height: 15px; 17 | padding: 0; 18 | float: right; 19 | color: #000; 20 | font-size: 20px; 21 | border: 0; 22 | outline: 0; 23 | background-color: #F6F6F6 24 | } 25 | 26 | .quantity input.qty { 27 | position: relative; 28 | border: 0; 29 | width: 100%; 30 | height: 40px; 31 | padding: 10px 25px 10px 10px; 32 | text-align: center; 33 | font-weight: 400; 34 | font-size: 15px; 35 | border-radius: 0; 36 | background-clip: padding-box 37 | } 38 | 39 | .quantity .minus, .quantity .plus { 40 | line-height: 0; 41 | background-clip: padding-box; 42 | -webkit-border-radius: 0; 43 | -moz-border-radius: 0; 44 | border-radius: 0; 45 | -webkit-background-size: 6px 30px; 46 | -moz-background-size: 6px 30px; 47 | color: #bbb; 48 | font-size: 20px; 49 | position: absolute; 50 | height: 50%; 51 | border: 0; 52 | right: 0; 53 | padding: 0; 54 | width: 25px; 55 | z-index: 3 56 | } 57 | 58 | .quantity .minus:hover, .quantity .plus:hover { 59 | background-color: #dad8da 60 | } 61 | 62 | .quantity .minus { 63 | bottom: 0 64 | } 65 | .shopping-cart { 66 | margin-top: 20px; 67 | } 68 | 69 | @media only screen and (max-width: 768px) { 70 | .product-name { 71 | font-size: 1rem; 72 | margin-top: .5rem; 73 | } 74 | 75 | .product-description { 76 | font-size: 1rem; 77 | } 78 | 79 | .product-quantity-container { 80 | margin-top: .5rem; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/components/Footer/Footer.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Footer = () => { 4 | return ( 5 |
6 |
7 |

Copyright © Emre Baskan 2019

8 |
9 |
10 | ); 11 | }; 12 | 13 | export default Footer; -------------------------------------------------------------------------------- /src/components/Header/Header.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {connect} from 'react-redux'; 3 | import {NavLink} from 'react-router-dom'; 4 | 5 | const Header = ({cartLength}) => { 6 | 7 | return ( 8 |