Skip to content

Commit 779930c

Browse files
authored
chore: polish map (#63)
* optimize page Signed-off-by: kerthcet <kerthcet@gmail.com> * polish Signed-off-by: kerthcet <kerthcet@gmail.com> --------- Signed-off-by: kerthcet <kerthcet@gmail.com>
1 parent d934ac2 commit 779930c

9 files changed

Lines changed: 352 additions & 157 deletions

File tree

‎Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
.PHONY: launch data cover worldmap contributors
1+
.PHONY: start data cover worldmap contributors
22

3-
launch: data
3+
start: data
44
@echo "Launching the application..."
55
npm run dev
66

‎assets/scss/common/_custom.scss‎

Lines changed: 205 additions & 121 deletions
Large diffs are not rendered by default.

‎data/contributors.json‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
"short": "London",
129129
"offset": {
130130
"dx": 0,
131-
"dy": -28,
131+
"dy": -27,
132132
"anchor": "middle"
133133
},
134134
"count": 2,
@@ -331,9 +331,9 @@
331331
"countryOnly": true,
332332
"short": "Poland",
333333
"offset": {
334-
"dx": 11,
335-
"dy": 4,
336-
"anchor": "start"
334+
"dx": 2,
335+
"dy": -13,
336+
"anchor": "middle"
337337
},
338338
"count": 1,
339339
"people": [
@@ -473,7 +473,7 @@
473473
"short": "Berlin",
474474
"offset": {
475475
"dx": 0,
476-
"dy": -11,
476+
"dy": -26,
477477
"anchor": "middle"
478478
},
479479
"count": 1,
@@ -654,8 +654,8 @@
654654
"lng": 27.57,
655655
"short": "Minsk",
656656
"offset": {
657-
"dx": 11,
658-
"dy": 4,
657+
"dx": 8,
658+
"dy": 17,
659659
"anchor": "start"
660660
},
661661
"count": 1,
@@ -714,9 +714,9 @@
714714
"lng": 4.9,
715715
"short": "Amsterdam",
716716
"offset": {
717-
"dx": 11,
718-
"dy": -25,
719-
"anchor": "start"
717+
"dx": 0,
718+
"dy": -41,
719+
"anchor": "middle"
720720
},
721721
"count": 1,
722722
"people": [

‎data/projects.yaml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ projects:
4242
url: https://github.com/InftyAI/mlx
4343
description: "Rust bindings for Apple's MLX framework."
4444

45-
# Rendered below the grid as plain text — not a project, and not a link, so it
46-
# has no `repo` (no star count) and no `url`.
45+
# Rendered below the grid as one line — not a project, so it has no `repo` (no
46+
# star count). `url` is optional: set it and the name becomes a link; leave it out
47+
# and the line is plain text, as it was.
4748
cta:
4849
name: "✨ Donation Plan"
4950
description: "Got a brilliant idea? Let's build something extraordinary together."

‎hugo_stats.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"error404",
7676
"feature-card",
7777
"feature-cta",
78+
"feature-cta-text",
7879
"feature-cta-title",
7980
"feature-grid",
8081
"feature-grid-title",
@@ -91,6 +92,7 @@
9192
"h-auto",
9293
"h5",
9394
"home",
95+
"home-hidden-title",
9496
"home-title",
9597
"icon",
9698
"icon-tabler",
@@ -188,6 +190,8 @@
188190
"worldmap-hit",
189191
"worldmap-hit-left",
190192
"worldmap-hits",
193+
"worldmap-key-dot",
194+
"worldmap-key-title",
191195
"worldmap-label",
192196
"worldmap-land",
193197
"worldmap-layout",

‎layouts/_default/home.html‎

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ <h1 class="home-title">{{ .Title }}</h1>
2323
cards be the first thing on it.
2424

2525
Its own section with its own heading — the map is not an eighth project, and
26-
nesting it under "Projects" would have filed it as one.
26+
nesting it under "Projects" would have filed it as one. The heading is the first
27+
entry of the key under the map rather than a label over it: a label band above
28+
the map and a key band below it were two layers saying one thing.
2729

2830
Both data files are generated and committed (`make worldmap`, `make
2931
contributors`), so this needs no lookup at build time and cannot be emptied
@@ -32,15 +34,14 @@ <h1 class="home-title">{{ .Title }}</h1>
3234
{{ $map := site.Data.worldmap -}}
3335
<section class="section section-contributors">
3436
<div class="container">
35-
<h2 class="feature-grid-title">Contributors</h2>
3637
{{/* `.cities` rather than `len .places`: a country-level fallback is a mark
3738
but not a city, so counting the marks called India a city. */}}
3839
{{ $summary := printf "%d of %d contributors, in %d cities across %d countries" (int .located) (int .total) (int .cities) (int .countryCount) -}}
3940
<div class="worldmap-layout">
4041
<figure class="worldmap">
4142
{{/* `role="img"` with a label: the map is one graphic, and without it
4243
a screen reader would read out a path, ten empty groups and the
43-
city names a second time. The list beside it carries the detail,
44+
city names a second time. The key under it carries the detail,
4445
as text that can be navigated rather than only announced. */}}
4546
<svg class="worldmap-svg" viewBox="0 0 {{ $map.width }} {{ $map.height }}" role="img"
4647
aria-label="{{ $summary }}." xmlns="http://www.w3.org/2000/svg">
@@ -111,7 +112,7 @@ <h2 class="feature-grid-title">Contributors</h2>
111112
these dots are comparable, not measurable. Nothing here rests
112113
on reading a count out of a radius — the card that opens on a
113114
city lists who is there, so its exact number can be counted off
114-
the faces, and the shares are the text list beside the map.
115+
the faces, and the shares are the key under the map.
115116

116117
The compression is at the top rather than in the base, because
117118
the base is set from the narrowest case. These are viewBox
@@ -296,18 +297,26 @@ <h2 class="feature-grid-title">Contributors</h2>
296297
and a row per city (or per country) turned the column into a ranking of
297298
Chinese cities rather than the spread the map is for.
298299

299-
The last row is "Others", the contributors with no location on their
300-
profile, so the column is shares of everyone rather than of the half
301-
the map can draw.
300+
The shares are of everyone, not of the half the map can draw.
302301

303302
It is also what a screen reader or a keyboard gets, since the svg is a
304303
single `role="img"` graphic. */}}
305304
<div class="worldmap-summary">
305+
{{/* After the figure in source order, which costs nothing: the svg is a
306+
labelled `role="img"`, so a screen reader announces what it is before
307+
reaching this. */}}
308+
{{/* The key's own label, first on its line, so the map is named as
309+
the contributors' map without a heading band above it. */}}
310+
{{/* The dot is the map's own mark, so the label reads as a legend entry —
311+
this is what a dot is — as well as the section's name. */}}
312+
<h2 class="worldmap-key-title"><span class="worldmap-key-dot" aria-hidden="true"></span>Contributors</h2>
306313
<ul class="worldmap-regions">
307-
{{ range .regions -}}
308-
{{/* Only "Others" carries a note — the one row whose name does not
309-
say what it counts. */}}
310-
<li{{ with .note }} title="{{ . }}"{{ end }}>
314+
{{/* Without "Others", the contributors whose profile does not say
315+
where they are: a "location unknown" row was the key's largest
316+
region. The shares stay shares of everyone, as
317+
tools/contributors.mjs computes them. */}}
318+
{{ range where .regions "name" "ne" "Others" -}}
319+
<li>
311320
<span class="worldmap-region-name">{{ .name }}</span>
312321
{{/* Percentages, not counts, and they add to 100 — see the
313322
apportionment in tools/contributors.mjs. */}}
@@ -348,8 +357,10 @@ <h2 class="feature-grid-title">Contributors</h2>
348357
<section class="section section-md section-features">
349358
<div class="container">
350359
{{/* Names the grid, so the seven project headings hang off a section
351-
instead of directly off the page's h1. */}}
352-
<h2 class="feature-grid-title">Projects</h2>
360+
instead of directly off the page's h1. Read out but not shown: seven
361+
cards of repositories with star counts say what they are, and the label
362+
was one more band between the map and them. */}}
363+
<h2 class="feature-grid-title home-hidden-title">Projects</h2>
353364
{{/* A list, because that is what seven sibling projects are: screen
354365
readers announce the count and allow item-by-item navigation.
355366
Flexbox rather than Bootstrap's row/col — it needs no breakpoint
@@ -391,10 +402,16 @@ <h3>
391402
<section class="section section-cta">
392403
<div class="container">
393404
{{ with site.Data.projects.cta -}}
394-
<div class="feature-cta">
405+
{{/* One line rather than a title over a sentence: the page ends on it, and
406+
two lines of its own read as one more block rather than a sign-off. */}}
407+
<p class="feature-cta">
408+
{{ if .url -}}
409+
<a class="feature-cta-title" href="{{ .url }}">{{ .name }}</a>
410+
{{- else -}}
395411
<span class="feature-cta-title">{{ .name }}</span>
396-
<p>{{ .description }}</p>
397-
</div>
412+
{{- end }}
413+
<span class="feature-cta-text">{{ .description }}</span>
414+
</p>
398415
{{ end -}}
399416
</div>
400417
</section>

