Spaces:
Sleeping
Sleeping
Create Swipercomponent.js
Browse files- Swipercomponent.js +47 -0
Swipercomponent.js
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import React, { useState } from "react";
|
2 |
+
import { Swiper, SwiperSlide } from "swiper/react";
|
3 |
+
import "swiper/css";
|
4 |
+
import "swiper/css/effect-coverflow";
|
5 |
+
import "swiper/css/pagination";
|
6 |
+
import { EffectCoverflow, Pagination } from "swiper/modules";
|
7 |
+
import "./Swipercomponent.css"; // Ensure you create a corresponding CSS file
|
8 |
+
|
9 |
+
const avatars = [
|
10 |
+
{ name: "Rat", image: "images/rat.png", description: "Clever and resourceful. Loves puzzles and word games.", sample: "Let's solve a riddle together!" },
|
11 |
+
{ name: "Ox", image: "images/ox.png", description: "Strong and dependable. Very patient when explaining concepts.", sample: "I will guide you step by step." },
|
12 |
+
{ name: "Tiger", image: "images/tiger.png", description: "Brave and energetic. Loves exciting challenges.", sample: "Let's make learning an adventure!" },
|
13 |
+
{ name: "Rabbit", image: "images/rabbit.png", description: "Gentle and kind. Encourages learning through storytelling.", sample: "I have a story to share with you!" },
|
14 |
+
{ name: "Dragon", image: "images/dragon.png", description: "Confident and intelligent. Explains ideas clearly.", sample: "I will help you think like a scholar!" },
|
15 |
+
{ name: "Snake", image: "images/snake.png", description: "Calm and analytical. Gives insightful explanations.", sample: "Let's break this down logically!" },
|
16 |
+
{ name: "Horse", image: "images/horse.png", description: "Cheerful and enthusiastic. Encourages active participation.", sample: "Come on, let's say it together!" },
|
17 |
+
{ name: "Goat", image: "images/sheep.png", description: "Creative and friendly. Uses fun examples.", sample: "Let's use pictures to understand this!" },
|
18 |
+
{ name: "Monkey", image: "images/monkey.png", description: "Smart and playful. Makes learning fun.", sample: "I love word games! Do you?" },
|
19 |
+
{ name: "Rooster", image: "images/rooster.png", description: "Confident and vocal. Encourages clear pronunciation.", sample: "Let's practice speaking clearly!" },
|
20 |
+
{ name: "Dog", image: "images/dog.png", description: "Loyal and encouraging. Builds confidence in learners.", sample: "You're doing a great job!" },
|
21 |
+
{ name: "Pig", image: "images/pig.png", description: "Easygoing and kind. Makes learning feel natural.", sample: "Let's take it step by step together!" }
|
22 |
+
];
|
23 |
+
|
24 |
+
function SwiperComponent({ onSelectAvatar }) {
|
25 |
+
const [selected, setSelected] = useState(avatars[0]); // Default to the first avatar
|
26 |
+
|
27 |
+
const handleSelect = (avatar) => {
|
28 |
+
setSelected(avatar);
|
29 |
+
onSelectAvatar(avatar);
|
30 |
+
};
|
31 |
+
|
32 |
+
return (
|
33 |
+
<div className="swiper-container">
|
34 |
+
<Swiper
|
35 |
+
effect={"coverflow"}
|
36 |
+
grabCursor={true}
|
37 |
+
centeredSlides={true}
|
38 |
+
slidesPerView={"auto"}
|
39 |
+
coverflowEffect={{
|
40 |
+
rotate: 0,
|
41 |
+
stretch: 0,
|
42 |
+
depth: 100,
|
43 |
+
modifier: 2.5,
|
44 |
+
slideShadows: false,
|
45 |
+
}}
|
46 |
+
pagination={true}
|
47 |
+
|