pull/136/merge
Ananth Sounder 2 years ago committed by GitHub
commit 0d41437888
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>30DaysOfScript: Inline Script</title>
</head>
<body onclick="alert('Welcome to 30DaysOfJavaScript!')">
Click Me
</body>
</html>

File diff suppressed because it is too large Load Diff

@ -1,96 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link <meta name="viewport" content="width=device-width, initial-scale=1.0" />
href="https://fonts.googleapis.com/css?family=Montserrat:300,400,500|Roboto:300,400,500&display=swap" <title>30 days of react</title>
rel="stylesheet"
/>
<meta
name="description"
content="Web site created using create-react-app"
/>
<title>30 Days Of React App</title>
<style>
/* == General style === */
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
html,
body {
height: 100%;
line-height: 1.5;
font-family: 'Montserrat';
font-weight: 300;
color: black;
}
.root {
min-height: 100%;
position: relative;
}
.header-wrapper,
.main-wrapper,
.footer-wrapper {
width: 85%;
margin: auto;
}
.header-wrapper,
.main-wrapper {
padding: 10px;
margin: 2px auto;
}
h1 {
font-size: 70px;
font-weight: 300;
}
h2,
h3 {
font-weight: 300;
}
header {
background-color: #61dbfb;
padding: 10px;
}
main {
padding: 10px 10px 60px;
/* Height of the footer */
}
ul {
margin-left: 15px;
}
ul li {
list-style: none;
}
footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
/* Height of the footer */
background: #6cf;
}
.footer-wrapper {
font-weight: 400;
text-align: center;
line-height: 60px;
}
</style>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>

@ -1,116 +1,51 @@
// index.js // index.js
import React from 'react' //index.js
import ReactDOM from 'react-dom' // importing the react and react-dom package
// To get the root element from the HTML document import React from "react";
import asabenehImage from './images/asabeneh.jpg' import ReactDOM from "react-dom";
// to import the doSomeMath from the math.js with or without extension
import doSomeMath from './math.js'
// to import the other modules
// since these modules were not exported as default we have to desctructure
import { addTwo, multiply, subtract } from './math.js'
import * as everything from './math.js'
console.log(addTwo(5, 5))
console.log(doSomeMath.addTwo(5, 5))
console.log(everything)
// JSX element, header
// JSX element, header
const welcome = 'Welcome to 30 Days Of React'
const title = 'Getting Started React'
const subtitle = 'JavaScript Library'
const author = {
firstName: 'Asabeneh',
lastName: 'Yetayeh',
}
const date = 'Oct 2, 2020'
// JSX element, header // JSX element, header
const header = ( const header = (
<header> <header>
<div className='header-wrapper'> <h1>Welcome to 30 Days Of React</h1>
<h1>{welcome}</h1> <h2>Getting Started React</h2>
<h2>{title}</h2> <h3>JavaScript Library</h3>
<h3>{subtitle}</h3> <p>Ananth Vankipuram</p>
<p> <small>Nov 14, 2021</small>
Instructor: {author.firstName} {author.lastName}
</p>
<small>Date: {date}</small>
</div>
</header> </header>
) );
const numOne = 3
const numTwo = 2
const result = (
<p>
{numOne} + {numTwo} = {numOne + numTwo}
</p>
)
const yearBorn = 1820
const currentYear = new Date().getFullYear()
const age = currentYear - yearBorn
const personAge = (
<p>
{' '}
{author.firstName} {author.lastName} is {age} years old
</p>
)
// JSX element, main
const techs = ['HTML', 'CSS', 'JavaScript']
const techsFormatted = techs.map((tech) => <li>{tech}</li>)
const user = (
<div>
<img src={asabenehImage} alt='asabeneh image' />
</div>
)
// JSX element, main // JSX element, main
const main = ( const main = (
<main> <main>
<div className='main-wrapper'> <p>Prerequisite to get started react.js:</p>
<p> <ul>
Prerequisite to get started{' '} <li>HTML</li>
<strong> <li>CSS</li>
<em>react.js</em> <li>JavaScript</li>
</strong> </ul>
:
</p>
<ul>{techsFormatted}</ul>
{result}
{personAge}
{user}
</div>
</main> </main>
) );
const copyRight = 'Copyright 2020'
// JSX element, footer // JSX element, footer
const footer = ( const footer = (
<footer> <footer>
<div className='footer-wrapper'> <p>Copyright 2020</p>
<p>{copyRight}</p>
</div>
</footer> </footer>
) );
// JSX element, app // JSX element, app, a container or a parent
const app = ( const app = (
<div className='app'> <div>
{header} {header}
{main} {main}
{footer} {footer}
</div> </div>
) );
const rootElement = document.getElementById('root') const rootElement = document.getElementById("root");
// we render the JSX element using the ReactDOM package // we render the JSX element using the ReactDOM package
ReactDOM.render(app, rootElement) // ReactDOM has the render method and the render method takes two argument
ReactDOM.render(app, rootElement);
// or
// ReactDOM.render([header, main, footer], rootElement)

@ -1,12 +0,0 @@
// math.js
export const addTwo = (a, b) => a + b
export const multiply = (a, b) => a * b
export const subtract = (a, b) => a - b
export default(function doSomeMath() {
return {
addTwo,
multiply,
subtract,
}
})()
Loading…
Cancel
Save