|
|
@ -58,17 +58,21 @@ const Main = ({ numbers }) => (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
//Population
|
|
|
|
//Population
|
|
|
|
|
|
|
|
function numberWithCommas(x) {
|
|
|
|
|
|
|
|
return x.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const Country = ({ countries }) => {
|
|
|
|
const Country = ({ countries }) => {
|
|
|
|
const countryList = countries.map((country) =>
|
|
|
|
const countryList = countries.map((country) =>
|
|
|
|
<tr className='tr'>
|
|
|
|
<tr className='tr'>
|
|
|
|
<td className='td-name'>{country.name}</td>
|
|
|
|
<td className='td-name'>{country.name}</td>
|
|
|
|
<td className='td-line'>
|
|
|
|
<td className='td-line'>
|
|
|
|
<div className='div-line' style={{marginRight : `${100 - country.prc}%`, color: 'white'}}>
|
|
|
|
<div className='div-line' style={{ marginRight: `${100 - country.prc}%`, color: 'white' }}>
|
|
|
|
{country.name}
|
|
|
|
{country.name}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</td>
|
|
|
|
<td className='td-value'>
|
|
|
|
<td className='td-value'>
|
|
|
|
{new Intl.NumberFormat('ru-RU').format(country.population)}
|
|
|
|
{numberWithCommas(country.population)}
|
|
|
|
</td>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tr>
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -79,7 +83,7 @@ const Country = ({ countries }) => {
|
|
|
|
const Population = ({ countries, count }) => (
|
|
|
|
const Population = ({ countries, count }) => (
|
|
|
|
<main>
|
|
|
|
<main>
|
|
|
|
<h1>{count} most populated countries in the world</h1>
|
|
|
|
<h1>{count} most populated countries in the world</h1>
|
|
|
|
<Country countries={countries} />
|
|
|
|
<table className='table'><Country countries={countries} /></table>
|
|
|
|
</main>
|
|
|
|
</main>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|