diff --git a/docs/index.html b/docs/index.html index 99aee247c9..d2465cbdb3 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,5 +1,5 @@ - +
-
+
{% for object in objects %} {% if object.href %}{% endif %} @@ -14,7 +14,7 @@
{{ locale.typing.alt }} -
+

{{ locale.tagline }}

{{ icons.read() }}{{ locale.start_label }} {{ icons.github() }}GitHub diff --git a/overrides/homepage/locales/en.json b/overrides/homepage/locales/en.json index ac8ae29722..9bf07d05ec 100644 --- a/overrides/homepage/locales/en.json +++ b/overrides/homepage/locales/en.json @@ -1,9 +1,8 @@ { "hero_class": "hero-div hero-div--en", - "list_layout": true, "labels": { "astronaut": "Getting to know algorithms", - "chapter_computational_complexity": "Complexity", + "chapter_computational_complexity": "Complexity analysis", "chapter_array_and_linkedlist": "Arrays and linked lists", "chapter_stack_and_queue": "Stacks and queues", "chapter_hashing": "Hash tables", diff --git a/overrides/homepage/locales/ja.json b/overrides/homepage/locales/ja.json index c596958b91..5f22fbf6c7 100644 --- a/overrides/homepage/locales/ja.json +++ b/overrides/homepage/locales/ja.json @@ -1,9 +1,8 @@ { "hero_class": "hero-div hero-div--ja", - "list_layout": true, "labels": { - "astronaut": "アルゴリズム入門", - "chapter_computational_complexity": "計算量", + "astronaut": "アルゴリズムとの出会い", + "chapter_computational_complexity": "計算量の解析", "chapter_array_and_linkedlist": "配列と連結リスト", "chapter_stack_and_queue": "スタックとキュー", "chapter_hashing": "ハッシュテーブル", diff --git a/overrides/homepage/locales/ko.json b/overrides/homepage/locales/ko.json index c5ae386964..7151d14aee 100644 --- a/overrides/homepage/locales/ko.json +++ b/overrides/homepage/locales/ko.json @@ -1,9 +1,8 @@ { "hero_class": "hero-div hero-div--ko", - "list_layout": false, "labels": { "astronaut": "알고리즘과의 첫 만남", - "chapter_computational_complexity": "복잡도", + "chapter_computational_complexity": "복잡도 분석", "chapter_array_and_linkedlist": "배열과 연결 리스트", "chapter_stack_and_queue": "스택과 큐", "chapter_hashing": "해시 테이블", diff --git a/overrides/homepage/locales/ru.json b/overrides/homepage/locales/ru.json index a40d5f0245..4a0ba6b550 100644 --- a/overrides/homepage/locales/ru.json +++ b/overrides/homepage/locales/ru.json @@ -1,25 +1,24 @@ { "hero_class": "hero-div hero-div--ru", - "list_layout": true, "labels": { - "astronaut": "Первое знакомство с алгоритмами", - "chapter_computational_complexity": "Сложность", + "astronaut": "Введение в алгоритмы", + "chapter_computational_complexity": "Анализ сложности", "chapter_array_and_linkedlist": "Массивы и списки", - "chapter_stack_and_queue": "Стеки и очереди", + "chapter_stack_and_queue": "Стек и очередь", "chapter_hashing": "Хеш-таблицы", "chapter_tree": "Деревья", - "chapter_heap": "Кучи", + "chapter_heap": "Куча", "chapter_graph": "Графы", "chapter_searching": "Поиск", "chapter_sorting": "Сортировка", "chapter_divide_and_conquer": "Разделяй и властвуй", "chapter_backtracking": "Поиск с возвратом", "chapter_dynamic_programming": "Динамическое программирование", - "chapter_greedy": "Жадные алгоритмы" + "chapter_greedy": "Жадность" }, "label_styles": { - "astronaut": "left: 49.244%; top: 22.2%;", - "chapter_computational_complexity": "left: 34.244%; top: 33.919%;", + "astronaut": "left: 52.244%; top: 20.919%;", + "chapter_computational_complexity": "left: 39.244%; top: 33.919%;", "chapter_array_and_linkedlist": "left: 83.897%; top: 76.259%;", "chapter_stack_and_queue": "left: 77.571%; top: 91.25%;", "chapter_hashing": "left: 68.862%; top: 46.292%;", @@ -31,7 +30,7 @@ "chapter_divide_and_conquer": "left: 28.42%; top: 8.679%;", "chapter_backtracking": "left: 4.742%; top: 50.113%;", "chapter_dynamic_programming": "left: 6.561%; top: 75.351%;", - "chapter_greedy": "left: 20.619%; top: 86.85%;" + "chapter_greedy": "left: 21.619%; top: 86.85%;" }, "typing": { "style": "height: min(9vh, 12vw);", diff --git a/overrides/homepage/locales/zh.json b/overrides/homepage/locales/zh.json index a1c3ad00d3..cc0ad4f35f 100644 --- a/overrides/homepage/locales/zh.json +++ b/overrides/homepage/locales/zh.json @@ -1,9 +1,8 @@ { "hero_class": "hero-div", - "list_layout": false, "labels": { "astronaut": "初识算法", - "chapter_computational_complexity": "复杂度", + "chapter_computational_complexity": "复杂度分析", "chapter_array_and_linkedlist": "数组与链表", "chapter_stack_and_queue": "栈与队列", "chapter_hashing": "哈希表", diff --git a/overrides/javascripts/starfield.js b/overrides/javascripts/starfield.js index 70acd0f446..176dad4a85 100644 --- a/overrides/javascripts/starfield.js +++ b/overrides/javascripts/starfield.js @@ -20,7 +20,6 @@ const reduced = matchMedia("(prefers-reduced-motion: reduce)"); const finePointer = matchMedia("(hover: hover) and (pointer: fine)"); - const mobile = matchMedia("(max-width: 900px)"); const listeners = []; const on = (target, type, fn) => { target.addEventListener(type, fn); @@ -74,12 +73,11 @@ try { paused = sessionStorage.getItem("hello-algo:hero-paused") === "true"; } catch (_) { /* Storage is optional. */ } const staticMotion = () => reduced.matches || paused; - const listLayout = () => mobile.matches && ["hero-div--en", "hero-div--ru", "hero-div--ja"].some(name => map.classList.contains(name)); const canRun = () => !destroyed && visible && !suspended && !document.hidden && !staticMotion(); const wrap = (n, size) => ((n % size) + size) % size; function renderObjects() { - const enabled = !reduced.matches && !listLayout(); + const enabled = !reduced.matches; if (!enabled) items.forEach(item => restoreImage(item.image)); if (planets) { try { planets.render(time, enabled, pointer); } @@ -94,7 +92,7 @@ } function loadObjects() { - if (objectsRequested || destroyed || !visible || reduced.matches || listLayout()) return; + if (objectsRequested || destroyed || !visible || reduced.matches) return; objectsRequested = true; const planetReady = import(new URL("hero-planets.js", moduleBase).href).then(module => { if (destroyed) return; @@ -144,7 +142,7 @@ const mix = 1 - Math.exp(-dt * 5); pointer.x += (target.x - pointer.x) * mix; pointer.y += (target.y - pointer.y) * mix; - const still = staticMotion() || listLayout(); + const still = staticMotion(); const central = item => item.astronaut || item.image.dataset.heroAsset === 'chapter_computational_complexity'; const centralSelected = items.some(item => central(item) && (item.anchor === hovered || item.anchor === focused)); for (const item of items) { @@ -239,7 +237,7 @@ speed: 0.35 + random() * 0.45, color: ["#d0dedc", "#c5d2e8", "#e3d5bf"][i % 3], })); - if (!paused || reduced.matches || listLayout()) moveIllustrations(0); + if (!paused || reduced.matches) moveIllustrations(0); drawStars(); planets?.resize(); renderObjects(); @@ -251,7 +249,6 @@ for (const item of items) { if (!item.label) continue; item.label.style.marginLeft = item.originalLabelMargin; - if (listLayout()) continue; const bounds = item.label.getBoundingClientRect(); const nudge = Math.max(left - bounds.left, Math.min(0, right - bounds.right)); const base = parseFloat(getComputedStyle(item.label).marginLeft) || 0; @@ -291,7 +288,6 @@ }); on(reduced, "change", updatePlayback); on(finePointer, "change", () => { target = { x: 0, y: 0 }; resize(); }); - on(mobile, "change", resize); on(document, "visibilitychange", updatePlayback); on(window, "pagehide", () => { suspended = true; updatePlayback(); }); on(window, "pageshow", () => { suspended = false; updatePlayback(); }); @@ -302,7 +298,7 @@ const intersectionObserver = new IntersectionObserver(entries => { visible = entries[0].isIntersecting; updatePlayback(); - if (!objectsRequested && (!visible || reduced.matches || listLayout())) settleReady(); + if (!objectsRequested && (!visible || reduced.matches)) settleReady(); }); intersectionObserver.observe(hero); diff --git a/overrides/stylesheets/extra.css b/overrides/stylesheets/extra.css index e7630cbd9d..2e3023f516 100644 --- a/overrides/stylesheets/extra.css +++ b/overrides/stylesheets/extra.css @@ -408,64 +408,6 @@ a:hover .text-button span { z-index: 1; } -/* The illustrated chapter map becomes readable touch targets on small screens. */ -@media screen and (max-width: 600px) { - .home-div:has(> .hero-div--en) { - display: block; - height: auto !important; - margin-top: 0 !important; - padding: 0.5rem 0 1rem !important; - } - - .home-div > .hero-div--en { - display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 0.35rem 0.5rem; - width: calc(100% - 1.5rem); - height: auto; - margin: 0.5rem auto 1rem; - } - - .home-div > .hero-div--en > img { - display: none; - } - - .home-div > .hero-div--en > a { - display: flex; - align-items: center; - gap: 0.4rem; - min-width: 0; - min-height: 48px; - padding: 0.3rem 0.15rem; - text-align: left; - } - - .home-div > .hero-div--en > a > img { - position: static; - flex-shrink: 0; - width: 32px !important; - height: 32px !important; - object-fit: contain; - } - - .home-div > .hero-div--en > a > span { - position: static; - min-width: 0; - transform: none; - white-space: normal; - font-size: 13px; - line-height: 1.3; - } - - .home-div > .hero-div--en + .heading-div { - position: relative; - left: auto; - bottom: auto; - transform: none; - padding: 0 0.75rem; - } -} - .hero-div--ru { font-size: min(1.45vh, 2vw); } diff --git a/overrides/stylesheets/hero-motion.css b/overrides/stylesheets/hero-motion.css index 9cd507a8b4..83527714e4 100644 --- a/overrides/stylesheets/hero-motion.css +++ b/overrides/stylesheets/hero-motion.css @@ -12,44 +12,73 @@ .home-div.home-universe-bg { --hero-starfield-bg-color: var(--home-universe-bg); + --hero-map-height: min(84svh, 75vw); background-color: var(--home-universe-bg); position: relative; display: flex; - flex-direction: column; - height: auto; - min-height: calc(min(100svh, 120vw) - 2.4rem); - margin-top: 0; - padding: 0 0 1rem; + justify-content: center; + align-items: center; + height: min(100svh, 120vw); + margin-top: -2.4rem; + padding: 0; overflow: hidden; } -/* Keep the map below the header and let captions grow in their own space. - Absolute positioning clipped the map and overlaid its bottom labels on short screens. */ +/* Restore the static illustration's scale and centered composition in every language. */ .home-div.home-universe-bg > .hero-div { flex: none; - max-width: 100%; - height: auto; - aspect-ratio: 4 / 3; - margin: 0 auto; + width: min(112svh, 100%); + height: var(--hero-map-height); + margin: -2.4rem auto 0; + font-size: max(9px, min(1.8svh, 2.5vw)); } +.home-div.home-universe-bg > :is(.hero-div--en, .hero-div--ja, .hero-div--ru, .hero-div--ko) { + font-size: max(9px, min(1.5svh, 2vw)); +} + +/* The title occupies the illustration's lower central negative space, as in the static page. */ .home-div.home-universe-bg > .heading-div { - position: relative; - left: auto; - bottom: auto; - transform: none; - padding: 0 .75rem 2rem; + position: absolute; + left: 50%; + bottom: min(2svh, 3vw); + transform: translateX(-50%); + padding: 0; } -.home-div.home-universe-bg > .heading-div p { - text-wrap: balance; +@media screen and (max-width: 60em) { + .home-div.home-universe-bg { + /* Keep the upper labels below the header on very small/short viewports. */ + min-height: calc(var(--hero-map-height) + 8rem); + } + .home-div.home-universe-bg > .hero-div { margin-top: -4rem; } } -/* Reserve room for the heading and actions on ordinary desktop screens. - Short landscape screens keep a readable map and scroll instead of shrinking it. */ -@media (min-width: 901px) and (min-height: 640px) { - .home-div.home-universe-bg > .hero-div { - max-width: min(100%, calc((100svh - 16rem) * 4 / 3)); +.home-universe-bg .heading-div .rounded-button { pointer-events: auto; } + +/* Preserve the map on phones and short windows; translations grow downward. */ +@media (max-width: 600px), (max-height: 600px) { + .home-div.home-universe-bg { + display: block; + height: auto; + min-height: min(100svh, 120vw); + padding-top: max(2rem, calc((min(100svh, 120vw) - var(--hero-map-height) - 4rem) / 2)); + } + .home-div.home-universe-bg > .hero-div { margin: 0 auto; } + .home-div.home-universe-bg > .heading-div { + position: relative; + left: auto; + bottom: auto; + transform: none; + margin-top: -2rem; + padding-bottom: max(1.5rem, min(2svh, 3vw)); + } +} +@media (max-width: 600px) { + .home-universe-bg.hero-universe .hero-motion-toggle { bottom: .25rem; } + .home-universe-bg .heading-div p { + font-size: clamp(12px, 3.5vw, 16px); + padding-inline: 12px; } } @@ -185,13 +214,11 @@ .hero-div > a > noscript > img { width: auto; position: absolute; } .hero-div img[data-hero-fallback]:not([src]) { opacity: 0 !important; } -@keyframes hero-object-reveal { from { opacity: 0; } to { opacity: 1; } } .hero-universe .hero-div > a > img.hero-replaced { opacity: 0; } .hero-universe .hero-objects-canvas { - animation: hero-object-reveal 400ms ease-out both; position: absolute; inset: 0; width: 100%; @@ -217,43 +244,13 @@ } /* Long localized labels need space beside the new volumetric silhouettes. */ -.hero-three-active :is(.hero-div--en, .hero-div--ru) > a[href$="chapter_greedy/"] > span { +.hero-three-active .hero-div--en > a[href$="chapter_greedy/"] > span { margin-left: -4%; } -.hero-three-active :is(.hero-div--en, .hero-div--ru, .hero-div--ja) > a[href$="chapter_stack_and_queue/"] > span { +.hero-three-active :is(.hero-div--en, .hero-div--ja) > a[href$="chapter_stack_and_queue/"] > span { margin-left: 4%; } -/* Long translated chapter names use readable native links on narrow screens. */ -@media screen and (min-width: 901px) { - /* Keep the original planet silhouettes; move long labels into the open gaps. */ - .hero-universe :is(.hero-div--en, .hero-div--ru, .hero-div--ja, .hero-div--ko) > a[href$="chapter_introduction/"] > span { - margin-top: .6rem; - } - .hero-universe .hero-div--en > a[href$="chapter_divide_and_conquer/"] > span { - margin-left: -4.5%; - } -} - -@media screen and (max-width: 900px) { - .home-div.home-universe-bg > :is(.hero-div--en, .hero-div--ru, .hero-div--ja) { aspect-ratio: auto; } - .hero-universe .hero-div--ko > a[href$="chapter_introduction/"] > span { - left: 48% !important; - top: 95% !important; - } - .hero-universe .hero-div--ko > a[href$="chapter_divide_and_conquer/"] > span { - margin-left: -2%; - } - .home-div:has(> :is(.hero-div--en, .hero-div--ru, .hero-div--ja)) { display: block; height: auto !important; margin-top: 0 !important; padding: .5rem 0 1rem !important; } - .home-div > :is(.hero-div--en, .hero-div--ru, .hero-div--ja) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .35rem .5rem; width: calc(100% - 1.5rem); height: auto; margin: .5rem auto 1rem; } - .home-div > :is(.hero-div--en, .hero-div--ru, .hero-div--ja) > img { display: none; } - .home-div > :is(.hero-div--en, .hero-div--ru, .hero-div--ja) > a { display: flex; align-items: center; gap: .4rem; min-width: 0; min-height: 48px; padding: .3rem .15rem; text-align: left; } - .home-div > :is(.hero-div--en, .hero-div--ru, .hero-div--ja) > a > noscript > img, - .home-div > :is(.hero-div--en, .hero-div--ru, .hero-div--ja) > a > img { position: static; flex-shrink: 0; width: 32px !important; height: 32px !important; object-fit: contain; } - .home-div > :is(.hero-div--en, .hero-div--ru, .hero-div--ja) > a > span { position: static; min-width: 0; transform: none; white-space: normal; font-size: 13px; line-height: 1.3; } - .home-div > :is(.hero-div--en, .hero-div--ru, .hero-div--ja) + .heading-div { position: relative; left: auto; bottom: auto; transform: none; padding: 0 .75rem; } -} - /* Restore the animated, hand-drawn glass from the accepted motion study. */ .hero-universe .hero-div > a > .hero-hourglass { position: absolute; @@ -280,3 +277,21 @@ /* Intrinsic dimensions reserve space without overriding responsive media height. */ .home-div .profile-img { height: auto; } .home-div video.intro-image { height: auto; } + +/* Keep the full chapter title centered above the hourglass on compact maps. */ +@media (max-width: 600px), (max-height: 600px) { + .hero-div > a[href="chapter_computational_complexity/"] > span { + width: 22%; + max-width: 12ch; + white-space: normal; + text-align: center; + line-height: 1.15; + text-wrap: balance; + } +} + +@media (max-width: 600px), (max-height: 600px) { + .hero-div:is(.hero-div--ja, .hero-div--ru) > a[href="chapter_sorting/"] > span { + margin-top: 3%; + } +} diff --git a/overrides/zensical/stylesheets/extra.css b/overrides/zensical/stylesheets/extra.css index e2b045fc17..1516a37bf3 100644 --- a/overrides/zensical/stylesheets/extra.css +++ b/overrides/zensical/stylesheets/extra.css @@ -529,64 +529,6 @@ html:has(body[data-md-color-scheme="default"]) { z-index: 1; } -/* The illustrated chapter map becomes readable touch targets on small screens. */ -@media screen and (max-width: 600px) { - .home-div:has(> .hero-div--en) { - display: block; - height: auto !important; - margin-top: 0 !important; - padding: 0.5rem 0 1rem !important; - } - - .home-div > .hero-div--en { - display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 0.35rem 0.5rem; - width: calc(100% - 1.5rem); - height: auto; - margin: 0.5rem auto 1rem; - } - - .home-div > .hero-div--en > img { - display: none; - } - - .home-div > .hero-div--en > a { - display: flex; - align-items: center; - gap: 0.4rem; - min-width: 0; - min-height: 48px; - padding: 0.3rem 0.15rem; - text-align: left; - } - - .home-div > .hero-div--en > a > img { - position: static; - flex-shrink: 0; - width: 32px !important; - height: 32px !important; - object-fit: contain; - } - - .home-div > .hero-div--en > a > span { - position: static; - min-width: 0; - transform: none; - white-space: normal; - font-size: 13px; - line-height: 1.3; - } - - .home-div > .hero-div--en + .heading-div { - position: relative; - left: auto; - bottom: auto; - transform: none; - padding: 0 0.75rem; - } -} - .hero-div--ru { font-size: min(1.45vh, 2vw); } diff --git a/ru/docs/index.html b/ru/docs/index.html index 3335b3ed96..d0447d3145 100644 --- a/ru/docs/index.html +++ b/ru/docs/index.html @@ -1,5 +1,5 @@ - +