‎layouts/blog/list.html‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{{/* The theme's blog list (doks-core layouts/blog/list.html), copied whole so the
2+
empty case can be added in front of it: everything after the `else` is the
3+
theme's template unchanged, and is what to re-copy if doks-core changes it.
4+
5+
With no posts the theme rendered a "Blog" heading over an empty page, linked
6+
from the navbar. Until there is something to read, the page says what the
7+
site's own 404 says — same strings (`404_title`, `404_text`) and the same
8+
markup as doks-core's layouts/404.html — rather than a blank that looks like
9+
a broken page. */}}
10+
{{ define "main" }}
11+
{{ if not .Pages -}}
12+
<div class="row justify-content-center">
13+
<div class="col-md-12 col-lg-10 col-xl-8">
14+
<article>
15+
<h1 class="text-center">{{ i18n "404_title" }}</h1>
16+
<p class="text-center">{{ i18n "404_text" }}</p>
17+
</article>
18+
</div>
19+
</div>
20+
{{ else -}}
21+
<div class="row justify-content-center">
22+
<div class="col-md-12 col-lg-9">
23+
{{ if .Params.avatar -}}
24+
{{ $image := .Resources.GetMatch (printf "**%s" .Params.avatar) -}}
25+
{{ $imageLq := $image.Resize "15x15 webp q95" -}}
26+
{{ $image = $image.Resize "300x300 webp q95" -}}
27+
<div class="contributor-image">
28+
<img class="img-fluid lazyload blur-up rounded-circle" src="{{ $imageLq.RelPermalink }}" data-src="{{ $image.RelPermalink }}" alt="{{ .Title }}" width="150" height="150">
29+
</div>
30+
{{ end -}}
31+
{{ with .Params.headline -}}
32+
<h1 class="text-center">{{ . }}</h1>
33+
{{ else -}}
34+
<h1 class="text-center">{{ .Title }}</h1>
35+
{{ end -}}
36+
{{ with .Params.summary -}}<p class="lead text-center">{{ . }}</p>{{ end -}}
37+
{{ with .Content -}}<div class="text-center">{{ . }}</div>{{ end -}}
38+
</div>
39+
</div>
40+
<div class="row justify-content-center">
41+
<div class="col-lg-9">
42+
{{ $paginator := .Paginate (.Data.Pages) -}}
43+
{{ range $paginator.Pages -}}
44+
<div class="card">
45+
{{ if site.Params.doks.imageList -}}
46+
{{- $images := .Resources.ByType "image" -}}
47+
{{- $featured := $images.GetMatch "*feature*" -}}
48+
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
49+
{{- if $featured -}}
50+
{{ partial "img" (dict
51+
"page" .
52+
"src" $featured
53+
"alt" .Title
54+
"class" "rounded-top-1"
55+
)}}
56+
{{ end -}}
57+
{{ end -}}
58+
<div class="card-body">
59+
<article>
60+
<h2 class="h3"><a class="stretched-link text-body" href="{{ .RelPermalink }}">{{ .Params.title }}</a></h2>
61+
<p>{{ .Params.summary | safeHTML }}</p>
62+
{{ partial "main/blog-meta.html" . -}}
63+
</article>
64+
</div>
65+
</div>
66+
{{ end -}}
67+
</div>
68+
</div>
69+
<div class="row justify-content-center">
70+
<div class="col-md-12 col-lg-9">
71+
{{ template "_internal/pagination.html" . }}
72+
</div>
73+
</div>
74+
{{ end -}}
75+
{{ end }}

