Skip to content

Commit c4ed596

Browse files
authored
refactor(home.view): rework authors section (#267)
1 parent c61aff9 commit c4ed596

File tree

4 files changed

+65
-58
lines changed

4 files changed

+65
-58
lines changed

public/css/views/home.css

Lines changed: 43 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@
140140
text-shadow: none;
141141
font-size: 15px;
142142
color: var(--secondary-darker);
143+
flex-grow: 1;
144+
flex-basis: 100%;
143145
}
144146

145147
#home--view .home--body .pannel {
@@ -196,6 +198,7 @@
196198
color: #263238;
197199
font-size: 12px;
198200
font-weight: bold;
201+
padding: 4px;
199202
}
200203

201204
#home--view .home--body .module>.title>i {
@@ -287,88 +290,73 @@
287290
flex-wrap: wrap;
288291
margin-left: -10px;
289292
margin-top: -10px;
290-
justify-content: center;
291293
}
292294

293295
.home--maintainers>.person {
294-
width: 60px;
295-
height: 60px;
296+
height: 50px;
297+
flex-basis: 300px;
298+
display : flex;
296299
position: relative;
297300
box-sizing: border-box;
298301
border-radius: 4px;
302+
overflow: hidden;
299303
margin-left: 10px;
300304
margin-top: 10px;
301-
box-shadow: -2px 1px 11px 0px #2d2d2d78;
305+
box-shadow: 2px 2px 6px 0px #00000012;
306+
border: 1px solid #bfbfbf;
307+
color: #546884;
308+
flex-grow: 1;
302309
}
303310

304-
.home--maintainers>.person:hover {
305-
box-shadow: -2px 1px 11px 0px var(--primary);
306-
color: var(--secondary);
307-
cursor: pointer;
311+
.home--maintainers>.person.hidden {
312+
display: none;
308313
}
309314

310-
.home--maintainers>.person>div.packagescount {
311-
position: absolute;
312-
right: 0;
313-
bottom: 0;
314-
display: flex;
315-
align-items: center;
316-
font-family: "mononoki";
317-
font-size: 13px;
318-
height: 20px;
319-
text-shadow: 0px 0px 3px #000;
320-
background: -moz-linear-gradient(top, rgba(0,0,0,0) 0%, rgba(0,0,0,0.81) 100%);
321-
background: -webkit-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.81) 100%);
322-
background: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,0.81) 100%);
323-
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00000000', endColorstr='#cf000000',GradientType=0 );
324-
padding: 0 5px;
315+
.home--maintainers>.person.url:hover {
316+
border-color: var(--primary);
317+
cursor: pointer;
325318
}
326319

327-
.home--maintainers>.person>div.packagescount>i {
328-
margin-right: 4px;
320+
.home--maintainers>.person>img {
321+
width: 50px;
329322
}
330323

331-
.home--maintainers>.person>img {
332-
width: inherit;
333-
border-radius: 4px;
324+
.home--maintainers>.person>i{
325+
margin-right: 10px;
326+
display: flex;
327+
align-items: center;
328+
color: #1976D2;
334329
}
335330

336331
.home--maintainers>.person>.whois {
337-
visibility: hidden;
338-
width: 200px;
339-
padding: 10px;
340-
background-color: #000;
341-
color: #FFF;
342-
text-align: center;
343-
border-radius: 4px;
344-
padding: 5px;
345-
position: absolute;
332+
display: flex;
333+
flex-direction: column;
334+
justify-content: center;
335+
margin-left: 10px;
346336
font-size: 13px;
347-
text-shadow: 1px 1px 1px rgba(20, 20, 20, 0.5);
348-
top: 110%;
349-
left: -70px;
350337
font-family: "mononoki";
351-
z-index: 50;
352-
}
353-
354-
.home--maintainers>.person>.whois::after {
355-
content: "";
356-
position: absolute;
357-
bottom: 100%;
358-
left: 50%;
359-
margin-left: -5px;
360-
border-width: 5px;
361-
border-style: solid;
362-
border-color: transparent transparent #000 transparent;
338+
flex-grow: 1;
339+
margin-right: 10px;
363340
}
364341

365342
.home--maintainers>.person>.whois>span {
366-
color: var(--secondary);
343+
color: var(--secondary-darker);
344+
font-size: 12px;
367345
margin-top: 5px;
368346
}
369347

370-
.home--maintainers>.person:hover .whois {
371-
visibility: visible;
348+
.home--maintainers>.person>div.packagescount {
349+
display: flex;
350+
align-items: center;
351+
font-family: "mononoki";
352+
font-size: 14px;
353+
margin-right: 10px;
354+
flex-basis: 40px;
355+
flex-shrink: 0;
356+
}
357+
358+
.home--maintainers>.person>div.packagescount>i {
359+
margin-right: 4px;
372360
}
373361

374362
/**

public/js/components/home.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,20 @@ export class HomeView {
206206

207207
const authors = [...this.secureDataSet.authors.entries()]
208208
.sort((left, right) => right[1].count - left[1].count);
209-
for (const [name, data] of authors) {
209+
const maxAuthors = 8;
210+
const hideItems = authors.length > maxAuthors;
211+
212+
for (let id = 0; id<authors.length; id++) {
213+
const [name, data] = authors[id];
210214
const { count, email, url = null } = data;
211215

216+
const hasURL = typeof url === "string";
212217
const person = utils.createDOMElement("div", {
213218
className: "person",
214219
childs: [
215220
utils.createAvatarImageElement(email),
216221
createWhois(name, email),
222+
hasURL ? utils.createDOMElement("i", { className: "icon-link" }) : null,
217223
utils.createDOMElement("div", {
218224
className: "packagescount",
219225
childs: [
@@ -223,12 +229,22 @@ export class HomeView {
223229
})
224230
]
225231
});
226-
if (typeof url === "string") {
232+
if (hideItems && id >= maxAuthors) {
233+
person.classList.add("hidden");
234+
}
235+
236+
if (hasURL) {
237+
person.classList.add("url");
227238
person.addEventListener("click", () => window.open(url, "_blank"));
228239
}
240+
229241
fragment.appendChild(person);
230242
}
243+
if (hideItems) {
244+
fragment.appendChild(utils.createExpandableSpan(maxAuthors));
245+
}
231246

247+
document.getElementById("authors-count").innerHTML = authors.length;
232248
document.querySelector(".home--maintainers").appendChild(fragment);
233249
}
234250
}

public/js/utils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export function createDOMElement(kind = "div", options = {}) {
3535
el.className = className;
3636
}
3737
classList.forEach((name) => el.classList.add(name));
38-
childs.forEach((child) => el.appendChild(child));
38+
childs
39+
.filter((child) => child !== null)
40+
.forEach((child) => el.appendChild(child));
3941

4042
for (const [key, value] of Object.entries(attributes)) {
4143
el.setAttribute(key, value);

views/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
<div class="title">
105105
<i class="icon-users"></i>
106106
<p>Authors</p>
107+
<span class="count" id="authors-count">0</span>
107108
</div>
108109
<div class="content">
109110
<div class="home--maintainers"></div>

0 commit comments

Comments
 (0)