06-day-activities

pull/331/head
Dan.Kapustin 2 years ago
parent c43e16892a
commit bd20ecc198

@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

@ -0,0 +1,70 @@
# Getting Started with Create React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
The page will reload when you make changes.\
You may also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `npm run build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

File diff suppressed because it is too large Load Diff

@ -0,0 +1,38 @@
{
"name": "06-my-map-list-keysc",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

@ -0,0 +1,178 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
href="https://fonts.googleapis.com/css?family=Montserrat:300,400,500|Roboto:300,400,500&display=swap"
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: 25;
padding: 10px;
}
main {
padding: 10px;
padding-bottom: 60px;
/* Height of the footer */
}
ul {
margin-left: 15px;
}
ul li {
list-style: none;
}
footer {
position: relative;
bottom: 0;
width: 100%;
height: 60px;
/* Height of the footer */
background: #6cf;
}
.footer-wrapper {
font-weight: 400;
text-align: center;
line-height: 60px;
}
.odds-number {
background-color: yellow;
}
.even-number {
background-color: green;
}
.prime-number {
background-color: red;
}
.num-table {
display: table;
width: 100%;
border: 1px solid white;
border-spacing: 5px;
align-items: center;
}
.num-table-row {
display: table-row;
width: auto;
clear: both;
border: 0.5px solid white;
}
.num-table-col {
float: left;
display: table-column;
width: 200px;
border: 0.5px solid white;
text-align: center;
}
tr {
height: 25px;
}
.td-name {
width: 100px;
text-align: left;
}
.td-line {
width: 150px;
text-align: left;
}
.td-value {
width: 80px;
text-align: right;
}
.div-line {
color: orange;
background-color: orange;
}
.graph-title {
font-size: small;
font-family: Arial;
text-align: center;
}
.graphs {
display: flex;
justify-content: center;
}
#stat {
display: flex;
justify-content: center;
}
.stat-table {
border: thin solid gray;
}
</style>
</head>
<body>
<div id="root"></div>
</body>
</html>

@ -0,0 +1,13 @@
export const tenHighestPopulation = [
{ country: 'World', population: 7693165599 },
{ country: 'China', population: 1377422166 },
{ country: 'India', population: 1295210000 },
{ country: 'United States of America', population: 323947000 },
{ country: 'Indonesia', population: 258705000 },
{ country: 'Brazil', population: 206135893 },
{ country: 'Pakistan', population: 194125062 },
{ country: 'Nigeria', population: 186988000 },
{ country: 'Bangladesh', population: 161006790 },
{ country: 'Russian Federation', population: 146599183 },
{ country: 'Japan', population: 126960000 },
]

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

@ -0,0 +1,146 @@
import React from 'react'
import ReactDOM from 'react-dom'
import { countriesData } from './data/countries'
//Header
const Header = ({ headerText, subHeaderText }) => {
return (
<header>
<div>
<h1>{headerText}</h1>
<h2>{subHeaderText}</h2>
</div>
</header>
)
}
// Footer Component
const Footer = ({ copyRight }) => (
<footer>
<div className='footer-wrapper'>
<p>Copyright {copyRight.getFullYear()}</p>
</div>
</footer>
)
//Main
const isPrime = (num) => {
for (let i = 2, s = Math.sqrt(num); i <= s; i++) {
if (num % i === 0) return false;
}
return num > 1;
}
const Numbers = ({ numbers }) => {
const numList = numbers.map((number) =>
<div className='num-table-col'>
<div className={
(number % 2 == 0)
? ((isPrime(number)) ? "prime-number" : "even-number")
: ((isPrime(number)) ? "prime-number" : "odds-number")
}>{number}
</div>
</div>
)
return numList
}
const Main = ({ numbers }) => (
<main>
<div className='num-table'>
<div className='num-table-row'>
<Numbers numbers={numbers} />
</div>
</div>
</main>
)
//Population
const Country = ({ countries }) => {
const countryList = countries.map((country) =>
<tr className='tr'>
<td className='td-name'>{country.name}</td>
<td className='td-line'>
<div className='div-line' style={{marginRight : `${100 - country.prc}%`, color: 'white'}}>
{country.name}
</div>
</td>
<td className='td-value'>
{new Intl.NumberFormat('ru-RU').format(country.population)}
</td>
</tr>
)
return countryList
}
const Population = ({ countries, count }) => (
<main>
<h1>{count} most populated countries in the world</h1>
<Country countries={countries} />
</main>
)
// The App, or the parent or the container component
// Functional Component
const App = () => {
const headerText = '30 Days of React'
const subHeaderText = 'Number Generator'
const date = new Date()
const N = 31
const numbers = Array(N).fill().map((_, i) => i + 1)
numbers.unshift(0)
const topCount = 10
const topPopulatedCountries = ((countries, count) => {
// add World
const data = countries
.map((country) => {
return { name: country.name, population: country.population }
})
const world = data
.map((country) => {
return { name: country.name, population: country.population }
})
.reduce((w, c) => {
return { name: 'World', population: w.population += c.population, languages: [] }
}, { name: 'World', population: 0 })
data.push(world)
// find top <count> countries by population and add field Prc - country population / world population
const topCountries = data
.map((country) => {
return { name: country.name, population: country.population }
})
.sort((a, b) => (
b.population - a.population
))
.slice(0, count + 1)
.map(({ name, population }) => ({ name: name, population: population, prc: (population / world.population) * 100 }))
return topCountries
})
const topCountries = topPopulatedCountries(countriesData, topCount)
return (
<div className='app'>
<Header
headerText={headerText}
subHeaderText={subHeaderText}
/>
<Main numbers={numbers} />
<Population
countries={topCountries}
count={topCount}
/>
<Footer copyRight={date} />
</div>
)
}
const rootElement = document.getElementById('root')
ReactDOM.render(<App />, rootElement)
Loading…
Cancel
Save