import React from 'react';
import 'bootstrap/dist/css/bootstrap.min.css';// Import Bootstrap CSS
import 'bootstrap/dist/js/bootstrap.bundle.min.js';// Import Bootstrap JS, includes Popper.js
import './App.css';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import { motion } from 'framer-motion';// Import motion from Framer Motion
import Navbar from './components/Navbar';
import Header from './components/Header';
import Services from './components/Services';
import Portfolio from './components/Portfolio';
import Contact from './components/Contact';
import Footer from './components/Footer';
const pageAnimation = {
initial: { opacity: 0, y: -20 },// Initial state
animate: { opacity: 1, y: 0 },// Animate to this state
exit: { opacity: 0, y: 20 },// Exit state
transition: { duration: 0.3 }// Animation duration
};
const App = () => (
<Route path="/services" element={
<motion.div initial="initial" animate="animate" exit="exit" variants={pageAnimation}>
<Services />
</motion.div>
} />
<Route path="/portfolio" element={
<motion.div initial="initial" animate="animate" exit="exit" variants={pageAnimation}>
<Portfolio />
</motion.div>
} />
<Route path="/contact" element={
<motion.div initial="initial" animate="animate" exit="exit" variants={pageAnimation}>
<Contact />
</motion.div>
} />
<Route path="/" element={
<motion.div initial="initial" animate="animate" exit="exit" variants={pageAnimation}>
<h2>Please select a section from the navigation.</h2>
</motion.div>
} />
</Routes>
</main>
<Footer />
</Router>
);
export default App;
but i dont want to use route: I would perfer todo something like this code:
// src/App.js
import React from 'react';
import Section1 from './components/Section1';
import Section2 from './components/Section2';
import Section3 from './components/Section3';
import Section4 from './components/Section4';
import { motion } from 'framer-motion';
import './App.css';
const App = () => {
return (
{['section1', 'section2', 'section3', 'section4'].map((section, index) => (
<motion.button
key={index}
onClick={() => document.getElementById(section).scrollIntoView({ behavior: 'smooth' })}
whileHover={{ scale: 1.1 }}
whileTap={{ scale: 0.9 }}
transition={{ type: 'spring', stiffness: 400, damping: 10 }}
>
Section {index + 1}
</motion.button>
))}
);
};
export default App;