Don't forget to use <buttons> when creating buttons for your page i.e <button>sign up </button>. Reminder: for accessibility purposes, don't use divs as buttons!
To create a button with an image i.e. shopping cart button
<button>
<img src=“imagesource” alt=“Cart”/>
<span>0</span> // this would have to be updated as a function once actually running the website with JS
</button>
Use dev tools to help debug through console and elements.style{} to test modifications
Define images with id/classes (classes preferred) so that it’s easy to modify
Display flex defaults to positioning items/elements into a row; for column use display: flex-direction column
For bugs, the first part is the name of the file and extension, and the first number refers to the line where the error can be found i.e. script.js:24:9
Creating a grid in JS using map, join, and the categories
Pre-set up:
Create an array with a function withconst functionname = [{}] i.e.
CSS for Nav (where I had the hardest time -- reference step-by-step by Shaila)
Body: Start with setting up a background color within the body, as well as defining the font-family that will be used across the page. Also add margin:0 so that it defaults to the full page length i.e.
Body {
background-color: white;
Font-family: “chicken-sandwich”;
Margin: 0;
}
Nav: Set background color. Use display flex to make elements display in a row (instead of a column by default). Use justify-content to add spacing between elements and align-items to align the elements horizontally. Use position: fixed so that it remains locked over the page as you scroll. Add z-index in order to layer elements over each other. Overflow scroll will allow your page to be responsive with scrolling it to the side when the screen is smaller. i.e.
Nav Elements: To target elements within the nav (i.e. links with a tags) use nav a{}. Use text-decoration to remove the underline that defaults with links. Adjust color and font size. Use :hover to define action when someone hovers over the links (i.e. change color). i.e.
nav a{
text-decoration: none;
color: black;
Font-size: 1.5rem;
Padding-right: 1.5rem;
}
nav a:hover{
color: grey
}
Nav Elements: Give the Popeyes logo a class so that it can be targeted specifically. Set a proportion using width so that you can just set (this is only true because the logo is wrapped but an a tag). i.e.
.popeyeslogo {
Width: 100%;
}
Nav Elements: To adjust buttons first define a class for the buttons. Use a div to wrap the button elements and arrange them horizontally instead of vertically, align and add padding i.e.
Override native button display i.e. make it look less like an old-school button and customize the style
.signupbutton{
Background-color: orange;
color: white;
border: none;
Padding: 0.5rem 2rem; // first number defines top and bottom, second number defines left and right
Border-radius: 1 rem;
Text-transform: uppercase;
Letter-spacing: 0.5px;
Cursor: pointer;
}
.Json
.Json is a universally accepted standard to transmit code to the internet (any language can speak back and forth using Jason)
Important considerations when using .json
Very similar to JavaScript language style
All the code must be inserted within {}
async is used when declaring a function that happens asynchronously. It is often paired with await command. Once you await inside a function, you must mark the function as async
Use this when fetching data-within-data (i.e. list of followers); not a normal url, but a url that contains an array of data within itself i.e.
Basic Commands & Refreshers
object-fit:cover
won't crop your images<buttons>
when creating buttons for your page i.e<button>sign up </button>
. Reminder: for accessibility purposes, don't use divs as buttons!script.js:24:9
Creating a grid in JS using map, join, and the categories Pre-set up:
const functionname = [{}]
i.e.Step 1: Select the main element
Step 2:Use map and join to transform the categories array into a single string of HTML that represents one card for each category
Step 3: Insert that HTML into the main element
Reference: https://repl.it/@ppereira1/MiniPopeyesMenu#script.js
Popeyes Menu Website (weekend Project)
CSS for Nav (where I had the hardest time -- reference step-by-step by Shaila)
Body: Start with setting up a background color within the body, as well as defining the font-family that will be used across the page. Also add margin:0 so that it defaults to the full page length i.e.
Nav: Set background color. Use display flex to make elements display in a row (instead of a column by default). Use justify-content to add spacing between elements and align-items to align the elements horizontally. Use position: fixed so that it remains locked over the page as you scroll. Add z-index in order to layer elements over each other. Overflow scroll will allow your page to be responsive with scrolling it to the side when the screen is smaller. i.e.
Nav Elements: To target elements within the nav (i.e. links with
a
tags) usenav a{}
. Use text-decoration to remove the underline that defaults with links. Adjust color and font size. Use :hover to define action when someone hovers over the links (i.e. change color). i.e.Nav Elements: Give the Popeyes logo a class so that it can be targeted specifically. Set a proportion using width so that you can just set (this is only true because the logo is wrapped but an
a
tag). i.e.Nav Elements: To adjust buttons first define a class for the buttons. Use a div to wrap the button elements and arrange them horizontally instead of vertically, align and add padding i.e.
Override native button display i.e. make it look less like an old-school button and customize the style
.Json .Json is a universally accepted standard to transmit code to the internet (any language can speak back and forth using Jason) Important considerations when using .json
async
is used when declaring a function that happens asynchronously. It is often paired withawait
command. Once youawait
inside a function, you must mark the function asasync
Use this when fetching data-within-data (i.e. list of followers); not a normal url, but a url that contains an array of data within itself i.e.
Reference: https://repl.it/@ppereira1/GithubProfileAPI#script.js