Merge pull request #1516 from TacticalReader/main

Upgraded typing game, chat backend, and main index files
pull/1526/head
Lee Stott 11 months ago committed by GitHub
commit 6934238552
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -198,6 +198,9 @@ Compare some programming languages. What are some of the unique traits of JavaSc
Study a bit on the different languages available to the programmer. Try to write a line in one language, and then rewrite it in two others. What did you learn? Study a bit on the different languages available to the programmer. Try to write a line in one language, and then rewrite it in two others. What did you learn?
## Assignment ## Assignment
[Reading the Docs](assignment.md) [Reading the Docs](assignment.md)
> Note: When selecting tools for your assignment, do not choose editors, browsers, or command line tools already listed above.

@ -1,11 +1,17 @@
# Reading the Docs
## Instructions ## Instructions
There are many tools that a web developer may need that are on the [MDN documentation for client-side tooling](https://developer.mozilla.org/docs/Learn/Tools_and_testing/Understanding_client-side_tools/Overview). Select 3 tools not covered in the lesson, explain why a web developer would use it, and search for a tool that falls under this category and share its documentation. Do not use the same tool example on MDN docs. There are many tools that a web developer may need that are listed on the [MDN documentation for client-side tooling](https://developer.mozilla.org/docs/Learn/Tools_and_testing/Understanding_client-side_tools/Overview). Select **three tools** that are **not covered in this lesson** (excluding [list specific tools or refer to lesson content]), explain **why** a web developer would use each tool, and find a tool that fits each category. For each, share a link to its official documentation (not the example used on MDN).
**Format:**
- Tool name
- Why a web developer would use it (2-3 sentences)
- Link to documentation
**Length:**
- Each explanation should be 2-3 sentences.
## Rubric ## Rubric
Exemplary | Adequate | Needs Improvement Exemplary | Adequate | Needs Improvement
--- | --- | -- | --- | --- | -- |
|Explained why web developer would use tool| Explained how, but not why developer would use tool| Did not mention how or why a developer would use tool | Explained why web developer would use tool | Explained how, but not why developer would use tool | Did not mention how or why a developer would use tool |

@ -2,10 +2,10 @@
## Instructions ## Instructions
Imagine you are building a shopping cart. Write some documentation on the data types that you would need to complete your shopping experience. How did you arrive at your choices? Imagine you are building a shopping cart. Write documentation on the data types you would need to complete your shopping experience. For each data type, explain how and why you would use it, and provide an example. The six JavaScript data types are: String, Number, Boolean, Null, Undefined, and Object.
## Rubric ## Rubric
Criteria | Exemplary | Adequate | Needs Improvement Criteria | Exemplary | Adequate | Needs Improvement
--- | --- | --- | -- | --- | --- | --- | -- |
||The six data types are listed and explored in detail, documenting their use|Four datatypes are explored|Two data types are explored| Data Types | All six data types are listed, explored in detail, and documented with examples | Four data types are explored with some explanation | Two data types are explored with minimal explanation |

@ -1,11 +1,39 @@
# Practice your HTML: Build a blog mockup # HTML Practice Assignment: Build a Blog Mockup
## Objective
Design and hand-code the HTML structure for a personal blog homepage. This exercise will help you practice semantic HTML, layout planning, and code organization.
## Instructions ## Instructions
Imagine you are designing, or redesigning, your personal web site. Create a graphical mockup of your site, and then write down the HTML markup you would use to build out the various elements of the site. You can do this on paper, and scan it, or use software of your choice, just make sure to hand-code the HTML markup. 1. **Design Your Blog Mockup**
- Sketch a visual mockup of your blog homepage. Include key sections such as header, navigation, main content, sidebar, and footer.
- You may use paper and scan your sketch, or use digital tools (e.g., Figma, Adobe XD, Canva, or even PowerPoint).
2. **Identify HTML Elements**
- List the HTML elements you plan to use for each section (e.g., `<header>`, `<nav>`, `<main>`, `<article>`, `<aside>`, `<footer>`, `<section>`, `<h1>``<h6>`, `<p>`, `<img>`, `<ul>`, `<li>`, `<a>`, etc.).
3. **Write the HTML Markup**
- Hand-code the HTML for your mockup. Focus on semantic structure and best practices.
- Include at least 10 distinct HTML elements.
- Add comments to explain your choices and structure.
4. **Submit Your Work**
- Upload your sketch/mockup and your HTML file.
- Optionally, provide a brief reflection (23 sentences) on your design decisions.
## Rubric ## Rubric
| Criteria | Exemplary | Adequate | Needs Improvement | | Criteria | Exemplary | Adequate | Needs Improvement |
| -------- | ----------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | |------------------|--------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|---------------------------------------------------------------------------------|
| | A blog layout is represented visually with at least 10 elements of markup displayed | A blog layout is represented visually with around 5 elements of markup displayed | A blog layout is represented visually with at most 3 elements of markup displayed | | Visual Mockup | Clear, detailed mockup with labeled sections and thoughtful layout | Basic mockup with some labeled sections | Minimal or unclear mockup; lacks section labels |
| HTML Elements | Uses 10+ semantic HTML elements; demonstrates understanding of structure and best practices | Uses 59 HTML elements; some semantic structure | Uses fewer than 5 elements; lacks semantic structure |
| Code Quality | Well-organized, readable code with comments; follows HTML standards | Mostly organized code; few comments | Disorganized code; lacks comments |
| Reflection | Insightful reflection on design choices and challenges | Basic reflection | No reflection or lacks relevance |
## Tips
- Use semantic HTML tags for better accessibility and SEO.
- Organize your code with indentation and comments.
- Refer to [MDN HTML Elements Reference](https://developer.mozilla.org/en-US/docs/Web/HTML/Element) for guidance.
- Think about how your layout could be extended or styled in future assignments.

@ -1,11 +1,27 @@
# CSS Refactoring # CSS Refactoring Assignment
## Objective
Refactor the terrarium project to use **Flexbox** or **CSS Grid** for layout. Update the HTML and CSS as needed to achieve a modern, responsive design. You do not need to implement draggable elements—focus on layout and styling only.
## Instructions ## Instructions
Restyle the terrarium using either Flexbox or CSS Grid, and take screenshots to show that you have tested it on several browsers. You might need to change the markup so create a new version of the app with the art in place for your refactor. Don't worry about making the elements draggable; only refactor the HTML and CSS for now. 1. **Create a new version** of the terrarium app. Update the markup and CSS to use Flexbox or CSS Grid for layout.
2. **Ensure the art and elements are in place** as in the original version.
3. **Test your design** in at least two different browsers (e.g., Chrome, Firefox, Edge).
4. **Take screenshots** of your terrarium in each browser to demonstrate cross-browser compatibility.
5. **Submit** your updated code and screenshots.
## Rubric ## Rubric
| Criteria | Exemplary | Adequate | Needs Improvement | | Criteria | Exemplary | Adequate | Needs Improvement |
| -------- | ----------------------------------------------------------------- | ----------------------------- | ------------------------------------ | |------------|--------------------------------------------------------------------------|---------------------------------------|----------------------------------------|
| | Present a completely restyled terrarium using Flexbox or CSS Grid | Restyle a few of the elements | Fail to restyle the terrarium at all | | Layout | Fully refactored using Flexbox or CSS Grid; visually appealing and responsive | Some elements refactored; partial use of Flexbox or Grid | Little or no use of Flexbox or Grid; layout unchanged |
| Cross-Browser | Screenshots provided for multiple browsers; consistent appearance | Screenshots for one browser; minor inconsistencies | No screenshots or major inconsistencies |
| Code Quality | Clean, well-organized HTML/CSS; clear comments | Some organization; few comments | Disorganized code; lacks comments |
## Tips
- Review [Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) and [CSS Grid](https://css-tricks.com/snippets/css/complete-guide-grid/) guides.
- Use browser developer tools to test responsiveness.
- Comment your code for clarity.

@ -1,76 +1,109 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<title>Welcome to my Virtual Terrarium</title> <title>Welcome to my Virtual Terrarium</title>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- import the webpage's stylesheet --> <!-- Font Awesome CDN for icons -->
<link rel="stylesheet" href="./style.css" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" />
<!-- import the webpage's JavaScript file --> <!-- import the webpage's stylesheet -->
<script src="./script.js" defer></script> <link rel="stylesheet" href="./style.css" />
</head> <!-- import the webpage's JavaScript file -->
<script src="./script.js" defer></script>
</head>
<body>
<div id="page">
<!-- Navigation Bar -->
<nav>
<ul>
<li><a href="#"><i class="fas fa-home"></i> Home</a></li>
<li><a href="#"><i class="fas fa-leaf"></i> Plants</a></li>
<li><a href="#"><i class="fas fa-seedling"></i> Care Tips</a></li>
<li><a href="#"><i class="fas fa-info-circle"></i> About</a></li>
<li><a href="#"><i class="fas fa-envelope"></i> Contact</a></li>
</ul>
</nav>
<body> <header>
<div id="page"> <h1><i class="fas fa-jar"></i> My Terrarium</h1>
<h1>My Terrarium</h1> <p>Welcome to your virtual plant paradise! <i class="fas fa-smile-beam"></i></p>
</header>
<div id="left-container" class="container"> <main>
<div class="plant-holder"> <section id="plant-selection">
<img class="plant" alt="plant" id="plant1" src="./images/plant1.png" /> <div id="left-container" class="container">
</div> <!-- Left-side plants -->
<div class="plant-holder"> <div class="plant-holder">
<img class="plant" alt="plant" id="plant2" src="./images/plant2.png" /> <img class="plant" alt="plant" id="plant1" src="./images/plant1.png" />
</div> </div>
<div class="plant-holder"> <div class="plant-holder">
<img class="plant" alt="plant" id="plant3" src="./images/plant3.png" /> <img class="plant" alt="plant" id="plant2" src="./images/plant2.png" />
</div> </div>
<div class="plant-holder"> <div class="plant-holder">
<img class="plant" alt="plant" id="plant4" src="./images/plant4.png" /> <img class="plant" alt="plant" id="plant3" src="./images/plant3.png" />
</div> </div>
<div class="plant-holder"> <div class="plant-holder">
<img class="plant" alt="plant" id="plant5" src="./images/plant5.png" /> <img class="plant" alt="plant" id="plant4" src="./images/plant4.png" />
</div> </div>
<div class="plant-holder"> <div class="plant-holder">
<img class="plant" alt="plant" id="plant6" src="./images/plant6.png" /> <img class="plant" alt="plant" id="plant5" src="./images/plant5.png" />
</div> </div>
<div class="plant-holder"> <div class="plant-holder">
<img class="plant" alt="plant" id="plant7" src="./images/plant7.png" /> <img class="plant" alt="plant" id="plant6" src="./images/plant6.png" />
</div> </div>
</div> <div class="plant-holder">
<div id="right-container" class="container"> <img class="plant" alt="plant" id="plant7" src="./images/plant7.png" />
<div class="plant-holder"> </div>
<img class="plant" alt="plant" id="plant8" src="./images/plant8.png" /> </div>
</div> <div id="right-container" class="container">
<div class="plant-holder"> <!-- Right-side plants -->
<img class="plant" alt="plant" id="plant9" src="./images/plant9.png" /> <div class="plant-holder">
</div> <img class="plant" alt="plant" id="plant8" src="./images/plant8.png" />
<div class="plant-holder"> </div>
<img class="plant" alt="plant" id="plant10" src="./images/plant10.png" /> <div class="plant-holder">
</div> <img class="plant" alt="plant" id="plant9" src="./images/plant9.png" />
<div class="plant-holder"> </div>
<img class="plant" alt="plant" id="plant11" src="./images/plant11.png" /> <div class="plant-holder">
</div> <img class="plant" alt="plant" id="plant10" src="./images/plant10.png" />
<div class="plant-holder"> </div>
<img class="plant" alt="plant" id="plant12" src="./images/plant12.png" /> <div class="plant-holder">
</div> <img class="plant" alt="plant" id="plant11" src="./images/plant11.png" />
<div class="plant-holder"> </div>
<img class="plant" alt="plant" id="plant13" src="./images/plant13.png" /> <div class="plant-holder">
</div> <img class="plant" alt="plant" id="plant12" src="./images/plant12.png" />
<div class="plant-holder"> </div>
<img class="plant" alt="plant" id="plant14" src="./images/plant14.png" /> <div class="plant-holder">
</div> <img class="plant" alt="plant" id="plant13" src="./images/plant13.png" />
</div> </div>
<div class="plant-holder">
<img class="plant" alt="plant" id="plant14" src="./images/plant14.png" />
</div>
</div>
</section>
<div id="terrarium"> <section id="terrarium-section">
<div class="jar-top"></div> <div id="terrarium">
<div class="jar-walls"> <div class="jar-top"></div>
<div class="jar-glossy-long"></div> <div class="jar-walls">
<div class="jar-glossy-short"></div> <div class="jar-glossy-long"></div>
</div> <div class="jar-glossy-short"></div>
<div class="dirt"></div> </div>
<div class="jar-bottom"></div> <div class="dirt"></div>
</div> <div class="jar-bottom"></div>
</div> </div>
</body> </section>
</html> </main>
<footer>
<p>
<i class="fas fa-copyright"></i> 2025 My Terrarium. All rights reserved.
&nbsp;|&nbsp;
<a href="https://github.com/" target="_blank"><i class="fab fa-github"></i> GitHub</a>
&nbsp;|&nbsp;
<a href="mailto:info@myterrarium.com"><i class="fas fa-envelope"></i> Email</a>
</p>
</footer>
</div>
</body>
</html>

@ -103,3 +103,108 @@ h1 {
bottom: 45%; bottom: 45%;
left: 5%; left: 5%;
} }
/* ...existing code... */
/* Navigation Bar Styles */
nav {
background: linear-gradient(90deg, #d1e1df 60%, #b2c9c6 100%);
box-shadow: 0 2px 8px rgba(58,36,29,0.08);
padding: 0.5rem 0;
margin-bottom: 1rem;
}
nav ul {
display: flex;
justify-content: center;
align-items: center;
gap: 2rem;
list-style: none;
margin: 0;
padding: 0;
}
nav li a {
color: #3a241d;
text-decoration: none;
font-size: 1.1rem;
font-weight: 600;
transition: color 0.2s;
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.5rem 1rem;
border-radius: 0.5rem;
}
nav li a:hover, nav li a:focus {
background: #e6f2f0;
color: #2d7c6f;
box-shadow: 0 2px 8px rgba(45,124,111,0.08);
}
/* Font Awesome Icon Styles */
.fas, .fab {
color: #2d7c6f;
font-size: 1.2em;
vertical-align: middle;
transition: color 0.2s;
}
nav li a:hover .fas,
nav li a:hover .fab {
color: #3a241d;
}
header h1 .fas {
color: #3a241d;
margin-right: 0.5rem;
font-size: 1.3em;
}
header p .fas {
color: #2d7c6f;
margin-left: 0.3rem;
}
footer {
background: #d1e1df;
text-align: center;
padding: 1rem 0;
margin-top: 2rem;
font-size: 1rem;
color: #3a241d;
border-top: 2px solid #b2c9c6;
}
footer a {
color: #2d7c6f;
text-decoration: none;
margin: 0 0.5rem;
font-weight: 600;
transition: color 0.2s;
}
footer a:hover, footer a:focus {
color: #3a241d;
text-decoration: underline;
}
footer .fab, footer .fas {
margin-right: 0.3rem;
font-size: 1.1em;
vertical-align: middle;
}
/* Responsive adjustments for navigation */
@media (max-width: 700px) {
nav ul {
flex-direction: column;
gap: 1rem;
}
nav li a {
font-size: 1rem;
padding: 0.5rem 0.5rem;
}
}
/* ...existing code... */

@ -6,3 +6,151 @@
background-color: lightcoral; background-color: lightcoral;
border-color: red; border-color: red;
} }
/* Global Styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Segoe UI", Roboto, Arial, sans-serif;
}
body {
background: linear-gradient(135deg, #f9fafb, #e3f2ef);
color: #2d3436;
display: flex;
flex-direction: column;
align-items: center;
padding: 2rem;
min-height: 100vh;
}
/* Title */
h1 {
font-size: 2.5rem;
font-weight: 700;
color: #2d7c6f;
display: flex;
align-items: center;
gap: 0.6rem;
margin-bottom: 1rem;
text-shadow: 1px 2px 4px rgba(0, 0, 0, 0.1);
}
/* Info */
div i.fa-info-circle {
color: #00796b;
margin-right: 0.4rem;
}
div {
font-size: 1rem;
margin-bottom: 1rem;
text-align: center;
max-width: 500px;
color: #555;
}
/* Quote Display */
#quote {
font-size: 1.2rem;
font-weight: 500;
color: #333;
margin: 1rem auto;
padding: 1rem;
border-left: 4px solid #2d7c6f;
background: #f1fdfb;
border-radius: 8px;
max-width: 600px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
/* Message */
#message {
font-size: 1.1rem;
font-weight: 600;
margin: 0.8rem;
color: #ff7043;
text-align: center;
}
/* Input Box */
input#typed-value {
padding: 0.8rem 1rem;
font-size: 1rem;
width: 280px;
border: 2px solid #2d7c6f;
border-radius: 12px;
outline: none;
transition: 0.3s ease;
margin-right: 0.4rem;
}
input#typed-value:focus {
border-color: #00796b;
box-shadow: 0 0 8px rgba(0, 121, 107, 0.3);
}
/* Pen Icon */
.fa-pen {
color: #2d7c6f;
font-size: 1.2rem;
vertical-align: middle;
}
/* Start Button */
button#start {
background: linear-gradient(135deg, #2d7c6f, #26a69a);
color: white;
font-size: 1rem;
padding: 0.8rem 1.6rem;
border: none;
border-radius: 12px;
margin-top: 1.5rem;
cursor: pointer;
transition: transform 0.2s ease, box-shadow 0.3s ease;
}
button#start:hover {
transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}
button#start i {
margin-right: 0.4rem;
}
/* Date & Time */
#datetime {
margin-top: 1.5rem;
font-size: 1rem;
font-weight: 600;
color: #37474f;
display: flex;
align-items: center;
justify-content: center;
gap: 0.6rem;
}
#datetime .fas {
color: #2d7c6f;
}
/* Responsive */
@media (max-width: 600px) {
h1 {
font-size: 2rem;
}
#quote {
font-size: 1rem;
padding: 0.8rem;
}
input#typed-value {
width: 200px;
}
button#start {
width: 100%;
}
}

