Skip to content

Commit

Permalink
Merge pull request #386 from Anshikapal05/main
Browse files Browse the repository at this point in the history
Added Success Stories and Inspiration Board
  • Loading branch information
Avdhesh-Varshney authored Nov 11, 2024
2 parents 06a38b4 + cfc5f92 commit b4dfed4
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Footer from "./components/shared/Footer";
import Home from "./pages/Home";
import About from "./pages/About";
import Help from "./pages/Help";
import SuccessStories from "./pages/SuccessStories";
import Feedback from "./pages/Feedback";

import ChanakyaAudio from "./pages/resources/ChanakyaAudio";
Expand Down Expand Up @@ -130,7 +131,7 @@ function App() {
path="/resources/chanakyagpt"
element={<ChanakyaGpt />}
/>

<Route exact path="/successstories" element={<SuccessStories />} />
<Route exact path="/contributor" element={<Contributors />} />
<Route
path="/contributor/details"
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/Navbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
position: relative;
display: inline-block;
transition: color 0.3s ease-in-out;

white-space: nowrap;
}

.nav-link::before {
Expand Down
11 changes: 10 additions & 1 deletion src/components/shared/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,16 @@ const Navbar = () => {
</li>
</ul>
</li>

<li className="nav-item">
<Link
className="nav-link"
to="/successstories"
style={{ color: textColor }}
onClick={handleLinkClick}
>
Success Stories
</Link>
</li>
<li className="nav-item">
<Link
className="nav-link"
Expand Down
92 changes: 92 additions & 0 deletions src/css/SuccessStories.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/* Dark mode colors */
body.dark {
--background-color: #2c2a2a;
--text-color: #000000;
--card-background: #3a3a3a;
--heading-color: #363636;
--button-background: #3d8b3d;
--button-hover: #317532;
transition: background-color 0.25s, color 0.25s;
}
.story-container {
max-width: 800px;
margin: auto;
padding: 20px;
background-color: var(--background-color);
color: var(--text-color);
border-radius: 8px;
}

h1, h2 {
text-align: center;
color: var(--heading-color);
margin-bottom: 80px; /* Add space below each heading */
margin-top: 80px; /* Add space above each heading */
}
.story-form h3{
text-align: center;
}
.story-form {
margin-bottom: 30px;
}

input, textarea {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 8px;
}

button {
width: 100%;
padding: 10px;
background-color: #28a745;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}

button:hover {
background-color: #218838;
}

.stories {
display: flex;
flex-wrap: wrap;
gap: 20px;
margin-bottom: 30px; /* Add space below each story section */
}

.story {
background-color: var(--card-background);
flex: 1 1 calc(50% - 20px);
color: var(--text-color);
padding: 15px;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.story h3 {
color: var(--heading-color);
margin: 0 0 10px;
}

/* Initial stories (great minds) */
.story.initial {
background: #e7f3ff; /* Light blue */
border-left: 4px solid #1e90ff;
}

/* Personal stories */
.story.personal {
background: #fff7e6; /* Light orange */
border-left: 4px solid #ff9800;
}

/* User-submitted stories */
.story.user-submitted {
background: #f0f9e9; /* Light green */
border-left: 4px solid #28a745;
}
97 changes: 97 additions & 0 deletions src/pages/SuccessStories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import React, { useState, useEffect } from 'react';
import '../css/SuccessStories.css'; // Import CSS for styling

const SuccessStories = () => {
const [name, setName] = useState('');
const [story, setStory] = useState('');
const [stories, setStories] = useState([]);

// Load initial stories and saved stories from local storage
useEffect(() => {
const savedStories = JSON.parse(localStorage.getItem('stories')) || [];
const initialStories = [
{ name: "Chanakya", story: "Known as the father of Indian economics and political science, Chanakya's teachings on governance and strategy in the Arthashastra have shaped political thinking and leadership for centuries.", type: 'initial' },
{ name: "Confucius", story: "Confucius emphasized family, respect, and ethical governance, creating a system of thought that influenced East Asian culture, philosophy, and political systems for over two millennia.", type: 'initial' },
{ name: "Plato", story: "Plato, one of the foundational figures in Western philosophy, wrote works like 'The Republic,' which explores justice, morality, and the ideal state, laying the groundwork for modern philosophy and political theory.", type: 'initial' },
{ name: "Sun Tzu", story: "Author of 'The Art of War,' Sun Tzu's timeless insights on strategy and warfare remain relevant in business, sports, and personal success, advocating for knowledge, preparation, and adaptability.", type: 'initial' },

// Personal stories inspired by these great minds
{ name: "Aditi", story: "Inspired by Chanakya, I've learned to approach my career with a strategic mindset, always planning ahead and thinking about the bigger picture. His teachings have helped me navigate office politics gracefully.", type: 'personal' },
{ name: "Rahul", story: "Confucius's emphasis on respect and family has transformed the way I communicate with my parents and colleagues. His philosophy reminds me daily to prioritize harmony and respect in my relationships.", type: 'personal' },
{ name: "Sneha", story: "Reading Plato’s ideas on justice and morality made me rethink my role in society. I now volunteer regularly, and I've become more conscious of how my actions impact others.", type: 'personal' },
{ name: "Vikram", story: "Sun Tzu's 'Art of War' inspired me to approach challenges in my startup with patience and a focus on adaptability. I’ve learned that preparation and understanding my competitors is crucial.", type: 'personal' },
];
setStories([...initialStories, ...savedStories]);
}, []);

// Save stories to local storage whenever they update
useEffect(() => {
localStorage.setItem('stories', JSON.stringify(stories.filter(s => s.type === 'user-submitted')));
}, [stories]);

const handleSubmit = () => {
if (name.trim() && story.trim()) {
setStories([...stories, { name, story, type: 'user-submitted' }]);
setName('');
setStory('');
alert("Your story has been submitted successfully!");
} else {
alert("Please fill out both fields.");
}
};

return (
<div className="container">
<h1>Success Stories and Inspiration Board</h1>
<div className="story-form">
<h3>Share Your Story!</h3>
<input
type="text"
placeholder="Your Name"
value={name}
onChange={(e) => setName(e.target.value)}
required
/>
<textarea
placeholder="Your Success Story"
value={story}
onChange={(e) => setStory(e.target.value)}
required
/>
<button onClick={handleSubmit}>Submit</button>
</div>

<h2>Inspiration from Great Minds</h2>
<div className="stories">
{stories.filter(s => s.type === 'initial').map((s, index) => (
<div key={index} className="story initial">
<h3>{s.name}</h3>
<p>{s.story}</p>
</div>
))}
</div>

<h2>Personal Stories Inspired by Great Minds</h2>
<div className="stories">
{stories.filter(s => s.type === 'personal').map((s, index) => (
<div key={index} className="story personal">
<h3>{s.name}</h3>
<p>{s.story}</p>
</div>
))}
</div>

<h2>Stories from Our Community</h2>
<div className="stories">
{stories.filter(s => s.type === 'user-submitted').map((s, index) => (
<div key={index} className="story user-submitted">
<h3>{s.name}</h3>
<p>{s.story}</p>
</div>
))}
</div>
</div>
);
};

export default SuccessStories;

0 comments on commit b4dfed4

Please sign in to comment.