-
-
Notifications
You must be signed in to change notification settings - Fork 281
Sheffield | 26-ITP-Jan | Mona- Eltantawy | Sprint 3| Sprint3 /Quote generator #1153
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
Mona-Eltantawy
wants to merge
5
commits into
CodeYourFuture:main
Choose a base branch
from
Mona-Eltantawy: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.
+101
−11
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9f9b2b0
updated the title and h1 elements.
Mona-Eltantawy ca4da9b
I wrote 3 variables to define the quote, auother, and neq-quote.
Mona-Eltantawy 942eaa2
I wrote a CSS file for the html file.
Mona-Eltantawy 477fd88
Re-edited the HTML file and formatted it.
Mona-Eltantawy 195d942
fixed the function
Mona-Eltantawy 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
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,15 +1,17 @@ | ||
| <!DOCTYPE html> | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Title here</title> | ||
| <title>Quote generator app</title> | ||
| <script defer src="quotes.js"></script> | ||
| <link rel="stylesheet" href="style.css" /> | ||
| </head> | ||
| <body> | ||
| <h1>hello there</h1> | ||
| <p id="quote"></p> | ||
| <p id="author"></p> | ||
| <button type="button" id="new-quote">New quote</button> | ||
| <div class="container"> | ||
| <p id="quote"></p> | ||
| <p id="author"></p> | ||
| <button type="button" id="new-quote">New quote</button> | ||
| </div> | ||
| </body> | ||
| </html> |
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 |
|---|---|---|
|
|
@@ -14,12 +14,17 @@ | |
| // Examples of use | ||
| // --------------- | ||
| // pickFromArray(['a','b','c','d']) // maybe returns 'c' | ||
| // DOM elements | ||
| const quote = document.querySelector("#quote"); | ||
| const author = document.querySelector("#author"); | ||
| const newquote = document.querySelector("#new-quote"); | ||
|
|
||
| // You don't need to change this function | ||
| function pickFromArray(choices) { | ||
| return choices[Math.floor(Math.random() * choices.length)]; | ||
| // utility function (given) | ||
| function pickFromArray(quotes) { | ||
| return quotes[Math.floor(Math.random() * quotes.length)]; | ||
| } | ||
|
|
||
|
|
||
| // A list of quotes you can use in your app. | ||
| // DO NOT modify this array, otherwise the tests may break! | ||
| const quotes = [ | ||
|
|
@@ -490,4 +495,21 @@ const quotes = [ | |
| }, | ||
| ]; | ||
|
|
||
| // call pickFromArray with the quotes array to check you get a random quote | ||
|
|
||
|
|
||
| function showRandomQuote() { | ||
| const randomQuote = pickFromArray(quotes); | ||
| quote.textContent = randomQuote.quote; | ||
| author.textContent = randomQuote.author; | ||
| } | ||
|
|
||
| function setup() { | ||
| showRandomQuote(); | ||
|
|
||
| quote.addEventListener("click", showRandomQuote); | ||
| author.addEventListener("click", showRandomQuote); | ||
| newquote.addEventListener("click", showRandomQuote); | ||
|
Comment on lines
+509
to
+511
Contributor
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. Why make also the quote and author paragraph elements clickable? |
||
| } | ||
|
|
||
|
|
||
| window.addEventListener("load", setup); | ||
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,67 @@ | ||
| /** Write your CSS in here **/ | ||
| * { | ||
| padding: 0; | ||
| margin: 0; | ||
| box-sizing: border-box; | ||
| } | ||
| body { | ||
| background-color: orange; | ||
| display: flex; | ||
| justify-content: center; /* horizontal centering */ | ||
| align-items: flex-start; /* vertical centering */ | ||
| height: 100vh; /* full viewport height */ | ||
| font-family: Georgia, "Times New Roman", Times, serif; | ||
| } | ||
|
|
||
| .container { | ||
| background-color: white; | ||
| width: 70%; | ||
| max-width: 650px; | ||
| padding: 60px 80px; | ||
| border-radius: 8px; | ||
| text-align: center; /* centers text inside */ | ||
| margin: 20% 20%; | ||
| display: block; | ||
| } | ||
|
|
||
| #quote { | ||
| font-size: 28px; | ||
| color: #f59e0b; | ||
| line-height: 1.5; | ||
| position: relative; | ||
| margin-bottom: 30px; | ||
| } | ||
| #quote::before { | ||
| content: "“"; | ||
| font-size: 80px; | ||
| position: absolute; | ||
| left: -40px; | ||
| top: -20px; | ||
| color: #f59e0b; | ||
| } | ||
| #author { | ||
| display: block; | ||
| text-align: right; | ||
| font-size: 16px; | ||
| color: #f59e0b; | ||
| margin-bottom: 20px; | ||
| } | ||
| #author::before { | ||
| content: "~ "; | ||
| font-size: 20px; | ||
| color: #f59e0b; | ||
| } | ||
| #new-quote { | ||
| align-items: right; | ||
| text-align: right; | ||
| background-color: #f59e0b; | ||
| color: white; | ||
| border: none; | ||
| padding: 10px 20px; | ||
| cursor: pointer; | ||
| font-size: 14px; | ||
| border-radius: 2px; | ||
| display: block; | ||
| } | ||
| #new-quote :hover { | ||
| opacity: 0.9; | ||
| } |
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.
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.
To make variable names (for storing DOM objects) more meaningful, a better practice is to add a suffix to the variable names. For examples,
quoteEl,authorEl,newQuoteButton.