‎layouts/partials/head/resource-hints.html‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@
5555
room a mark at the centre has — around 130px at 320px wide, still a readable
5656
column of faces. */}}
5757
{{ $room := cond (gt $pos.x (mul 0.5 $map.width)) (sub $left (div $size 2.0)) (sub (sub 100.0 $left) (div $size 2.0)) -}}
58-
{{ $rules = $rules | append (printf ".worldmap-hit:nth-child(%d){left:%.3f%%;top:%.3f%%;width:%.3f%%;--map-room:%.3f}" (add $i 1) $left $top $size $room) -}}
58+
{{ $rules = $rules | append (printf ".worldmap-hit:nth-child(%d){left:%.3f%%;top:%.3f%%;width:calc(%.3f%% * var(--mark-scale, 1));--map-room:%.3f}" (add $i 1) $left $top $size $room) -}}
59+
{{/* The point the svg's group for this mark is scaled about — its dot's centre, in
60+
viewBox units. See `.worldmap-place` in the stylesheet; `nth-of-type` because the
61+
groups are the only `<g>` in the svg, one per mark in this same order. */}}
62+
{{ $rules = $rules | append (printf ".worldmap-place:nth-of-type(%d){transform-origin:%.1fpx %.1fpx}" (add $i 1) $pos.x $pos.y) -}}
5963
{{ end -}}
6064
{{/* The target path carries a hash of the rules, which is not decoration: it is what
6165
keeps this stylesheet from going stale against the page it positions.

‎tools/locations.json‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@
10151015
"United States": "North America",
10161016
"Vietnam": "Asia"
10171017
},
1018-
"//labels": "Where each city's name is drawn relative to its dot, in viewBox units, keyed by label so aliases share one entry. Hand-placed because no automatic rule survives the two crowded corners of the map. Guangzhou and Shenzhen are 100km apart, which is 2.6 units at this scale, so one name goes below its dot and the other to the right; and Dublin, Cambridge, Amsterdam, Berlin and Minsk sit within 94 units of each other on one latitude, where 340 units of names have to be stacked onto separate rows above and below, with Barcelona taking the row under Amsterdam. Anything not listed defaults to `start` a little to the right. `anchor` is an SVG text-anchor: start places the text to the right of the dot, end to its left, middle centres it. A name reads as belonging to the dot nearest its anchored edge, so that is what a new entry has to get right — the dots in those two clusters are close enough that a name 20 units out can sit nearer a neighbour's dot than its own. Lucknow and Chengdu are the third case, and what collides there is a name with a dot rather than a name with a name: they are 64 units apart on nearly one latitude, and Chengdu's name reaches 49 of those units back west, so on the default anchor Lucknow's own name ran east under Chengdu's and Chengdu's ran over Lucknow's dot. Lucknow is anchored `end` so its name goes west into the empty Arabian Sea instead, where the nearest dot is Bengaluru's 35 units below, and Chengdu's `dy` lifts it a row above Lucknow's dot — which is the half of this that only moving Lucknow's name could not fix, since it was Chengdu's name that was sitting on somebody else's dot. A name also has to stay inside the map, which is what the eastern edge asks for: the svg does not clip, and on the default `start` anchor New Zealand's name ran 65 units past the map's right edge and into the region list beside it, so it is anchored `end` and drawn below Melbourne's row instead.",
1018+
"//labels": "Where each city's name is drawn relative to its dot, in viewBox units, keyed by label so aliases share one entry. Hand-placed because no automatic rule survives the two crowded corners of the map. Guangzhou and Shenzhen are 100km apart, which is 2.6 units at this scale, so one name goes below its dot and the other to the right; and Dublin, Cambridge, Amsterdam, Berlin and Minsk sit within 94 units of each other on one latitude, where 340 units of names have to be stacked onto separate rows above and below, with Barcelona taking the row under Amsterdam. Poland and Minsk extend that cluster east to Moscow, and on the default anchor each name ran over the next dot along — Poland's over Minsk's, Minsk's over Moscow's. So the names over the cluster are a stack, each centred on its own dot: Amsterdam on top, London and Berlin under it, Poland lowest; and Minsk's goes below its dot, into the gap above Romania. Centring is the point of it: a name that starts at its dot and runs right covers the dot after it, which read as that city's name rather than its own. Lucknow and Chengdu are the third case, and what collides there is a name with a dot rather than a name with a name: they are 64 units apart on nearly one latitude, and Chengdu's name reaches 49 of those units back west, so on the default anchor Lucknow's own name ran east under Chengdu's and Chengdu's ran over Lucknow's dot. Lucknow is anchored `end` so its name goes west into the empty Arabian Sea instead, where the nearest dot is Bengaluru's 35 units below, and Chengdu's `dy` lifts it a row above Lucknow's dot — which is the half of this that only moving Lucknow's name could not fix, since it was Chengdu's name that was sitting on somebody else's dot. A name also has to stay inside the map, which is what the eastern edge asks for: the svg does not clip, and on the default `start` anchor New Zealand's name ran 65 units past the map's right edge and into the region list beside it, so it is anchored `end` and drawn below Melbourne's row instead.",
10191019
"labels": {
10201020
"Shanghai, China": {
10211021
"dx": 15,
@@ -1054,7 +1054,7 @@
10541054
},
10551055
"Berlin, Germany": {
10561056
"dx": 0,
1057-
"dy": -11,
1057+
"dy": -26,
10581058
"anchor": "middle"
10591059
},
10601060
"Melbourne, Australia": {
@@ -1073,8 +1073,18 @@
10731073
"anchor": "end"
10741074
},
10751075
"Amsterdam, Netherlands": {
1076-
"dx": 11,
1077-
"dy": -25,
1076+
"dx": 0,
1077+
"dy": -41,
1078+
"anchor": "middle"
1079+
},
1080+
"Poland": {
1081+
"dx": 2,
1082+
"dy": -13,
1083+
"anchor": "middle"
1084+
},
1085+
"Minsk, Belarus": {
1086+
"dx": 8,
1087+
"dy": 17,
10781088
"anchor": "start"
10791089
},
10801090
"Barcelona, Spain": {
@@ -1099,7 +1109,7 @@
10991109
},
11001110
"London, UK": {
11011111
"dx": 0,
1102-
"dy": -28,
1112+
"dy": -27,
11031113
"anchor": "middle"
11041114
},
11051115
"New Zealand": {

0 commit comments

Comments
 (0)