first commit
@@ -0,0 +1,285 @@
|
||||
/* Federated Core Docs
|
||||
Palette: paper, ink, federation blue, ochre signal, hairline sage. */
|
||||
@font-face { font-family: "Public Sans"; src: url("../fonts/public-sans-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
|
||||
@font-face { font-family: "Public Sans"; src: url("../fonts/public-sans-latin-wght-italic.woff2") format("woff2"); font-weight: 100 900; font-style: italic; font-display: swap; }
|
||||
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
|
||||
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/ibm-plex-mono-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
|
||||
|
||||
:root {
|
||||
--paper: #F7F8F5;
|
||||
--paper-2: #EEF1EC;
|
||||
--ink: #17232B;
|
||||
--ink-2: #4E5D65;
|
||||
--blue: #24527A;
|
||||
--blue-ink: #1B3F5F;
|
||||
--blue-wash: #E3ECF3;
|
||||
--ochre: #B07A12;
|
||||
--ochre-wash: #F6ECD4;
|
||||
--line: #CFD6D2;
|
||||
--strike: #B5452F;
|
||||
--code-bg: #EBEFEA;
|
||||
--focus: #2F7BC0;
|
||||
--sans: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
|
||||
--mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
|
||||
--measure: 68ch;
|
||||
--header-h: 60px;
|
||||
color-scheme: light;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--paper: #12191E;
|
||||
--paper-2: #18222A;
|
||||
--ink: #E3E9EB;
|
||||
--ink-2: #A3B1B8;
|
||||
--blue: #8DBDE3;
|
||||
--blue-ink: #B6D5EE;
|
||||
--blue-wash: #1C2D3B;
|
||||
--ochre: #E2B04F;
|
||||
--ochre-wash: #2C2516;
|
||||
--line: #2C3A42;
|
||||
--strike: #E08770;
|
||||
--code-bg: #1A252C;
|
||||
--focus: #8DBDE3;
|
||||
color-scheme: dark;
|
||||
}
|
||||
}
|
||||
|
||||
*, *::before, *::after { box-sizing: border-box; }
|
||||
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
|
||||
body {
|
||||
margin: 0; background: var(--paper); color: var(--ink);
|
||||
font: 400 1.0625rem/1.65 var(--sans);
|
||||
font-feature-settings: "kern", "liga";
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
|
||||
a:hover { color: var(--blue-ink); text-decoration-thickness: 2px; }
|
||||
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
|
||||
main:focus { outline: none; }
|
||||
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
||||
.skip { position: absolute; left: 12px; top: -48px; z-index: 50; background: var(--ink); color: var(--paper); padding: 8px 12px; }
|
||||
.skip:focus { top: 8px; }
|
||||
s { text-decoration-color: var(--strike); text-decoration-thickness: 1.5px; }
|
||||
|
||||
/* Masthead */
|
||||
.masthead { position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: 1px solid var(--line); }
|
||||
.masthead-inner { height: var(--header-h); display: flex; align-items: center; gap: 24px; padding: 0 24px; max-width: 1440px; margin: 0 auto; }
|
||||
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
|
||||
.brand:hover { color: var(--ink); }
|
||||
.mark { width: 32px; height: 28px; image-rendering: pixelated; }
|
||||
.brand-sub { font-weight: 400; color: var(--ink-2); }
|
||||
.topnav { display: flex; gap: 20px; }
|
||||
.topnav a { color: var(--ink-2); text-decoration: none; font-size: 0.95rem; padding: 4px 0; border-bottom: 2px solid transparent; }
|
||||
.topnav a:hover { color: var(--ink); }
|
||||
.topnav a[aria-current] { color: var(--ink); border-bottom-color: var(--blue); }
|
||||
.search { position: relative; margin-left: auto; width: min(340px, 40vw); }
|
||||
.search input {
|
||||
width: 100%; font: inherit; font-size: 0.95rem; color: var(--ink); background: var(--paper-2);
|
||||
border: 1px solid var(--line); border-radius: 6px; padding: 7px 34px 7px 12px;
|
||||
}
|
||||
.search input::placeholder { color: var(--ink-2); }
|
||||
.search input:focus { outline: 2px solid var(--focus); outline-offset: 0; background: var(--paper); }
|
||||
.search-key { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font: 600 0.75rem var(--mono); color: var(--ink-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; }
|
||||
.search-results {
|
||||
position: absolute; top: calc(100% + 6px); right: 0; width: min(460px, 92vw); max-height: 70vh; overflow: auto;
|
||||
margin: 0; padding: 6px; list-style: none; background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
|
||||
box-shadow: 0 12px 32px -12px rgb(10 25 35 / 0.35);
|
||||
}
|
||||
.search-results li a { display: block; padding: 8px 10px; border-radius: 5px; color: var(--ink); text-decoration: none; }
|
||||
.search-results li a:hover, .search-results li a[aria-selected="true"] { background: var(--blue-wash); }
|
||||
.search-results .r-title { font-weight: 650; }
|
||||
.search-results .r-meta { display: block; font-size: 0.82rem; color: var(--ink-2); }
|
||||
.search-results .r-empty { padding: 10px; color: var(--ink-2); font-size: 0.92rem; }
|
||||
.nav-toggle { display: none; }
|
||||
|
||||
/* Frame */
|
||||
.frame { max-width: 1440px; margin: 0 auto; display: grid; grid-template-columns: 1fr; }
|
||||
.is-doc .frame { grid-template-columns: 264px minmax(0, 1fr); }
|
||||
main { min-width: 0; padding: 40px 24px 80px; }
|
||||
.is-doc main { padding: 40px 48px 96px; }
|
||||
|
||||
/* Sidebar */
|
||||
.sidebar {
|
||||
position: sticky; top: var(--header-h); align-self: start; height: calc(100vh - var(--header-h)); overflow-y: auto;
|
||||
padding: 28px 16px 48px 24px; border-right: 1px solid var(--line); font-size: 0.93rem;
|
||||
}
|
||||
.side-group + .side-group { margin-top: 28px; }
|
||||
.side-heading { display: block; font-weight: 700; color: var(--ink); text-decoration: none; margin-bottom: 6px; }
|
||||
.side-sub { margin: 18px 0 4px; font-size: 0.8rem; font-weight: 600; color: var(--ink-2); }
|
||||
.sidebar ul { list-style: none; margin: 0; padding: 0; }
|
||||
.sidebar li a { display: block; padding: 3px 10px; margin-left: -10px; border-radius: 4px; color: var(--ink-2); text-decoration: none; line-height: 1.45; }
|
||||
.sidebar li a:hover { color: var(--ink); background: var(--paper-2); }
|
||||
.sidebar a[aria-current="page"] { color: var(--blue-ink); background: var(--blue-wash); font-weight: 600; }
|
||||
.side-heading[aria-current="page"] { background: none; }
|
||||
|
||||
/* Docs */
|
||||
.doc-wrap { display: grid; grid-template-columns: minmax(0, var(--measure)) 220px; gap: 56px; }
|
||||
.doc { min-width: 0; max-width: var(--measure); }
|
||||
.doc-head { margin-bottom: 32px; }
|
||||
.doc-kicker { margin: 0 0 8px; font-size: 0.9rem; }
|
||||
.doc-kicker a { color: var(--ink-2); text-decoration: none; }
|
||||
.doc-kicker a:hover { color: var(--blue); }
|
||||
h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -0.015em; font-weight: 750; text-wrap: balance; }
|
||||
h1 { font-size: clamp(2rem, 1.4rem + 2vw, 2.75rem); margin: 0 0 12px; letter-spacing: -0.025em; }
|
||||
.doc-lede { font-size: 1.2rem; line-height: 1.5; color: var(--ink-2); margin: 0; max-width: 60ch; }
|
||||
.factsheet { margin: 24px 0 0; padding: 0; border-top: 1px solid var(--line); }
|
||||
.factsheet > div { display: grid; grid-template-columns: 9.5em 1fr; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); }
|
||||
.factsheet dt { color: var(--ink-2); font-size: 0.92rem; padding-top: 1px; }
|
||||
.factsheet dd { margin: 0; overflow-wrap: anywhere; }
|
||||
.replaces s { white-space: nowrap; }
|
||||
.replaces .sep, .dir-replaces .sep { color: var(--ink-2); }
|
||||
|
||||
.prose > :first-child { margin-top: 0; }
|
||||
.prose h2 { font-size: 1.6rem; margin: 2.4em 0 0.6em; padding-top: 0.2em; }
|
||||
.prose h3 { font-size: 1.22rem; margin: 1.9em 0 0.5em; }
|
||||
.prose h4 { font-size: 1.02rem; margin: 1.6em 0 0.4em; }
|
||||
.prose p, .prose ul, .prose ol, .prose table, .prose pre { margin: 0 0 1.1em; }
|
||||
.prose ul, .prose ol { padding-left: 1.4em; }
|
||||
.prose li { margin: 0.25em 0; }
|
||||
.prose li > ul, .prose li > ol { margin: 0.25em 0 0.4em; }
|
||||
.prose ol > li::marker { font-weight: 650; color: var(--ink-2); }
|
||||
.prose strong { font-weight: 650; }
|
||||
.prose code { font: 0.86em var(--mono); background: var(--code-bg); padding: 0.12em 0.36em; border-radius: 4px; overflow-wrap: anywhere; }
|
||||
.prose pre { font: 0.86rem/1.55 var(--mono); background: var(--code-bg) !important; padding: 14px 16px; border-radius: 6px; overflow-x: auto; border: 1px solid var(--line); }
|
||||
.prose pre code { background: none; padding: 0; font-size: inherit; }
|
||||
.prose table { width: 100%; border-collapse: collapse; font-size: 0.95rem; display: block; overflow-x: auto; }
|
||||
.prose th, .prose td { text-align: left; vertical-align: top; padding: 8px 14px 8px 0; border-bottom: 1px solid var(--line); }
|
||||
.prose th { font-weight: 650; border-bottom-color: var(--ink-2); }
|
||||
.prose kbd { font: 600 0.8em var(--mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--paper-2); }
|
||||
.prose blockquote { margin: 0 0 1.1em; padding-left: 16px; border-left: 3px solid var(--line); color: var(--ink-2); }
|
||||
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }
|
||||
|
||||
/* Callouts */
|
||||
.callout { margin: 1.5em 0; padding: 14px 18px; border-left: 4px solid var(--line); background: var(--paper-2); border-radius: 0 6px 6px 0; }
|
||||
.callout > :last-child { margin-bottom: 0; }
|
||||
.callout p { margin: 0 0 0.6em; }
|
||||
.callout-title { font-weight: 700; margin-bottom: 4px !important; }
|
||||
.callout-note { border-left-color: var(--blue); background: var(--blue-wash); }
|
||||
.callout-superpanel { border-left-color: var(--blue); }
|
||||
.callout-warning { border-left-color: var(--strike); }
|
||||
.callout-enterprise { border-left-color: var(--ochre); background: var(--ochre-wash); }
|
||||
.screenshot { margin: 1.5em 0; }
|
||||
.screenshot a { display: block; }
|
||||
.screenshot img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; }
|
||||
.screenshot figcaption { margin-top: 8px; font-size: 0.88rem; color: var(--ink-2); }
|
||||
.screenshot-src { font-style: italic; }
|
||||
.callout-foot { font-size: 0.88rem; color: var(--ink-2); margin-top: 0.8em !important; }
|
||||
|
||||
.further { margin-top: 3em; padding-top: 1.4em; border-top: 1px solid var(--line); }
|
||||
.further h2 { font-size: 1.15rem; margin: 0 0 0.6em; }
|
||||
.further ul { margin: 0; padding-left: 1.2em; }
|
||||
|
||||
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 3.5em; }
|
||||
.pager a { display: block; padding: 12px 16px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; font-weight: 650; color: var(--ink); }
|
||||
.pager a:hover { border-color: var(--blue); color: var(--blue-ink); }
|
||||
.pager span { display: block; font-weight: 400; font-size: 0.85rem; color: var(--ink-2); }
|
||||
.pager-next { grid-column: 2; text-align: right; }
|
||||
|
||||
.toc { position: sticky; top: calc(var(--header-h) + 40px); align-self: start; max-height: calc(100vh - var(--header-h) - 60px); overflow-y: auto; font-size: 0.88rem; }
|
||||
.toc-title { font-weight: 700; margin: 0 0 8px; }
|
||||
.toc ul { list-style: none; margin: 0; padding: 0; }
|
||||
.toc ul ul { padding-left: 12px; }
|
||||
.toc li a { display: block; padding: 3px 0 3px 10px; border-left: 2px solid var(--line); color: var(--ink-2); text-decoration: none; line-height: 1.4; }
|
||||
.toc li a:hover { color: var(--ink); }
|
||||
.toc li a.is-active { color: var(--blue-ink); border-left-color: var(--blue); }
|
||||
|
||||
.guide-list { list-style: none; padding: 0; margin: 2em 0 0; counter-reset: g; border-top: 1px solid var(--line); }
|
||||
.guide-list li { counter-increment: g; display: grid; grid-template-columns: 2.2em 1fr; padding: 16px 0; border-bottom: 1px solid var(--line); }
|
||||
.guide-list li::before { content: counter(g); font-weight: 750; color: var(--ink-2); grid-row: span 2; }
|
||||
.guide-list a { font-weight: 650; font-size: 1.08rem; }
|
||||
.guide-list p { margin: 2px 0 0; color: var(--ink-2); }
|
||||
|
||||
/* Directory: the signature element. Open-source app on the left, the service it retires struck through on the right. */
|
||||
.directory { margin-top: 8px; }
|
||||
.dir-group { margin-top: 40px; }
|
||||
.dir-group-head h2, .dir-group-head h3 { font-size: 1.15rem; margin: 0 0 4px; padding-bottom: 8px; border-bottom: 2px solid var(--ink); }
|
||||
.dir-list { list-style: none; margin: 0; padding: 0; }
|
||||
.dir-row { display: grid; grid-template-columns: 10rem minmax(0, 1fr) minmax(0, 15rem); gap: 6px 24px; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--line); }
|
||||
.dir-name { font-weight: 700; font-size: 1.05rem; text-decoration: none; }
|
||||
.dir-name:hover { text-decoration: underline; }
|
||||
.dir-desc { color: var(--ink-2); }
|
||||
.dir-replaces { font-size: 0.93rem; text-align: right; color: var(--ink); }
|
||||
|
||||
/* Home */
|
||||
.is-home main { max-width: 1200px; margin: 0 auto; width: 100%; padding: 64px 32px 96px; }
|
||||
.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 64px; align-items: center; padding-bottom: 56px; border-bottom: 1px solid var(--line); }
|
||||
.hero h1 { font-size: clamp(2.3rem, 1.4rem + 3.4vw, 3.9rem); line-height: 1.04; letter-spacing: -0.035em; font-weight: 800; margin: 0 0 20px; max-width: 14ch; }
|
||||
.hero-lede { font-size: 1.2rem; line-height: 1.55; color: var(--ink-2); max-width: 54ch; margin: 0 0 28px; }
|
||||
.hero-links { display: flex; flex-wrap: wrap; gap: 12px; margin: 0; }
|
||||
.btn { display: inline-block; padding: 10px 18px; border-radius: 6px; background: var(--blue); color: var(--paper); text-decoration: none; font-weight: 650; border: 1px solid var(--blue); }
|
||||
.btn:hover { background: var(--blue-ink); border-color: var(--blue-ink); color: var(--paper); }
|
||||
.btn-quiet { background: transparent; color: var(--blue); border-color: var(--line); }
|
||||
.btn-quiet:hover { background: var(--blue-wash); color: var(--blue-ink); border-color: var(--blue); }
|
||||
.swap { margin: 0; }
|
||||
.swap-list { list-style: none; margin: 0; padding: 0; font-size: clamp(1.2rem, 0.9rem + 1vw, 1.55rem); font-weight: 650; letter-spacing: -0.01em; }
|
||||
.swap-list li { display: grid; grid-template-columns: 1fr 40px 1fr; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
|
||||
.swap-list li:first-child { border-top: 1px solid var(--line); }
|
||||
.swap-list s { color: var(--ink-2); font-weight: 500; text-align: right; text-decoration-thickness: 2px; }
|
||||
.swap-list a { text-decoration: none; }
|
||||
.swap-list a:hover { text-decoration: underline; }
|
||||
.swap-arrow { height: 2px; background: var(--line); position: relative; }
|
||||
.swap-arrow::after { content: ""; position: absolute; right: -1px; top: -4px; border: 5px solid transparent; border-left: 7px solid var(--line); border-right: 0; }
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
.swap-list s { animation: strike-in 700ms cubic-bezier(.2,.7,.2,1) both; }
|
||||
.swap-list li:nth-child(2) s { animation-delay: 90ms; } .swap-list li:nth-child(3) s { animation-delay: 180ms; }
|
||||
.swap-list li:nth-child(4) s { animation-delay: 270ms; } .swap-list li:nth-child(5) s { animation-delay: 360ms; }
|
||||
.swap-list li:nth-child(6) s { animation-delay: 450ms; }
|
||||
@keyframes strike-in { from { text-decoration-color: transparent; } to { text-decoration-color: var(--strike); } }
|
||||
}
|
||||
.home-section { margin-top: 56px; }
|
||||
.home-section-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 32px; align-items: end; }
|
||||
.home-section-head h2 { font-size: 2rem; margin: 0; letter-spacing: -0.025em; }
|
||||
.home-section-head p { margin: 0; color: var(--ink-2); }
|
||||
|
||||
.site-footer { border-top: 1px solid var(--line); font-size: 0.88rem; color: var(--ink-2); }
|
||||
.site-footer-inner { max-width: 1440px; margin: 0 auto; padding: 28px 24px 40px; }
|
||||
.site-footer p { margin: 0 0 6px; max-width: 80ch; }
|
||||
|
||||
/* Syntax highlighting (minimal) */
|
||||
.chroma .c, .chroma .c1, .chroma .cm { color: var(--ink-2); font-style: italic; }
|
||||
.chroma .s, .chroma .s1, .chroma .s2 { color: var(--ochre); }
|
||||
.chroma .k, .chroma .nb, .chroma .nt { color: var(--blue); }
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 1240px) {
|
||||
.doc-wrap { grid-template-columns: minmax(0, 1fr); }
|
||||
.toc { display: none; }
|
||||
}
|
||||
@media (max-width: 960px) {
|
||||
.hero { grid-template-columns: 1fr; gap: 40px; }
|
||||
.home-section-head { grid-template-columns: 1fr; gap: 8px; }
|
||||
.dir-row { grid-template-columns: 9rem minmax(0, 1fr); }
|
||||
.dir-replaces { grid-column: 2; text-align: left; }
|
||||
}
|
||||
@media (max-width: 860px) {
|
||||
.is-doc .frame { grid-template-columns: 1fr; }
|
||||
.is-doc main { padding: 28px 20px 72px; }
|
||||
.nav-toggle { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; margin-left: -8px; background: none; border: 0; color: var(--ink); cursor: pointer; border-radius: 6px; }
|
||||
.is-home .nav-toggle { display: none; }
|
||||
.nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after { display: block; width: 20px; height: 2px; background: currentColor; position: relative; }
|
||||
.nav-toggle-bars::before, .nav-toggle-bars::after { content: ""; position: absolute; left: 0; }
|
||||
.nav-toggle-bars::before { top: -6px; } .nav-toggle-bars::after { top: 6px; }
|
||||
.sidebar { position: fixed; left: 0; top: var(--header-h); bottom: 0; width: min(320px, 86vw); height: auto; background: var(--paper); z-index: 15; transform: translateX(-100%); visibility: hidden; transition: transform 200ms ease, visibility 0s 200ms; }
|
||||
.sidebar.is-open { transform: none; visibility: visible; transition: transform 200ms ease; box-shadow: 0 0 0 100vmax rgb(10 20 28 / 0.35); }
|
||||
.topnav { display: none; }
|
||||
.masthead-inner { gap: 12px; padding: 0 16px; }
|
||||
.search { width: auto; flex: 1; max-width: 300px; }
|
||||
.search-key { display: none; }
|
||||
}
|
||||
@media (max-width: 560px) {
|
||||
.brand-text { display: none; }
|
||||
.is-home main { padding: 40px 20px 72px; }
|
||||
.dir-row { grid-template-columns: 1fr; gap: 2px; }
|
||||
.dir-replaces { grid-column: 1; }
|
||||
.factsheet > div { grid-template-columns: 1fr; gap: 0; }
|
||||
.swap-list li { grid-template-columns: 1fr 28px 1fr; gap: 8px; }
|
||||
.pager { grid-template-columns: 1fr; }
|
||||
.pager-next { grid-column: 1; }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) { .sidebar, .sidebar.is-open { transition: none; } }
|
||||
|
||||
/* Refinements */
|
||||
.search input:focus ~ .search-key, .search input:not(:placeholder-shown) ~ .search-key { display: none; }
|
||||
.factsheet code { font: 0.92rem var(--mono); }
|
||||
.dir-replaces { color: var(--ink-2); line-height: 1.5; }
|
||||
.dir-replaces s { white-space: nowrap; }
|
||||
@@ -0,0 +1,129 @@
|
||||
// Sidebar toggle, "on this page" highlighting, and client-side search.
|
||||
|
||||
const toggle = document.querySelector(".nav-toggle");
|
||||
const sidebar = document.getElementById("sidebar");
|
||||
if (toggle && sidebar) {
|
||||
const setOpen = (open) => {
|
||||
sidebar.classList.toggle("is-open", open);
|
||||
toggle.setAttribute("aria-expanded", String(open));
|
||||
};
|
||||
toggle.addEventListener("click", () => setOpen(!sidebar.classList.contains("is-open")));
|
||||
document.addEventListener("keydown", (e) => { if (e.key === "Escape") setOpen(false); });
|
||||
document.addEventListener("click", (e) => {
|
||||
if (sidebar.classList.contains("is-open") && !sidebar.contains(e.target) && !toggle.contains(e.target)) setOpen(false);
|
||||
});
|
||||
const current = sidebar.querySelector('[aria-current="page"]');
|
||||
if (current) current.scrollIntoView({ block: "center" });
|
||||
}
|
||||
|
||||
// Highlight the current heading in the table of contents.
|
||||
const tocLinks = [...document.querySelectorAll(".toc a")];
|
||||
if (tocLinks.length && "IntersectionObserver" in window) {
|
||||
const map = new Map(tocLinks.map((a) => [decodeURIComponent(a.hash.slice(1)), a]));
|
||||
const headings = [...map.keys()].map((id) => document.getElementById(id)).filter(Boolean);
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
entries.forEach((entry) => {
|
||||
if (entry.isIntersecting) {
|
||||
tocLinks.forEach((a) => a.classList.remove("is-active"));
|
||||
map.get(entry.target.id)?.classList.add("is-active");
|
||||
}
|
||||
});
|
||||
}, { rootMargin: "0px 0px -70% 0px" });
|
||||
headings.forEach((h) => observer.observe(h));
|
||||
}
|
||||
|
||||
// Search
|
||||
const input = document.getElementById("search-input");
|
||||
const results = document.getElementById("search-results");
|
||||
const script = document.currentScript || document.querySelector("script[data-index]");
|
||||
const indexURL = script ? script.dataset.index : "/index.json";
|
||||
let index = null;
|
||||
let selected = -1;
|
||||
|
||||
async function loadIndex() {
|
||||
if (index) return index;
|
||||
try {
|
||||
const res = await fetch(indexURL);
|
||||
index = await res.json();
|
||||
} catch (err) {
|
||||
index = [];
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
const norm = (s) => (s || "").toLowerCase();
|
||||
|
||||
function score(item, terms) {
|
||||
let total = 0;
|
||||
for (const t of terms) {
|
||||
const title = norm(item.title);
|
||||
let s = 0;
|
||||
if (title === t) s += 100;
|
||||
else if (title.startsWith(t)) s += 60;
|
||||
else if (title.includes(t)) s += 40;
|
||||
if (norm(item.replaces).includes(t)) s += 30;
|
||||
if (norm(item.tagline).includes(t)) s += 15;
|
||||
if (norm(item.headings).includes(t)) s += 12;
|
||||
if (norm(item.body).includes(t)) s += 4;
|
||||
if (!s) return 0; // every term must match somewhere
|
||||
total += s;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
function escapeHTML(s) {
|
||||
return s.replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c]));
|
||||
}
|
||||
|
||||
function render(items, query) {
|
||||
selected = -1;
|
||||
if (!query) { results.hidden = true; input.setAttribute("aria-expanded", "false"); return; }
|
||||
results.hidden = false;
|
||||
input.setAttribute("aria-expanded", "true");
|
||||
if (!items.length) {
|
||||
results.innerHTML = `<li class="r-empty">No pages match “${escapeHTML(query)}”. Try an app name or a service you want to replace, like “Dropbox”.</li>`;
|
||||
return;
|
||||
}
|
||||
results.innerHTML = items.slice(0, 8).map((it) => {
|
||||
const meta = it.replaces ? `${it.section}. Replaces ${it.replaces}` : it.section;
|
||||
return `<li><a href="${it.url}"><span class="r-title">${escapeHTML(it.title)}</span><span class="r-meta">${escapeHTML(meta)}</span></a></li>`;
|
||||
}).join("");
|
||||
}
|
||||
|
||||
async function search() {
|
||||
const q = input.value.trim();
|
||||
const data = await loadIndex();
|
||||
const terms = norm(q).split(/\s+/).filter(Boolean);
|
||||
const hits = data
|
||||
.map((item) => ({ item, s: score(item, terms) }))
|
||||
.filter((x) => x.s > 0)
|
||||
.sort((a, b) => b.s - a.s)
|
||||
.map((x) => x.item);
|
||||
render(hits, q);
|
||||
}
|
||||
|
||||
function move(delta) {
|
||||
const links = [...results.querySelectorAll("a")];
|
||||
if (!links.length) return;
|
||||
selected = (selected + delta + links.length) % links.length;
|
||||
links.forEach((a, i) => a.setAttribute("aria-selected", String(i === selected)));
|
||||
links[selected].scrollIntoView({ block: "nearest" });
|
||||
}
|
||||
|
||||
if (input && results) {
|
||||
input.addEventListener("focus", loadIndex, { once: true });
|
||||
input.addEventListener("input", search);
|
||||
input.addEventListener("keydown", (e) => {
|
||||
if (e.key === "ArrowDown") { e.preventDefault(); move(1); }
|
||||
else if (e.key === "ArrowUp") { e.preventDefault(); move(-1); }
|
||||
else if (e.key === "Enter") {
|
||||
const links = results.querySelectorAll("a");
|
||||
const target = links[selected >= 0 ? selected : 0];
|
||||
if (target) { e.preventDefault(); window.location.href = target.href; }
|
||||
} else if (e.key === "Escape") { input.value = ""; render([], ""); input.blur(); }
|
||||
});
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.key === "/" && !/input|textarea|select/i.test(document.activeElement.tagName)) { e.preventDefault(); input.focus(); }
|
||||
});
|
||||
document.addEventListener("click", (e) => { if (!e.target.closest(".search")) { results.hidden = true; input.setAttribute("aria-expanded", "false"); } });
|
||||
}
|
||||
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 81 KiB |
|
After Width: | Height: | Size: 74 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 95 KiB |
|
After Width: | Height: | Size: 112 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 102 KiB |
|
After Width: | Height: | Size: 121 KiB |
|
After Width: | Height: | Size: 91 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 71 KiB |
|
After Width: | Height: | Size: 90 KiB |
|
After Width: | Height: | Size: 138 KiB |
|
After Width: | Height: | Size: 191 KiB |
|
After Width: | Height: | Size: 255 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 368 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 107 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 82 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 193 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 183 KiB |
|
After Width: | Height: | Size: 171 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 81 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 111 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 93 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 44 KiB |