Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
164 changes: 108 additions & 56 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,38 @@
<title>CodeClip</title>

<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Bitcount:[email protected]&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Bitcount:[email protected]&family=Oooh+Baby&display=swap" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Bitcount:[email protected]&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css2?family=Bitcount:[email protected]&family=Oooh+Baby&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css"
integrity="sha512-Evv84Mr4kqVGRNSgIGL/F/aIDqQb7xQ2vcrdIwxfjThSH8CSR7PBEakCr51Ck+w+/U6swU2Im1vVX0SVk9ABhg=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>

<!-- Material Icons -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link
href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet"
/>

<!-- Styles -->
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="styles.css" />

<!-- Sentry Script -->
<script src="https://js.sentry-cdn.com/8994bf86fecf7733832520db1565ab1f.min.js" crossorigin="anonymous"></script>
<script
src="https://js.sentry-cdn.com/8994bf86fecf7733832520db1565ab1f.min.js"
crossorigin="anonymous"
></script>
</head>
<body>
<!-- Header Component -->
Expand All @@ -30,12 +49,21 @@
<nav class="header__nav" id="navMenu">
<ul class="nav__list">
<li><a href="#" class="nav__link">Home</a></li>
<li><a href="./pages/challenges.html" class="nav__link">Challenges</a></li>
<li>
<a href="./pages/challenges.html" class="nav__link">Challenges</a>
</li>
<li><a href="/editor.html" class="nav__link">Editor</a></li>
<li><a href="#" class="nav__link">Profile</a></li>
<li>
<i class="fa-solid fa-moon" id="theme-toggle"></i>
</li>
</ul>
</nav>
<button class="header__toggle" id="navToggle" aria-label="Open navigation menu">
<button
class="header__toggle"
id="navToggle"
aria-label="Open navigation menu"
>
<span class="hamburger"></span>
<span class="hamburger"></span>
<span class="hamburger"></span>
Expand All @@ -57,15 +85,22 @@
<div class="hero__text">
<p class="hero__subtitle">🚀 An Interactive Coding Platform</p>
<h1 class="hero__title">
Code. <span class="highlight">Challenge.</span><br />
Conquer.
<span id="element"></span>
</h1>
<p class="hero__description">
Discover CodeClip, an exhilarating, lightweight web app that empowers developers to master coding challenges right in their browser! Whether you're tackling algorithms, debugging scripts, or showcasing your solutions to the open-source community, CodeClip offers a seamless, interactive experience with a sleek interface, real-time feedback, and effortless sharing via unique URLs or GitHub Gists.
Discover CodeClip, an exhilarating, lightweight web app that
empowers developers to master coding challenges right in their
browser! Whether you're tackling algorithms, debugging scripts,
or showcasing your solutions to the open-source community,
CodeClip offers a seamless, interactive experience with a sleek
interface, real-time feedback, and effortless sharing via unique
URLs or GitHub Gists.
</p>
<div class="hero__cta">
<a href="/coding" class="btn btn-primary">🎯 Start Coding</a>
<a href="/challenges" class="btn btn-secondary">📚 View Challenges</a>
<a href="/challenges" class="btn btn-secondary"
>📚 View Challenges</a
>
</div>
</div>
<div class="hero__visual">
Expand All @@ -76,9 +111,17 @@ <h1 class="hero__title">
<span class="circle green"></span>
</div>
<div class="code-content">
<div class="code-line"><span class="comment">// Welcome to CodeClip</span></div>
<div class="code-line"><span class="keyword">function</span> <span class="string">solveProblem</span>() {</div>
<div class="code-line"> <span class="keyword">return</span> <span class="string">'Success!'</span>;</div>
<div class="code-line">
<span class="comment">// Welcome to CodeClip</span>
</div>
<div class="code-line">
<span class="keyword">function</span>
<span class="string">solveProblem</span>() {
</div>
<div class="code-line">
<span class="keyword">return</span>
<span class="string">'Success!'</span>;
</div>
<div class="code-line">}</div>
</div>
</div>
Expand All @@ -87,53 +130,62 @@ <h1 class="hero__title">
</div>
</section>

<!-- Feature Cards -->
<div class="content">
<div class="card">
<a href="#" target="_blank">
<div class="icon"><i class="material-icons md-36" alt="Challenge vault icon">security</i></div>
<p class="title">Challenge Vault</p>
<p class="text">All your challenges in one place — track, review, repeat.</p>
</a>
</div>

<div class="card">
<a href="#" target="_blank">
<div class="icon"><i class="material-icons md-36" alt="Code editor icon">code</i></div>
<p class="title">Code Editor</p>
<p class="text">Write, test, and edit code seamlessly in your personal editor.</p>
</a>
</div>

<div class="card">
<a href="#" target="_blank">
<div class="icon"><i class="material-icons md-36" alt="Solution sharing icon">share</i></div>
<p class="title">Solution Sharing </p>
<p class="text">Show your approach. Discover new ones.</p>
</a>
</div>

<div class="card">
<a href="#" target="_blank">
<div class="icon"><i class="material-icons md-36" alt="AI recommendation icon">smart_toy</i></div>
<p class="title">AI Recommendation </p>
<p class="text">Let AI guide your next steps with personalized recommendations.</p>
</a>
<section class="features" id="features">
<h2 class="section-title">Why Choose <span>CodeClip</span>?</h2>
<div class="features-grid">
<div class="feature-card">
<i class="fa-solid fa-vault"></i>
<h3>Challenge Vault</h3>
<p>
A rich collection of curated coding problems to sharpen your
skills.
</p>
</div>
<div class="feature-card">
<i class="fa-solid fa-code"></i>
<h3>Code Editor</h3>
<p>
Write, run, and debug code directly in the browser with real-time
feedback.
</p>
</div>
<div class="feature-card">
<i class="fa-solid fa-share-nodes"></i>
<h3>Solution Sharing</h3>
<p>
Collaborate and share your solutions with the community for peer
feedback.
</p>
</div>
<div class="feature-card">
<i class="fa-solid fa-robot"></i>
<h3>AI Recommendations</h3>
<p>
Get personalized challenge suggestions based on your progress and
interests.
</p>
</div>
</div>
</div>
</main>

<!-- Theme Toggle -->
<div class="theme-toggle-container">
<button id="theme-toggle" class="theme-toggle-btn">Toggle Theme</button>
</div>
</section>

<!-- Footer -->
<div id="footer"></div>

<!-- Scripts -->

<script src="https://unpkg.com/[email protected]/dist/typed.umd.js"></script>

<!-- Setup and start animation! -->
<script>
var typed = new Typed("#element", {
strings: ["Code", "Challenge", "Conquer"],
typeSpeed: 50,
loop: true,
});
</script>

<script type="module" src="scripts/data.js"></script>
<script type="module" src="scripts/app.js"></script>
<script type="module" src="./scripts/theme.js"></script>
</body>
</html>
</html>
78 changes: 45 additions & 33 deletions scripts/theme.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,54 @@
import { saveUserSettings, loadUserSettings } from './data.js';
import { saveUserSettings, loadUserSettings } from "./data.js";

document.addEventListener("DOMContentLoaded", () => {
const toggleBtn = document.getElementById("theme-toggle");
const toggleBtn = document.getElementById("theme-toggle");

const setTheme = (theme) => {
document.documentElement.setAttribute("data-theme", theme);
const success = saveUserSettings({ ...loadUserSettings(), theme });
if (!success) {
alert('Failed to save theme preference.');
}
};
const setTheme = (theme) => {
document.documentElement.setAttribute("data-theme", theme);

// Toggle icon based on theme
if (theme === "dark") {
toggleBtn.classList.remove("fa-sun");
toggleBtn.classList.add("fa-moon");
} else {
toggleBtn.classList.remove("fa-moon");
toggleBtn.classList.add("fa-sun");
}

const success = saveUserSettings({ ...loadUserSettings(), theme });
if (!success) {
alert("Failed to save theme preference.");
}
};

// Apply saved theme on load
const savedSettings = loadUserSettings();
const savedTheme = savedSettings.theme;
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
const initialTheme = savedTheme || (prefersDark ? "dark" : "light");
setTheme(initialTheme);
// Apply saved theme on load
const savedSettings = loadUserSettings();
const savedTheme = savedSettings.theme;
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
const initialTheme = savedTheme || (prefersDark ? "dark" : "light");
setTheme(initialTheme);

// Toggle button click
toggleBtn.addEventListener("click", () => {
const current = document.documentElement.getAttribute("data-theme");
const newTheme = current === "light" ? "dark" : "light";
setTheme(newTheme);
});
// Toggle button click
toggleBtn.addEventListener("click", () => {
const current = document.documentElement.getAttribute("data-theme");
const newTheme = current === "light" ? "dark" : "light";
setTheme(newTheme);
});

// Real-time sync: The theme changed in one tab is linked and synced with the theme change in other tabs.
window.addEventListener("storage", (event) => {
if (event.key === "codeclip_user_settings") {
try {
const newSettings = JSON.parse(event.newValue);
if (newSettings && newSettings.theme) {
document.documentElement.setAttribute("data-theme", newSettings.theme);
}
} catch (e) {
// Ignore parse errors
// Real-time sync: The theme changed in one tab is linked and synced with the theme change in other tabs.
window.addEventListener("storage", (event) => {
if (event.key === "codeclip_user_settings") {
try {
const newSettings = JSON.parse(event.newValue);
if (newSettings && newSettings.theme) {
document.documentElement.setAttribute(
"data-theme",
newSettings.theme
);
}
} catch (e) {
// Ignore parse errors
}
});
}
});
});

Loading