@ -1,23 +1,110 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<title>Typing</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./index.css" /> <title>Typing</title>
</head> <!-- Font Awesome CDN for icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" />
<link rel="stylesheet" href="./index.css" />
<style>
#datetime {
text-align: center;
margin-bottom: 1rem;
font-size: 1.1rem;
color: #2d7c6f;
}
#datetime .fas {
margin-right: 0.3rem;
color: #3a241d;
font-size: 1.1em;
vertical-align: middle;
}
/* Hide label visually but keep for accessibility */
.hidden-label {
position: absolute;
left: -10000px;
top: auto;
width: 1px;
height: 1px;
overflow: hidden;
}
/* ...existing code... */
</style>
</head>
<body> <body>
<h1>Practice your typing</h1> <h1>
<div>Click start to have a quote displayed. Type the quote as fast as you can!</div> <i class="fas fa-keyboard"></i> Practice your typing
</h1>
<div>
<i class="fas fa-info-circle"></i>
Click start to have a quote displayed. Type the quote as fast as you can!
</div>
<p id="quote"></p> <p id="quote"></p>
<p id="message"></p> <p id="message"></p>
<div> <div>
<input type="text" aria-label="current word" id="typed-value" /> <label for="typed-value" class="hidden-label">Current word</label>
</div> <input type="text" aria-label="current word" id="typed-value" placeholder="Type here..." />
<div> <i class="fas fa-pen"></i>
<button id="start" type="button">Start</button> </div>
</div> <div>
<script src="./index.js"></script> <button id="start" type="button">
</body> <i class="fas fa-play"></i> Start
</button>
</div>
<script src="./index.js"></script>
<!-- ...existing code... -->
<body>
<h1>
<i class="fas fa-keyboard"></i> Practice your typing
</h1>
<div id="datetime">
<i class="fas fa-calendar-day"></i>
<span id="current-date"></span>
&nbsp;|&nbsp;
<i class="fas fa-clock"></i>
<span id="current-time"></span>
</div>
<!-- ...existing code... -->
</body>
<!-- ...existing code... -->
<script>
// ...existing code...
function updateDateTime() {
const now = new Date();
// Format date as DD/MM/YYYY
const day = String(now.getDate()).padStart(2, '0');
const month = String(now.getMonth() + 1).padStart(2, '0');
const year = now.getFullYear();
const formattedDate = `${day}/${month}/${year}`;
// Format time as HH:MM AM/PM (12-hour)
let hours = now.getHours();
const minutes = String(now.getMinutes()).padStart(2, '0');
const ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12;
hours = hours ? hours : 12; // 0 should be 12
const formattedTime = `${hours}:${minutes} ${ampm}`;
document.getElementById('current-date').textContent = formattedDate;
document.getElementById('current-time').textContent = formattedTime;
}
// Initial call and update every minute
updateDateTime();
setInterval(updateDateTime, 60000);
// ...existing code...
</script>
</body>
</html> </html>

@ -1,94 +1,94 @@
// Typing Game - Modern ES6+ Version
// Quotes pool
const quotes = [ const quotes = [
'When you have eliminated the impossible, whatever remains, however improbable, must be the truth.', "When you have eliminated the impossible, whatever remains, however improbable, must be the truth.",
'There is nothing more deceptive than an obvious fact.', "There is nothing more deceptive than an obvious fact.",
'I ought to know by this time that when a fact appears to be opposed to a long train of deductions it invariably proves to be capable of bearing some other interpretation.', "I ought to know by this time that when a fact appears to be opposed to a long train of deductions it invariably proves to be capable of bearing some other interpretation.",
'I never make exceptions. An exception disproves the rule.', "I never make exceptions. An exception disproves the rule.",
'What one man can invent another can discover.', "What one man can invent another can discover.",
'Nothing clears up a case so much as stating it to another person.', "Nothing clears up a case so much as stating it to another person.",
'Education never ends, Watson. It is a series of lessons, with the greatest for the last.', "Education never ends, Watson. It is a series of lessons, with the greatest for the last."
]; ];
// array for storing the words of the current challenge // State
let words = []; let words = [];
// stores the index of the word the player is currently typing
let wordIndex = 0; let wordIndex = 0;
// default value for startTime (will be set on start) let startTime = 0;
let startTime = Date.now();
// UI Elements
const quoteElement = document.querySelector("#quote");
const messageElement = document.querySelector("#message");
const typedValueElement = document.querySelector("#typed-value");
const startButton = document.querySelector("#start");
// Messages system
const messages = {
success: (seconds) => `🎉 Congratulations! You finished in ${seconds.toFixed(2)} seconds.`,
error: "⚠️ Oops! There's a mistake.",
start: "⌨️ Start typing to begin the game."
};
// grab UI items // Utility: pick random quote
const quoteElement = document.getElementById('quote'); const getRandomQuote = () => quotes[Math.floor(Math.random() * quotes.length)];
const messageElement = document.getElementById('message')
const typedValueElement = document.getElementById('typed-value');
document.getElementById('start').addEventListener('click', function () { // Utility: render quote as spans
// get a quote const renderQuote = (quote) => {
const quoteIndex = Math.floor(Math.random() * quotes.length); quoteElement.innerHTML = quote
const quote = quotes[quoteIndex]; .split(" ")
// Put the quote into an array of words .map((word, i) => `<span ${i === 0 ? 'class="highlight"' : ""}>${word}</span>`)
words = quote.split(' '); .join(" ");
// reset the word index for tracking };
wordIndex = 0;
// UI updates // Utility: highlight current word
// Create an array of span elements so we can set a class const highlightWord = (index) => {
const spanWords = words.map(function (word) { return `<span>${word} </span>` }); [...quoteElement.children].forEach((el, i) => {
// Convert into string and set as innerHTML on quote display el.classList.toggle("highlight", i === index);
quoteElement.innerHTML = spanWords.join(''); });
// Highlight the first word };
quoteElement.childNodes[0].className = 'highlight';
// Clear any prior messages
messageElement.innerText = '';
// Setup the textbox // Game start
// Clear the textbox const startGame = () => {
typedValueElement.value = ''; const quote = getRandomQuote();
// set focus words = quote.split(" ");
typedValueElement.focus(); wordIndex = 0;
// set the event handler renderQuote(quote);
// Start the timer messageElement.textContent = messages.start;
startTime = new Date().getTime(); typedValueElement.value = "";
}); typedValueElement.focus();
typedValueElement.addEventListener('input', (e) => { startTime = Date.now();
// Get the current word };
const currentWord = words[wordIndex];
// get the current value
const typedValue = typedValueElement.value;
if (typedValue === currentWord && wordIndex === words.length - 1) { // Typing logic
// end of quote const handleTyping = () => {
// Display success const currentWord = words[wordIndex];
const elapsedTime = new Date().getTime() - startTime; const typedValue = typedValueElement.value;
const message = `CONGRATULATIONS! You finished in ${elapsedTime / 1000} seconds.`;
messageElement.innerText = message;
} else if (typedValue.endsWith(' ') && typedValue.trim() === currentWord) {
// end of word
// clear the typedValueElement for the new word
typedValueElement.value = '';
// move to the next word
wordIndex++;
// reset the class name for all elements in quote
for (const wordElement of quoteElement.childNodes) {
wordElement.className = '';
}
// highlight the new word
quoteElement.childNodes[wordIndex].className = 'highlight';
} else if (currentWord.startsWith(typedValue)) {
// currently correct
// highlight the next word
typedValueElement.className = '';
} else {
// error state
typedValueElement.className = 'error';
}
});
// Add this at the end of the file if (typedValue === currentWord && wordIndex === words.length - 1) {
const messages = { // Game finished
success: "CONGRATULATIONS! You finished in {seconds} seconds.", const elapsedTime = (Date.now() - startTime) / 1000;
error: "Oops! There's a mistake.", messageElement.textContent = messages.success(elapsedTime);
start: "Start typing to begin the game." typedValueElement.disabled = true;
} else if (typedValue.endsWith(" ") && typedValue.trim() === currentWord) {
// Word completed
typedValueElement.value = "";
wordIndex++;
highlightWord(wordIndex);
} else if (currentWord.startsWith(typedValue)) {
// Correct so far
typedValueElement.classList.remove("error");
} else {
// Error
typedValueElement.classList.add("error");
messageElement.textContent = messages.error;
}
}; };
export default messages; // Event Listeners
startButton.addEventListener("click", startGame);
typedValueElement.addEventListener("input", handleTyping);
// Default state
messageElement.textContent = "👉 Click Start to begin!";

@ -1,34 +1,47 @@
function loadTexture(path) { async function loadTexture(path) {
return new Promise((resolve) => { return new Promise(resolve => {
const img = new Image(); const img = new Image();
img.src = path; img.src = path;
img.onload = () => { img.onload = () => resolve(img);
resolve(img); });
} }
}) function drawText(ctx, text, x, y, fontSize = 40, color = "#ff007f", align = "center") {
} ctx.save();
ctx.font = `${fontSize}px Orbitron, monospace`;
function createEnemies(ctx, canvas, enemyImg) { ctx.fillStyle = color;
const MONSTER_TOTAL = 5; ctx.textAlign = align;
const MONSTER_WIDTH = MONSTER_TOTAL * 98; ctx.shadowColor = "#181733";
const START_X = (canvas.width - MONSTER_WIDTH) / 2; ctx.shadowBlur = 12;
const STOP_X = START_X + MONSTER_WIDTH; ctx.fillText(text, x, y);
ctx.restore();
for (let x = START_X; x < STOP_X; x += 98) {
for (let y = 0; y < 50 * 5; y += 50) {
ctx.drawImage(enemyImg, x, y);
} }
} function createEnemies(ctx, canvas, enemyImg) {
} const MONSTER_TOTAL = 7;
const MONSTER_ROWS = 5;
window.onload = async() => { const ENEMY_SIZE = 65;
canvas = document.getElementById("canvas"); const START_X = (canvas.width - (MONSTER_TOTAL * ENEMY_SIZE)) / 2;
ctx = canvas.getContext("2d"); for (let row = 0; row < MONSTER_ROWS; row++) {
const heroImg = await loadTexture('assets/player.png') for (let col = 0; col < MONSTER_TOTAL; col++) {
const enemyImg = await loadTexture('assets/enemyShip.png') const x = START_X + col * ENEMY_SIZE;
const y = 60 + row * ENEMY_SIZE;
ctx.fillStyle = 'black'; ctx.drawImage(enemyImg, x, y, ENEMY_SIZE, ENEMY_SIZE);
ctx.fillRect(0,0, canvas.width, canvas.height); }
ctx.drawImage(heroImg, canvas.width/2 - 45, canvas.height - (canvas.height /4)); }
createEnemies(ctx, canvas, enemyImg); }
}; window.onload = async () => {
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
// Use emoji icons as game characters if images aren't available
const heroImg = await loadTexture('assets/player.png');
const enemyImg = await loadTexture('assets/enemyShip.png');
ctx.fillStyle = '#181733';
ctx.fillRect(0, 0, canvas.width, canvas.height);
drawText(ctx, "Prepare for Battle!", canvas.width/2, 70, 48, "#fff");
// Draw hero
ctx.drawImage(heroImg, canvas.width/2 - 45, canvas.height - (canvas.height / 4), 90, 90);
createEnemies(ctx, canvas, enemyImg);
// Example: Draw power up icon beside hero
ctx.font = "38px FontAwesome";
ctx.fillStyle = "#ffd700";
ctx.fillText("\uf059", canvas.width/2 + 60, canvas.height - (canvas.height / 4) + 42); // Star icon
};

