Skip to content

Commit e48d25c

Browse files
committed
Add Carousel
gh-16
1 parent 52e74c4 commit e48d25c

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

shop-ui/ui/src/routes/Home.js

+27-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, {useEffect, useState} from "react";
2+
import {Carousel} from 'primereact/carousel';
23
import {fetchSocksByTag} from "./Tag";
34
import {Link} from "react-router-dom";
45
import {Tags} from "../components/Tags";
@@ -10,14 +11,35 @@ export function Home() {
1011
}, []);
1112
return <div className="p-grid p-dir-rev">
1213
<div className="p-col-10">
13-
<h2>Spring Socks</h2>
14-
<ul>
15-
{socks.map(sock => <li key={sock.id}><Link
16-
to={`/details/${sock.id}`}>{sock.name}</Link></li>)}
17-
</ul>
14+
<h2>WE LOVE SOCKS!</h2>
15+
<p>
16+
100% SATISFACTION GUARANTEED<br/>
17+
<img src={'/img/spring_socks_1.jpg'} alt={"Spring Socks"}
18+
style={{
19+
height: '430px',
20+
display: 'flex',
21+
alignItems: 'center',
22+
}}
23+
/><br/>
24+
Socks were invented by woolly mammoths to keep warm. They died out because
25+
stupid humans had to cut their legs off to get their socks
26+
</p>
27+
<h2>Featured Socks</h2>
28+
<Carousel value={socks} itemTemplate={itemTemplate} numVisible={3}
29+
numScroll={1}
30+
autoplayInterval={3000}></Carousel>
1831
</div>
1932
<div className="p-col-2">
2033
<Tags/>
2134
</div>
2235
</div>;
36+
}
37+
38+
function itemTemplate(sock) {
39+
return <p>
40+
<Link to={`/details/${sock.id}`}>
41+
<img alt={sock.name} src={sock.imageUrl && sock.imageUrl[0]}
42+
height={'270px'}/><br/>
43+
{sock.name}</Link>
44+
</p>;
2345
}

0 commit comments

Comments
 (0)