Dynamische Daten in Seitentemplates eingefügt
This commit is contained in:
765
webseite/subject.php
Normal file
765
webseite/subject.php
Normal file
@@ -0,0 +1,765 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<?php
|
||||
require_once ("classes/SubjectData.php");
|
||||
require_once ("classes/TopicData.php");
|
||||
|
||||
$subjectData = SubjectData::fromName($_GET["subject"]);
|
||||
$topics = $subjectData->topics;
|
||||
?>
|
||||
|
||||
<html lang="de">
|
||||
<!--topics-->
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?php echo($subjectData->displayName); ?> 5. Klasse - Modern</title>
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
}
|
||||
|
||||
:root {
|
||||
--primary: #7C3AED;
|
||||
--primary-light: #9F67FF;
|
||||
--primary-dark: #6D28D9;
|
||||
--bg-color: #F4F7FE;
|
||||
--card-bg: #ffffff;
|
||||
--text-primary: #1E293B;
|
||||
--text-secondary: #64748B;
|
||||
--accent: #F59E0B;
|
||||
}
|
||||
|
||||
/* Add this right after the existing :root {...} block in the style section */
|
||||
:root[data-theme="dark"] {
|
||||
--primary: #9F67FF;
|
||||
--primary-light: #B794F4;
|
||||
--primary-dark: #7C3AED;
|
||||
--bg-color: #1A1A2E;
|
||||
--card-bg: #1E293B;
|
||||
--text-primary: #E2E8F0;
|
||||
--text-secondary: #A0AEC0;
|
||||
--accent: #F59E0B;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--bg-color);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
width: 280px;
|
||||
height: 100vh;
|
||||
background: var(--primary);
|
||||
padding: 2rem;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
transition: transform 0.3s ease;
|
||||
z-index: 50;
|
||||
}
|
||||
|
||||
.sidebar-header {
|
||||
color: white;
|
||||
margin-bottom: 2rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.sidebar-header i {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 1rem;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
text-decoration: none;
|
||||
border-radius: 12px;
|
||||
margin-bottom: 0.5rem;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
color: white;
|
||||
transform: translateX(5px);
|
||||
}
|
||||
|
||||
.nav-link i {
|
||||
margin-right: 1rem;
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.search-container {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 280px;
|
||||
right: 0;
|
||||
padding: 1rem 2rem;
|
||||
background: var(--card-bg);
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
||||
transition: left 0.3s ease;
|
||||
z-index: 40;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
flex: 1;
|
||||
padding: 0.75rem 1rem;
|
||||
border: 2px solid #E2E8F0;
|
||||
border-radius: 12px;
|
||||
outline: none;
|
||||
font-size: 1rem;
|
||||
transition: all 0.2s ease;
|
||||
background: var(--bg-color);
|
||||
}
|
||||
|
||||
.search-box:focus {
|
||||
border-color: var(--primary);
|
||||
box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
|
||||
}
|
||||
|
||||
.main-content {
|
||||
margin-left: 280px;
|
||||
width: calc(100% - 280px);
|
||||
padding-top: 5rem;
|
||||
transition: margin-left 0.3s ease;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
|
||||
gap: 2rem;
|
||||
padding: 2rem;
|
||||
max-width: 1600px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.topic-card {
|
||||
background: var(--card-bg);
|
||||
border-radius: 20px;
|
||||
padding: 2rem;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
||||
transform: translateY(0);
|
||||
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
|
||||
box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.topic-card::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 5px;
|
||||
background: linear-gradient(90deg, var(--primary), var(--accent));
|
||||
transform: scaleX(0);
|
||||
transform-origin: left;
|
||||
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.topic-card:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
|
||||
0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.topic-card:hover::before {
|
||||
transform: scaleX(1);
|
||||
}
|
||||
|
||||
.topic-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 1.5rem;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.topic-icon {
|
||||
font-size: 2.5rem;
|
||||
color: var(--primary);
|
||||
margin-right: 1rem;
|
||||
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
|
||||
color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.topic-card:hover .topic-icon {
|
||||
transform: rotate(-10deg);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.topic-title {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.topic-description {
|
||||
font-size: 1rem;
|
||||
color: var(--text-secondary);
|
||||
line-height: 1.7;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.related-topics {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.download-section {
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
.progress-container {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.download-section h4 {
|
||||
margin-bottom: 1rem;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.download-links {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.download-btn {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
color: white;
|
||||
padding: 0.75rem 1.25rem;
|
||||
border-radius: 10px;
|
||||
text-decoration: none;
|
||||
font-size: 0.9rem;
|
||||
transition: all 0.2s ease;
|
||||
backdrop-filter: blur(5px);
|
||||
flex: 1;
|
||||
min-width: 120px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
transform: translateY(0); /* Set initial transform state */
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.download-btn:hover {
|
||||
transform: translateY(-2px);
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.progress-label {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 0.5rem;
|
||||
font-size: 0.9rem;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
height: 8px;
|
||||
background: #E2E8F0;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.progress {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, var(--primary), var(--accent));
|
||||
border-radius: 4px;
|
||||
width: 0%;
|
||||
transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
.sidebar {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
|
||||
.sidebar.active {
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
.main-content {
|
||||
margin-left: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.search-container {
|
||||
left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.menu-toggle {
|
||||
position: fixed;
|
||||
top: 1rem;
|
||||
left: 1rem;
|
||||
z-index: 60;
|
||||
background: white;
|
||||
border: none;
|
||||
padding: 0.75rem;
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
.menu-toggle {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
/* Add floating animation for icons */
|
||||
@keyframes float {
|
||||
0%, 100% { transform: translateY(0); }
|
||||
50% { transform: translateY(-10px); }
|
||||
}
|
||||
|
||||
/* Add theme toggle button styles */
|
||||
.theme-toggle {
|
||||
position: fixed;
|
||||
top: 1rem;
|
||||
right: 1rem;
|
||||
z-index: 100;
|
||||
background: var(--card-bg);
|
||||
border: none;
|
||||
padding: 0.75rem;
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
||||
color: var(--text-primary);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.theme-toggle:hover {
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
/* Update animation keyframes */
|
||||
@keyframes cardAppear {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(20px);
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Add these styles back for the download section */
|
||||
.download-section {
|
||||
background: linear-gradient(135deg, var(--primary-light), var(--primary));
|
||||
padding: 1.5rem;
|
||||
border-radius: 12px;
|
||||
color: white;
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
.download-section h4 {
|
||||
margin-bottom: 1rem;
|
||||
font-size: 1rem;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
.download-links {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.download-btn {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
color: white;
|
||||
padding: 0.75rem 1.25rem;
|
||||
border-radius: 10px;
|
||||
text-decoration: none;
|
||||
font-size: 0.9rem;
|
||||
transition: all 0.2s ease;
|
||||
backdrop-filter: blur(5px);
|
||||
flex: 1;
|
||||
min-width: 120px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.download-btn:hover {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
/* Add these styles for the related-topics section */
|
||||
.related-topics {
|
||||
background: rgba(124, 58, 237, 0.05);
|
||||
padding: 1.25rem;
|
||||
border-radius: 12px;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.related-topics h4 {
|
||||
color: var(--primary);
|
||||
margin-bottom: 1rem;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.related-topics ul {
|
||||
list-style: none;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.related-topics li {
|
||||
background: white;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 20px;
|
||||
font-size: 0.9rem;
|
||||
color: var(--text-secondary);
|
||||
border: 1px solid rgba(124, 58, 237, 0.2);
|
||||
transition: all 0.2s ease;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.related-topics li:hover {
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
/* Add dark mode support for related topics */
|
||||
:root[data-theme="dark"] .related-topics {
|
||||
background: rgba(124, 58, 237, 0.1);
|
||||
}
|
||||
|
||||
:root[data-theme="dark"] .related-topics li {
|
||||
background: var(--card-bg);
|
||||
border-color: rgba(124, 58, 237, 0.3);
|
||||
}
|
||||
|
||||
/* Improved search box */
|
||||
.search-box {
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.search-box:focus {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(124, 58, 237, 0.15);
|
||||
}
|
||||
|
||||
/* Improved topic card hover */
|
||||
.topic-card {
|
||||
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.topic-card:hover {
|
||||
transform: translateY(-5px) scale(1.01);
|
||||
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
/* Improved icon animation */
|
||||
.topic-icon {
|
||||
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.topic-card:hover .topic-icon {
|
||||
transform: scale(1.2) rotate(-10deg);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
/* Active nav link style */
|
||||
.nav-link.active {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<button class="menu-toggle" onclick="toggleSidebar()">
|
||||
<i class="fas fa-bars"></i>
|
||||
</button>
|
||||
|
||||
<nav class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<i class="fas fa-graduation-cap"></i>
|
||||
<h2><?php echo($subjectData->displayName); ?></h2>
|
||||
</div>
|
||||
<!-- Remove this section -->
|
||||
<!-- <div class="accessibility-controls mb-4">...</div> -->
|
||||
|
||||
<a href="homepage.php" class="nav-link">
|
||||
<i class="fas fa-home"></i> Homepage
|
||||
</a>
|
||||
<a href="#" class="nav-link">
|
||||
<i class="fas fa-book"></i> Kurse
|
||||
</a>
|
||||
<a href="#" class="nav-link">
|
||||
<i class="fas fa-trophy"></i> Erfolge
|
||||
</a>
|
||||
<a href="#" class="nav-link">
|
||||
<i class="fas fa-chart-line"></i> Fortschritt
|
||||
</a>
|
||||
<a href="#" class="nav-link">
|
||||
<i class="fas fa-question-circle"></i> Hilfe
|
||||
</a>
|
||||
</nav>
|
||||
|
||||
<div class="search-container">
|
||||
<input type="text" class="search-box" id="searchInput" placeholder="Suche nach Themen, Übungen oder Hilfe..." oninput="handleSearch()">
|
||||
</div>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="container">
|
||||
|
||||
<?php
|
||||
|
||||
foreach ($topics as $topic) {
|
||||
?>
|
||||
|
||||
<div class="topic-card" onclick="window.location.href='topic.php?subject=<?php echo($topic->subjectId); ?>&topic=<?php echo($topic->id); ?>'" style="cursor: pointer;">
|
||||
<div class="topic-header">
|
||||
<i class="fas <?php echo($topic->icon); ?> topic-icon"></i>
|
||||
<h3 class="topic-title"><?php echo($topic->displayName); ?></h3>
|
||||
</div>
|
||||
<div class="topic-content">
|
||||
<p class="topic-description">
|
||||
<?php echo($topic->description); ?>
|
||||
</p>
|
||||
<div class="related-topics">
|
||||
<h4>Verwandte Themen:</h4>
|
||||
<ul>
|
||||
<?php
|
||||
foreach ($topic->relatedTopics as $relatedTopic) {
|
||||
?>
|
||||
|
||||
<li><?php echo($relatedTopic); ?></li>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="download-section">
|
||||
<h4>Übungen herunterladen:</h4>
|
||||
<div class="download-links">
|
||||
<?php
|
||||
foreach ($topic->files as $file) {
|
||||
?>
|
||||
|
||||
|
||||
<a href="#" class="download-btn">
|
||||
<i class="fas fa-file-pdf"></i>
|
||||
<?php echo($file); ?>
|
||||
</a>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<a href="#" class="download-btn">
|
||||
<i class="fas fa-file-pdf"></i>
|
||||
Übung 1
|
||||
</a>
|
||||
<a href="#" class="download-btn">
|
||||
<i class="fas fa-file-pdf"></i>
|
||||
Übung 2
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="progress-bar" data-progress="100">
|
||||
<div class="progress"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function toggleSidebar() {
|
||||
document.querySelector('.sidebar').classList.toggle('active');
|
||||
}
|
||||
|
||||
// Animate progress bars on load
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const progressBars = document.querySelectorAll('.progress-bar');
|
||||
progressBars.forEach(bar => {
|
||||
const progressContainer = bar.closest('.progress-container');
|
||||
const progressLabel = progressContainer.querySelector('.progress-label');
|
||||
const percentage = progressLabel.lastElementChild.textContent.replace('%', '');
|
||||
|
||||
setTimeout(() => {
|
||||
bar.style.width = percentage + '%';
|
||||
}, 300);
|
||||
});
|
||||
});
|
||||
|
||||
// Theme toggle functionality
|
||||
function toggleTheme() {
|
||||
const root = document.documentElement;
|
||||
const themeToggle = document.querySelector('.theme-toggle i');
|
||||
|
||||
if (root.getAttribute('data-theme') === 'dark') {
|
||||
root.removeAttribute('data-theme');
|
||||
themeToggle.classList.remove('fa-sun');
|
||||
themeToggle.classList.add('fa-moon');
|
||||
localStorage.setItem('theme', 'light');
|
||||
} else {
|
||||
root.setAttribute('data-theme', 'dark');
|
||||
themeToggle.classList.remove('fa-moon');
|
||||
themeToggle.classList.add('fa-sun');
|
||||
localStorage.setItem('theme', 'dark');
|
||||
}
|
||||
}
|
||||
|
||||
// Check for saved theme preference
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const savedTheme = localStorage.getItem('theme');
|
||||
const root = document.documentElement;
|
||||
const themeToggle = document.querySelector('.theme-toggle i');
|
||||
|
||||
if (savedTheme === 'dark') {
|
||||
root.setAttribute('data-theme', 'dark');
|
||||
themeToggle.classList.remove('fa-moon');
|
||||
themeToggle.classList.add('fa-sun');
|
||||
}
|
||||
|
||||
// Add stagger effect to cards
|
||||
const cards = document.querySelectorAll('.topic-card');
|
||||
cards.forEach((card, index) => {
|
||||
card.style.animationDelay = `${index * 0.1}s`;
|
||||
});
|
||||
|
||||
// Initialize progress bars
|
||||
const progressBars = document.querySelectorAll('.progress-bar');
|
||||
progressBars.forEach(bar => {
|
||||
const progress = bar.getAttribute('data-progress');
|
||||
const progressElement = bar.querySelector('.progress');
|
||||
setTimeout(() => {
|
||||
progressElement.style.width = `${progress}%`;
|
||||
}, 300);
|
||||
});
|
||||
});
|
||||
|
||||
// Update progress bars to 100%
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const progressBars = document.querySelectorAll('.progress-bar');
|
||||
progressBars.forEach(bar => {
|
||||
const progressElement = bar.querySelector('.progress');
|
||||
setTimeout(() => {
|
||||
progressElement.style.width = '100%';
|
||||
}, 300);
|
||||
});
|
||||
});
|
||||
|
||||
// Add preview functionality
|
||||
function togglePreview(element) {
|
||||
const previewContent = element.nextElementSibling;
|
||||
const isHidden = previewContent.style.display === 'none';
|
||||
|
||||
if (isHidden) {
|
||||
// Load preview content
|
||||
previewContent.innerHTML = `
|
||||
<div class="p-4 bg-gray-50 rounded-lg mt-4">
|
||||
<h4 class="font-semibold mb-2">Schnelle Übung:</h4>
|
||||
<div class="interactive-question mb-4">
|
||||
<!-- Dynamic content based on topic -->
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
gsap.to(previewContent, {
|
||||
height: 'auto',
|
||||
opacity: 1,
|
||||
duration: 0.3,
|
||||
display: 'block'
|
||||
});
|
||||
} else {
|
||||
gsap.to(previewContent, {
|
||||
height: 0,
|
||||
opacity: 0,
|
||||
duration: 0.3,
|
||||
onComplete: () => {
|
||||
previewContent.style.display = 'none';
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Add card hover effects
|
||||
document.querySelectorAll('.topic-card').forEach(card => {
|
||||
card.addEventListener('mouseenter', () => {
|
||||
gsap.to(card.querySelector('.topic-icon'), {
|
||||
rotate: -10,
|
||||
scale: 1.2,
|
||||
duration: 0.3
|
||||
});
|
||||
});
|
||||
|
||||
card.addEventListener('mouseleave', () => {
|
||||
gsap.to(card.querySelector('.topic-icon'), {
|
||||
rotate: 0,
|
||||
scale: 1,
|
||||
duration: 0.3
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function handleSearch() {
|
||||
const searchTerm = document.getElementById('searchInput').value.toLowerCase();
|
||||
const topicCards = document.querySelectorAll('.topic-card');
|
||||
|
||||
topicCards.forEach(card => {
|
||||
const title = card.querySelector('.topic-title').textContent.toLowerCase();
|
||||
const description = card.querySelector('.topic-description').textContent.toLowerCase();
|
||||
const relatedTopics = Array.from(card.querySelectorAll('.related-topics li'))
|
||||
.map(li => li.textContent.toLowerCase())
|
||||
.join(' ');
|
||||
|
||||
const content = `${title} ${description} ${relatedTopics}`;
|
||||
|
||||
if (content.includes(searchTerm)) {
|
||||
card.style.display = 'block';
|
||||
// Optional: Add animation for appearing cards
|
||||
gsap.to(card, {
|
||||
opacity: 1,
|
||||
y: 0,
|
||||
duration: 0.3
|
||||
});
|
||||
} else {
|
||||
card.style.display = 'none';
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Code injected by live-server -->
|
||||
</body></html>
|
||||
Reference in New Issue
Block a user