@ -1,6 +1,49 @@
<html> <!DOCTYPE html>
<body> <html lang="en">
<canvas id ="canvas" width="1024" height="768"></canvas> <head>
<script src="app.js"></script> <meta charset="UTF-8">
</body> <title>Enhanced Canvas Game</title>
</html> <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=Orbitron:wght@700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
<style>
body {
background: linear-gradient(135deg, #2d2a4a 0%, #181733 100%);
color: #fff;
font-family: 'Orbitron', 'Arial', sans-serif;
margin: 0;
text-align: center;
}
h1 {
font-family: 'Orbitron', monospace;
margin-top: 32px;
font-size: 2.7rem;
letter-spacing: 2px;
text-shadow: 0 3px 12px #ff007f;
}
.info-bar {
margin: 20px 0;
font-size: 1.3rem;
}
#canvas {
border: 4px solid #ff007f;
box-shadow: 0 0 40px #ff007f22;
display: block;
margin: 20px auto;
background: #12121c;
}
</style>
</head>
<body>
<h1>
<i class="fa-solid fa-rocket"></i>
Arcade Monster Attack
<i class="fa-solid fa-skull-crossbones"></i>
</h1>
<div class="info-bar">
<i class="fa-solid fa-star"></i> Score: <span id="score">0</span>
<i class="fa-solid fa-heart"></i> Lives: <span id="lives">3</span>
</div>
<canvas id="canvas" width="1024" height="768"></canvas>
</html>

File diff suppressed because it is too large Load Diff

