-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
directory and shop data into reducer, and creating its own reselector
- Loading branch information
Showing
10 changed files
with
95 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
.collection-item { | ||
width: 22%; | ||
width: 22vw; | ||
display: flex; | ||
flex-direction: column; | ||
height: 350px; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
import {connect} from 'react-redux'; | ||
|
||
// eslint-disable-next-line | ||
import CollectionItem from '../../components/collection-items/collection-items.component'; | ||
|
||
import { selectShopCollection } from '../../redux/shop/shop.selector'; | ||
|
||
import './collection.styles.scss'; | ||
|
||
const CollectionPage = ({ collection }) => { | ||
const {title, items} = collection; | ||
return ( | ||
<div className='collection-page'> | ||
<h2 className='title'>{ title }</h2> | ||
<div className='items'> | ||
{ | ||
items.map(item=>( | ||
<CollectionItem key={item.id} item={item} /> | ||
)) | ||
} | ||
</div> | ||
</div> | ||
) | ||
}; | ||
|
||
const mapStateToProps = (state, ownProps) => ({ | ||
collection: selectShopCollection(ownProps.match.params.collectionId)(state) | ||
}) | ||
|
||
export default connect(mapStateToProps)(CollectionPage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.collection-page { | ||
display: flex; | ||
flex-direction: column; | ||
|
||
.title { | ||
font-size: 38px; | ||
margin: 0 auto 30px; | ||
} | ||
|
||
.items { | ||
display: grid; | ||
grid-template-columns: 1fr 1fr 1fr 1fr; | ||
grid-gap: 10px; | ||
|
||
& .collection-item { | ||
margin-bottom: 30px; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
import { createSelector } from 'reselect'; | ||
import memoize from 'lodash.memoize'; | ||
|
||
const selectShop = state => state.shop; | ||
|
||
export const selectShopCollection = createSelector( | ||
export const selectShopCollections = createSelector( | ||
[selectShop], | ||
shop=>shop.collections | ||
) | ||
|
||
export const selectShopCollectionWMemoize = createSelector( | ||
[selectShop], | ||
shop => shop.collections | ||
); | ||
|
||
export const selectShopCollection = memoize((collectionUrlParam) => | ||
createSelector( | ||
[selectShopCollections], | ||
collections=> collections[collectionUrlParam] | ||
) | ||
) | ||
|
||
export const selectCollectionForPreview = createSelector( | ||
[selectShopCollectionWMemoize], | ||
collections=>Object.keys(collections).map(key=>collections[key]) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters