-
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* js-dom-task * newlines at the ends * another newline * remove useless lines * small fixings
- Loading branch information
1 parent
7c0a8bf
commit 527c80e
Showing
3 changed files
with
271 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<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>Dom task</title> | ||
|
||
<link rel="preconnect" href="https://fonts.googleapis.com"> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap" rel="stylesheet"> | ||
|
||
<link rel="stylesheet" href="style.css"> | ||
<link rel="shortcut icon" type="image/png" href="img/favicon.png"/> | ||
</head> | ||
<body> | ||
|
||
<div class="wrapper"> | ||
<h1 class="wrapper__title">Solar System</h1> | ||
<div class="inner_wrapper"> | ||
<aside class="aside"> | ||
<ul class="aside__list"> | ||
<li class="aside__item"> | ||
Mercury | ||
</li> | ||
<li class="aside__item"> | ||
Venus | ||
</li> | ||
<li class="aside__item"> | ||
Earth | ||
</li> | ||
<li class="aside__item"> | ||
Mars | ||
</li> | ||
<li class="aside__item"> | ||
Jupiter | ||
</li> | ||
<li class="aside__item"> | ||
Saturn | ||
</li> | ||
<li class="aside__item"> | ||
Uranus | ||
</li> | ||
<li class="aside__item"> | ||
Neptune | ||
</li> | ||
</ul> | ||
</aside> | ||
<main class="main"> | ||
<div class="main__container container"> | ||
<h2 class="container__title">Solar system</h2> | ||
<div class="container__desc"> | ||
The Solar Systemis the gravitationally bound system of the Sun and the objects that orbit it. It formed 4.6 billion years ago from the gravitational collapse of a giant interstellar molecular cloud. The vast majority (99.86%) of the system's mass is in the Sun, with most of the remaining mass contained in the planet Jupiter. The four inner system planets—Mercury, Venus, Earth and Mars—are terrestrial planets, being composed primarily of rock and metal. The four giant planets of the outer system are substantially larger and more massive than the terrestrials. | ||
</div> | ||
</div> | ||
</main> | ||
</div> | ||
</div> | ||
|
||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
const solarSystem = { | ||
title: 'Solar system', | ||
desc: "The Solar Systemis the gravitationally bound system of the Sun and the objects that orbit it. It formed 4.6 billion years ago from the gravitational collapse of a giant interstellar molecular cloud. The vast majority (99.86%) of the system's mass is in the Sun, with most of the remaining mass contained in the planet Jupiter. The four inner system planets—Mercury, Venus, Earth and Mars—are terrestrial planets, being composed primarily of rock and metal. The four giant planets of the outer system are substantially larger and more massive than the terrestrials. ", | ||
}; | ||
|
||
const planets = [ | ||
{ | ||
title: 'Mercury', | ||
desc: "Mercury is the smallest planet in the Solar System and the closest to the Sun. Its orbit around the Sun takes 87.97 Earth days, the shortest of all the Sun's planets. It is named after the Roman god Mercurius (Mercury), god of commerce, messenger of the gods, and mediator between gods and mortals, corresponding to the Greek god Hermes (Ἑρμῆς). Like Venus, Mercury orbits the Sun within Earth's orbit as an inferior planet, and its apparent distance from the Sun as viewed from Earth never exceeds 28°. This proximity to the Sun means the planet can only be seen near the western horizon after sunset or the eastern horizon before sunrise, usually in twilight.", | ||
}, | ||
{ | ||
title: 'Venus', | ||
desc: "Venus is the second planet from the Sun and is named after the Roman goddess of love and beauty. As the brightest natural object in Earth's night sky after the Moon, Venus can cast shadows and can be visible to the naked eye in broad daylight. Venus's orbit is smaller than that of Earth, but its maximal elongation is 47°; thus, at latitudes with a day-night cycle, it is most readily visible for up to a few hours following the start of sunset or before sunrise. At times, it has been seen in a completely dark sky. Venus orbits the Sun every 224.7 Earth days.It has a synodic day length of 117 Earth days and a sidereal rotation period of 243 Earth days.", | ||
}, | ||
{ | ||
title: 'Earth', | ||
desc: "Earth is the third planet from the Sun and the only astronomical object known to harbor life. While large volumes of water can be found throughout the Solar System, only Earth sustains liquid surface water. About 71% of Earth's surface is made up of the ocean, dwarfing Earth's polar ice, lakes, and rivers. The remaining 29% of Earth's surface is land, consisting of continents and islands. Earth's surface layer is formed of several slowly moving tectonic plates, interacting to produce mountain ranges, volcanoes, and earthquakes. Earth's liquid outer core generates the magnetic field that shapes Earth's magnetosphere, deflecting destructive solar winds.", | ||
}, | ||
{ | ||
title: 'Mars', | ||
desc: "Mars is the fourth planet from the Sun and the second-smallest planet in the Solar System, being larger than only Mercury. In the English language, Mars is named for the Roman god of war. Mars is a terrestrial planet with a thin atmosphere, and has a crust primarily composed of elements similar to Earth's crust, as well as a core made of iron and nickel. Mars has surface features such as impact craters, valleys, dunes, and polar ice caps. It has two small and irregularly shaped moons: Phobos and Deimos.", | ||
}, | ||
{ | ||
title: 'Jupiter', | ||
desc: "Jupiter is the fifth planet from the Sun and the largest in the Solar System. It is a gas giant with a mass more than two and a half times that of all the other planets in the Solar System combined, but slightly less than one-thousandth the mass of the Sun. Jupiter is the third brightest natural object in the Earth's night sky after the Moon and Venus, and it has been observed since prehistoric times. It was named after the Roman god Jupiter, the king of the gods.", | ||
}, | ||
{ | ||
title: 'Saturn', | ||
desc: "Saturn is the sixth planet from the Sun and the second-largest in the Solar System, after Jupiter. It is a gas giant with an average radius of about nine and a half times that of Earth. It has only one-eighth the average density of Earth; however, with its larger volume, Saturn is over 95 times more massive", | ||
}, | ||
{ | ||
title: 'Uranus', | ||
desc: "Uranus is the seventh planet from the Sun. Its name is a reference to the Greek god of the sky, Uranus, who, according to Greek mythology, was the great-grandfather of Ares (Mars), grandfather of Zeus (Jupiter) and father of Cronus (Saturn). It has the third-largest planetary radius and fourth-largest planetary mass in the Solar System. Uranus is similar in composition to Neptune, and both have bulk chemical compositions which differ from that of the larger gas giants Jupiter and Saturn. ", | ||
}, | ||
{ | ||
title: 'Neptune', | ||
desc: "Neptune is the eighth planet from the Sun and the farthest known solar planet. In the Solar System, it is the fourth-largest planet by diameter, the third-most-massive planet, and the densest giant planet. It is 17 times the mass of Earth, and slightly more massive than its near-twin Uranus. Neptune is denser and physically smaller than Uranus because its greater mass causes more gravitational compression of its atmosphere. It is referred to as one of the solar system's two ice giant planets (the other one being Uranus)." | ||
}, | ||
]; | ||
|
||
const solarTitle = document.querySelector('.wrapper__title'); | ||
const asideList = document.querySelector('.aside__list'); | ||
const solarSystemTitle = document.querySelector('.container__title'); | ||
const solarSystemDesc = document.querySelector('.container__desc'); | ||
|
||
let selected; | ||
|
||
solarTitle.addEventListener('click', function() { | ||
solarSystemTitle.innerText = solarSystem.title; | ||
solarSystemDesc.innerText = solarSystem.desc; | ||
|
||
if (selected) { | ||
selected.classList.remove('focused'); | ||
} | ||
}); | ||
|
||
asideList.addEventListener('click', function(event) { | ||
const listTarget = event.target; | ||
if (listTarget.tagName === 'UL') return; | ||
highlightFocused(listTarget); | ||
|
||
const listTargetTitle = listTarget.innerText; | ||
|
||
const thatInPlanets = planets.filter(item => { | ||
return item.title === listTargetTitle; | ||
}); | ||
|
||
solarSystemDesc.innerText = thatInPlanets[0].desc; | ||
solarSystemTitle.innerText = thatInPlanets[0].title; | ||
}); | ||
|
||
function highlightFocused(item) { | ||
if (selected) { | ||
selected.classList.remove('focused'); | ||
} | ||
selected = item; | ||
selected.classList.add('focused'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
:root { | ||
--border-color: #cecece; | ||
--aside-bg-color: #e8ebe6; | ||
--dark-color: rgb(21, 21, 21); | ||
} | ||
|
||
* { | ||
padding: 0; | ||
margin: 0; | ||
box-sizing: border-box; | ||
font-family: 'Montserrat', sans-serif; | ||
transition: .3s; | ||
} | ||
|
||
body { | ||
background-color: var(--dark-color); | ||
background-image: url(img/planets/earth.jpg); | ||
background-repeat: no-repeat; | ||
background-size: cover; | ||
background-position: center; | ||
} | ||
|
||
.wrapper { | ||
max-width: 1000px; | ||
margin: 0 auto; | ||
padding: 0 15px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
min-height: 100vh; | ||
} | ||
|
||
.wrapper__title { | ||
margin-bottom: 30px; | ||
cursor: pointer; | ||
|
||
text-align: center; | ||
background-color: transparent; | ||
color: #fff; | ||
} | ||
|
||
.inner_wrapper { | ||
width: 100%; | ||
display: grid; | ||
grid-template-columns: 1fr 2fr; | ||
min-height: 400px; | ||
border-radius: 8px; | ||
border: 2px solid var(--border-color); | ||
} | ||
|
||
/* aside -------------------------------------------------------------- */ | ||
|
||
.aside { | ||
background-color: var(--aside-bg-color); | ||
display: flex; | ||
border-radius: 5px 0px 0px 5px; | ||
} | ||
|
||
.aside__list { | ||
list-style: none; | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
} | ||
|
||
.aside__item { | ||
padding: 15px; | ||
cursor: pointer; | ||
color: var(--dark-color); | ||
border-radius: 5px 0px 0px 5px; | ||
} | ||
|
||
.focused { | ||
background-color: var(--dark-color); | ||
color: #fff; | ||
opacity: .8; | ||
} | ||
|
||
.aside__item:not(:last-child){ | ||
border-bottom: 2px solid var(--border-color); | ||
} | ||
|
||
/* main --------------------------------------------------------------- */ | ||
|
||
.main { | ||
display: flex; | ||
background-color: rgba(21, 21, 21, 0.857); | ||
border-radius: 0px 5px 5px 0px; | ||
} | ||
|
||
.container { | ||
padding: 30px; | ||
color: #fff; | ||
} | ||
|
||
.container__title { | ||
margin-bottom: 20px; | ||
} | ||
|
||
.container__img { | ||
max-width: 100%; | ||
} | ||
|
||
@media screen and (max-width: 768px) { | ||
.inner_wrapper { | ||
min-height: 500px; | ||
} | ||
} | ||
|
||
@media screen and (max-width: 530px) { | ||
|
||
.wrapper { | ||
margin: 100px 0; | ||
} | ||
|
||
.inner_wrapper { | ||
grid-template-columns: 1fr; | ||
text-align: center; | ||
} | ||
|
||
.aside { | ||
text-align: center; | ||
border-radius: 5px 5px 0px 0px; | ||
} | ||
|
||
.main { | ||
min-height: 400px; | ||
border-radius: 0px 0px 5px 5px; | ||
} | ||
} |