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

added some styling to buttons #19

Merged
merged 1 commit into from
Aug 20, 2023
Merged
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
10 changes: 5 additions & 5 deletions madlibs.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function parseStory(rawStory) {
rawStory = rawStory.replace(/\,/g, " ,");
let arrWord = rawStory.split(" ");
let storyToObj = [];
arrWord.forEach(item => {
arrWord.forEach((item) => {
if (item.match(/[[a-zA-Z]]/g)) {
let key = item.split("[");
switch (key[1]) {
Expand Down Expand Up @@ -165,6 +165,7 @@ function madlibsEdit(processedStory) {
previewPara.className = "previewText";

const newArr = [];
//making a for loop over the processed story to check whether the item has a pos or not
for (const item of processedStory) {
if (item.pos) {
const input = document.createElement("input");
Expand All @@ -180,7 +181,7 @@ function madlibsEdit(processedStory) {
input.setAttribute("maxlength", "20");
span.innerHTML = ` ${item.pos}`;
// event listener for live update in the preview
input.addEventListener("input", e => {
input.addEventListener("input", (e) => {
if (e.target.value === "") {
span.innerHTML = ` ${item.pos}`;
} else {
Expand All @@ -189,7 +190,6 @@ function madlibsEdit(processedStory) {
});
// Highlighting currently focused input
input.addEventListener("focus", function () {
input.style.backgroundColor = "green";
input.style.backgroundColor = "#b9ddb8b8";
});
// input blur
Expand All @@ -210,7 +210,7 @@ function madlibsEdit(processedStory) {
}
// HotKeys event
newArr.forEach((input, i) => {
input.addEventListener("keypress", e => {
input.addEventListener("keypress", (e) => {
if (e.key === "Enter") {
if (i < newArr.length - 1) {
newArr[i + 1].focus();
Expand All @@ -227,6 +227,6 @@ function madlibsEdit(processedStory) {

getRawStory()
.then(parseStory)
.then(processedStory => {
.then((processedStory) => {
madlibsEdit(processedStory);
});
31 changes: 14 additions & 17 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ button {
top: 38%;
transform: translate(-50%, -50%);
font-weight: 300;
padding-bottom:20px;
padding-bottom: 20px;
}

.progress-bar {
Expand Down Expand Up @@ -275,30 +275,27 @@ button {
}

/* style for music and reset button */

#resetButton,
#musicButton {
color: rgb(255, 255, 255);
padding: 10px 20px;
background-color: #c99a73;
font-size: 16px;
letter-spacing: 2px;
text-decoration: none;
color: black;
cursor: pointer;
border-radius: 10px;
border: 5px solid #ffb904;
background: #372c28;
box-shadow: 0px 4px 20px 0px rgba(3, 155, 0, 0.72);
border: none;
padding: 0.25em 0.5em;
box-shadow: 1px 1px 0px 0px, 2px 2px 0px 0px;
margin-bottom: 20px;
margin-right: 30px;
width: 100px;
font-weight: bold;
}

#resetButton {
color: white;
padding: 10px 20px;
cursor: pointer;
border-radius: 10px;
border: 5px solid #ffb904;
background: #372c28;
box-shadow: 0px 4px 20px 0px rgba(3, 155, 0, 0.72);
margin-bottom: 20px;
margin-left: 30px;
width: 100px;
button:hover {
filter: brightness(130%);
}

/* for when it goes under a certain width */
Expand Down