This repository has been archived by the owner on Jul 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from mirumee/151/empty_search_hide_filters
[151] Hide filters, add home page collection upon empty search
- Loading branch information
Showing
14 changed files
with
239 additions
and
164 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
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 |
---|---|---|
|
@@ -15,9 +15,5 @@ | |
@media (max-width: $small-screen) { | ||
grid-template-columns: 1fr; | ||
} | ||
|
||
&__filter { | ||
min-width: 15rem; | ||
} | ||
} | ||
} |
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,56 @@ | ||
import * as React from "react"; | ||
import { Query } from "react-apollo"; | ||
import { Link } from "react-router-dom"; | ||
|
||
import { Carousel, Loader, ProductListItem } from ".."; | ||
import { generateProductUrl, maybe } from "../../core/utils"; | ||
import { GET_FEATURED_PRODUCTS } from "./queries"; | ||
|
||
import "./scss/index.scss"; | ||
|
||
interface ProductsFeaturedProps { | ||
title?: string; | ||
} | ||
|
||
const ProductsFeatured: React.SFC<ProductsFeaturedProps> = ({ title }) => { | ||
return ( | ||
<Query query={GET_FEATURED_PRODUCTS}> | ||
{({ error, data, loading }) => { | ||
const products = maybe( | ||
() => data.shop.homepageCollection.products.edges, | ||
[] | ||
); | ||
|
||
if (products.length) { | ||
return ( | ||
<div className="products-featured"> | ||
<div className="container"> | ||
<h3>{title}</h3> | ||
<Carousel> | ||
{products.map(({ node: product }) => ( | ||
<Link | ||
to={generateProductUrl(product.id, product.name)} | ||
key={product.id} | ||
> | ||
<ProductListItem product={product} /> | ||
</Link> | ||
))} | ||
</Carousel> | ||
</div> | ||
</div> | ||
); | ||
} | ||
if (loading) { | ||
return <Loader />; | ||
} | ||
return null; | ||
}} | ||
</Query> | ||
); | ||
}; | ||
|
||
ProductsFeatured.defaultProps = { | ||
title: "Featured" | ||
}; | ||
|
||
export default ProductsFeatured; |
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,30 @@ | ||
import gql from "graphql-tag"; | ||
|
||
export const GET_FEATURED_PRODUCTS = gql` | ||
query ProductsList { | ||
shop { | ||
homepageCollection { | ||
id | ||
products(first: 20) { | ||
edges { | ||
node { | ||
id | ||
name | ||
thumbnailUrl | ||
thumbnailUrl2x: thumbnailUrl(size: 510) | ||
category { | ||
id | ||
name | ||
} | ||
price { | ||
currency | ||
amount | ||
localized | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`; |
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,17 @@ | ||
@import "../../App/scss/variables.scss"; | ||
|
||
.products-featured { | ||
padding: 2rem 0 4rem; | ||
|
||
h3 { | ||
text-transform: uppercase; | ||
font-weight: $bold-font-weight; | ||
margin-bottom: $spacer * 2; | ||
} | ||
|
||
a { | ||
display: inline-block; | ||
text-decoration: none; | ||
color: $base-font-color; | ||
} | ||
} |
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
Oops, something went wrong.