Skip to content

Commit 514c6ff

Browse files
committed
Added Product cards
1 parent b5b563c commit 514c6ff

File tree

6 files changed

+148
-19
lines changed

6 files changed

+148
-19
lines changed

src/assets/scss/components/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
@import 'footer';
2222
@import 'alerts';
2323
@import 'search';
24+
@import 'productCard.scss';
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
.product-select-container {
2+
text-align: center;
3+
4+
.product-select {
5+
margin-bottom: 10px;
6+
width: 100%;
7+
}
8+
}
9+
10+
.product-card {
11+
border-radius: 5px;
12+
box-shadow: 0px 2px 15px $shadow-color;
13+
margin: 8px 15px;
14+
padding: 10px;
15+
text-transform: uppercase;
16+
transition: 0.2s;
17+
width: 260px;
18+
19+
.circle-container {
20+
width: 100%;
21+
22+
.circle {
23+
border: 1px solid $primary;
24+
border-radius: 50%;
25+
height: 10px;
26+
margin: auto;
27+
margin-top: 10px;
28+
width: 10px;
29+
}
30+
}
31+
32+
.product-title {
33+
padding-left: 10px;
34+
width: 160px;
35+
36+
h2 {
37+
margin: 0;
38+
}
39+
}
40+
41+
.product-logo {
42+
width: 90px;
43+
44+
img {
45+
width: 90px;
46+
}
47+
}
48+
49+
&-selected {
50+
background-color: $primary;
51+
color: $eos-white;
52+
transform: scale(1.03);
53+
54+
.circle {
55+
background-color: $eos-white;
56+
}
57+
}
58+
59+
&:hover {
60+
cursor: pointer;
61+
transform: scale(1.03);
62+
}
63+
}

src/assets/scss/pages/home.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ $subheader-font-size: 18px;
44
.product-introduction {
55
display: flex;
66
font-family: $font-family-spartan;
7-
margin: 88px 0px;
7+
margin: 32px 0px;
88

99
.subheader {
1010
font-size: $subheader-font-size;

src/components/ProductSelect.jsx

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import React from 'react'
2+
import Skeleton from 'react-loading-skeleton'
3+
4+
const ProductSkeleton = () => {
5+
return (
6+
<div className='flex flex-row flex-center product-card'>
7+
<div className='flex flex-center'>
8+
<div className='product-logo'>
9+
<Skeleton height={62} />
10+
</div>
11+
<div className='product-title'>
12+
<Skeleton count={2} height={30} />
13+
</div>
14+
</div>
15+
<div className='circle-container'>
16+
<div className='circle'></div>
17+
</div>
18+
</div>
19+
)
20+
}
21+
22+
const ProductCard = ({ product, selected, setProduct }) => {
23+
return (
24+
<div
25+
className={`flex flex-center flex-align-center product-card ${
26+
selected ? 'product-card-selected' : ''
27+
}`}
28+
onClick={() => {
29+
if (!selected) {
30+
setProduct(product.Name)
31+
} else {
32+
setProduct('All')
33+
}
34+
}}
35+
>
36+
<div className='flex flex-center'>
37+
<div className='flex flex-align-center product-logo'>
38+
<img src={product.logo.url} alt={`${product.Name} logo`} />
39+
</div>
40+
<div className='product-title'>
41+
<h2>{product.Name}</h2>
42+
</div>
43+
</div>
44+
<div className='circle-container'>
45+
<div className='circle'></div>
46+
</div>
47+
</div>
48+
)
49+
}
50+
51+
const ProductSelect = ({ product, products, setProduct }) => {
52+
return (
53+
<div className='product-select-container'>
54+
<h4>Select a Product</h4>
55+
<div className='flex flex-row flex-center product-select'>
56+
{!products && [1, 2, 3].map((i) => <ProductSkeleton key={i} />)}
57+
{products !== null &&
58+
products.map((p) => (
59+
<ProductCard
60+
key={p.Name}
61+
product={p}
62+
selected={p.Name === product}
63+
setProduct={setProduct}
64+
/>
65+
))}
66+
</div>
67+
</div>
68+
)
69+
}
70+
71+
export default ProductSelect

src/components/Stories.js

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import SearchInput from '../modules/SearchInput'
99

1010
import Lists from '../utils/Lists'
1111
import userStory from '../services/user_story'
12+
import ProductSelect from './ProductSelect'
1213

1314
const Stories = ({ authorId, followerId }) => {
1415
const [currentStateSelected, selectState] = useState('Under consideration')
@@ -25,7 +26,7 @@ const Stories = ({ authorId, followerId }) => {
2526

2627
const [category, setCategory] = useState('All')
2728

28-
const [products, setProducts] = useState([])
29+
const [products, setProducts] = useState(null)
2930

3031
const [categories, setCategories] = useState([])
3132

@@ -39,8 +40,6 @@ const Stories = ({ authorId, followerId }) => {
3940

4041
const statusDropdownContainer = useRef()
4142

42-
const productDropdownContainer = useRef()
43-
4443
const sortDropdownContainer = useRef()
4544

4645
const categoryDropdownContainer = useRef()
@@ -139,13 +138,8 @@ const Stories = ({ authorId, followerId }) => {
139138
const fetchProducts = async () => {
140139
const response = await userStory.getProducts()
141140
return response.data.data.product !== null
142-
? setProducts([
143-
'All',
144-
...response.data.data.products?.map((ele) => {
145-
return ele.Name
146-
})
147-
])
148-
: setProducts(['All'])
141+
? setProducts([...response.data.data.products])
142+
: setProducts([])
149143
}
150144
fetchProducts()
151145
}, [])
@@ -186,6 +180,11 @@ const Stories = ({ authorId, followerId }) => {
186180

187181
return (
188182
<div>
183+
<ProductSelect
184+
product={product}
185+
products={products}
186+
setProduct={setProduct}
187+
/>
189188
<div className='roadmap-container'>
190189
<div className='roadmap'>
191190
{Lists.stateList &&
@@ -234,14 +233,6 @@ const Stories = ({ authorId, followerId }) => {
234233
setAuthorQuery={setAuthorQuery}
235234
/>
236235
<div className='flex flex-row options-bar'>
237-
<Dropdown
238-
title='Product'
239-
reference={productDropdownContainer}
240-
curr={product}
241-
setCurr={setProduct}
242-
itemList={products}
243-
data-cy='product-dropdown'
244-
/>
245236
<Dropdown
246237
title='Categories'
247238
reference={categoryDropdownContainer}

src/services/user_story.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ const userStory = {
190190
query: `query {
191191
products {
192192
Name
193+
logo {
194+
url
195+
}
193196
}
194197
}`
195198
}

0 commit comments

Comments
 (0)