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 9 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
35 changes: 12 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
## The Golden Rule:
![wireframe of MAGIC-8-BALL](assets/8BALLwireframe.png)

🦸 🦸‍♂️ `Stop starting and start finishing.` 🏁
# HTML

If you work on more than one feature at a time, you are guaranteed to multiply your bugs and your anxiety.
- 2 sections
- h - for title and circles
- input - for question
- button

## Making a plan
# EVENT

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.**

Additional considerations:

- 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?)
- button click
- hide section
- display section
- pick a random number between 0 and length of array
- set the content of the answer to the random choice
49 changes: 43 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,48 @@
/* Imports */
const questionSection = document.getElementById('question-section');
const answerSection = document.getElementById('answer-section');
const button = document.getElementById('button');
const askAgain = document.getElementById('ask-button');
const answer = document.getElementById('answer');
const input = document.getElementById('input');

/* Get DOM Elements */
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',
];

/* State */
button.addEventListener('click', () => {
toggleSections();

/* Events */
const randomInt = Math.floor(Math.random() * answers.length);
const randomChoice = answers[randomInt];
input.value = '';
answer.textContent = randomChoice;
});

/* Display Functions */
function toggleSections() {
questionSection.classList.toggle('hide');
answerSection.classList.toggle('hide');
}

// (don't forget to call any display functions you want to run on page load!)
askAgain.addEventListener('click', () => {
toggleSections();
});

answers.style.fontFamily = 'Fredoka One';
Binary file added assets/8.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/8BALLwireframe.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/8ball.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 52 additions & 37 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,39 +1,54 @@
<!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>Magic 8 Ball</title>
<link rel="icon" type="image/x-icon" href="assets/8ball.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 -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Fredoka+One&display=swap"
rel="stylesheet"
/>
</head>

<body>
<main>
<div class="center-screen">
<section id="question-section" class="question-section">
<h1 class="title">MAGIC 8 BALL</h1>
<input
class="input"
id="input"
type="text"
placeholder="What would you like to know?"
/>
<button class="button" id="button">8</button>
</section>
</div>

<section id="answer-section" class="answer-section hide">
<h1 class="big-circle">
<p id="answer" class="small-circle"></p>
</h1>
<button id="ask-button" class="ask-button">8</button>
</section>
</main>
</body>
</html>
123 changes: 109 additions & 14 deletions styles/global.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
:root {
--background: rgb(224, 234, 247);
--background: rgb(0, 0, 0);
--header-background: rgb(254, 251, 245);
--primary-font: Corbel, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'DejaVu Sans',
'Bitstream Vera Sans', 'Liberation Sans', Verdana, 'Verdana Ref', sans-serif;
Expand All @@ -12,24 +12,119 @@ body {
grid-template-rows: auto 1fr;
}

header {
position: sticky;
top: 0;
padding: 15px;
height: 80px;
main {
padding: 100px;
}

display: flex;
align-items: center;
gap: 10px;
/* * {
border: solid 1px;
} */

background-color: var(--header-background);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
.question-section {
display: grid;
justify-content: center;
align-content: center;
text-align: center;
}

header .logo {
height: 100%;
.answer-section {
display: grid;
justify-content: center;
align-content: center;
}

main {
.big-circle {
width: 540px;
height: 540px;
display: grid;
justify-content: center;
align-content: center;
background-color: black;
border-radius: 270px;
border: solid 0.1rem;
border-color: white;
margin-top: 40px;
}

.small-circle {
width: 300px;
height: 300px;
background-color: white;
border-radius: 150px;
display: grid;
text-align: center;
align-items: center;
font-size: 1.6rem;
padding: 20px;
line-height: 1.4rem;
font-family: 'Fredoka One';
font-weight: lighter;
}

.button {
display: grid;
justify-self: center;
width: 3rem;
height: 3rem;
margin-top: 12rem;
background-color: rgb(255, 255, 255);
border: none;
border-radius: 30px;
opacity: 0.3;
transition: 0.3s;
align-items: center;
font-size: 32px;
}

.button:hover {
opacity: 1;
}

.hide {
display: none;
}

.title {
margin-bottom: 94px;
font-size: 2rem;
background-color: black;
color: white;
border-radius: 30px;
font-family: 'Fredoka One';
}

.input {
background-image: url('/Users/rafa/alchemy/onboarding/MAGIC-8-BALL/assets/8.png');
background-repeat: no-repeat;
height: 300px;
width: 300px;
text-align: center;
border: none;
outline: none;
font-size: 14px;
font-family: Verdana, Geneva, Tahoma, sans-serif;
border-radius: 150px;
background-image: url('/Users/rafa/alchemy/onboarding/MAGIC-8-BALL/assets/8.png');
background-repeat: no-repeat;
word-wrap: break-word;
word-break: break-all;
}

.ask-button {
width: 3rem;
height: 3rem;
margin-top: 3.2rem;
background-color: rgb(255, 255, 255);
border: none;
border-radius: 30px;
display: grid;
justify-self: center;
opacity: 0.3;
transition: 0.3s;
align-items: center;
font-size: 32px;
}

.ask-button:hover {
opacity: 1;
}
Loading