Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Quotes #546

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions components/Quotes/Quotes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React, { useState, useEffect } from 'react';
import axios from 'axios';
import { Swiper, SwiperSlide } from 'swiper/react';
import 'swiper/swiper-bundle.css';
import styles from 'styles/Home.module.css'; // Import your styles


const Quotes = () => {
const [quotes, setQuotes] = useState([]);

useEffect(() => {
const fetchQuotes = async () => {
try {
const response = await axios.get('https://api.quotable.io/quotes?limit=10');
setQuotes(response.data.results);
} catch (error) {
console.log(error);
}
};
fetchQuotes();
}, []);

if (quotes.length === 0) {
return <p>Loading quotes...</p>;
}

return (
<div data-aos="fade-up">
<h2 className={styles.grabh2}>Quotes</h2>
<div className={styles['quotes-container']}>
<Swiper
spaceBetween={30}
loop={true}
pagination={{ clickable: true }}
effect={'slide'} // Add the effect prop to enable auto transition
autoplay={{ delay: 3000 }} // Set the delay (in ms) for auto transition
>
{quotes.map((quote, index) => (
<SwiperSlide key={quote._id}>
<div className={styles['quote-wrapper']}>
<p className={styles['quote-text']}><b>"{quote.content}"</b></p>
<p>- {quote.author}</p>
</div>
</SwiperSlide>
))}
</Swiper>
</div>
</div>
);
};

export default Quotes;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"react-markdown": "^8.0.7",
"react-vanilla-tilt": "^1.0.0",
"sass": "^1.45.1",
"styled-components": "^5.3.6",
"styled-components": "^5.3.11",
Shahil093 marked this conversation as resolved.
Show resolved Hide resolved
"swiper": "^9.3.2",
"yarn": "^1.22.19"
},
Expand Down
4 changes: 4 additions & 0 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import 'aos/dist/aos.css';
import TestimonialCard from 'components/Testimonial/Testimonial';
import GoToTop from 'components/GoToTop';

import Quotes from 'components/Quotes/Quotes';


export default function Home() {
const { dispatch } = useContext(Store);

Expand Down Expand Up @@ -295,6 +298,7 @@ export default function Home() {
</form>
</section>
</main>
<Quotes />
<TestimonialCard />
<Footer />
</>
Expand Down
37 changes: 37 additions & 0 deletions styles/Home.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,40 @@ input:focus {
#sub:hover > div > div {
background: rgb(159, 154, 255) !important;
}





/* Styles for the container wrapping the Quotes component */
.container {
display: flex;
justify-content: center;
align-items: center;
height: 50vh; /* Adjust this value based on your layout */
}
Shahil093 marked this conversation as resolved.
Show resolved Hide resolved

/* Styles for the quotes container */
.quotes-container {
display: flex;
justify-content: center;
align-items: center;
height: 30vh;
overflow: hidden;
justify-content: center;
}

/* Styles for the quote wrapper */
.quote-wrapper {
background-color: rgba(255, 255, 255, 0.7);
border-radius: 10px;
padding: 30px;
/* max-width: 500px; */
text-align: center;
}

/* Styles for the quote text */
.quote-text {
font-size: 1.5rem;
margin-bottom: 20px;
}
Shahil093 marked this conversation as resolved.
Show resolved Hide resolved
Loading