-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from Birkbeck2/debugging-live-coding
Debugging live coding
- Loading branch information
Showing
4 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// app.js | ||
|
||
let form = document.querySelector('#form') | ||
|
||
function changeColor(event) [ | ||
event,preventDefault() | ||
let colorSelect = form.querySelector('#color') | ||
let color = colorSelect.value | ||
for square = document.querySelector('.square') | ||
square.className = `square ${color}` | ||
} | ||
|
||
changeForm.addEventListener('submit', changeColor) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-GB"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Sandbox: Using JavaScript on forms, improved with select</title> | ||
<link rel="stylesheet" href="styles.css"> | ||
<!-- #region script --> | ||
<script src="main.js" defer></script> | ||
<!-- #endregion script --> | ||
</head> | ||
<body> | ||
<main class="container"> | ||
<a href="index.html"><h1>Sandbox: Using JavaScript on forms, improved with select</h1></a> | ||
<!-- #region form --> | ||
<form action="" id="background-color-form" method="post"> | ||
<div> | ||
<label for="color">mustard, red, or blue?</label> | ||
</div> | ||
<div> | ||
<select id="color" name="color"> | ||
<option value="mustard">Mustard</option> | ||
<option value="red">Red</option> | ||
<option value="blue">Blue</option> | ||
</select> | ||
<button type="submit">Submit</button> | ||
</div> | ||
</form> | ||
<!-- #endregion form --> | ||
<section class="flex-container"> | ||
<div class="shape square mustard"></div> | ||
</section> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* Body and container */ | ||
body { | ||
background: #202124; | ||
font-family: sans-serif; | ||
margin: auto; | ||
max-width: 800px; | ||
} | ||
|
||
.container { | ||
color: #fdfeff; | ||
text-align: center; | ||
margin: 1rem; | ||
} | ||
|
||
/* Heading */ | ||
h1 { | ||
color: #fdfeff; | ||
} | ||
a { | ||
text-decoration: none; | ||
} | ||
|
||
/* Form */ | ||
form { | ||
margin-top: 1rem; | ||
} | ||
select, | ||
button { | ||
padding: 0.5rem; | ||
font-size: 1.1rem; | ||
} | ||
|
||
/* Shape gallery */ | ||
.flex-container { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 4rem; | ||
flex-wrap: wrap; | ||
justify-content: center; | ||
align-items: center; | ||
margin-top: 4rem; | ||
} | ||
@media screen and (min-width: 600px) { | ||
.flex-container { | ||
flex-direction: row; | ||
} | ||
} | ||
|
||
.shape { | ||
height: 5rem; | ||
width: 5rem; | ||
transition: all 0.4s; | ||
} | ||
|
||
/* Colors */ | ||
/* Credit the Open Library of Humanities */ | ||
|
||
.mustard { | ||
background: #c08031; | ||
} | ||
.red { | ||
background: #e94c33; | ||
} | ||
.blue { | ||
background: #1579a0; | ||
} | ||
|
||
/* Form */ | ||
form { | ||
margin-top: 1rem; | ||
} | ||
form label, | ||
form input, | ||
form select, | ||
form button { | ||
font-size: 1.1rem; | ||
margin: 1rem; | ||
} | ||
|