Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add task solution #4936

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Implement the [Stars Block](https://www.figma.com/file/ojkArVazq7vsX0nbpn9CxZ/Moyo-%2F-Catalog-(ENG)?node-id=11325%3A2960) used in a card and catalog.

Hold `Alt` key (`Option` on MacOS) to measure distances in Figma.
Hold `Alt` key (`Option` on MacOS) to measure distances in Figma.

> Here are the [Layout Tasks Instructions](https://mate-academy.github.io/layout_task-guideline)

Expand All @@ -22,8 +22,8 @@ Hold `Alt` key (`Option` on MacOS) to measure distances in Figma.

❗️ Replace `<your_account>` with your Github username and copy the links to `Pull Request` description:

- [DEMO LINK](https://<your_account>.github.io/layout_stars/)
- [TEST REPORT LINK](https://<your_account>.github.io/layout_stars/report/html_report/)
- [DEMO LINK](https://<RuslanMudryi>.github.io/layout_stars/)
- [TEST REPORT LINK](https://<RuslanMudryi>.github.io/layout_stars/report/html_report/)

❗️ Copy this `Checklist` to the `Pull Request` description after links, and put `- [x]` before each point after you checked it.

Expand Down
45 changes: 44 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,49 @@
/>
</head>
<body>
<h1>Stars</h1>
<div class="container">
<div class="stars stars--0">
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
</div>
<div class="stars stars--1">
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
</div>
<div class="stars stars--2">
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
</div>
<div class="stars stars--3">
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
</div>
<div class="stars stars--4">
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
</div>
<div class="stars stars--5">
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
</div>
Comment on lines +16 to +58

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add empty lines between sibling elements to improve readability. This is especially important for multi-line blocks. But remember, don't add them between parent and child elements.

Comment on lines +16 to +58

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the checklist, you should add an empty line between multiline sibling blocks of HTML. This can make your code more readable.

</div>
</body>
</html>
141 changes: 140 additions & 1 deletion src/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,140 @@
/* add styles here */
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
margin: 0;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're styling a lot of elements using their tag names, which goes against the checklist. The only exceptions should be the html and body tags. It's recommended to style elements using .classes, and if needed with :pseudo-classes, pseudo-elements and [attributes].

padding: 0;
border: 0;
font-size: 100%;
font-size: inherit;
vertical-align: baseline;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're using the * selector which is not recommended due to its impact on performance. It's better to set styles only for elements that require them.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are using * selector which impacts the performance. Set styles only for elements that require them. Zeroing out your margins, paddings or other styles with '*' is still inefficient for browser.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are using tag names for styling. It's recommended to style all elements using .classes and if needed with :pseudo-classes, pseudo-elements and [attributes].

/* Для забезпечення належного відображення */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
display: block;
}

body {
line-height: 1;
}

ol,
ul {
list-style: none;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you're styling the ol and ul tags directly, which is not recommended. You should use classes to style these elements.

blockquote,
q {
quotes: none;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the checklist, you should avoid using tag names for styling (except html and body). In this case, you are using the body tag which is acceptable. However, you are using the * selector to set styles for all elements which can impact performance. It's better to set styles only for elements that require them.

.stars {
display: flex;
}

.stars__star {
box-sizing: border-box;
background-repeat: no-repeat;
height: 16px;
width: 16px;
background-position: center;
background-image: url('./images/star.svg');
}

Comment on lines +7 to +17

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of the code is well written. You've used classes for styling, which is good practice.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good practice to provide alternative images in case the main one doesn't work or takes time to load. You can use the CSS background property to set multiple background images. If the first background image is not found, the next one will be used.

.stars__star:not(:first-child) {
margin-left: 4px;
}

Comment on lines +19 to +21

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good use of the :not(:first-child) pseudo-class. It helps to avoid unnecessary left margin on the first star.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be consistent with your margins. It's better to add only top or bottom margins, but not both, to avoid potential margin collapse. Here, you are adding a left margin which is fine as long as you are consistent with it throughout your CSS.

.stars--1 .stars__star:nth-child(-n + 1),
.stars--2 .stars__star:nth-child(-n + 2),
.stars--3 .stars__star:nth-child(-n + 3),
.stars--4 .stars__star:nth-child(-n + 4),
.stars--5 .stars__star:nth-child(-n + 5) {
background-image: url('./images/star-active.svg');
}
Loading