mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-08 14:11:56 -07:00
website: redesign part 4
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
main.build {
|
||||
min-height: 100dvh;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
color: white;
|
||||
font-size: 4rem;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
main.explore {
|
||||
min-height: 100dvh;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
color: white;
|
||||
font-size: 4rem;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
main.home {
|
||||
min-height: 100dvh;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
color: white;
|
||||
font-size: 4rem;
|
||||
}
|
||||
|
||||
+13
-13
@@ -15,10 +15,9 @@ function createChart(label) {
|
||||
|
||||
/**
|
||||
* @param {string} title
|
||||
* @param {number[]} indexes
|
||||
*/
|
||||
function createSectionId(title, indexes) {
|
||||
return `${indexes.join("-")}-${title.toLowerCase().replaceAll(" ", "-")}`;
|
||||
function createSectionId(title) {
|
||||
return title.toLowerCase().replaceAll(" ", "-");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,9 +29,10 @@ function createSection(section, indexes) {
|
||||
const title = document.createElement(indexes.length === 1 ? "h1" : "h2");
|
||||
const anchor = document.createElement("a");
|
||||
const description = document.createElement("p");
|
||||
const id = createSectionId(section.title);
|
||||
|
||||
element.id = createSectionId(section.title, indexes);
|
||||
anchor.href = `#${element.id}`;
|
||||
title.id = id;
|
||||
anchor.href = `#${id}`;
|
||||
anchor.append(section.title);
|
||||
title.append(anchor);
|
||||
description.append(section.description);
|
||||
@@ -52,7 +52,7 @@ function createSection(section, indexes) {
|
||||
function createContentsItem(section, indexes) {
|
||||
const item = document.createElement("li");
|
||||
const anchor = document.createElement("a");
|
||||
anchor.href = `#${createSectionId(section.title, indexes)}`;
|
||||
anchor.href = `#${createSectionId(section.title)}`;
|
||||
anchor.append(section.title);
|
||||
item.append(anchor);
|
||||
|
||||
@@ -83,7 +83,7 @@ function createContents() {
|
||||
|
||||
/** @param {HTMLElement} main */
|
||||
function initScrollSpy(main) {
|
||||
const sections = [...main.querySelectorAll("section[id]")];
|
||||
const titles = [...main.querySelectorAll("h1[id], h2[id]")];
|
||||
const visible = new Set();
|
||||
const links = new Map(
|
||||
[...main.querySelectorAll('nav a[href^="#"]')].map((link) => [
|
||||
@@ -96,15 +96,15 @@ function initScrollSpy(main) {
|
||||
let current = null;
|
||||
|
||||
function update() {
|
||||
const section = sections.find((section) => visible.has(section.id));
|
||||
if (!section) return;
|
||||
const title = titles.find((title) => visible.has(title.id));
|
||||
if (!title) return;
|
||||
|
||||
const hash = `#${section.id}`;
|
||||
const hash = `#${title.id}`;
|
||||
if (hash === current) return;
|
||||
|
||||
links.get(current)?.removeAttribute("aria-current");
|
||||
links.get(hash)?.setAttribute("aria-current", "location");
|
||||
history.replaceState(null, "", `/learn${hash}`);
|
||||
history.replaceState(null, "", hash);
|
||||
current = hash;
|
||||
}
|
||||
|
||||
@@ -119,8 +119,8 @@ function initScrollSpy(main) {
|
||||
update();
|
||||
});
|
||||
|
||||
for (const section of sections) {
|
||||
observer.observe(section);
|
||||
for (const title of titles) {
|
||||
observer.observe(title);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
main.learn {
|
||||
min-height: 100dvh;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 14rem;
|
||||
gap: 4rem;
|
||||
padding: 8rem 2rem 6rem;
|
||||
color: white;
|
||||
|
||||
article {
|
||||
width: min(100%, 52rem);
|
||||
justify-self: center;
|
||||
|
||||
section {
|
||||
scroll-margin-top: 6rem;
|
||||
}
|
||||
|
||||
> section + section {
|
||||
margin-top: 8rem;
|
||||
}
|
||||
@@ -27,6 +21,7 @@ main.learn {
|
||||
h2 {
|
||||
font-weight: 400;
|
||||
line-height: 1;
|
||||
scroll-margin-top: 6rem;
|
||||
|
||||
a {
|
||||
position: relative;
|
||||
|
||||
@@ -12,8 +12,10 @@ body {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
overflow: auto;
|
||||
color: white;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
scroll-behavior: smooth;
|
||||
transition: opacity 180ms ease;
|
||||
}
|
||||
|
||||
@@ -23,16 +25,9 @@ body {
|
||||
}
|
||||
}
|
||||
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
body > main {
|
||||
scroll-behavior: auto;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
html {
|
||||
scroll-behavior: auto;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user