-
-
Notifications
You must be signed in to change notification settings - Fork 212
NW | 25-ITP-Sep | TzeMing Ho | Sprint 3 | Quote Generator #803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
21aa7aa
081238f
ffe6668
75d1246
4e2d6df
e28e98d
11a4d4b
a9ba9ed
0e1bfe2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -491,3 +491,37 @@ const quotes = [ | |
| ]; | ||
|
|
||
| // call pickFromArray with the quotes array to check you get a random quote | ||
|
|
||
| function updateQuoteAndAuthor() { | ||
| const { quote, author } = pickFromArray(quotes); | ||
| document.getElementById("quote").textContent = quote; | ||
| document.getElementById("author").textContent = author; | ||
| } | ||
|
|
||
| function autoUpdateQuoteAndAuthor() { | ||
| const autoQuote = document.getElementById("toggle-btn"); | ||
| const newQuoteButton = document.getElementById("new-quote"); | ||
| const autoDisplayNotice = document.getElementById("auto-play-notice"); | ||
| let intervalId; | ||
| autoQuote.addEventListener("change", () => { | ||
| if (autoQuote.checked) { | ||
| newQuoteButton.style.display = "none"; | ||
| autoDisplayNotice.style.display = "block"; | ||
| intervalId = setInterval(() => { | ||
| updateQuoteAndAuthor(); | ||
| }, 3000); | ||
|
||
| } else { | ||
| clearInterval(intervalId); | ||
| newQuoteButton.style.display = "block"; | ||
| autoDisplayNotice.style.display = "none"; | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| window.onload = () => { | ||
| updateQuoteAndAuthor(); | ||
| autoUpdateQuoteAndAuthor(); | ||
| document | ||
| .getElementById("new-quote") | ||
| .addEventListener("click", updateQuoteAndAuthor); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have implemented the first part of this task quite well. However, you have yet to attempt the "auto-generate" task. Why is that?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was concerned that I couldn't figure out why the second test keeps failing. So, I made this pull request to seek for guidelines. However, if it is ok to move on, I would love to try implementing new features.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi sambabib, |
||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,116 @@ | ||
| /** Write your CSS in here **/ | ||
| :root { | ||
| --primary-bg-color: #e9b066; | ||
| --primary-color: #ffffff; | ||
| --auto-activated: #8fc9f8; | ||
| } | ||
|
|
||
| body { | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| justify-content: center; | ||
| text-align: center; | ||
| background-color: var(--primary-bg-color); | ||
| } | ||
|
|
||
| #poster { | ||
| width: 80%; | ||
| padding: 25px; | ||
| background-color: var(--primary-color); | ||
| color: var(--primary-bg-color); | ||
| font-size: larger; | ||
| font-style: italic; | ||
| position: relative; | ||
| top: 150px; | ||
| } | ||
|
|
||
| #quote { | ||
| font-weight: bold; | ||
| } | ||
|
|
||
| #slide-bar { | ||
| display: flex; | ||
| justify-content: end; | ||
| width: 90%; | ||
| } | ||
|
|
||
| #button-field { | ||
| display: flex; | ||
| justify-content: end; | ||
| margin-bottom: -10px; | ||
| } | ||
|
|
||
| #display-notice { | ||
| display: flex; | ||
| justify-content: end; | ||
| } | ||
|
|
||
| #auto-display-notice { | ||
| font-size: 12px; | ||
| } | ||
|
|
||
| button { | ||
| border-radius: 8px; | ||
| font-size: medium; | ||
| background-color: var(--primary-bg-color); | ||
| color: var(--primary-color); | ||
| border: none; | ||
| } | ||
|
|
||
| .switch { | ||
| position: relative; | ||
| display: inline-block; | ||
| width: 60px; | ||
| height: 34px; | ||
| } | ||
|
|
||
| .switch input { | ||
| opacity: 0; | ||
| width: 0; | ||
| height: 0; | ||
| } | ||
|
|
||
| /* The slider */ | ||
| .slider { | ||
| position: absolute; | ||
| cursor: pointer; | ||
| top: 0; | ||
| left: 0; | ||
| right: 0; | ||
| bottom: 0; | ||
| background-color: var(--primary-color); | ||
| transition: 0.4s; | ||
| } | ||
|
|
||
| .slider:before { | ||
| position: absolute; | ||
| content: ""; | ||
| height: 26px; | ||
| width: 26px; | ||
| left: 4px; | ||
| bottom: 4px; | ||
| background-color: var(--primary-bg-color); | ||
| transition: 0.4s; | ||
| } | ||
|
|
||
| input:checked + .slider { | ||
| background-color: var(--auto-activated); | ||
| } | ||
|
|
||
| input:focus + .slider { | ||
| box-shadow: 0 0 1px var(--auto-activated); | ||
| } | ||
|
|
||
| input:checked + .slider:before { | ||
| transform: translateX(26px); | ||
| } | ||
|
|
||
| /* Rounded sliders */ | ||
| .slider.round { | ||
| border-radius: 34px; | ||
| } | ||
|
|
||
| .slider.round:before { | ||
| border-radius: 50%; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the screen reader be able to understand what this button is for from the context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, Bhuwan. I should have added an aria-label for the input.