parent
8412c51b89
commit
6f2ae7272d
@ -1,108 +1,108 @@
|
|||||||
// index.js
|
// index.js
|
||||||
import React from 'react'
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom'
|
import ReactDOM from 'react-dom';
|
||||||
import asabenehImage from './images/asabeneh.jpg'
|
import asabenehImage from './images/asabeneh.jpg';
|
||||||
|
|
||||||
const hexaColor = () => {
|
const hexaColor = () => {
|
||||||
let str = '0123456789abcdef'
|
let str = '0123456789abcdef'
|
||||||
let color = ''
|
let color = ''
|
||||||
for (let i = 0; i < 6; i++) {
|
for (let i = 0; i < 6; i++) {
|
||||||
let index = Math.floor(Math.random() * str.length)
|
let index = Math.floor(Math.random() * str.length)
|
||||||
color += str[index]
|
color += str[index]
|
||||||
}
|
}
|
||||||
return '#' + color
|
return '#' + color
|
||||||
}
|
}
|
||||||
|
|
||||||
const HexaColor = () => {
|
const HexaColor = () => {
|
||||||
let bgColor = hexaColor()
|
let bgColor = hexaColor()
|
||||||
const styles = {
|
const styles = {
|
||||||
height: '100px',
|
height: '100px',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
'justify-content': 'center',
|
'justify-content': 'center',
|
||||||
'align-items': 'center',
|
'align-items': 'center',
|
||||||
fontFamily: 'Montserrat',
|
fontFamily: 'Montserrat',
|
||||||
margin: '2px auto',
|
margin: '2px auto',
|
||||||
borderRadius: '5px',
|
borderRadius: '5px',
|
||||||
width: '75%',
|
width: '75%',
|
||||||
border: '2px solid black',
|
border: '2px solid black',
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div style={styles}>
|
<div style={styles}>
|
||||||
<h2>{bgColor}</h2>
|
<h2>{bgColor}</h2>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Header Component
|
// Header Component
|
||||||
const Header = () => (
|
const Header = () => (
|
||||||
<header>
|
<header>
|
||||||
<div className='header-wrapper'>
|
<div className='header-wrapper'>
|
||||||
<h1>Welcome to 30 Days Of React</h1>
|
<h1>Welcome to 30 Days Of React</h1>
|
||||||
<h2>Getting Started React</h2>
|
<h2>Getting Started React</h2>
|
||||||
<h3>JavaScript Library</h3>
|
<h3>JavaScript Library</h3>
|
||||||
<p>Asabeneh Yetayeh</p>
|
<p>Asabeneh Yetayeh</p>
|
||||||
<small>Oct 3, 2020</small>
|
<small>Oct 3, 2020</small>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
)
|
)
|
||||||
|
|
||||||
// User Card Component
|
// User Card Component
|
||||||
const UserCard = () => (
|
const UserCard = () => (
|
||||||
<div className='user-card'>
|
<div className='user-card'>
|
||||||
<img src={asabenehImage} alt='asabeneh image' />
|
<img src={asabenehImage} alt='asabeneh image'/>
|
||||||
<h2>Asabeneh Yetayeh</h2>
|
<h2>Asabeneh Yetayeh</h2>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
// TechList Component
|
// TechList Component
|
||||||
const TechList = () => {
|
const TechList = () => {
|
||||||
const techs = ['HTML', 'CSS', 'JavaScript']
|
const techs = ['HTML', 'CSS', 'JavaScript']
|
||||||
const techsFormatted = techs.map((tech) => <li key={tech}>{tech}</li>)
|
const techsFormatted = techs.map((tech) => <li key={tech}>{tech}</li>)
|
||||||
return techsFormatted
|
return techsFormatted
|
||||||
}
|
}
|
||||||
const buttonStyles = {
|
const buttonStyles = {
|
||||||
padding: '10px 20px',
|
padding: '10px 20px',
|
||||||
background: 'rgb(0, 255, 0',
|
background: 'rgb(0, 255, 0',
|
||||||
border: 'none',
|
border: 'none',
|
||||||
borderRadius: 5,
|
borderRadius: 5,
|
||||||
}
|
}
|
||||||
|
|
||||||
const Button = () => <button style={buttonStyles}> action </button>
|
const Button = () => <button style={buttonStyles}> action </button>
|
||||||
|
|
||||||
// Main Component
|
// Main Component
|
||||||
const Main = () => (
|
const Main = () => (
|
||||||
<main>
|
<main>
|
||||||
<div className='main-wrapper'>
|
<div className='main-wrapper'>
|
||||||
<p>Prerequisite to get started react.js:</p>
|
<p>Prerequisite to get started react.js:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<TechList />
|
<TechList/>
|
||||||
</ul>
|
</ul>
|
||||||
<UserCard />
|
<UserCard/>
|
||||||
<div>
|
<div>
|
||||||
<HexaColor />
|
<HexaColor/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
)
|
)
|
||||||
|
|
||||||
// Footer Component
|
// Footer Component
|
||||||
const Footer = () => (
|
const Footer = () => (
|
||||||
<footer>
|
<footer>
|
||||||
<div className='footer-wrapper'>
|
<div className='footer-wrapper'>
|
||||||
<p>Copyright 2020</p>
|
<p>Copyright 2020</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
)
|
)
|
||||||
|
|
||||||
// The App, or the parent or the container component
|
// The App, or the parent or the container component
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<div className='app'>
|
<div className='app'>
|
||||||
<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.render(<App/>, rootElement)
|
||||||
|
Loading…
Reference in new issue