Skip to content
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

Dev #1

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5502
}
44 changes: 23 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
## The Golden Rule:
# Magic 8 Ball Plan

🦸 🦸‍♂️ `Stop starting and start finishing.` 🏁
![wireframe for magic 8 ball app](./assets/8-ball-wireframe.png)

If you work on more than one feature at a time, you are guaranteed to multiply your bugs and your anxiety.
## HTML

## Making a plan
- h1 for header
- section with

1. **Make a drawing of your app. Simple "wireframes"**
1. **Look at the drawing and name the HTML elements you'll need to realize your vision**
1. **Look at the drawing and imagine using the app. What _state_ do you need to track?**
1. **For each HTML element ask: Why do I need this? (i.e., "we need div to display the results in")**
1. **Once we know _why_ we need each element, think about how to implement the "Why" as a "How" (i.e., `resultsEl.textContent = newResults`)**
1. **Find all the 'events' (user clicks, form submit, on load etc) in your app. Ask one by one, "What happens when" for each of these events. Does any state change? Does any DOM update?**
1. **Think about how to validate each of your features according to a Definition of Done. (Hint: console.log usually helps here.)**
1. **Consider what features _depend_ on what other features. Use this dependency logic to figure out what order to complete tasks.**
* p tag for prompt
* text input for user question
* button for submit

Additional considerations:
- section with

- Ask: which of your HTML elements need to be hard coded, and which need to be dynamically generated?
- Consider your data model.
- What kinds of objects (i.e., Dogs, Friends, Todos, etc) will you need?
- What are the key/value pairs?
- What arrays might you need?
- What needs to live in a persistence layer?
- Is there some state we need to initialize?
- Ask: should any of this work be abstracted into functions? (i.e., is the work complicated? can it be reused?)
* img of 8 ball
* p tag to display the randomly selected answer
* button to ask again

## EVENTS

- button click (question submit)
- hide prompt
- display the image
- pick a random number between 0 and the length of the answers array -1
- set the content of the answer p to the random choice
- button click (ask again)
- hide 8 ball and the answer
- show prompt
52 changes: 51 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,60 @@
/* Imports */

/* Get DOM Elements */

const submitButton = document.getElementById('submit');
const promptSection = document.getElementById('prompt');
const fortuneSection = document.getElementById('fortune');
const answerP = document.getElementById('answer');
const resetButton = document.getElementById('reset');
/* State */

/* Events */
submitButton.addEventListener('click', () => {
// hide prompt
// display the image
toggleSections();
// pick a random number between 0 and length of the answers array - 1
const randomInt = Math.floor(Math.random() * answers.length);
// console.log(randomInt);
const randomChoice = answers[randomInt];
// console.log(randomChoice);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just delete these console.logs :D

// console.log('answers[12]', answers[12]);
// set the content of the answer p to the random choice
answerP.textContent = randomChoice;
});

resetButton.addEventListener('click', () => {
// hide 8 ball and the answer
// show prompt
toggleSections();
});

function toggleSections() {
promptSection.classList.toggle('hide');
fortuneSection.classList.toggle('hide');
}

const answers = [
'Yes, definitely',
'It is certain',
'It is decidedly so',
'Without a doubt',
'You may rely on it',
'As I see it, yes',
'Most Likely',
'Outlook good',
'Signs point to yes',
'Outlook hazy, try again',
'Ask again later',
'Better not tell you now',
'Cannot predict now',
'Concentrate and ask again',
'Don’t count on it',
'My reply is no',
'My sources say no',
'Outlook not so good',
'Very doubtful',
];

/* Display Functions */

Expand Down
Binary file added assets/8-ball-wireframe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/8-ball.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/JakeMorgan-favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/galaxy-background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
91 changes: 54 additions & 37 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,39 +1,56 @@
<!DOCTYPE html>
<html lang="en">

<head>
<!-- metadata -->
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />

<!-- title and favicon -->
<title>Web App</title>
<link rel="icon" type="image/x-icon" href="assets/alchemy-favicon.png" />

<!-- js -->
<script type="module" src="app.js"></script>

<!-- fonts -->
<!-- see https://fonts.google.com/ -->

<!-- css -->
<link rel="stylesheet" href="styles/reset.css" />
<link rel="stylesheet" href="styles/global.css" />
<!-- add link for page specific css -->

</head>

<body>
<header>
<img class="logo" src="assets/html_css_js.png" alt="logo">
<h1>Web App</h1>
</header>

<main>

</main>

</body>

</html>
<head>
<!-- metadata -->
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />

<!-- title and favicon -->
<title>Web App</title>
<link rel="icon" type="image/x-icon" href="assets/JakeMorgan-favicon.png" />

<!-- js -->
<script type="module" src="app.js"></script>

<!-- fonts -->
<!-- see https://fonts.google.com/ -->

<!-- css -->
<link rel="stylesheet" href="styles/reset.css" />
<link rel="stylesheet" href="styles/global.css" />
<!-- add link for page specific css -->
</head>

<body>
<header>
<img class="logo" src="assets/JakeMorgan-favicon.png" alt="logo" />
<h1>Magic 8 Ball</h1>
</header>

<main>
<section id="prompt" class="prompt">
<h1>What do you want to know?</h1>
<input type="text" />
<button id="submit">Submit</button>
</section>
<section id="fortune" class="fortune hide">
<div class="fortune-wrapper">
<img class="image" src="./assets/8-ball.png" alt="magic 8 ball" />
<p class="answer" id="answer"></p>
<svg class="triangle" viewbox="-1 -1 95 95">
<path
d="M5 4h14a2 2 0 0 1 1.84 2.75l-7.1 12.25a2 2 0 0 1 -3.5 0l-7.1 -12.25a2 2 0 0 1 1.75 -2.75"
fill="none"
stroke="currentColor"
stroke-width="0.5"
/>
</svg>
<button class="reset" id="reset">Ask again!</button>
<div class="shape left"></div>
<div class="shape right"></div>
</div>
</section>
</main>
</body>
</html>
68 changes: 67 additions & 1 deletion styles/global.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:root {
--background: rgb(224, 234, 247);
--header-background: rgb(254, 251, 245);
--header-background: rgb(3, 26, 65);
--primary-font: Corbel, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'DejaVu Sans',
'Bitstream Vera Sans', 'Liberation Sans', Verdana, 'Verdana Ref', sans-serif;
}
Expand All @@ -23,6 +23,7 @@ header {
gap: 10px;

background-color: var(--header-background);
color: white;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}

Expand All @@ -31,5 +32,70 @@ header .logo {
}

main {
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
background-image: url(../assets/galaxy-background.jpg);
color: white;
}

p {
}

.hide {
display: none;
}

.image {
width: 450px;
}

.fortune-wrapper {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
}

.answer {
position: relative;
text-align: justify;
z-index: 1;
bottom: 260px;
color: rgb(16, 162, 247);
font-size: 1rem;
text-transform: uppercase;
}

.shape {
width: 50%;
height: 100%;
}

.left {
shape-outside: polygon(50% 100%, 0 0, 100% 0);
float: left;
}

.right {
shape-outside: polygon(50% 100%, 0 0, 100% 0);
float: right;
}

.triangle {
position: relative;
z-index: 0;
bottom: 366px;
left: 280px;
width: 170%;
color: transparent;
}

.reset {
position: relative;
bottom: 800px;
}

p {
}