@ -1,20 +1,523 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<title>Space Game</title> <title>Space Game</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Canvas-based Space Game with accessible controls, HUD, and settings." />
<meta name="theme-color" content="#0b1023" />
<!-- Google Fonts: performance preconnect + fonts (apply via CSS later) -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!-- Swap or add families as desired -->
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Poppins:wght@400;600;800&display=swap" rel="stylesheet">
<!-- Font Awesome 6 (Free) via cdnjs -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css" integrity="sha512-bWn0gM3Yx6w5OV6v4p+WB6l3Zl9sJ2jQ4kN0N1bK2qgkvI6l3F8Vd6k1oB7f/0g0a9Qyxgkq+K6X1JQmJv9zYg==" crossorigin="anonymous" referrerpolicy="no-referrer">
<!-- Optional PWA hooks (files to be created later) -->
<link rel="manifest" href="manifest.webmanifest">
</head> </head>
<style>
/* Space Game — CSS */
/* Typography + Theme */
:root {
--bg: #070a1a;
--bg-2: #0b1023;
--panel: rgba(12, 17, 38, 0.75);
--panel-solid: #0c1126;
--primary: #5ac8fa;
--accent: #a78bfa;
--danger: #ff6b6b;
--success: #34d399;
--warning: #fbbf24;
--text: #e6eaf2;
--muted: #9aa4bf;
--border: #192243;
--shadow: rgba(0, 0, 0, 0.6);
}
*,
*::before,
*::after {
box-sizing: border-box;
}
html, body {
height: 100%;
}
body {
margin: 0;
color: var(--text);
background:
radial-gradient(circle at 20% 10%, #0f1533 0%, transparent 50%),
radial-gradient(circle at 80% 30%, #0b1b3a 0%, transparent 40%),
radial-gradient(circle at 30% 80%, #111a39 0%, transparent 40%),
var(--bg);
font-family: "Poppins", system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
line-height: 1.5;
}
/* Header + Nav */
header {
position: sticky;
top: 0;
z-index: 20;
background: linear-gradient(180deg, rgba(7,10,26,0.85) 0%, rgba(7,10,26,0.6) 100%);
backdrop-filter: blur(6px);
border-bottom: 1px solid var(--border);
padding: 0.75rem 1rem;
}
header h1 {
margin: 0;
font-family: "Orbitron", "Poppins", sans-serif;
font-weight: 800;
letter-spacing: 0.5px;
display: inline-flex;
align-items: center;
gap: 0.6rem;
}
nav[aria-label="Primary"] {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-top: 0.5rem;
}
nav[aria-label="Primary"] button {
appearance: none;
border: 1px solid var(--border);
background: linear-gradient(180deg, #121a3a 0%, #0d1430 100%);
color: var(--text);
border-radius: 10px;
padding: 0.55rem 0.85rem;
display: inline-flex;
align-items: center;
gap: 0.5rem;
cursor: pointer;
transition: transform 0.06s ease, box-shadow 0.2s ease, border-color 0.2s ease;
box-shadow: 0 2px 12px var(--shadow);
}
nav[aria-label="Primary"] button:hover {
border-color: var(--primary);
box-shadow: 0 4px 18px rgba(90, 200, 250, 0.25);
}
nav[aria-label="Primary"] button:active {
transform: translateY(1px) scale(0.98);
}
nav [data-action="start"] { background: linear-gradient(180deg, #10314a 0%, #0d2438 100%); }
nav [data-action="pause"] { background: linear-gradient(180deg, #1a1f3f 0%, #131936 100%); }
nav [data-action="reset"] { background: linear-gradient(180deg, #3b0d0d 0%, #2a0a0a 100%); }
nav [data-action="mute"][aria-pressed="true"] { background: linear-gradient(180deg, #3f1a1a 0%, #2a0e0e 100%); }
nav [data-action="fullscreen"] { background: linear-gradient(180deg, #162c3a 0%, #0f2331 100%); }
nav [data-action="open-settings"] { background: linear-gradient(180deg, #1a1440 0%, #13103a 100%); }
/* Main Layout */
main {
max-width: 1200px;
margin: 0 auto;
padding: 1rem;
}
/* HUD overlay */
#hud {
position: fixed;
left: 50%;
top: 64px;
transform: translateX(-50%);
width: min(100% - 2rem, 1180px);
z-index: 15;
}
#hud [role="status"] {
display: flex;
flex-wrap: wrap;
gap: 0.75rem 1rem;
align-items: center;
background: var(--panel);
border: 1px solid var(--border);
border-radius: 12px;
padding: 0.5rem 0.75rem;
backdrop-filter: blur(4px);
}
#hud span {
display: inline-flex;
align-items: center;
gap: 0.4rem;
color: var(--muted);
font-weight: 600;
}
#hud output {
color: var(--primary);
font-family: "Orbitron", "Poppins", sans-serif;
letter-spacing: 0.4px;
}
/* Canvas section */
#play {
position: relative;
margin-top: 1rem;
}
#play figure {
margin: 0;
border: 1px solid var(--border);
border-radius: 14px;
background:
radial-gradient(1200px 600px at 70% 30%, rgba(70, 78, 150, 0.15), transparent 60%),
radial-gradient(800px 400px at 20% 70%, rgba(88, 131, 186, 0.12), transparent 60%),
#081022;
box-shadow: 0 8px 28px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(255,255,255,0.02);
overflow: hidden;
}
#play figcaption {
position: absolute;
z-index: 5;
inset: 0 auto auto 0;
margin: 0.5rem 0 0 0.5rem;
padding: 0.25rem 0.5rem;
background: rgba(8, 16, 34, 0.7);
border: 1px solid var(--border);
border-radius: 8px;
color: var(--muted);
font-size: 0.85rem;
}
#myCanvas {
display: block;
width: 100%;
height: auto;
background: linear-gradient(180deg, #000814 0%, #001d3d 100%);
}
/* Help + Leaderboard */
#help, #leaderboard {
margin-top: 1rem;
background: var(--panel);
border: 1px solid var(--border);
border-radius: 12px;
padding: 1rem;
}
#help h2, #leaderboard h2 {
margin-top: 0;
font-family: "Orbitron", "Poppins", sans-serif;
}
#help ul {
margin: 0.5rem 0 0 1rem;
padding: 0;
}
#scores {
margin: 0.5rem 0 0 1rem;
padding: 0;
}
#scores li {
margin: 0.25rem 0;
color: var(--text);
}
/* Dialogs */
dialog {
border: 1px solid var(--border);
border-radius: 14px;
padding: 1rem;
background: var(--panel-solid);
color: var(--text);
width: min(520px, calc(100% - 2rem));
box-shadow: 0 24px 60px rgba(0,0,0,0.55);
}
dialog header h2 {
margin: 0 0 0.5rem 0;
font-family: "Orbitron", "Poppins", sans-serif;
}
dialog section {
display: grid;
gap: 0.75rem;
margin-bottom: 0.5rem;
}
dialog label {
font-size: 0.95rem;
color: var(--muted);
}
dialog input[type="range"],
dialog select,
dialog input[type="url"],
dialog input[type="file"] {
width: 100%;
color: var(--text);
background: #0f1733;
border: 1px solid var(--border);
border-radius: 10px;
padding: 0.5rem;
}
dialog menu {
display: flex;
justify-content: flex-end;
gap: 0.5rem;
margin: 0;
padding: 0.5rem 0 0 0;
}
dialog button {
appearance: none;
border: 1px solid var(--border);
background: linear-gradient(180deg, #121a3a 0%, #0d1430 100%);
color: var(--text);
border-radius: 10px;
padding: 0.5rem 0.85rem;
cursor: pointer;
}
dialog::backdrop {
background: rgba(3, 6, 20, 0.6);
backdrop-filter: blur(3px);
}
/* Footer */
footer {
margin: 1rem 0;
color: var(--muted);
text-align: center;
}
/* Focus styles */
:focus-visible {
outline: 2px solid var(--primary);
outline-offset: 2px;
border-radius: 6px;
}
/* Fullscreen adjustments */
#play:fullscreen, /* section fullscreen */
#myCanvas:fullscreen {
background: #000;
}
#play:fullscreen #myCanvas,
#myCanvas:fullscreen {
width: 100vw;
height: 100vh;
}
/* Small screens */
@media (max-width: 600px) {
#hud [role="status"] {
justify-content: space-between;
}
nav[aria-label="Primary"] {
gap: 0.4rem;
}
nav[aria-label="Primary"] button {
padding: 0.5rem 0.65rem;
}
}
</style>
<body> <body>
<p>Image to use:</p> <a href="#play" aria-label="Skip to game">Skip to Game</a>
<p>Canvas:</p>
<header>
<h1 aria-label="Space Game">
<i class="fa-solid fa-rocket" aria-hidden="true"></i>
Space Game
</h1>
<nav aria-label="Primary">
<button type="button" data-action="start" aria-label="Start">
<i class="fa-solid fa-play" aria-hidden="true"></i> Start
</button>
<button type="button" data-action="pause" aria-label="Pause">
<i class="fa-solid fa-circle-pause" aria-hidden="true"></i> Pause
</button>
<button type="button" data-action="reset" aria-label="Reset">
<i class="fa-solid fa-rotate-right" aria-hidden="true"></i> Reset
</button>
<button type="button" data-action="mute" aria-pressed="false" aria-label="Mute">
<i class="fa-solid fa-volume-xmark" aria-hidden="true"></i> Mute
</button>
<button type="button" data-action="fullscreen" aria-label="Toggle fullscreen">
<i class="fa-solid fa-expand" aria-hidden="true"></i> Fullscreen
</button>
<button type="button" data-action="open-settings" aria-controls="settingsDialog" aria-haspopup="dialog">
<i class="fa-solid fa-gear" aria-hidden="true"></i> Settings
</button>
</nav>
</header>
<main id="main" tabindex="-1">
<!-- HUD -->
<section id="hud" aria-label="Game HUD">
<div role="status" aria-live="polite">
<span><i class="fa-solid fa-trophy" aria-hidden="true"></i> Score: <output id="score" name="score">0</output></span>
<span><i class="fa-solid fa-layer-group" aria-hidden="true"></i> Level: <output id="level" name="level">1</output></span>
<span><i class="fa-solid fa-heart" aria-hidden="true"></i> Lives: <output id="lives" name="lives">3</output></span>
<span><i class="fa-solid fa-shield-halved" aria-hidden="true"></i> Shield: <output id="shield" name="shield">100%</output></span>
<span><i class="fa-solid fa-gauge" aria-hidden="true"></i> FPS: <output id="fps" name="fps">0</output></span>
<span><i class="fa-regular fa-clock" aria-hidden="true"></i> Time: <output id="time" name="time">00:00</output></span>
</div>
</section>
<!-- Game Canvas -->
<section id="play" aria-label="Game Canvas">
<figure>
<figcaption>Canvas</figcaption>
<canvas id="myCanvas" width="1024" height="768">
Your browser does not support the HTML5 canvas tag.
</canvas>
</figure>
</section>
<!-- Controls Help -->
<section id="help" aria-label="Controls Guide">
<h2><i class="fa-solid fa-gamepad" aria-hidden="true"></i> Controls</h2>
<ul>
<li>Move: Arrow keys or WASD</li>
<li>Fire: Space</li>
<li>Special: Shift</li>
<li>Pause: P</li>
<li>Toggle Fullscreen: F</li>
</ul>
</section>
<!-- Assets and Audio Hooks (managed by app.js) -->
<section id="assets" hidden aria-hidden="true">
<h2><i class="fa-regular fa-image" aria-hidden="true"></i> Assets</h2>
<!-- Optional: let players provide an image URL for background/sprites (read by app.js) -->
<label for="bgImageUrl">Background image URL</label>
<input id="bgImageUrl" type="url" placeholder="https://example.com/space.jpg" inputmode="url">
<label for="spriteUpload">Upload sprite images</label>
<input id="spriteUpload" type="file" accept="image/*" multiple>
<!-- Preloadable audio (sources to be provided) -->
<audio id="sfxShoot" preload="auto">
<source src="assets/audio/shoot.mp3" type="audio/mpeg">
</audio>
<audio id="sfxExplosion" preload="auto">
<source src="assets/audio/explosion.mp3" type="audio/mpeg">
</audio>
<audio id="bgMusic" preload="auto" loop>
<source src="assets/audio/music.mp3" type="audio/mpeg">
</audio>
</section>
<!-- Leaderboard -->
<section id="leaderboard" aria-label="Leaderboard">
<h2><i class="fa-solid fa-ranking-star" aria-hidden="true"></i> Leaderboard</h2>
<ol id="scores">
<li data-initials="AAA" data-score="10000">AAA — 10,000</li>
<li data-initials="BBB" data-score="8000">BBB — 8,000</li>
<li data-initials="CCC" data-score="5000">CCC — 5,000</li>
</ol>
</section>
<!-- Settings Dialog (open via Settings button; JS can call showModal()) -->
<dialog id="settingsDialog" aria-labelledby="settingsTitle">
<form method="dialog">
<header>
<h2 id="settingsTitle">
<i class="fa-solid fa-sliders" aria-hidden="true"></i>
Settings
</h2>
</header>
<section>
<label for="difficulty">Difficulty</label>
<select id="difficulty" name="difficulty">
<option value="easy">Easy</option>
<option value="normal" selected>Normal</option>
<option value="hard">Hard</option>
<option value="insane">Insane</option>
</select>
<label for="graphics">Graphics</label>
<select id="graphics" name="graphics">
<option value="low">Low</option>
<option value="medium" selected>Medium</option>
<option value="high">High</option>
<option value="ultra">Ultra</option>
</select>
<label for="musicVolume">Music Volume</label>
<input id="musicVolume" name="musicVolume" type="range" min="0" max="100" value="60" />
<label for="sfxVolume">SFX Volume</label>
<input id="sfxVolume" name="sfxVolume" type="range" min="0" max="100" value="80" />
<label for="controlScheme">Control Scheme</label>
<select id="controlScheme" name="controlScheme">
<option value="wasd" selected>WASD + Space</option>
<option value="arrows">Arrows + Space</option>
<option value="custom">Custom</option>
</select>
</section>
<menu>
<button value="cancel" aria-label="Close settings">
<i class="fa-solid fa-xmark" aria-hidden="true"></i>
Close
</button>
<button value="apply" data-action="apply-settings" aria-label="Apply settings">
<i class="fa-solid fa-check" aria-hidden="true"></i>
Apply
</button>
</menu>
</form>
</dialog>
<!-- Pause Overlay (can be shown via JS) -->
<dialog id="pauseDialog" aria-labelledby="pauseTitle">
<form method="dialog">
<h2 id="pauseTitle"><i class="fa-solid fa-circle-pause" aria-hidden="true"></i> Paused</h2>
<p>Game is paused.</p>
<menu>
<button value="resume" data-action="resume">
<i class="fa-solid fa-play" aria-hidden="true"></i>
Resume
</button>
<button value="restart" data-action="reset">
<i class="fa-solid fa-rotate-right" aria-hidden="true"></i>
Restart
</button>
</menu>
</form>
</dialog>
<canvas id="myCanvas" width="1024" height="768" style="border:1px solid #d3d3d3;"> </main>
Your browser does not support the HTML5 canvas tag.</canvas>
<script src="app.js"> <footer>
<small>
<i class="fa-regular fa-circle-question" aria-hidden="true"></i>
Tip: Ensure app.js wires up data-action buttons, dialog show/close, audio, and canvas rendering.
</small>
</footer>
</script> <noscript>
JavaScript is required to play this game.
</noscript>
<!-- Keep your game logic here -->
<script defer src="app.js"></script>
</body> </body>
</html> </html>

@ -2,179 +2,312 @@
// Constants // Constants
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
const serverUrl = 'http://localhost:5000/api'; const serverUrl = 'http://localhost:5000/api'; // reserved for future server swap
const storageKey = 'savedAccount'; const storageKey = 'savedAccount';
const accountsKey = 'accounts'; // New key for all accounts const accountsKey = 'accounts';
const schemaKey = 'schemaVersion';
const schemaVersion = 1;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Router // Intl helpers
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
const routes = { const userLocale = navigator.language || 'en-IN';
'/dashboard': { title: 'My Account', templateId: 'dashboard', init: refresh },
'/login': { title: 'Login', templateId: 'login' } function isIsoCurrency(code) {
}; if (!code) return false;
const c = String(code).trim().toUpperCase();
function navigate(path) { if (!/^[A-Z]{3}$/.test(c)) return false;
window.history.pushState({}, path, window.location.origin + path); // Verify against supported values when available
updateRoute(); try {
if (typeof Intl.supportedValuesOf === 'function') {
return Intl.supportedValuesOf('currency').includes(c);
}
} catch {}
return true; // fallback accept 3-letter code
} }
function updateRoute() { function toCurrency(amount, currency) {
const path = window.location.pathname; const n = Number(amount);
const route = routes[path]; if (!Number.isFinite(n)) return String(amount);
const c = String(currency || '').trim();
if (!route) { if (isIsoCurrency(c)) {
return navigate('/dashboard'); // Accounting style shows negatives in parentheses if supported
const fmt = new Intl.NumberFormat(userLocale, {
style: 'currency',
currency: c.toUpperCase(),
currencySign: 'accounting',
maximumFractionDigits: 2
});
return fmt.format(n);
} }
// Fallback: symbol + localized number
const num = new Intl.NumberFormat(userLocale, {
maximumFractionDigits: 2
}).format(n);
return c ? `${c} ${num}` : num;
}
const template = document.getElementById(route.templateId); function toDate(dateStr) {
const view = template.content.cloneNode(true); // Expect yyyy-mm-dd; fallback to today if invalid
const app = document.getElementById('app'); const d = dateStr ? new Date(dateStr) : new Date();
app.innerHTML = ''; if (Number.isNaN(d.getTime())) return new Date();
app.appendChild(view); return d;
}
if (typeof route.init === 'function') {
route.init();
}
document.title = route.title; function formatDate(dateStr) {
const d = toDate(dateStr);
const fmt = new Intl.DateTimeFormat(userLocale, { dateStyle: 'medium' });
return fmt.format(d);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// API interactions (replaced with localStorage logic) // Storage and state
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function safeParse(json, fallback) {
try { return JSON.parse(json); } catch { return fallback; }
}
function getAccounts() { function getAccounts() {
return JSON.parse(localStorage.getItem(accountsKey) || '[]'); return safeParse(localStorage.getItem(accountsKey), []);
} }
function saveAccounts(accounts) { function saveAccounts(accounts) {
localStorage.setItem(accountsKey, JSON.stringify(accounts)); localStorage.setItem(accountsKey, JSON.stringify(accounts));
} }
function migrateSchema() {
const v = Number(localStorage.getItem(schemaKey) || 0);
if (v >= schemaVersion) return;
let accounts = getAccounts();
// Example migration scaffolding:
// if (v < 1) { /* future migrations */ }
saveAccounts(accounts);
localStorage.setItem(schemaKey, String(schemaVersion));
}
function findAccount(user) { function findAccount(user) {
const accounts = getAccounts(); const accounts = getAccounts();
return accounts.find(acc => acc.user === user) || null; return accounts.find(acc => acc.user === user) || null;
} }
async function getAccount(user) { async function getAccount(user) {
// Simulate async
return new Promise(resolve => { return new Promise(resolve => {
setTimeout(() => { setTimeout(() => {
const acc = findAccount(user); const acc = findAccount(user);
if (!acc) resolve({ error: 'Account not found' }); resolve(acc || { error: 'Account not found' });
else resolve(acc); }, 60);
}, 100);
}); });
} }
function uuid() {
// Works on HTTPS and localhost; fallback otherwise
if (globalThis.crypto && typeof crypto.randomUUID === 'function') {
return crypto.randomUUID();
}
return 'tx-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 8);
}
async function createAccount(accountJson) { async function createAccount(accountJson) {
return new Promise(resolve => { return new Promise(resolve => {
setTimeout(() => { setTimeout(() => {
let data; const data = safeParse(accountJson, null);
try { if (!data) return resolve({ error: 'Malformed account data' });
data = JSON.parse(accountJson); const user = String(data.user || '').trim();
} catch (e) { if (!user) return resolve({ error: 'Username required' });
return resolve({ error: 'Malformed account data' }); if (findAccount(user)) return resolve({ error: 'User already exists' });
}
if (!data.user) return resolve({ error: 'Username required' }); const currency = String(data.currency || 'INR').trim();
if (findAccount(data.user)) return resolve({ error: 'User already exists' });
// Set up initial account structure
const newAcc = { const newAcc = {
user: data.user, user,
description: data.description || '', description: String(data.description || ''),
balance: 0, balance: Number(data.balance || 0) || 0,
currency: data.currency || 'USD', currency: isIsoCurrency(currency) ? currency.toUpperCase() : currency,
transactions: [] transactions: []
}; };
const accounts = getAccounts(); const accounts = getAccounts();
accounts.push(newAcc); accounts.push(newAcc);
saveAccounts(accounts); saveAccounts(accounts);
resolve(newAcc); resolve(newAcc);
}, 100); }, 80);
}); });
} }
async function createTransaction(user, transactionJson) { async function createTransaction(user, transactionJson) {
return new Promise(resolve => { return new Promise(resolve => {
setTimeout(() => { setTimeout(() => {
const tx = safeParse(transactionJson, null);
if (!tx) return resolve({ error: 'Malformed transaction data' });
const amount = Number(tx.amount);
const object = String(tx.object || '').trim();
const dateStr = tx.date || new Date().toISOString().slice(0, 10);
if (!Number.isFinite(amount)) return resolve({ error: 'Amount must be a valid number' });
if (!object) return resolve({ error: 'Object is required' });
const accounts = getAccounts(); const accounts = getAccounts();
const idx = accounts.findIndex(acc => acc.user === user); const idx = accounts.findIndex(acc => acc.user === user);
if (idx === -1) return resolve({ error: 'Account not found' }); if (idx === -1) return resolve({ error: 'Account not found' });
const tx = JSON.parse(transactionJson);
tx.amount = parseFloat(tx.amount); const newTx = {
tx.date = tx.date || new Date().toISOString().slice(0, 10); id: uuid(),
accounts[idx].balance += tx.amount; date: dateStr,
accounts[idx].transactions.push(tx); object,
amount
};
// Update balance and push transaction
accounts[idx].balance = (Number(accounts[idx].balance) || 0) + amount;
accounts[idx].transactions = (accounts[idx].transactions || []);
accounts[idx].transactions.push(newTx);
saveAccounts(accounts); saveAccounts(accounts);
resolve(tx); resolve(newTx);
}, 100); }, 80);
}); });
} }
// --------------------------------------------------------------------------- // Keep a frozen state object to avoid accidental mutations
// Global state
// ---------------------------------------------------------------------------
let state = Object.freeze({ let state = Object.freeze({
account: null account: null
}); });
function updateState(property, newData) { function updateState(property, newData) {
state = Object.freeze({ state = Object.freeze({ ...state, [property]: newData });
...state, // Persist active account only
[property]: newData
});
localStorage.setItem(storageKey, JSON.stringify(state.account)); localStorage.setItem(storageKey, JSON.stringify(state.account));
} }
// Cross-tab sync: refresh when accounts or active account change in another tab
window.addEventListener('storage', (e) => {
if (e.key === accountsKey || e.key === storageKey) {
if (state.account?.user) {
refresh().catch(() => {});
}
}
});
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Login/register // DOM helpers
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
async function login() { function qs(id) {
const loginForm = document.getElementById('loginForm') return document.getElementById(id);
const user = loginForm.user.value; }
const data = await getAccount(user);
if (data.error) { function updateElement(id, textOrNode) {
return updateElement('loginError', data.error); const el = qs(id);
if (!el) return;
while (el.firstChild) el.removeChild(el.firstChild);
el.append(textOrNode);
}
// Resolve multiple possible IDs used by older markup
function setTextByAnyId(ids, text) {
for (const id of ids) {
const el = qs(id);
if (el) { el.textContent = text; return true; }
}
return false;
}
// ---------------------------------------------------------------------------
// Router
// ---------------------------------------------------------------------------
const routes = {
'/dashboard': { title: 'My Account', templateId: 'dashboard', init: refresh },
'/login': { title: 'Login', templateId: 'login', init: attachAuthHandlers }
};
function navigate(path) {
// Store path in history state and URL
history.pushState({ path }, '', path);
updateRoute();
}
function updateRoute() {
const path = history.state?.path || window.location.pathname;
const route = routes[path] || routes['/dashboard'];
const template = document.getElementById(route.templateId);
const view = template.content.cloneNode(true);
const app = document.getElementById('app');
app.innerHTML = '';
app.appendChild(view);
// Attach handlers after DOM is rendered
attachGlobalHandlers();
if (typeof route.init === 'function') {
Promise.resolve(route.init()).catch(err => console.error(err));
} }
document.title = route.title;
}
// Browser back/forward
window.addEventListener('popstate', () => updateRoute());
// ---------------------------------------------------------------------------
// Auth
// ---------------------------------------------------------------------------
async function login() {
const form = qs('loginForm');
if (!form) return;
if (!form.checkValidity()) { form.reportValidity(); return; }
const user = String(form.user.value || '').trim();
const data = await getAccount(user);
if (data.error) return updateElement('loginError', data.error);
updateState('account', data); updateState('account', data);
navigate('/dashboard'); navigate('/dashboard');
} }
async function register() { async function register() {
const registerForm = document.getElementById('registerForm'); const form = qs('registerForm');
const formData = new FormData(registerForm); if (!form) return;
const data = Object.fromEntries(formData); if (!form.checkValidity()) { form.reportValidity(); return; }
const data = Object.fromEntries(new FormData(form));
data.user = String(data.user || '').trim();
data.currency = String(data.currency || '').trim();
data.description = String(data.description || '').trim();
data.balance = Number(data.balance || 0) || 0;
const jsonData = JSON.stringify(data); const jsonData = JSON.stringify(data);
const result = await createAccount(jsonData); const result = await createAccount(jsonData);
if (result.error) { if (result.error) return updateElement('registerError', result.error);
return updateElement('registerError', result.error);
}
updateState('account', result); updateState('account', result);
navigate('/dashboard'); navigate('/dashboard');
} }
function attachAuthHandlers() {
const loginForm = qs('loginForm');
if (loginForm) {
loginForm.addEventListener('submit', (e) => { e.preventDefault(); login(); });
}
const registerForm = qs('registerForm');
if (registerForm) {
registerForm.addEventListener('submit', (e) => { e.preventDefault(); register(); });
}
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Dashboard // Dashboard
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
async function updateAccountData() { async function updateAccountData() {
const account = state.account; const account = state.account;
if (!account) { if (!account) return logout();
return logout();
}
const data = await getAccount(account.user); const data = await getAccount(account.user);
if (data.error) { if (data.error) return logout();
return logout();
}
updateState('account', data); updateState('account', data);
} }
@ -186,74 +319,133 @@ async function refresh() {
function updateDashboard() { function updateDashboard() {
const account = state.account; const account = state.account;
if (!account) { if (!account) return logout();
return logout();
}
updateElement('description', account.description); // Description (support both #description and #transactions-description subtitles)
updateElement('balance', account.balance.toFixed(2)); setTextByAnyId(['description', 'transactions-description'], account.description || 'Transactions');
updateElement('currency', account.currency);
// Update transactions // Balance and currency
const transactionsRows = document.createDocumentFragment(); const balanceText = toCurrency(account.balance, account.currency);
for (const transaction of account.transactions) { setTextByAnyId(['balance', 'balance-value'], balanceText);
const transactionRow = createTransactionRow(transaction);
transactionsRows.appendChild(transactionRow);
}
updateElement('transactions', transactionsRows);
}
function createTransactionRow(transaction) { // Some markups use a separate currency span; keep it empty when using formatted output
setTextByAnyId(['balance-currency', 'currency'], '');
// Transactions (sorted by date desc, then by insertion order)
const tbody = qs('transactions');
if (!tbody) return;
const frag = document.createDocumentFragment();
const template = document.getElementById('transaction'); const template = document.getElementById('transaction');
const transactionRow = template.content.cloneNode(true);
const tr = transactionRow.querySelector('tr'); const sorted = [...(account.transactions || [])]
tr.children[0].textContent = transaction.date; .sort((a, b) => String(b.date).localeCompare(String(a.date)));
tr.children[1].textContent = transaction.object;
tr.children[2].textContent = transaction.amount.toFixed(2); for (const tx of sorted) {
return transactionRow; const row = template.content.cloneNode(true);
const tr = row.querySelector('tr');
const tds = tr.children;
tds[0].textContent = formatDate(tx.date);
tds[1].textContent = tx.object;
tds[2].textContent = toCurrency(tx.amount, account.currency);
if (tx.amount < 0) tr.classList.add('debit');
if (tx.amount > 0) tr.classList.add('credit');
frag.appendChild(row);
}
tbody.innerHTML = '';
tbody.appendChild(frag);
} }
function addTransaction() { function addTransaction() {
const dialog = document.getElementById('transactionDialog'); const dialog = qs('transactionDialog');
if (!dialog) return;
dialog.classList.add('show'); dialog.classList.add('show');
// Reset form // Reset form and set today
const transactionForm = document.getElementById('transactionForm'); const form = qs('transactionForm');
transactionForm.reset(); if (form) {
form.reset();
form.date.valueAsDate = new Date();
// Move focus to first field
form.date.focus();
}
// Close handlers
const backdrop = dialog.querySelector('[data-dismiss]') || dialog;
backdrop.addEventListener('click', onDialogDismissClick);
dialog.addEventListener('keydown', onDialogKeydown);
}
function onDialogDismissClick(e) {
if (e.target?.hasAttribute?.('data-dismiss')) {
cancelTransaction();
}
}
// Set date to today function onDialogKeydown(e) {
transactionForm.date.valueAsDate = new Date(); if (e.key === 'Escape') {
cancelTransaction();
}
} }
async function confirmTransaction() { async function confirmTransaction() {
const dialog = document.getElementById('transactionDialog'); const form = qs('transactionForm');
dialog.classList.remove('show'); if (!form) return;
// Inline validation
const amountVal = Number(form.amount.value);
const objectVal = String(form.object.value || '').trim();
if (!Number.isFinite(amountVal)) {
setFormError('transactionError', 'Amount must be a valid number');
return;
}
if (!objectVal) {
setFormError('transactionError', 'Object is required');
return;
}
const transactionForm = document.getElementById('transactionForm'); clearFormError('transactionError');
const formData = new FormData(transactionForm); const jsonData = JSON.stringify(Object.fromEntries(new FormData(form)));
const jsonData = JSON.stringify(Object.fromEntries(formData));
const data = await createTransaction(state.account.user, jsonData); const data = await createTransaction(state.account.user, jsonData);
if (data.error) { if (data.error) {
return updateElement('transactionError', data.error); setFormError('transactionError', data.error);
return;
} }
// Update local state with new transaction // Update local state
const newAccount = { const newAccount = {
...state.account, ...state.account,
balance: state.account.balance + data.amount, balance: (Number(state.account.balance) || 0) + data.amount,
transactions: [...state.account.transactions, data] transactions: [...(state.account.transactions || []), data]
} };
updateState('account', newAccount); updateState('account', newAccount);
// Update display // Close dialog and update view
cancelTransaction();
updateDashboard(); updateDashboard();
} }
async function cancelTransaction() { function setFormError(id, message) {
const dialog = document.getElementById('transactionDialog'); updateElement(id, message);
const el = qs(id);
if (el) el.focus();
}
function clearFormError(id) {
const el = qs(id);
if (el) el.textContent = '';
}
function cancelTransaction() {
const dialog = qs('transactionDialog');
if (!dialog) return;
dialog.classList.remove('show'); dialog.classList.remove('show');
dialog.removeEventListener('keydown', onDialogKeydown);
const opener = document.querySelector('button[onclick="addTransaction()"]');
if (opener) opener.focus();
} }
function logout() { function logout() {
@ -262,13 +454,31 @@ function logout() {
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Utils // Global listeners
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function updateElement(id, textOrNode) { function attachGlobalHandlers() {
const element = document.getElementById(id); // Intercept form submissions for inline handlers in markup
element.textContent = ''; // Removes all children const loginForm = qs('loginForm');
element.append(textOrNode); if (loginForm && !loginForm.__wired) {
loginForm.__wired = true;
loginForm.addEventListener('submit', (e) => { e.preventDefault(); login(); });
}
const registerForm = qs('registerForm');
if (registerForm && !registerForm.__wired) {
registerForm.__wired = true;
registerForm.addEventListener('submit', (e) => { e.preventDefault(); register(); });
}
const txForm = qs('transactionForm');
if (txForm && !txForm.__wired) {
txForm.__wired = true;
txForm.addEventListener('submit', (e) => { e.preventDefault(); confirmTransaction(); });
}
const cancelBtn = document.querySelector('#transactionDialog [data-dismiss]');
if (cancelBtn && !cancelBtn.__wired) {
cancelBtn.__wired = true;
cancelBtn.addEventListener('click', cancelTransaction);
}
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -276,14 +486,20 @@ function updateElement(id, textOrNode) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function init() { function init() {
// Restore state // Schema migration
const savedState = localStorage.getItem(storageKey); migrateSchema();
if (savedState) {
updateState('account', JSON.parse(savedState)); // Restore active account
const saved = safeParse(localStorage.getItem(storageKey), null);
if (saved) updateState('account', saved);
// Seed history state if missing
if (!history.state || !history.state.path) {
const initialPath = state.account ? '/dashboard' : '/login';
history.replaceState({ path: initialPath }, '', initialPath);
} }
// Update route for browser back/next buttons // Initial route render
window.onpopstate = () => updateRoute();
updateRoute(); updateRoute();
} }

@ -1,47 +1,96 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en" data-theme="auto">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<meta name="theme-color" content="#0a7cff">
<title>Squirrel Banking</title> <title>Squirrel Banking</title>
<!-- Local Font Awesome (ensure this path exists locally) -->
<link rel="stylesheet" href="assets/fontawesome/css/all.min.css">
<!-- App styles -->
<link rel="stylesheet" href="styles.css"> <link rel="stylesheet" href="styles.css">
<!-- App logic -->
<script src="app.js" defer></script> <script src="app.js" defer></script>
</head> </head>
<body> <body>
<!-- Placeholder where we will insert our app HTML based on route --> <noscript>Please enable JavaScript to use this app.</noscript>
<div id="app">Loading...</div>
<!-- SPA mount point -->
<div id="app" aria-live="polite">Loading…</div>
<!-- Login page template --> <!-- Login page template -->
<template id="login"> <template id="login">
<section class="login-page"> <section class="page page-auth" aria-labelledby="loginTitle">
<div class="login-container"> <div class="auth-card">
<div class="login-title text-center"> <div class="brand">
<span class="hide-xs">Squirrel</span> <i class="fa-solid fa-squirrel brand-icon" aria-hidden="true"></i>
<img class="login-logo" src="logo.svg" alt="Squirrel Banking Logo"> <h1 id="loginTitle" class="brand-title">
<span class="hide-xs">Banking</span> <span class="hide-xs">Squirrel</span>
<img class="brand-logo" src="logo.svg" alt="Squirrel Banking Logo">
<span class="hide-xs">Banking</span>
</h1>
</div> </div>
<div class="login-content">
<h2 class="text-center">Login</h2> <div class="auth-panels">
<form id="loginForm" action="javascript:login()"> <section class="auth-panel" aria-labelledby="loginHeading">
<label for="username">Username</label> <h2 id="loginHeading" class="panel-title">
<input id="username" name="user" type="text" maxlength="20" required> <i class="fa-solid fa-right-to-bracket" aria-hidden="true"></i> Login
<div id="loginError" class="error" role="alert"></div> </h2>
<button>Login</button> <form id="loginForm" action="javascript:void(0)" novalidate>
</form> <label for="username" class="field-label">Username</label>
<p class="login-separator text-center"><span>OR</span></p> <div class="field">
<h2 class="text-center">Register</h2> <i class="fa-solid fa-user" aria-hidden="true"></i>
<form id="registerForm" action="javascript:register()"> <input id="username" name="user" type="text" maxlength="20" autocomplete="username" required>
<label for="user">Username (required)</label> </div>
<input id="user" name="user" type="text" maxlength="20" required> <div id="loginError" class="error" role="alert" aria-live="polite"></div>
<label for="currency">Currency (required)</label> <button class="btn btn-primary" type="submit">
<input id="currency" name="currency" type="text" maxlength="5" value="$" required> <i class="fa-solid fa-arrow-right-to-bracket" aria-hidden="true"></i>
<label for="description">Description</label> Login
<input id="description" name="description" type="text" maxlength="100"> </button>
<label for="current-balance">Current balance</label> </form>
<input id="current-balance" name="balance" type="number" value="0"> </section>
<div id="registerError" class="error" role="alert"></div>
<button>Register</button> <div class="auth-sep" role="separator" aria-label="Or">OR</div>
</form>
<section class="auth-panel" aria-labelledby="registerHeading">
<h2 id="registerHeading" class="panel-title">
<i class="fa-solid fa-user-plus" aria-hidden="true"></i> Register
</h2>
<form id="registerForm" action="javascript:void(0)" novalidate>
<label for="user" class="field-label">Username (required)</label>
<div class="field">
<i class="fa-solid fa-id-badge" aria-hidden="true"></i>
<input id="user" name="user" type="text" maxlength="20" autocomplete="username" required>
</div>
<label for="currency" class="field-label">Currency (required)</label>
<div class="field">
<i class="fa-solid fa-coins" aria-hidden="true"></i>
<input id="currency" name="currency" type="text" maxlength="5" placeholder="INR or ₹" required>
</div>
<label for="description" class="field-label">Description</label>
<div class="field">
<i class="fa-solid fa-note-sticky" aria-hidden="true"></i>
<input id="description" name="description" type="text" maxlength="100" placeholder="About the account">
</div>
<label for="current-balance" class="field-label">Current balance</label>
<div class="field">
<i class="fa-solid fa-wallet" aria-hidden="true"></i>
<input id="current-balance" name="balance" type="number" value="0" step="any" inputmode="decimal">
</div>
<div id="registerError" class="error" role="alert" aria-live="polite"></div>
<button class="btn btn-ghost" type="submit">
<i class="fa-solid fa-user-check" aria-hidden="true"></i>
Register
</button>
</form>
</section>
</div> </div>
</div> </div>
</section> </section>
@ -49,48 +98,109 @@
<!-- Dashboard page template --> <!-- Dashboard page template -->
<template id="dashboard"> <template id="dashboard">
<section class="dashboard-page"> <section class="page page-dash">
<header class="dashboard-header"> <header class="dash-header">
<img class="dashboard-logo" src="logo.svg" alt="Squirrel Banking Logo"> <div class="brand compact">
<h1 class="dashboard-title hide-xs">Squirrel Banking</h1> <img class="brand-logo" src="logo.svg" alt="">
<button onclick="logout()">Logout</button> <h1 class="brand-title hide-xs">Squirrel Banking</h1>
</div>
<div class="header-actions">
<button class="btn btn-icon" type="button" id="themeToggle" aria-label="Toggle theme">
<i class="fa-solid fa-moon" aria-hidden="true"></i>
</button>
<button class="btn btn-icon" type="button" onclick="logout()" aria-label="Logout">
<i class="fa-solid fa-right-from-bracket" aria-hidden="true"></i>
</button>
</div>
</header> </header>
<div class="balance">
<div>Balance</div> <section class="summary">
<span id="balance"></span> <div class="balance" aria-live="polite">
<span id="balance-currency"></span> <div class="balance-label">
</div> <i class="fa-solid fa-chart-line" aria-hidden="true"></i>
<div class="dashboard-content"> Balance
</div>
<div class="balance-value">
<span id="balance">0</span>
<span id="balance-currency"></span>
</div>
</div>
<div class="account-meta">
<i class="fa-solid fa-circle-info" aria-hidden="true"></i>
<span id="account-info" class="muted"></span>
</div>
</section>
<section class="dash-content">
<div class="transactions-title"> <div class="transactions-title">
<h2 id="transactions-description"></h2> <h2 id="transactions-description">
<button onclick="addTransaction()">Add transaction</button> <i class="fa-solid fa-receipt" aria-hidden="true"></i>
Transactions
</h2>
<button class="btn btn-primary" type="button" onclick="addTransaction()">
<i class="fa-solid fa-plus" aria-hidden="true"></i>
Add transaction
</button>
</div> </div>
<table class="transactions-table" aria-label="Transactions"> <table class="transactions-table" aria-label="Transactions">
<thead> <thead>
<tr> <tr>
<th>Date</th> <th scope="col"><i class="fa-solid fa-calendar-day" aria-hidden="true"></i> Date</th>
<th>Object</th> <th scope="col"><i class="fa-solid fa-file-lines" aria-hidden="true"></i> Object</th>
<th>Amount</th> <th scope="col" class="num"><i class="fa-solid fa-indian-rupee-sign" aria-hidden="true"></i> Amount</th>
</tr> </tr>
</thead> </thead>
<tbody id="transactions"></tbody> <tbody id="transactions"></tbody>
</table> </table>
</div> </section>
</section> </section>
<section id="transactionDialog" class="dialog">
<div class="dialog-content"> <!-- Modal dialog: Add transaction -->
<h2 class="text-center">Add transaction</h2> <section id="transactionDialog" class="dialog" hidden>
<form id="transactionForm" action="javascript:void(0)"> <div class="dialog-backdrop" data-dismiss></div>
<label for="date">Date</label> <div class="dialog-content"
<input id="date" name="date" type="date" required> role="dialog"
<label for="object">Object</label> aria-modal="true"
<input id="object" name="object" type="text" maxlength="50" required> aria-labelledby="txDialogTitle"
<label for="amount">Amount (use negative value for debit)</label> aria-describedby="txDialogDesc">
<input id="amount" name="amount" type="number" value="0" step="any" required> <h2 id="txDialogTitle" class="text-center">
<div id="transactionError" class="error" role="alert"></div> <i class="fa-solid fa-square-plus" aria-hidden="true"></i>
Add transaction
</h2>
<p id="txDialogDesc" class="muted text-center">
Use negative amount for debit and positive for credit; Esc closes [web guideline aligned].
</p>
<form id="transactionForm" action="javascript:void(0)" novalidate>
<label for="date">Date</label>
<div class="field">
<i class="fa-solid fa-calendar-days" aria-hidden="true"></i>
<input id="date" name="date" type="date" required>
</div>
<label for="object">Object</label>
<div class="field">
<i class="fa-solid fa-tag" aria-hidden="true"></i>
<input id="object" name="object" type="text" maxlength="50" required>
</div>
<label for="amount">Amount (negative for debit)</label>
<div class="field">
<i class="fa-solid fa-money-bill-transfer" aria-hidden="true"></i>
<input id="amount" name="amount" type="number" value="0" step="any" inputmode="decimal" required>
</div>
<div id="transactionError" class="error" role="alert" aria-live="polite"></div>
<div class="dialog-buttons"> <div class="dialog-buttons">
<button type="button" class="button-alt" formaction="javascript:cancelTransaction()" formnovalidate>Cancel</button> <button type="button" class="btn btn-ghost" data-dismiss>
<button formaction="javascript:confirmTransaction()">OK</button> <i class="fa-solid fa-xmark" aria-hidden="true"></i>
Cancel
</button>
<button type="submit" class="btn btn-primary">
<i class="fa-solid fa-check" aria-hidden="true"></i>
OK
</button>
</div> </div>
</form> </form>
</div> </div>
@ -102,8 +212,8 @@
<tr> <tr>
<td></td> <td></td>
<td></td> <td></td>
<td></td> <td class="num"></td>
</tr> </tr>
</template> </template>
</body> </body>
</html> </html>

@ -1,125 +1,267 @@
/* ==========================================================================
Design Tokens and Theming
========================================================================== */
:root { :root {
/* Colors */ /* Brand */
--primary: #0091ea; --primary: #0091ea;
--primary-light: #7bbde6; --primary-600: #007ccc;
--primary-700: #0066a8;
/* Neutrals */
--text: #1b1f24;
--muted: #5a6370;
--white: #ffffff;
--surface: #ffffff;
--surface-2: #f5f7fb;
--border: #c7cdd8;
/* Accents */
--accent: #546e7a; --accent: #546e7a;
--grey: #445; --error: #ff5522;
--error: #f52;
/* Backgrounds */
--background: #f5f5f6; --background: #f5f5f6;
--background-accent: #cfe5f2; --background-accent: #e8f2fb;
--white: #fff;
--border: #99a; /* Effects */
/* Sizes */ --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
--radius: 10px; --shadow-md: 0 6px 16px rgba(16, 24, 40, .12);
--space-xs: 5px; --focus: 3px solid rgba(0, 145, 234, .4);
/* Radius and Spacing */
--radius: 12px;
--radius-sm: 8px;
--space-2xs: 4px;
--space-xs: 6px;
--space-sm: 10px; --space-sm: 10px;
--space-md: 20px; --space-md: 20px;
--space-lg: 28px;
--space-xl: 40px; --space-xl: 40px;
}
/* ------------------------------------------------------------------------ */ /* Typography */
/* Micro reset */ --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
/* ------------------------------------------------------------------------ */ --font-size: 16px;
/* Opt into user color schemes */
color-scheme: light dark;
}
/* Dark theme via user preference */
@media (prefers-color-scheme: dark) {
:root {
--text: #e9edf4;
--muted: #aab4c3;
--surface: #131720;
--surface-2: #0f131b;
--background: #0b0e14;
--background-accent: #0f1822;
--border: #2a3443;
--shadow-sm: 0 1px 2px rgba(0,0,0,.45);
--shadow-md: 0 8px 24px rgba(0,0,0,.5);
--focus: 3px solid rgba(0, 145, 234, .55);
}
}
* { /* Respect reduced motion */
box-sizing: border-box; @media (prefers-reduced-motion: reduce) {
* {
animation-duration: 1ms !important;
animation-iteration-count: 1 !important;
transition-duration: 1ms !important;
scroll-behavior: auto !important;
}
} }
/* ==========================================================================
Base and Reset
========================================================================== */
* { box-sizing: border-box; }
html, body, #app { html, body, #app {
margin: 0; margin: 0;
padding: 0; padding: 0;
height: 100%; height: 100%;
} }
/* ------------------------------------------------------------------------ */ html {
/* General styles */ font-size: 100%;
/* ------------------------------------------------------------------------ */ }
body { body {
font-family: Arial, Helvetica, sans-serif; font-family: var(--font-ui);
font-size: 16px; font-size: var(--font-size);
color: var(--text);
background: var(--background);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
accent-color: var(--primary);
} }
/* Utilities */
.text-center { text-align: center; }
.hide-xs { display: none; }
@media (min-width: 480px) { .hide-xs { display: initial; } }
.sr-only {
position: absolute;
width: 1px; height: 1px;
padding: 0; margin: -1px;
overflow: hidden; clip: rect(0, 0, 1px, 1px);
white-space: nowrap; border: 0;
}
/* Focus states (WCAG-friendly) */
:where(a, button, [role="button"], input, select, textarea):focus-visible {
outline: var(--focus);
outline-offset: 2px;
border-radius: 6px;
}
/* ==========================================================================
Headings and Text
========================================================================== */
h2 { h2 {
color: var(--primary); color: var(--primary);
text-transform: uppercase; text-transform: uppercase;
font-weight: bold; font-weight: 700;
font-size: 1.5rem; font-size: 1.5rem;
margin: var(--space-md) 0; margin: var(--space-md) 0;
} }
/* Muted text helper */
.muted { color: var(--muted); }
/* ==========================================================================
Forms
========================================================================== */
form { form {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
margin: var(--space-sm) var(--space-md); margin: var(--space-sm) var(--space-md);
gap: var(--space-xs);
} }
input { label {
margin-top: var(--space-xs); color: var(--muted);
margin-bottom: var(--space-sm); text-transform: uppercase;
height: 45px; font-size: 80%;
padding: var(--space-xs) var(--space-sm); letter-spacing: .02em;
}
input, select, textarea {
height: 44px;
padding: 0 var(--space-sm);
border: 1px solid var(--border); border: 1px solid var(--border);
border-radius: var(--radius); border-radius: var(--radius-sm);
background: var(--surface);
color: var(--text);
box-shadow: var(--shadow-sm);
transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
} }
input::placeholder,
textarea::placeholder { color: color-mix(in oklab, var(--muted) 80%, var(--text)); }
input:focus { input:focus {
border-color: var(--primary); border-color: var(--primary-600);
outline: 0; outline: 0;
box-shadow: 0 0 0 4px color-mix(in oklab, var(--primary) 20%, transparent);
} }
label { .error {
color: var(--grey); color: var(--error);
text-transform: uppercase; margin: var(--space-2xs) 0;
font-size: 80%;
} }
button { .error:empty { display: none; }
font-weight: bold;
/* Native UI controls pick up brand via accent-color */
input[type="checkbox"],
input[type="radio"],
input[type="range"],
progress { accent-color: var(--primary); }
/* ==========================================================================
Buttons
========================================================================== */
button,
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 8px;
font-weight: 700;
background-color: var(--primary); background-color: var(--primary);
color: var(--white); color: var(--white);
height: 40px; height: 40px;
padding: var(--space-xs); padding: 0 var(--space-md);
border: 0; border: 0;
border-radius: var(--radius); border-radius: var(--radius-sm);
text-transform: uppercase; text-transform: uppercase;
min-width: 100px; min-width: 110px;
margin: var(--space-sm) 0; margin: var(--space-sm) 0;
box-shadow: var(--shadow-sm);
transition: filter .12s ease, transform .12s ease, background-color .12s ease;
} }
.button-alt { button:hover,
.btn:hover { filter: brightness(110%); cursor: pointer; }
button:active,
.btn:active { transform: translateY(1px); }
button:focus-visible,
.btn:focus-visible { outline: var(--focus); }
.button-alt,
.btn-ghost {
background-color: transparent; background-color: transparent;
color: var(--primary); color: var(--primary);
border: 1px solid color-mix(in oklab, var(--primary) 40%, var(--border));
box-shadow: none;
} }
button:hover { .btn-icon {
filter: brightness(115%); min-width: auto;
cursor: pointer; width: 40px; height: 40px;
padding: 0;
border-radius: 50%;
} }
button:focus { /* ==========================================================================
outline: none; Login Page
border: 3px solid var(--grey); ========================================================================== */
}
.error { .login-page {
color: var(--error); display: flex;
margin: var(--space-xs) 0; height: 100%;
align-items: center;
justify-content: center;
background:
radial-gradient(800px 500px at 20% -10%, color-mix(in oklab, var(--primary) 30%, transparent), transparent 60%),
radial-gradient(800px 500px at 120% 10%, color-mix(in oklab, var(--primary-600) 20%, transparent), transparent 55%),
linear-gradient(var(--primary), var(--primary-600));
} }
.error:empty { .login-container {
display: none; flex: auto;
max-width: 520px;
max-height: 100%;
overflow: auto;
padding: var(--space-sm);
} }
/* ------------------------------------------------------------------------ */
/* Login page */
/* ------------------------------------------------------------------------ */
.login-title { .login-title {
font-size: 2rem; font-size: 2rem;
font-weight: bold; font-weight: 800;
color: var(--white); color: var(--white);
margin: var(--space-md); margin: var(--space-md);
text-align: center;
} }
.login-logo { .login-logo {
@ -127,24 +269,12 @@ button:focus {
vertical-align: middle; vertical-align: middle;
} }
.login-page {
display: flex;
height: 100%;
align-items: center;
justify-content: center;
background: linear-gradient(var(--primary), var(--primary-light));
}
.login-container {
flex: auto;
max-width: 480px;
max-height: 100%;
overflow: auto;
}
.login-content { .login-content {
background-color: var(--background); background-color: var(--surface);
padding: var(--space-sm); padding: var(--space-md);
border-radius: var(--radius);
box-shadow: var(--shadow-md);
border: 1px solid var(--border);
} }
.login-separator { .login-separator {
@ -157,14 +287,15 @@ button:focus {
.login-separator > span { .login-separator > span {
position: relative; position: relative;
top: -0.5em; top: -0.6em;
background-color: var(--background); background-color: var(--surface);
padding: var(--space-sm); padding: 0 var(--space-sm);
color: var(--muted);
} }
/* ------------------------------------------------------------------------ */ /* ==========================================================================
/* Dashboard page */ Dashboard
/* ------------------------------------------------------------------------ */ ========================================================================== */
.dashboard-page { .dashboard-page {
display: flex; display: flex;
@ -172,23 +303,35 @@ button:focus {
flex-direction: column; flex-direction: column;
} }
/* Make content responsive to its own width (container queries) */
.dashboard-content {
width: 100%;
max-width: 960px;
align-self: center;
padding: var(--space-sm);
container-type: inline-size;
container-name: dash;
}
.dashboard-header { .dashboard-header {
background-color: var(--grey); background-color: var(--accent);
padding: 0 var(--space-sm) padding: var(--space-xs) var(--space-sm);
display: flex;
align-items: center;
justify-content: space-between;
} }
.dashboard-header button { .dashboard-header button {
float: right; border: 1px solid color-mix(in oklab, var(--white) 35%, transparent);
border: 1px solid;
background-color: transparent; background-color: transparent;
color: var(--white);
} }
.dashboard-title { .dashboard-title {
font-size: 1.5rem; font-size: 1.5rem;
font-weight: bold; font-weight: 800;
color: var(--white); color: var(--white);
vertical-align: middle; margin: 0 var(--space-sm);
margin: 0 var(--space-sm)
} }
.dashboard-logo { .dashboard-logo {
@ -198,19 +341,22 @@ button:focus {
} }
.balance { .balance {
background: radial-gradient(circle at center, var(--primary), var(--primary-light)); background: radial-gradient(circle at center, var(--primary), var(--primary-600));
text-align: center; text-align: center;
padding: var(--space-md) var(--space-sm);
} }
.balance > div { .balance > div {
color: var(--white); color: var(--white);
padding-top: var(--space-xs); padding-top: var(--space-2xs);
text-transform: uppercase; text-transform: uppercase;
letter-spacing: .08em;
} }
.balance > span { .balance > span {
color: var(--white); color: var(--white);
font-size: 3rem; font-size: clamp(2rem, 5vw, 3rem);
font-weight: 800;
} }
.transactions-title { .transactions-title {
@ -219,8 +365,9 @@ button:focus {
align-items: center; align-items: center;
padding: 0 var(--space-sm); padding: 0 var(--space-sm);
color: var(--accent); color: var(--accent);
font-weight: bold; font-weight: 800;
font-size: 1.5rem; font-size: 1.25rem;
gap: var(--space-sm);
} }
.transactions-title > div { .transactions-title > div {
@ -229,21 +376,30 @@ button:focus {
white-space: nowrap; white-space: nowrap;
} }
/* ==========================================================================
Transactions Table
========================================================================== */
.transactions-table { .transactions-table {
width: 100%; width: 100%;
font-size: 1.2rem; font-size: 1.05rem;
padding: var(--space-sm); padding: var(--space-sm);
margin: 0; margin: 0;
border-spacing: 0; border-spacing: 0;
background-color: var(--background); background-color: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow-sm);
} }
.transactions-table thead th { .transactions-table thead th {
border-bottom: 1px solid var(--border); border-bottom: 1px solid var(--border);
color: var(--muted);
font-weight: 700;
} }
.transactions-table tr:nth-child(even) { .transactions-table tr:nth-child(even) {
background-color: var(--background-accent); background-color: var(--surface-2);
} }
.transactions-table td, .transactions-table td,
@ -254,7 +410,6 @@ button:focus {
.transactions-table td:first-child, .transactions-table td:first-child,
.transactions-table th:first-child { .transactions-table th:first-child {
/* Make first column use the minimum width */
width: 1%; width: 1%;
white-space: nowrap; white-space: nowrap;
} }
@ -264,88 +419,90 @@ button:focus {
text-align: right; text-align: right;
} }
/* Condense table in narrow containers */
@container dash (width < 520px) {
.transactions-table {
font-size: 1rem;
border-radius: var(--radius-sm);
padding: var(--space-xs);
}
}
/* ==========================================================================
Dialog (Modal)
========================================================================== */
.dialog { .dialog {
display: none; display: none;
position: absolute; position: fixed;
top: 0; inset: 0;
left: 0;
right: 0;
bottom: 0;
left: 0;
top: 0;
overflow: auto; overflow: auto;
background-color: rgba(0,0,0,0.4); background-color: rgba(0,0,0,.45);
animation: slideFromTop 0.3s ease-in-out;
justify-content: center; justify-content: center;
align-items: flex-start; align-items: flex-start;
padding: var(--space-sm);
z-index: 1000;
} }
.dialog.show { .dialog.show { display: flex; }
display: flex;
}
@keyframes slideFromTop {
from {
top: -300px;
opacity: 0;
}
to {
top: 0;
opacity: 1;
}
}
.dialog-content { .dialog-content {
flex: auto; flex: auto;
background-color: var(--white); background-color: var(--surface);
max-width: 480px; color: var(--text);
max-width: 520px;
max-height: 100%; max-height: 100%;
padding: var(--space-sm); padding: var(--space-md);
} border-radius: var(--radius);
border: 1px solid var(--border);
.dialog-buttons { box-shadow: var(--shadow-md);
text-align: right; margin-top: var(--space-xl);
transform: translateY(-8px);
animation: dialogIn .25s ease-out both;
} }
/* ------------------------------------------------------------------------ */ @keyframes dialogIn {
/* Utilities */ from { opacity: 0; transform: translateY(-14px); }
/* ------------------------------------------------------------------------ */ to { opacity: 1; transform: translateY(0); }
.text-center {
text-align: center;
} }
.hide-xs { .dialog-buttons {
display: none; display: flex;
justify-content: flex-end;
gap: var(--space-sm);
} }
/* ------------------------------------------------------------------------ */ /* ==========================================================================
/* Responsive adaptations */ Responsive
/* ------------------------------------------------------------------------ */ ========================================================================== */
@media only screen and (min-width: 480px) {
.hide-xs {
display: initial;
}
@media (min-width: 480px) {
.login-content, .login-content,
.dialog-content { .dialog-content {
border-radius: var(--radius); border-radius: var(--radius);
} }
}
.dialog-content { @media (min-width: 768px) {
margin-top: var(--space-xl); .dashboard-content {
max-width: 900px;
} }
} }
@media only screen and (min-width: 768px) { /* ==========================================================================
.transactions-table { Legacy compatibility mappings (existing class names)
border-radius: var(--radius); ========================================================================== */
}
.dashboard-content { .button-alt { /* keep existing alias */
width: 100%; background-color: transparent;
max-width: 768px; color: var(--primary);
align-self: center; border: 1px solid color-mix(in oklab, var(--primary) 40%, var(--border));
} }
/* Keep original variable names for backward compatibility where possible */
:root {
--space-xs: var(--space-xs);
--space-sm: var(--space-sm);
--space-md: var(--space-md);
--space-xl: var(--space-xl);
} }

@ -1,161 +1,164 @@
# Using a code editor
This lesson covers the basics of using [VSCode.dev](https://vscode.dev) a web-based code editor so that you can make changes to your code and contribute to a project without installing anything on your computer.
<!---- ***
TODO: add an optional image
![Using a code editor](../../sketchnotes/webdev101-vscode-dev.png)
> Sketchnote by [Author name](https://example.com)
---->
<!--- # Using a Code Editor: Mastering [VSCode.dev](https://vscode.dev)
## Pre-Lecture Quiz
[Pre-lecture quiz](https://ff-quizzes.netlify.app/web/quiz/3)
---->
## Learning objectives **Welcome!**
This lesson takes you from the basics to advanced use of [VSCode.dev](https://vscode.dev)—the powerful, web-based code editor. Youll learn how to confidently edit code, manage projects, track changes, install extensions, and collaborate like a pro—all from your browser, with zero installation required.
In this lesson, you'll learn how to: ***
- Use a code editor in a code project ## Learning Objectives
- Keep track of changes with version control
- Customize the editor for development
### Prerequisites By the end of this lesson, youll be able to:
Before you begin, you'll need to create an account with [GitHub](https://github.com). Navigate to [GitHub](https://github.com/) and create an account if you haven't already. - Efficiently use a code editor on any project, anywhere
- Seamlessly track your work with built-in version control
- Personalize and boost your development workflow with editor customizations and extensions
### Introduction ***
A code editor is an essential tool for writing programs and collaborating with existing coding projects. Once you understand the basics of an editor and how to make use of its features, you'll be able to apply them when writing code. ## Prerequisites
## Getting started with VSCode.dev To get started, **sign up for a free [GitHub](https://github.com) account**, which lets you manage code repositories and collaborate worldwide. If you dont have an account yet, [create one here](https://github.com/).
[VSCode.dev](https://vscode.dev) is a code editor on the web. You don't need to install anything in order to use it, just like opening any other website. To get started with the editor, open the following link: [https://vscode.dev](https://vscode.dev). If you aren't signed in into [GitHub](https://github.com/), follow the prompts to sign in or create a new account and then sign in. ***
Once it loads, it should look similar to this image: ## Why Use a Web-based Code Editor?
![Default VSCode.dev](../images/default-vscode-dev.png) A **code editor** like VSCode.dev is your command center for writing, editing, and managing code. With an intuitive interface, tons of features, and immediate access via the browser, you can:
There are three main sections, starting from the far left and moving to the right: - Edit projects on any device
- Avoid the hassle of installations
- Collaborate and contribute instantly
1. The _activity bar_ which includes some icons, like the magnifying glass 🔎, the gear ⚙️, and a few others Once youre comfortable with VSCode.dev, youll be prepared to tackle coding tasks from anywhere, anytime.
1. The expanded activity bar which defaults to the _Explorer_, called the _side bar_.
1. And finally, the code area to the right.
Click on each of the icons to display a different menu. Once done, click on the _Explorer_ so you are back where you started. ***
When you start creating code or modifying existing code, it will happen in the biggest area to the right. You'll use this area to visualize existing code as well, which you'll do next. ## Getting Started with VSCode.dev
Navigate to **[VSCode.dev](https://vscode.dev)**—no install, no downloads. Signing in with GitHub unlocks full access, including syncing your settings, extensions, and repositories. If prompted, connect your GitHub account.
## Open a GitHub repository After loading, your workspace will look like this:
The first thing you'll need is to open a GitHub repository. There are multiple ways of opening a repository. In this section you'll see two different ways you can open a repository so that you can start working on changes. ![Default VSCode.dev](../images/default-vscode-dev has three core sections from left to right:
- **Activity bar:** The icons such as 🔎 (Search), ⚙️ (Settings), files, source control, etc.
- **Sidebar:** Changes context based on the activity bar icon selected (defaults to *Explorer* to show files).
- **Editor/code area:** The largest section to the right—where youll actually edit and view code.
### 1. With the editor Click through the icons to explore features, but return to the _Explorer_ to keep your place.
Use the editor itself to open a remote repository. If you go to [VSCode.dev](https://vscode.dev) you will see an _"Open Remote Repository"_ button: ***
![Open remote repository](../images/open-remote-repository.png) ## Opening a GitHub Repository
You can also use the command palette. The command palette is an input box where you can type any word that is part of a command or an action to find the right command to execute. Use the menu to the top-left, then select _View_, and then pick _Command Palette_, or using the following keyboard shortcut: Ctrl-Shift-P (on MacOS it would be Command-Shift-P). ### Method 1: From the Editor
![Palette Menu](../images/palette-menu.png) 1. Go to [VSCode.dev](https://vscode.dev). Click **"Open Remote Repository."**
Once the menu opens, type _open remote repository_, and then select the first option. Multiple repositories that you are part of or that you've opened recently will show up. You can also use a full GitHub URL to select one. Use the following URL and paste into the box: ![Open remote repository](../images/open-remote-repository use the _Command Palette_ (Ctrl-Shift-P, or Cmd-Shift-P on Mac).
``` ![Palette Menu](../images/palette-menu.pngopen remote repository.”
https://github.com/microsoft/Web-Dev-For-Beginners - Select the option.
``` - Paste your GitHub repo URL (e.g., `https://github.com/microsoft/Web-Dev-For-Beginners`) and hit Enter.
✅ If successful, you'll see all files for this repository loaded in the text editor. If successful, youll see the entire project loaded and ready to edit!
***
### 2. Using the URL ### Method 2: Instantly via URL
You can also use a url directly to load a repository. For example, the full URL for the current repo is [https://github.com/microsoft/Web-Dev-For-Beginners](https://github.com/microsoft/Web-Dev-For-Beginners), but you can swap the GitHub domain with `VSCode.dev/github` and load the repository directly. The resulting URL would be [https://vscode.dev/github/microsoft/Web-Dev-For-Beginners](https://vscode.dev/github/microsoft/Web-Dev-For-Beginners). Transform any GitHub repo URL to open directly in VSCode.dev by replacing `github.com` with `vscode.dev/github`.
E.g.:
- GitHub: `https://github.com/microsoft/Web-Dev-For-Beginners`
- VSCode.dev: `https://vscode.dev/github/microsoft/Web-Dev-For-Beginners`
## Edit files This feature supercharges quick access to ANY project.
Once you have opened the repository on the browser/ vscode.dev, the next step would be to make updates or changes to the project.
### 1. Create a new file ***
You can either create a file inside an existing folder, or create it in the root directory/folder. To create a new file, open a location/directory to which you want the file to be saved and select the _'New file ...'_ icon on the activity bar _(left)_, give it a name and hit enter. ## Editing Files in Your Project
![Create a new file](../images/create-new-file.png) Once your repo is open, you can:
### 2. Edit and save a file on the repository ### 1. **Create a New File**
- In the *Explorer* sidebar, navigate to your desired folder or use the root.
- Click the _New file ..._ icon.
- Name your file, press **Enter**, and your file appears instantly.
Using vscode.dev is helpful whenever you want to make quick updates to your project without having to load any software locally. ![Create a new file](../images/create-new-file 2. **Edit and Save Files**
To update your code, click the 'Explorer' icon, also located on the activity bar to view files & folders in the repository.
Select a file to open it on the code area, make your changes and save.
![Edit a file](../images/edit-a-file.png) - Click on a file in the *Explorer* to open it in the code area.
- Make your changes as needed.
- VSCode.dev automatically saves your changes, but you can press Ctrl+S to save manually.
Once you are done updating your project, select the _`source control`_ icon which contains all the new changes you have made to your repository. ![Edit a file](../images/edit-a-file.png. **Track & Commit Changes with Version Control**
To view the changes you made to your project, select the file(s) in the `Changes` folder in the expanded activity bar. This will open a 'Working Tree' for you to visually see the changes you made to the file. Red shows an omission to the project, while green signifies an addition. VSCode.dev has integrated **Git** version control!
![View changes](../images/working-tree.png) - Click the _'Source Control'_ icon to view all changes made.
- Files in the `Changes` folder show additions (green) and deletions (red).
![View changes](../images/working-tree.png changes by clicking the `+` next to files to prepare for commit.
- **Discard** unwanted changes by clicking the undo icon.
- Type a clear commit message, then click the checkmark to commit and push.
If you are satisfied with the changes you made, hover on the `Changes` folder and click the `+` button to stage the changes. Staging simply means preparing your changes to commit them to GitHub. To return to your repository on GitHub, select the hamburger menu at the top left.
If however you are not comfortable with some changes and you want to discard them, hover on the `Changes` folder and select the `undo` icon. ![Stage & commit changes](../images/edit-vscode.dev Up with Extensions
Then, type in a `commit message` _(A description of the change you have made to the project)_, click the `check icon` to commit and push your changes. Extensions let you add languages, themes, debuggers, and productivity tools to VSCode.dev—making your coding life easier and more fun.
Once done working on your project, select the `hamburger menu icon` at the top left to return to the repository on github.com. ### Browsing and Managing Extensions
![Stage & commit changes](../images/edit-vscode.dev.gif) - Click the **Extensions icon** on the activity bar.
- Search for an extension in the _'Search Extensions in Marketplace'_ box.
## Using extensions ![Extension details](../images/extension-details:
Installing extensions on VSCode allows you to add new features and customized development environment options on your editor to improve your development workflow. These extensions also help you add support for multiple programming languages and are often either generic extensions or language-based extensions. - **Installed**: All extensions youve added
- **Popular**: Industry favorites
- **Recommended**: Tailored to your workflow
To browse through the list of all available extensions, click the _`Extensions icon`_ on the activity bar and start typing the name of the extension on the text field labelled _'Search Extensions in Marketplace'_. ![View extensions](
You will see a list of extensions, each one containing **the extension name, publisher's name, a 1 sentence description, number of downloads** and **a star rating**.
![Extension details](../images/extension-details.png)
You can also view all previously installed extensions by expanding the _`Installed folder`_ , popular extensions used by most developers in the _`Popular folder`_ and recommended extensions for you either by users in the same workspace or based on your recently opened files in the _`recommended folder`_ . ***
![View extensions](../images/extensions.png) ### 1. **Install Extensions**
- Enter the extensions name in search, click it, and review details in the editor.
- Hit the **blue Install button** in the sidebar _or_ in the main code area.
### 1. Install Extensions ![Install extensions](../images/install-extension 2. **Customize Extensions**
To install an extension, type the extension's name in the search field and click on it to view additional information about the extension on the code area once it appears on the expanded activity bar.
You can either click the _blue install button_ on the expanded activity bar to install or use the install button that appears on the code area once you select the extension to load additional information. - Find your installed extension.
- Click the **Gear icon** → select _Extension Settings_ to fine-tune behaviors to your liking.
![Install extensions](../images/install-extension.gif) ![Modify extension settings](../images/extension-settings 3. **Manage Extensions**
You can:
### 2. Customize Extensions - **Disable:** Temporarily turn off an extension while keeping it installed
After installing the extension, you may need to modify its behaviour and customize it based on your preferences. To do this, select the Extensions icon, and this time, your extension will appear in the _Installed folder_, click on the _**Gear icon**_ and navigate to _Extensions Setting_ - **Uninstall:** Permanently remove it if no longer needed
![Modify extension settings](../images/extension-settings.png) Find the extension, hit the Gear icon, and select Disable or Uninstall, or use the blue buttons in the code area.
### 3. Manage Extensions ***
After installing and using your extension, vscode.dev offers options to manage your extension based on different needs. For example, you may choose to:
- **Disable:** _(You temporarily disable an extension when you no longer need it but don't want to uninstall it completely)_
Select the installed extension on the expanded activity bar > click the Gear icon > select 'Disable' or 'Disable (Workspace)' **OR** Open the extension on the code area and click the blue Disable button.
- **Uninstall:** Select installed extension on the expanded activity bar > click the Gear icon > select 'Uninstall' **OR** Open the extension on the code area and click the blue Uninstall button.
## Assignment
Test your skills: [Create a resume website using vscode.dev](https://github.com/microsoft/Web-Dev-For-Beginners/blob/main/8-code-editor/1-using-a-code-editor/assignment.md)
--- ***
## Assignment ## Further Exploration and Self-Study
[Create a resume website using vscode.dev](https://github.com/microsoft/Web-Dev-For-Beginners/blob/main/8-code-editor/1-using-a-code-editor/assignment.md)
- Dive deeper with [the official VSCode Web Docs](https://code.visualstudio.com/docs/editor/vscode-web?WT.mc_id=academic-0000-alfredodeza).
- Explore advanced workspace features, keyboard shortcuts, and settings.
<!---- ***
## Post-Lecture Quiz
[Post-lecture quiz](https://ff-quizzes.netlify.app/web/quiz/4)
---->
## Review & Self Study **Now youre ready to code, create, and collaborate—from anywhere, on any device, using VSCode.dev!**
Read more about [VSCode.dev](https://code.visualstudio.com/docs/editor/vscode-web?WT.mc_id=academic-0000-alfredodeza) and some of its other features.

@ -1,30 +1,56 @@
# api
from flask import Flask, request, jsonify from flask import Flask, request, jsonify
from llm import call_llm from llm import call_llm
from flask_cors import CORS from flask_cors import CORS
import logging
app = Flask(__name__) app = Flask(__name__)
CORS(app) # * example.com
# Configure CORS (allow all origins for development; restrict in production)
CORS(app, resources={r"/*": {"origins": "*"}})
# Set up logging
logging.basicConfig(level=logging.INFO)
@app.route("/", methods=["GET"]) @app.route("/", methods=["GET"])
def index(): def index():
return "Welcome to this lesson" """Root endpoint for API status."""
return jsonify({
"status": "ok",
"message": "Welcome to the Chat Project API"
})
@app.route("/health", methods=["GET"])
def health():
"""Health check endpoint."""
return jsonify({"status": "healthy"}), 200
@app.route("/test", methods=["GET"]) @app.route("/test", methods=["GET"])
def test(): def test():
return "Test" """Simple test endpoint."""
return jsonify({"result": "Test successful"}), 200
@app.route("/hello", methods=["POST"]) @app.route("/hello", methods=["POST"])
def hello(): def hello():
# get message from request body { "message": "do this taks for me" } """
data = request.get_json() Chat endpoint.
message = data.get("message", "") Expects JSON: { "message": "your message" }
Returns: { "response": "LLM response" }
"""
try:
data = request.get_json(force=True)
message = data.get("message", "").strip()
if not message:
logging.warning("No message provided in request.")
return jsonify({"error": "No message provided."}), 400
response = call_llm(message, "You are a helpful assistant.") logging.info(f"Received message: {message}")
return jsonify({ response = call_llm(message, "You are a helpful assistant.")
"response": response return jsonify({"response": response}), 200
})
except Exception as e:
logging.error(f"Error in /hello endpoint: {e}")
return jsonify({"error": "Internal server error."}), 500
if __name__ == "__main__": if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000) # Run the app with debug mode for development
app.run(host="0.0.0.0", port=5000, debug=True)

@ -1,29 +1,53 @@
import os import os
import logging
from openai import OpenAI from openai import OpenAI
# To authenticate with the model you will need to generate a personal access token (PAT) in your GitHub settings. # Configure logging
# Create your PAT token by following instructions here: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Environment variable check for GitHub token
GITHUB_TOKEN = os.environ.get("GITHUB_TOKEN")
if not GITHUB_TOKEN:
logger.error("GITHUB_TOKEN environment variable not set.")
raise EnvironmentError("GITHUB_TOKEN environment variable not set.")
# Model and endpoint configuration
MODEL_NAME = os.environ.get("LLM_MODEL", "openai/gpt-4o-mini")
BASE_URL = os.environ.get("LLM_BASE_URL", "https://models.github.ai/inference")
# Initialize OpenAI client
client = OpenAI( client = OpenAI(
base_url="https://models.github.ai/inference", base_url=BASE_URL,
api_key=os.environ["GITHUB_TOKEN"], api_key=GITHUB_TOKEN,
) )
def call_llm(prompt: str, system_message: str): def call_llm(prompt: str, system_message: str, temperature: float = 1.0, max_tokens: int = 4096, top_p: float = 1.0) -> str:
response = client.chat.completions.create( """
messages=[ Calls the LLM with the given prompt and system message.
{ Returns the model's response as a string.
"role": "system", """
"content": system_message, try:
}, logger.info(f"Calling LLM model '{MODEL_NAME}' with prompt: {prompt}")
{ response = client.chat.completions.create(
"role": "user", messages=[
"content": prompt, {"role": "system", "content": system_message},
} {"role": "user", "content": prompt}
], ],
model="openai/gpt-4o-mini", model=MODEL_NAME,
temperature=1, temperature=temperature,
max_tokens=4096, max_tokens=max_tokens,
top_p=1 top_p=top_p
) )
content = response.choices[0].message.content
logger.info("LLM response received successfully.")
return content
except Exception as e:
logger.error(f"Error calling LLM: {e}")
return "Sorry, there was an error processing your request."
return response.choices[0].message.content # Example usage (for testing)
if __name__ == "__main__":
test_prompt = "Hello, how are you?"
test_system = "You are a friendly assistant."
print(call_llm(test_prompt, test_system))

@ -1,35 +1,179 @@
<!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <!-- Character encoding and viewport -->
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta charset="utf-8" />
<title>Stellar AI Chat</title> <meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="styles.css"> <!-- Explicit color-scheme support and order of preference -->
</head> <meta name="color-scheme" content="dark light" />
<body>
<div class="app"> <!-- Theming the browser UI for light/dark modes -->
<header class="header"> <meta name="theme-color" media="(prefers-color-scheme: light)" content="#ffffff" />
<div style="display:flex;align-items:center;gap:12px;"> <meta name="theme-color" media="(prefers-color-scheme: dark)" content="#0b0b0f" />
<div class="logo">🤖</div>
<div> <!-- Site metadata -->
<h1>My company</h1> <title>Stellar AI Chat</title>
<p class="subtitle">Dark-mode chat UI — powered by the backend AI</p> <meta name="description" content="Accessible, dark-mode chat UI powered by a backend AI with live-region announcements and robust keyboard navigation." />
</div> <meta name="referrer" content="no-referrer" />
<!-- PWA hooks (optional; provide files if used) -->
<link rel="manifest" href="manifest.webmanifest" />
<!-- Performance: DNS + connection warming -->
<link rel="dns-prefetch" href="https://fonts.googleapis.com" />
<link rel="dns-prefetch" href="https://fonts.gstatic.com" />
<link rel="dns-prefetch" href="https://cdnjs.cloudflare.com" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link rel="preconnect" href="https://cdnjs.cloudflare.com" />
<!-- Fonts: Inter variable -->
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@300..900&display=swap"
rel="stylesheet"
/>
<!-- Icons: Font Awesome 6 -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css"
referrerpolicy="no-referrer"
/>
<!-- App styles -->
<link rel="stylesheet" href="styles.css" />
<!-- Respect reduced motion; define in CSS with @media (prefers-reduced-motion: reduce) -->
</head>
<body>
<noscript>
<p role="status" aria-live="polite">
JavaScript is required for live chat updates and sending messages.
</p>
</noscript>
<div class="app" id="app" data-theme="dark">
<header class="header">
<div class="brand">
<div class="logo" aria-hidden="true">
<i class="fa-solid fa-robot" aria-hidden="true"></i>
</div> </div>
</header> <div>
<h1 class="title">My company</h1>
<p class="subtitle">Darkmode chat UI — powered by the backend AI</p>
</div>
</div>
<nav class="actions" aria-label="Header actions">
<button
class="icon-btn"
id="themeToggle"
type="button"
aria-label="Toggle theme"
aria-pressed="false"
>
<i class="fa-solid fa-moon" aria-hidden="true"></i>
</button>
<button
class="icon-btn"
id="clearChat"
type="button"
aria-label="Clear chat"
>
<i class="fa-solid fa-trash" aria-hidden="true"></i>
</button>
<button
class="icon-btn"
id="settings"
type="button"
aria-label="Settings"
aria-haspopup="dialog"
aria-expanded="false"
>
<i class="fa-solid fa-gear" aria-hidden="true"></i>
</button>
</nav>
</header>
<main class="chat" id="chat">
<!-- Live message stream for assistive tech:
role="log" conveys an updating feed; aria-live polite avoids interruption; aria-relevant focuses announcements -->
<div
class="messages"
id="messages"
role="log"
aria-live="polite"
aria-relevant="additions text"
aria-atomic="false"
aria-label="Chat messages"
></div>
<main class="chat" id="chat"> <form id="composer" class="composer" action="#" novalidate>
<div class="messages" id="messages" aria-live="polite"></div> <button
class="icon-left"
type="button"
id="attachBtn"
aria-label="Attach"
>
<i class="fa-solid fa-paperclip" aria-hidden="true"></i>
</button>
<form id="composer" class="composer" action="#"> <!-- Associate a real label for better accessibility -->
<textarea id="input" placeholder="Say hello — press Enter to send (Shift+Enter for newline)" rows="2"></textarea> <label for="input" class="visually-hidden">Message</label>
<button id="send" type="submit">Send</button> <textarea
</form> id="input"
</main> class="input"
placeholder="Say hello — Enter to send, Shift+Enter for newline"
rows="1"
spellcheck="true"
autocomplete="on"
autocapitalize="sentences"
enterkeyhint="send"
aria-label="Message input"
aria-describedby="composerHelp"
></textarea>
<div id="composerHelp" class="visually-hidden">
Press Enter to send, Shift+Enter for newline.
</div>
<div class="composer-actions">
<button
class="icon-btn"
type="button"
id="micBtn"
aria-label="Voice"
aria-pressed="false"
>
<i class="fa-solid fa-microphone" aria-hidden="true"></i>
</button>
<button
id="send"
class="send-btn"
type="submit"
aria-label="Send"
>
<span>Send</span>
<i class="fa-solid fa-paper-plane" aria-hidden="true"></i>
</button>
</div>
</form>
</main>
<footer class="footer">Running with backend at <code>http://127.0.0.1:5000/hello</code></footer> <footer class="footer">
</div> <!-- role="status" is appropriate for non-interruptive live updates -->
<div class="status" role="status" aria-live="polite">
<span class="dot" id="statusDot" aria-hidden="true"></span>
<span>Backend:</span>
<code>http://127.0.0.1:5000/hello</code>
</div>
</footer>
</div>
<script src="app.js"></script> <!-- App script; consider type=module and defer for performance -->
</body> <script src="app.js" defer></script>
</html> </body>
</html>

@ -1,16 +1,37 @@
## For Educators ### For Educators
Would you like to use this curriculum in your classroom? Please feel free to! You are welcome to use this curriculum in your classroom. It works seamlessly with GitHub Classroom and leading LMS platforms, and it can also be used as a standalone repo with your students.
In fact, you can use it within GitHub itself by using GitHub Classroom. ### Use with GitHub Classroom
To do that, fork this repo. You are going to need to create a repo for each lesson, so you're going to need to extract each folder into a separate repo. That way, [GitHub Classroom](https://classroom.github.com/classrooms) can pick up each lesson separately. To manage lessons and assignments per cohort, create one repository per lesson so GitHub Classroom can attach each assignment independently.
These [full instructions](https://github.blog/2020-03-18-set-up-your-digital-classroom-with-github-classroom/) will give you an idea of how to set up your classroom. - Fork this repo to your organization.
- Create a separate repo for each lesson by extracting each lesson folder into its own repository.
- Option A: Create empty repos (one per lesson) and copy the lesson folder contents into each.
- Option B: Use a Git historypreserving approach (e.g., split a folder into a new repo) if you need provenance.
- In GitHub Classroom, create an assignment per lesson and point it to the corresponding lesson repo.
- Recommended settings:
- Repository visibility: private for student work.
- Use starter code from the lesson repos default branch.
- Add issue and pull request templates for quizzes and submissions.
- Optionally configure autograding and tests if your lessons include them.
- Conventions that help:
- Repository names like lesson-01-intro, lesson-02-html, etc.
- Labels: quiz, assignment, needs-review, late, resubmission.
- Tags/releases per cohort (e.g., v2025-term1).
## Using it in Moodle, Canvas or Blackboard Tip: Avoid storing repositories inside synced folders (e.g., OneDrive/Google Drive) to prevent Git conflicts on Windows.
This curriculum works well in these Learning Management Systems! Use the [Moodle upload file](/teaching-files/webdev-moodle.mbz) for the full content, or try the [Common Cartridge file](/teaching-files/webdev-common-cartridge.imscc) which contains some of the content. Moodle Cloud does not support full Common Cartridge exports, so it is preferable to use the Moodle download file which can be uploaded into Canvas. Please let us know how we can improve this experience. ### Use with Moodle, Canvas, or Blackboard
This curriculum includes importable packages for common LMS workflows.
- Moodle: Use the Moodle upload file [Moodle upload file](/teaching-files/webdev-moodle.mbz) to load the full course.
- Common Cartridge: Use the Common Cartridge file [Common Cartridge file](/teaching-files/webdev-common-cartridge.imscc) for broader LMS compatibility.
- Notes:
- Moodle Cloud has limited Common Cartridge support. Prefer the Moodle file above, which can also be uploaded into Canvas.
- After import, review modules, due dates, and quiz settings to match your term schedule.
![Moodle](/teaching-files/moodle.png) ![Moodle](/teaching-files/moodle.png)
> The curriculum in a Moodle classroom > The curriculum in a Moodle classroom
@ -18,16 +39,26 @@ This curriculum works well in these Learning Management Systems! Use the [Moodle
![Canvas](/teaching-files/canvas.png) ![Canvas](/teaching-files/canvas.png)
> The curriculum in Canvas > The curriculum in Canvas
## Using the repo as is ### Use the repo directly (no Classroom)
If you would like to use this repo as it currently stands, without using GitHub Classroom, that can be done as well. You would need to communicate with your students which lesson to work through together. If you prefer not to use GitHub Classroom, you can run the course directly from this repo.
In an online format (Zoom, Teams, or other) you might form breakout rooms for the quizzes, and mentor students to help them get ready to learn. Then invite students to the quizzes and submit their answers as 'issues' at a certain time. You might do the same with assignments if you want students to work collaboratively out in the open. - Synchronous/online formats (Zoom/Teams):
- Run short mentorled warmups; use breakout rooms for quizzes.
- Announce a time window for quizzes; students submit answers as GitHub Issues.
- For collaborative assignments, students work in public lesson repos and open pull requests.
- Private/asynchronous formats:
- Students fork each lesson to their own **private** repos and add you as a collaborator.
- They submit via Issues (quizzes) and Pull Requests (assignments) on your classroom repo or their private forks.
If you prefer a more private format, ask your students to fork the curriculum, lesson by lesson, to their own GitHub repos as private repos, and give you access. Then they can complete quizzes and assignments privately and submit them to you via issues on your classroom repo. ### Best practices
There are many ways to make this work in an online classroom format. Please let us know what works best for you! - Provide an orientation lesson on Git/GitHub basics, Issues, and PRs.
- Use checklists in Issues for multistep quizzes/assignments.
- Add CONTRIBUTING.md and CODE_OF_CONDUCT.md to set classroom norms.
- Add accessibility notes (alt text, captions) and offer printable PDFs.
- Version your content per term and freeze lesson repos after publishing.
## Please give us your thoughts! ### Feedback and support
We want to make this curriculum work for you and your students. Connect with us at the [Teacher corner](https://github.com/microsoft/Web-Dev-For-Beginners/discussions/categories/teacher-corner) and open a [**new issue**](https://github.com/microsoft/Web-Dev-For-Beginners/issues/new/choose) for any requests, bugs and feedback. We want this curriculum to work for you and your students. Please open a new Issue in this repository for bugs, requests, or improvements, or start a discussion in the Teacher Corner.

@ -1,3 +1,108 @@
.app-nav ul li { .app-nav ul li {
width: max-content; width: max-content;
}
body {
font-family: 'Inter', Arial, sans-serif;
}
/* Body and Typography */
body {
font-family: 'Inter', Arial, sans-serif;
background: #f7f8fa;
color: #222;
margin: 0;
padding: 0;
}
/* Header Styling */
h1, h2, h3 {
font-weight: 700;
margin-top: 1.5em;
margin-bottom: 0.5em;
letter-spacing: 0.02em;
}
h1 i, h2 i, h3 i {
color: #0078d4;
margin-right: 0.5em;
}
/* Navigation Bar */
.app-nav {
background: #fff;
box-shadow: 0 2px 8px rgba(0,0,0,0.04);
padding: 1em 2em;
}
.app-nav ul {
list-style: none;
display: flex;
gap: 2em;
margin: 0;
padding: 0;
}
.app-nav ul li {
width: max-content;
}
.app-nav a {
text-decoration: none;
color: #0078d4;
font-weight: 500;
transition: color 0.2s;
}
.app-nav a:hover {
color: #005fa3;
}
/* Card Component */
.card {
background: #fff;
border-radius: 12px;
box-shadow: 0 4px 16px rgba(0,0,0,0.07);
padding: 2em;
margin: 2em 0;
transition: box-shadow 0.2s;
}
.card:hover {
box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
/* Button Styling */
.button {
background: #0078d4;
color: #fff;
border: none;
border-radius: 6px;
padding: 0.75em 1.5em;
font-size: 1em;
font-weight: 600;
cursor: pointer;
transition: background 0.2s;
display: inline-flex;
align-items: center;
gap: 0.5em;
}
.button:hover {
background: #005fa3;
}
/* Font Awesome Icon Styling */
.fa {
margin-right: 0.5em;
vertical-align: middle;
}
/* Responsive Layout */
@media (max-width: 600px) {
.app-nav ul {
flex-direction: column;
gap: 1em;
}
.card {
padding: 1em;
}
} }

@ -1,4 +1,5 @@
<!DOCTYPE html> <!-- Add Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet"><!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
@ -13,7 +14,8 @@
<body> <body>
<div id="app"></div> <div id="app"></div>
<script type="text/javascript"> <script type="text/javascript">
(function(c,l,a,r,i,t,y){ (function(c,l,a,r,i,t,y){ <!-- Add Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);

Loading…
Cancel
Save