diff --git a/docs/intro.md b/docs/intro.md index e1780d0..780c8c6 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -34,4 +34,16 @@ LibXR 是跨平台的 C++ 兼容层,包含外设驱动、数据结构、通信 [XRobot Onboarding](https://xrobot.work/XRobot-Onboarding/) -![XRobot Logo](/img/XRobot.png) +import ThemedImage from '@theme/ThemedImage'; +import useBaseUrl from '@docusaurus/useBaseUrl'; + + diff --git a/docusaurus.config.js b/docusaurus.config.js index 2f90415..831a3ef 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -6,7 +6,7 @@ module.exports = { trailingSlash: false, onBrokenLinks: 'throw', onDuplicateRoutes: 'warn', - favicon: 'img/XRobot.png', + favicon: 'img/favicon.svg', organizationName: 'xrobot-org', projectName: 'xrobot-org.github.io', diff --git a/i18n/en/docusaurus-plugin-content-docs/current/intro.md b/i18n/en/docusaurus-plugin-content-docs/current/intro.md index 1410d7a..6f7dc44 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/intro.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/intro.md @@ -34,4 +34,16 @@ The debug interfaces, XRUSB, advanced programming, design concepts and performan [XRobot Onboarding](https://xrobot.work/XRobot-Onboarding/) (Chinese) -![XRobot Logo](/img/XRobot.png) +import ThemedImage from '@theme/ThemedImage'; +import useBaseUrl from '@docusaurus/useBaseUrl'; + + diff --git a/src/components/showcase/RobotModules/arm.ts b/src/components/showcase/RobotModules/arm.ts index 68efd1f..6943c60 100644 --- a/src/components/showcase/RobotModules/arm.ts +++ b/src/components/showcase/RobotModules/arm.ts @@ -4,16 +4,18 @@ * * drawArm() paints through the engine's `g` wrapper onto a canvas; here, as in the exporter (of which makeXR5 / Rec / makeG * are a port), a recording canvas collects the fills, strokes and texts, and they become SVG - * markup with the colours of the current theme (TOKENS in armRig.js, both themes). The static file keeps the - * same elements at the rest pose with theme variables, so the still frame and the first animated frame match. + * markup with the colours of the current theme, read from the page's CSS variables (xrstyle-tokens.css, + * xrstyle-materials.css) when each frame is drawn. The static file keeps the same elements at the rest pose with + * theme variables, so the still frame and the first animated frame match. * Only loaded in the browser (dynamic import from index.tsx); nothing here touches the DOM at module level. */ -import { ANCHORS, ARM_K, ARM_KEYS, TOKENS, loadArmBeat } from './armRig.js'; +import { ANCHORS, ARM_K, ARM_KEYS, loadArmBeat } from './armRig.js'; import type { ArmPose } from './sim'; export { ARM_KEYS }; type Theme = 'light' | 'dark'; +type Tokens = (name: string) => string; type Pt = [number, number]; type Grad = { lg: true; p0: Pt; p1: Pt; stops: Array<[number, string]>; addColorStop?: (u: number, c: string) => void }; type El = @@ -28,10 +30,28 @@ const depth = (p: number[]) => p[1] - p[0] + (p[2] || 0); const sub = (a: number[], b: number[]) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]]; const f1 = (v: number) => (Math.round(v * 10) / 10).toString(); +// ------------------------------------------------------------------ theme colours from the page's CSS variables +// The drawing shades and mixes its colours (rgb(), shade(), mixc() in armRig.js), so it needs resolved values, not +// var() references: they are read from , whose data-theme is the theme being drawn. XRobot Style has no accent +// colour; the beat's `hero` (the active-joint marker, not drawn in the teach motion) is drawn in ink. +const TOKEN_ALIAS: Record = { hero: 'ink' }; +function cssTokens(): Tokens { + const style = getComputedStyle(document.documentElement); + const memo = new Map(); + return (name) => { + let v = memo.get(name); + if (v === undefined) { + v = style.getPropertyValue('--' + (TOKEN_ALIAS[name] || name)).trim(); + if (!v) throw new Error('token ' + name); + memo.set(name, v); + } + return v; + }; +} + // ------------------------------------------------------------------ XR5 stub: enough engine for the beat to load and draw /* eslint-disable @typescript-eslint/no-explicit-any */ -function makeXR5(theme: { v: Theme }): any { - const T = () => (TOKENS as Record>)[theme.v]; +function makeXR5(theme: { v: Theme; tok: Tokens }): any { const noop = () => {}; const callable = (): any => new Proxy(function () {}, { get: (_t, k) => (k === Symbol.toPrimitive ? () => 0 : callable()), apply: () => callable() }); @@ -44,8 +64,8 @@ function makeXR5(theme: { v: Theme }): any { ease: (t: number) => t * t * (3 - 2 * t), }, iso: { PJ, C, depth, add: (a: number[], b: number[]) => [a[0] + b[0], a[1] + b[1], a[2] + b[2]], mul: (a: number[], k: number) => [a[0] * k, a[1] * k, a[2] * k], sub }, - tok: (n: string) => { const v = T()[n]; if (v === undefined) throw new Error('token ' + n); return v; }, - mat: (m: string) => [T()['m-' + m], T()['m-' + m + '-l'], T()['m-' + m + '-f']], + tok: (n: string) => theme.tok(n), + mat: (m: string) => [theme.tok('m-' + m), theme.tok('m-' + m + '-l'), theme.tok('m-' + m + '-f')], theme: () => theme.v, anchor: (n: string) => { const a = (ANCHORS as Record)[n]; if (!a) throw new Error('anchor ' + n); return a.slice(); }, clock: { t: 0, te: 0 }, reduced: () => true, @@ -188,12 +208,13 @@ function markup(els: El[]): string { export type ArmRig = { draw(pose: ArmPose, theme: Theme): string }; export function createArmRig(): ArmRig { - const theme = { v: 'light' as Theme }; + const theme: { v: Theme; tok: Tokens } = { v: 'light', tok: () => { throw new Error('no theme yet'); } }; const X = loadArmBeat(makeXR5(theme), stubDocument); X.resetSim(); return { draw(pose, th) { theme.v = th; + theme.tok = cssTokens(); X.SIM.q = pose.q.map((d) => (d * Math.PI) / 180); X.SIM.grip = pose.grip; const g = makeG(ARM_K); diff --git a/src/components/showcase/RobotModules/armRig.js b/src/components/showcase/RobotModules/armRig.js index 4ee4f02..da57bf8 100644 --- a/src/components/showcase/RobotModules/armRig.js +++ b/src/components/showcase/RobotModules/armRig.js @@ -1,9 +1,9 @@ // Robot arm drawing for RobotModules/arm.ts. Generated from the arm beat 5-1 of the XRobot Style harness // (export_svg.py export_arm_rig), then reduced to the drawing: drawArm() and the geometry, kinematics and helpers it -// calls, with the token tables of both themes and the scene anchors it reads. arm.ts drives it along ARM_KEYS. +// calls, and the scene anchors it reads. arm.ts drives it along ARM_KEYS and supplies the colours from the page's +// CSS variables (xrstyle-tokens.css, xrstyle-materials.css). /* eslint-disable */ // @ts-nocheck -export const TOKENS = {"light":{"paper":"#f2f3f2","paper-raised":"#ffffff","paper-sunken":"#e6e8e6","line":"#d3d6d3","line-strong":"#7c827e","ink":"#111312","ink-muted":"#4d524f","on-ink":"#f2f3f2","ch0":"#7a5c00","ch1":"#006573","ch2":"#a1206f","ch3":"#2a6e1b","pass":"#16693a","fail":"#b42318","blocked":"#7d5100","hero":"#00838f","focus":"#111312","link":"#111312","ln-sil":"#111312e6","ln-face":"#111312c7","ln-fold":"#11131273","ln-detail":"#11131247","ln-wire":"#1113129e","m-plinth":"#ffffff","m-plinth-l":"#e8e8e8","m-plinth-f":"#d1d1d1","m-neutral":"#e5e6e4","m-neutral-l":"#cecfcd","m-neutral-f":"#b8b9b7","m-pcb-own":"#3e6aa4","m-pcb-own-l":"#2a568e","m-pcb-own-f":"#164278","m-pcb-green":"#397054","m-pcb-green-l":"#245c41","m-pcb-green-f":"#0c482f","m-pcb-black":"#40454c","m-pcb-black-l":"#2e3339","m-pcb-black-f":"#1d2228","m-pcb-red":"#914743","m-pcb-red-l":"#7b3330","m-pcb-red-f":"#651f1e","m-gold":"#deb866","m-gold-l":"#c7a24f","m-gold-f":"#b18c38","m-silk":"#f2f2ef","m-silk-l":"#dbdbd8","m-silk-f":"#c4c4c1","m-ic":"#262a28","m-ic-l":"#161918","m-ic-f":"#070a08","m-alu":"#dee2e5","m-alu-l":"#c7cbce","m-alu-f":"#b1b5b8","m-graphite":"#3a3d41","m-graphite-l":"#282b2f","m-graphite-f":"#181a1e","m-plastic-white":"#e4e3df","m-plastic-white-l":"#cdccc8","m-plastic-white-f":"#b7b6b2","m-cream":"#f0e7d6","m-cream-l":"#d9d0bf","m-cream-f":"#c2baa9","m-xt-yellow":"#e1c15d","m-xt-yellow-l":"#caab45","m-xt-yellow-f":"#b4952b","m-print-blue":"#6689b3","m-print-blue-l":"#52749d","m-print-blue-f":"#3e6087","m-copper":"#b97c52","m-copper-l":"#a2673d","m-copper-f":"#8c5329","m-fr4-edge":"#cbc9a8","m-fr4-edge-l":"#b5b392","m-fr4-edge-f":"#9f9d7d","m-mannequin":"#d6d0c9","m-mannequin-l":"#bfbab3","m-mannequin-f":"#a9a49d","m-passive":"#c9b28c","m-passive-l":"#b39c77","m-passive-f":"#9d8762","m-glass":"#17262e","m-glass-l":"#07161d","m-glass-f":"#00070d","m-screen":"#0f1211","m-screen-l":"#030504","m-screen-f":"#000000","m-led-r":"#c35045","m-led-r-l":"#ab3a31","m-led-r-f":"#93221d","m-led-g":"#2a904b","m-led-g-l":"#027b37","m-led-g-f":"#006623","m-led-b":"#2e69b2","m-led-b-l":"#17549b","m-led-b-f":"#004085","f-top":"#e5e6e4","f-left":"#cecfcd","f-front":"#b8b9b7","f-dark":"#262a28","hero-t":"#40a8b4","hero-f":"#00606b","hero-glow":"#00838f59","log-d":"#ff85cb","log-i":"#4fdded","log-p":"#8be36a","log-w":"#ffd84d","log-e":"#ff8a7a","space-1":"4px","space-2":"8px","space-3":"12px","space-4":"16px","space-6":"24px","space-8":"32px","space-12":"48px","space-16":"64px","radius-none":"0","chamfer":"8px","stroke":"1px","stroke-strong":"2px","duration-fast":"80ms","t-press":"120ms","duration-base":"160ms","measure-prose":"40em","measure-code":"100ch","measure-page":"1200px","size-control":"36px","size-target":"32px","size-nav":"56px","font-sans":"system-ui, -apple-system, \"PingFang SC\", \"Hiragino Sans GB\", \"Microsoft YaHei UI\", \"Microsoft YaHei\", \"Noto Sans CJK SC\", \"Source Han Sans SC\", sans-serif","font-mono":"ui-monospace, \"SF Mono\", \"Cascadia Mono\", \"JetBrains Mono\", Consolas, \"Noto Sans Mono CJK SC\", monospace"},"dark":{"paper":"#0c0e0d","paper-raised":"#151816","paper-sunken":"#070908","line":"#2a2e2c","line-strong":"#6f7672","ink":"#e6e8e6","ink-muted":"#a3a9a5","on-ink":"#0c0e0d","ch0":"#ffd84d","ch1":"#4fdded","ch2":"#ff85cb","ch3":"#8be36a","pass":"#5bd68a","fail":"#ff8a7a","blocked":"#f0b54a","hero":"#4fdded","focus":"#e6e8e6","link":"#e6e8e6","ln-sil":"#e6e8e68c","ln-face":"#e6e8e675","ln-fold":"#e6e8e638","ln-detail":"#e6e8e629","ln-wire":"#e6e8e680","m-plinth":"#151816","m-plinth-l":"#0a0d0b","m-plinth-f":"#040604","m-neutral":"#464b48","m-neutral-l":"#393e3b","m-neutral-f":"#2f3331","m-pcb-own":"#2c4e7b","m-pcb-own-l":"#1f406c","m-pcb-own-f":"#143560","m-pcb-green":"#28523c","m-pcb-green-l":"#1a442f","m-pcb-green-f":"#0e3a25","m-pcb-black":"#32363b","m-pcb-black-l":"#26292e","m-pcb-black-f":"#1c2024","m-pcb-red":"#6c3531","m-pcb-red-l":"#5d2824","m-pcb-red-f":"#511d1a","m-gold":"#b89a5a","m-gold-l":"#a88b4b","m-gold-f":"#9c7f3f","m-silk":"#d1d1ce","m-silk-l":"#c1c1be","m-silk-f":"#b4b4b1","m-ic":"#1b1e1c","m-ic-l":"#101311","m-ic-f":"#080a08","m-alu":"#6b6f73","m-alu-l":"#5d6165","m-alu-f":"#525659","m-graphite":"#3a3e43","m-graphite-l":"#2d3136","m-graphite-f":"#24272c","m-plastic-white":"#484845","m-plastic-white-l":"#3b3b38","m-plastic-white-f":"#31312e","m-cream":"#b1aa9c","m-cream-l":"#a19b8d","m-cream-f":"#958e81","m-xt-yellow":"#b69c4b","m-xt-yellow-l":"#a68d3b","m-xt-yellow-f":"#9a802d","m-print-blue":"#496588","m-print-blue-l":"#3b5779","m-print-blue-f":"#314c6d","m-copper":"#936240","m-copper-l":"#845432","m-copper-f":"#774927","m-fr4-edge":"#898870","m-fr4-edge-l":"#7a7962","m-fr4-edge-f":"#6f6e56","m-mannequin":"#5c5752","m-mannequin-l":"#4e4945","m-mannequin-f":"#433f3a","m-passive":"#8e7b5e","m-passive-l":"#7f6c50","m-passive-f":"#736145","m-glass":"#111c22","m-glass-l":"#061116","m-glass-f":"#02080d","m-screen":"#0f1211","m-screen-l":"#050807","m-screen-f":"#020302","m-led-r":"#c65a4f","m-led-r-l":"#b54b41","m-led-r-f":"#a73e35","m-led-g":"#3b9555","m-led-g-l":"#298647","m-led-g-f":"#187a3b","m-led-b":"#467cc0","m-led-b-l":"#376db0","m-led-b-f":"#2c61a3","f-top":"#464b48","f-left":"#393e3b","f-front":"#2f3331","f-dark":"#1b1e1c","hero-t":"#7dffff","hero-f":"#02b6c6","hero-glow":"#4fdded59","log-d":"#ff85cb","log-i":"#4fdded","log-p":"#8be36a","log-w":"#ffd84d","log-e":"#ff8a7a","space-1":"4px","space-2":"8px","space-3":"12px","space-4":"16px","space-6":"24px","space-8":"32px","space-12":"48px","space-16":"64px","radius-none":"0","chamfer":"8px","stroke":"1px","stroke-strong":"2px","duration-fast":"80ms","t-press":"120ms","duration-base":"160ms","measure-prose":"40em","measure-code":"100ch","measure-page":"1200px","size-control":"36px","size-target":"32px","size-nav":"56px","font-sans":"system-ui, -apple-system, \"PingFang SC\", \"Hiragino Sans GB\", \"Microsoft YaHei UI\", \"Microsoft YaHei\", \"Noto Sans CJK SC\", \"Source Han Sans SC\", sans-serif","font-mono":"ui-monospace, \"SF Mono\", \"Cascadia Mono\", \"JetBrains Mono\", Consolas, \"Noto Sans Mono CJK SC\", monospace"}}; export const ANCHORS = {"arm.base":[0.0,120.0,0.0],"armmat.ring":[-440.0,-16.0,6.0],"armmat.c":[-300.0,-15.0,6.0],"arm.panel":[-110.3,-26.0,84.0],"arm.led":[-110.3,46.0,62.0],"arm.plug":[0.0,123.5,28.0],"arm.o":[0.0,0.0,0.0],"arm.S":[0.0,0.0,316.0],"arm.j2":[0.0,84.0,316.0],"arm.j3":[-187.78862511435634,60.0,669.1790371435707],"arm.j4":[-511.1478406547085,28.0,564.1132590560885],"arm.grip":[-511.1478406547085,-16.0,344.1132590560885],"arm.top":[-187.78862511435634,0.0,757.1790371435707],"arm.back":[130.0,-130.0,0.0],"arm.front":[-500.0,200.0,0.0],"arm.envL":[-600.0,-60.0,240.0],"arm.envT":[-200.0,60.0,810.0]}; export const ARM_REST = {"q": [35, 62, -80, -72], "grip": 20}; export const ARM_K = 0.55; diff --git a/src/css/xrstyle-reading.css b/src/css/xrstyle-reading.css index 32f697a..bc17a4d 100644 --- a/src/css/xrstyle-reading.css +++ b/src/css/xrstyle-reading.css @@ -101,7 +101,7 @@ html.is-theme-transitioning *::after { .xr-progress-circle circle { fill: none; stroke-width: 3.5; - stroke-linecap: round; + stroke-linecap: butt; } .xr-progress-circle__track { @@ -147,8 +147,9 @@ html.is-theme-transitioning *::after { opacity: 0; transform: translateY(0.5rem); visibility: hidden; - transition: opacity 200ms ease, transform 200ms ease, visibility 200ms, - background-color 200ms ease, color 200ms ease, border-color 200ms ease; + transition: opacity var(--duration-base) ease-out, transform var(--duration-base) ease-out, + visibility var(--duration-base), background-color var(--duration-fast) linear, + color var(--duration-fast) linear, border-color var(--duration-fast) linear; } .xr-top-btn--show { @@ -175,12 +176,12 @@ html.is-theme-transitioning *::after { display: flex; align-items: center; justify-content: center; - transition: transform 200ms ease-out, opacity 200ms ease-out; + transition: transform var(--duration-base) ease-out, opacity var(--duration-base) ease-out; } .xr-top-btn__label { font-family: var(--font-mono); - font-size: 0.8rem; + font-size: var(--type-label-size); font-weight: 700; opacity: 0; transform: translateY(8px); @@ -232,22 +233,24 @@ html.is-theme-transitioning *::after { opacity: 1; } -/* Blockquote: a 3px accent bar (round-cornered) on a sunken panel. */ +/* Blockquote: a 3px ink-muted bar on a sunken panel. */ .markdown blockquote { padding: var(--space-3) var(--space-4); background-color: color-mix(in oklch, var(--paper-sunken) 60%, transparent); border-left: 3px solid var(--ink-muted); - border-radius: 3px; } -/* Tables: one outer frame, hairline row rules, no double borders. Infima's - * block display + overflow:auto stays, so wide tables still scroll inside - * the rounded frame. */ +/* Tables: one outer frame, hairline row rules, no double borders, tabular + * figures so the perf tables line up. Infima's block display + overflow:auto + * stays, so wide tables still scroll inside the frame; fit-content keeps the + * frame on the columns instead of the full text width. */ .markdown table { + width: fit-content; + max-width: 100%; border-collapse: separate; border-spacing: 0; border: var(--stroke) solid var(--line); - border-radius: 4px; + font-variant-numeric: tabular-nums; } .markdown table :is(th, td) { @@ -271,17 +274,16 @@ html.is-theme-transitioning *::after { .markdown :not(pre) > code { background-color: var(--paper-sunken); border: var(--stroke) solid var(--line); - border-radius: 3px; padding: 0.15em 0.4em; font-size: 0.875em; } -/* Theme-aware images: the intro-page logo PNG is ink-on-transparent, which - * disappears on the dark card (the md file keeps its plain image syntax; match by filename — - * Docusaurus rewrites markdown image URLs to hashed /assets/images paths). - * Inverting in the dark theme turns the ink strokes white (paper variant). */ -html[data-theme='dark'] .markdown img[src*='XRobot'] { - filter: invert(1); +/* The intro-page wordmark (ThemedImage: ink file on light, paper file on dark) + * keeps its clear space instead of the figure frame below. */ +.markdown img.xr-doc-logo { + margin: var(--space-6) 0; + border: 0; + background: none; } /* Links: the underline is a half-strength accent, full strength on hover. @@ -295,21 +297,15 @@ html[data-theme='dark'] .markdown img[src*='XRobot'] { text-decoration-color: var(--ink); } -/* hr fades out at both ends (Infima's border:0/height stay in charge). */ +/* hr: a plain hairline (Infima's border:0/height stay in charge). */ .markdown hr { - background: linear-gradient( - 90deg, - transparent, - var(--line-strong) 18%, - var(--line-strong) 82%, - transparent - ); + background: var(--line); } -/* Figures get a hairline frame and a small radius (site emoji stay bare). */ -.markdown img:not(.emoji) { +/* Figures get a hairline frame on a raised ground (site emoji stay bare). */ +.markdown img:not(.emoji, .xr-doc-logo) { border: var(--stroke) solid var(--line); - border-radius: 2px; + background: var(--paper-raised); } /* Breadcrumbs and the prev/next cards pick up a quiet accent on hover. */ @@ -329,14 +325,14 @@ html[data-theme='dark'] .markdown img[src*='XRobot'] { /* ========================================================================== g2) Current-page indication: sidebar, TOC, breadcrumbs. The active state - is marked by a left indicator bar, weight and a tinted background, not by hue. + is marked by a left indicator bar, bold weight and a sunken background, not by hue. ========================================================================== */ /* Exact current page: sunken background + ink bar on the left edge. */ .theme-doc-sidebar-container .menu__link--active:not(.menu__link--sublist) { position: relative; color: var(--ink); - font-weight: 650; + font-weight: 700; background: var(--paper-sunken); } @@ -353,19 +349,19 @@ html[data-theme='dark'] .markdown img[src*='XRobot'] { /* Category whose section contains the current page: bold ink text. */ .sidebar .menu__link--sublist.menu__link--active { color: var(--ink); - font-weight: 650; + font-weight: 700; } /* Right TOC: the heading of the section on screen. */ .table-of-contents .table-of-contents__link--active { color: var(--ink); - font-weight: 650; + font-weight: 700; } /* Breadcrumb tail = current page. */ .breadcrumbs__item--active .breadcrumbs__link { color: var(--ink); - font-weight: 650; + font-weight: 700; } /* ========================================================================== @@ -398,8 +394,8 @@ html[data-motion='off'].is-theme-transitioning *::after { } /* ========================================================================== - i) Long-code folding (>15 lines): 8 preview lines + fade gradient + a - toggle button at the bottom centre. + i) Long-code folding (>15 lines): 8 preview lines, cut by a solid band + with a hairline on top, and a toggle button centred in the band. The React CodeBlock wrapper renders: