-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
102 lines (88 loc) · 5.67 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Список стран</title>
<!-- Подключение шрифта Roboto -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
<!-- Подключение React с CDN -->
<script src="https://unpkg.com/react@18/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
<!-- Подключение Babel для транспайлинга JSX. Предупреждение: этот метод нельзя использовать в production-коде -->
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
</head>
<body>
<div class="wrap">
<header class="heading">
Список стран
</header>
<div id="react-app"></div>
</div>
<!-- Данные приложения -->
<script src="https://html-tasks.vercel.app/assets/data/column-css-task.js"></script>
<script type="text/babel">
function CountryGrid({ countriesListGroupedByLetter }) {
return (
<section className="country-grid">
{countriesListGroupedByLetter.map(({ letter, countries }) => (
<section className="country-grid__item" key={letter}>
<header aria-hidden="true" className="country-grid__item-first-letter">{letter}</header>
{countries.map((countryData, i) =>
<Country {...countryData} key={i} />
)}
</section>
))}
</section>
);
}
function Country({ flag, name, fullname, population, area }) {
return (
<article className="country">
<img className="country__flag" src={flag} alt="" />
<section className="country__description">
<heading className="country__names">
<p className="country__names--name">{name}</p>
<p className="country__names--fullname">{fullname}</p>
</heading>
<dl className="country__stats">
<div className="country__stat-container">
<dt className="country__stats--population">
<svg className="population__icon" width={16} height={16}><title>Население</title><use xlinkHref="#population" /></svg>
</dt>
<dd className="population__text">{population}</dd>
</div>
<div className="country__stat-container">
<dt className="country__stats--area">
<svg className="area__icon" width={16} height={16}><title>Площадь</title><use xlinkHref="#area" /></svg>
</dt>
<dd className="area__text">{area} км<sup><small>2</small></sup></dd>
</div>
</dl>
</section>
</article>
);
}
ReactDOM.createRoot(document.getElementById('react-app')).render(
<CountryGrid countriesListGroupedByLetter={window.MarkupTasksAPI.data.countryList()} />
);
</script>
<!-- Инлайновый SVG-спрайт, чтобы избежать дублирования в HTML -->
<svg width="0" height="0">
<symbol xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 11 13" id="population">
<path fill="#BCBCBC"
d="M5.19 6.18a2.6 2.6 0 1 0 0-5.19 2.6 2.6 0 0 0 0 5.19ZM10.37 10.71v.65a.65.65 0 0 1-.65.65H.65a.65.65 0 0 1-.65-.65v-.65a3.89 3.89 0 0 1 3.89-3.89h2.6a3.89 3.89 0 0 1 3.88 3.9Z">
</path>
</symbol>
<symbol xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 13" id="area">
<path fill="#BCBCBC"
d="M1.23 3.57c.6.3 1.25.5 1.93.63-.12.64-.2 1.3-.21 1.98H0a5.7 5.7 0 0 1 .87-2.77l.36.16ZM1.46 2.93l-.21-.1c.8-1 1.91-1.66 3.16-1.82l-.05.08A8.01 8.01 0 0 0 3.3 3.53a6.8 6.8 0 0 1-1.85-.6ZM3.3 9.45c.2.86.53 1.66.95 2.32l.16.24a4.9 4.9 0 0 1-3.18-1.84l.2-.1a7.4 7.4 0 0 1 1.86-.62ZM3.15 8.8c-.7.14-1.36.35-1.97.65l-.33.16C.36 8.81.05 7.86 0 6.84h2.95c.02.68.07 1.34.2 1.96ZM8.68 2.77l-.13.1c-.61.32-1.3.54-2.02.68A8.01 8.01 0 0 0 5.48 1.1L5.4 1c1.3.12 2.44.78 3.27 1.78ZM8.57 10.13l.15.08a4.81 4.81 0 0 1-3.3 1.8l.17-.26c.41-.66.72-1.46.96-2.32a7.5 7.5 0 0 1 2.02.7ZM3.54 6.86h2.73c-.01.64-.09 1.26-.2 1.84a7.6 7.6 0 0 0-2.31 0c-.13-.58-.2-1.22-.22-1.84ZM9.1 9.7l-.26-.17c-.65-.34-1.39-.6-2.15-.73.13-.62.18-1.28.2-1.94H10a5.83 5.83 0 0 1-.9 2.83ZM8.86 3.45l.22-.16c.54.81.87 1.81.92 2.87H6.89c-.02-.68-.1-1.34-.22-1.98.78-.14 1.5-.4 2.15-.73h.04ZM4.92 11.63l-.18-.26a7.03 7.03 0 0 1-.83-2.02 8.92 8.92 0 0 1 2.02 0c-.2.76-.49 1.46-.85 2.04l-.16.24ZM4.92 1.39l.07.1c.4.6.7 1.34.92 2.14a8.01 8.01 0 0 1-1.99 0c.22-.8.53-1.54.93-2.12l.07-.12ZM4.94 4.36c.38 0 .76-.02 1.14-.08.12.6.18 1.24.2 1.88H3.53c.02-.66.1-1.28.2-1.88a8 8 0 0 0 1.2.08Z">
</path>
</symbol>
</svg>
</body>
</html>