Skip to content

Commit 27e45f1

Browse files
committed
Add carousel in index page
1 parent a85cdc1 commit 27e45f1

10 files changed

+94
-74
lines changed

src/components/CarouselBox.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from "react";
2+
import styles from "./CarouselBox.module.css";
3+
import ReactCardCarousel from "react-card-carousel";
4+
5+
const CardList = [
6+
{
7+
img: "img/windows-demo.png",
8+
},
9+
{
10+
img: "img/macOS-demo.png",
11+
},
12+
{
13+
img: "img/linux-demo.png",
14+
},
15+
];
16+
17+
function Card({ img }) {
18+
return (
19+
<div className={styles.cardItem}>
20+
<img src={img} className={styles.cardImage} />
21+
</div>
22+
);
23+
}
24+
25+
export default function HomepageCarousel() {
26+
return (
27+
<div className={styles.carouselBox}>
28+
<ReactCardCarousel autoplay={true} spread={"wide"} autoplay_speed={5000}>
29+
{CardList.map((props, idx) => (
30+
<Card key={idx} {...props} />
31+
))}
32+
</ReactCardCarousel>
33+
</div>
34+
);
35+
}

src/components/CarouselBox.module.css

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.carouselBox {
2+
position: relative;
3+
height: 100%;
4+
width: 100%;
5+
display: flex;
6+
flex: 1;
7+
justify-content: center;
8+
align-items: middle;
9+
}
10+
11+
.cardItem {
12+
cursor: pointer;
13+
overflow: hidden;
14+
border-radius: 10px;
15+
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
16+
}
17+
18+
.cardImage {
19+
display: block;
20+
}

src/components/HomepageCarousel.js

-38
This file was deleted.

src/components/HomepageCarousel.module.css

-12
This file was deleted.

src/components/HomepageFeatures.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ function Feature({ Svg, title, description }) {
6262

6363
export default function HomepageFeatures() {
6464
return (
65-
<section className={styles.features}>
65+
<div className={styles.featuresSec}>
6666
<div className="container">
6767
<div className="row">
6868
{FeatureList.map((props, idx) => (
6969
<Feature key={idx} {...props} />
7070
))}
7171
</div>
7272
</div>
73-
</section>
73+
</div>
7474
);
7575
}

src/components/HomepageFeatures.module.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.features {
1+
.featuresSec {
22
display: flex;
33
align-items: center;
44
padding: 2rem 0;

src/pages/index.js

+27-16
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Translate from "@docusaurus/Translate";
77

88
import styles from "./index.module.css";
99
import HomepageFeatures from "../components/HomepageFeatures";
10-
import HomepageCarousel from "../components/HomepageCarousel";
10+
import CarouselBox from "../components/CarouselBox";
1111

1212
import CefViewBridge from "../components/CefViewBridge";
1313

@@ -17,20 +17,32 @@ function HomepageHeader() {
1717
return (
1818
<header className={clsx("hero hero--primary", styles.heroBanner)}>
1919
<div className="container">
20-
<h1 className="hero__title">{siteConfig.title}</h1>
21-
<p className="hero__subtitle">{siteConfig.tagline}</p>
22-
<div className={styles.buttons}>
23-
<Link
24-
className="button button--secondary button--lg"
25-
to="/docs/intros"
26-
>
27-
<Translate
28-
id="index.ButtonText.getStated"
29-
description="The text for button on index center"
30-
>
31-
Get Started
32-
</Translate>
33-
</Link>
20+
<div className={clsx("row", styles.indexRow)}>
21+
<div className="col">
22+
<h1 className="hero__title">{siteConfig.title}</h1>
23+
<p className="hero__subtitle">{siteConfig.tagline}</p>
24+
<div className={styles.buttons}>
25+
<Link
26+
className="button button--secondary button--lg"
27+
to="/docs/intros"
28+
>
29+
<Translate
30+
id="index.ButtonText.getStated"
31+
description="The text for button on index center"
32+
>
33+
Get Started
34+
</Translate>
35+
</Link>
36+
</div>
37+
</div>
38+
</div>
39+
40+
<div className={clsx("row", styles.indexRow)}>
41+
<div className="col">
42+
<div className={styles.carousel}>
43+
<CarouselBox />
44+
</div>
45+
</div>
3446
</div>
3547
</div>
3648
</header>
@@ -43,7 +55,6 @@ export default function Home() {
4355
<Layout title={`${siteConfig.title}`} description="">
4456
<HomepageHeader />
4557
<main>
46-
<HomepageCarousel />
4758
<HomepageFeatures />
4859
</main>
4960
</Layout>

src/pages/index.module.css

+9-5
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@
44
*/
55

66
.heroBanner {
7-
padding: 4rem 0;
7+
padding: 0 0;
88
text-align: center;
99
position: relative;
1010
overflow: hidden;
1111
}
1212

13-
@media screen and (max-width: 966px) {
14-
.heroBanner {
15-
padding: 2rem;
16-
}
13+
.indexRow {
14+
padding: 1rem 0;
15+
}
16+
17+
.carousel {
18+
width: 100%;
19+
padding-top: 15%;
20+
padding-bottom: 15%;
1721
}
1822

1923
.buttons {

static/img/macOS-demo-original.png

4.14 MB
Loading

static/img/macOS-demo.png

-3.02 MB
Loading

0 commit comments

Comments
 (0)