-
-
Notifications
You must be signed in to change notification settings - Fork 283
London | 26-ITP-Jan | Karla Grajales | Sprint 3 | Quote generator #1198
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
Open
Grajales-K
wants to merge
19
commits into
CodeYourFuture:main
Choose a base branch
from
Grajales-K:quote-generator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 12 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
8bc3e8c
feat: add container for quotes
Grajales-K c8b9d48
feat: add stylesheet and background styling for quote generator
Grajales-K 43a7d8e
feat: add media images and sound
Grajales-K 8291f6f
refactor: move example image to assets
Grajales-K 4841426
feat: add script.js for additional functionality in quote generator
Grajales-K 62c26cc
feat: implement random quote generation functionality
Grajales-K fcf0c91
feat: add auto-play functionality for random quotes
Grajales-K 0d91e68
feat: add background sound playback functionality
Grajales-K c72fb1b
feat: enhance quote generator with sound playback and auto-quote inte…
Grajales-K ee8e66d
refactor: remove unused pickFromArray function from quotes.js
Grajales-K 7847481
feat: add autoplay functionality for background sound and improve quo…
Grajales-K 81bbb7f
feat: update styles for quote generator with improved layout and design
Grajales-K 6d68eaa
feat: add button for auto-quote playback in quote generator
Grajales-K c7538f3
feat: rename button for auto-quote playback and update event listener
Grajales-K f0185ee
feat: improve sound playback logic and enhance quote display layout
Grajales-K beb1440
Revert "feat: improve sound playback logic and enhance quote display …
Grajales-K 4172f20
feat: update styles for quote generator with enhanced design and layo…
Grajales-K c14ea3a
feat: enhance quote generator with background sound playback and rand…
Grajales-K 9375e10
feat: refactor quote generation logic and improve event handling for …
Grajales-K File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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 hidden or 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,67 @@ | ||
| // added extra functionality to play music when the user click on autoplay | ||
| let backgroundSound = new Audio("assets/SPACE.mp3"); | ||
| let isSoundStarted = false; | ||
|
|
||
| //avoid auto-playing sound in test environment and jsdom which does not implement audio playback | ||
| function playSound() { | ||
| if (!navigator.userAgent.includes("jsdom")) { | ||
| backgroundSound.play().catch((error) => { | ||
| console.log("waiting for user interaction to start sound"); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| //generated random quote from the array of quotes | ||
| function pickFromArray(quotes) { | ||
| return quotes[Math.floor(Math.random() * quotes.length)]; | ||
| } | ||
|
|
||
| const container = document.querySelector("#container-quote"); | ||
| const quoteText = document.querySelector("#quote"); | ||
| const quoteAuthor = document.querySelector("#author"); | ||
| const button = document.querySelector("#new-quote"); | ||
|
|
||
| // updates the quote and author text in the HTML | ||
| function randomQuoteGenerate() { | ||
| const randomArr = pickFromArray(quotes); | ||
| quoteText.textContent = randomArr.quote; | ||
| quoteAuthor.textContent = randomArr.author; | ||
| } | ||
|
|
||
| // triggers the first random quote display once the window is fully loaded | ||
| window.onload = () => { | ||
| randomQuoteGenerate(); | ||
| }; | ||
|
|
||
| // listens for clicks to change quotes manually and start the background sound | ||
| button.addEventListener("click", () => { | ||
| randomQuoteGenerate(); | ||
| if (!isSoundStarted) { | ||
| playSound(); | ||
| isSoundStarted = true; | ||
| } | ||
| }); | ||
|
|
||
| const secondButton = document.createElement("button"); | ||
| secondButton.textContent = "Play Auto-Quotes"; | ||
| secondButton.classList.add("btn"); | ||
|
|
||
| container.appendChild(secondButton); | ||
|
Grajales-K marked this conversation as resolved.
Outdated
|
||
|
|
||
| let quoteInterval; | ||
|
|
||
| // toggles the automatic quote generator and manages the play/stop state | ||
| secondButton.addEventListener("click", () => { | ||
| if (quoteInterval) { | ||
| clearInterval(quoteInterval); | ||
| quoteInterval = null; | ||
| secondButton.textContent = "Play Auto-Quotes"; | ||
| } else { | ||
| quoteInterval = setInterval(randomQuoteGenerate, 2000); | ||
| secondButton.textContent = "Stop"; | ||
| if (!isSoundStarted) { | ||
| playSound(); | ||
| isSoundStarted = true; | ||
| } | ||
| } | ||
| }); | ||
|
Grajales-K marked this conversation as resolved.
Outdated
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1 +1,69 @@ | ||
| /** Write your CSS in here **/ | ||
| body { | ||
| background-image: url("./assets/stars.webp"); | ||
| background-size: cover; | ||
| background-position: center; | ||
| background-attachment: fixed; | ||
| margin: 0; | ||
| height: 100vh; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| font-family: Arial, sans-serif; | ||
| } | ||
|
|
||
|
|
||
| #container-quote { | ||
| background: rgba(0, 0, 0, 0.3); | ||
| backdrop-filter: blur(4px); | ||
| -webkit-backdrop-filter: blur(4px); | ||
| padding: 20px; | ||
| border-radius: 15px; | ||
| border: 1px solid rgba(255, 255, 255, 0.2); | ||
| box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5); | ||
| max-width: 400px; | ||
| width: 85%; | ||
| text-align: center; | ||
| } | ||
|
|
||
| h1 { | ||
| font-size: 1.4rem; | ||
| margin-bottom: 15px; | ||
| color: white; | ||
| } | ||
|
|
||
|
|
||
| #quote { | ||
| font-size: 1.2rem; | ||
| font-style: italic; | ||
| color: #3bffeb; | ||
| line-height: 1.3; | ||
| margin-bottom: 10px; | ||
| } | ||
|
|
||
|
|
||
| #author { | ||
| font-size: 0.9rem; | ||
| font-weight: bold; | ||
| color: #ffffff; | ||
| margin-bottom: 20px; | ||
| display: block; | ||
| } | ||
|
|
||
|
|
||
| #new-quote, .btn { | ||
| background-color: rgba(3, 251, 255, 0.15); | ||
| color: white; | ||
| border: 1px solid rgba(59, 255, 235, 0.5); | ||
| border-radius: 8px; | ||
| padding: 8px 16px; | ||
| font-size: 0.85rem; | ||
| cursor: pointer; | ||
| transition: all 0.3s ease; | ||
| margin: 5px; | ||
| } | ||
|
|
||
| #new-quote:hover, .btn:hover { | ||
| background-color: #3bffeb; | ||
| color: #000593; | ||
| transform: translateY(-2px); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.