AuroDocsSite Token/WCSS Loading Compliance #643
jordanjones243
started this conversation in
Technical Research Documents
Replies: 1 comment
|
This TRD looks great and covers all the aspects I can think of. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
auro-formkittest/dev harness1. Context
Released versions of design-tokens and WCSS are hand-copied into Content Stack before Test/QA/Prod
actually consume them. As a result, the deployed environments can lag behind what Design has published on
npm/CDN — there may be token versions on
@latestthat are not yet live in Test/QA/Prod.For pre-release theme testing to be meaningful, the docsite (and the component repos' localhost and test
environments) must run against the same token/WCSS version that is actually deployed — i.e., the version
installed as a dev dependency in the repo. They must never fetch tokens/WCSS from a CDN
@latestURL, because
@latestcan resolve to a version that is not yet in the target environment, so localresults would not match what ships.
The problem is therefore about how tokens are loaded per environment, not which token names the CSS
uses. The
auro-formkitrepo already follows the correct pattern and is the reference (see §4).Acceptance Criteria
Definition of "theme compliant" for this ticket: the environment renders using the installed
dev-dependency versions of DesignTokens and WebCoreStylesheets, with zero CDN references. This is a
loading guarantee — it is not a statement about which token names the CSS uses or whether every surface
re-themes.
Two consequences for scope:
@latest. Every CDN URL for DesignTokens /WebCoreStylesheets must be removed, including the ones currently pinned to the installed version
(§2.4). The only acceptable source is the installed dev dependency.
docsite. This TRD delivers the docsite target; localhost and test live in the individual
component repos and are tracked separately (§5), using the FormKit harness as the template.
2. Current State
The docsite is a hybrid: the main site loads tokens/WCSS from the installed dev dependency, but the
typography section fetches them from CDN
@latest.2.1 Already correct — served from the installed dev dependency
The Vite plugin
copyDepFiles(vite.config.js) serves/tokens/*fromnode_modules/@aurodesignsystem/design-tokens/distand/styles/*fromnode_modules/@aurodesignsystem/webcorestylesheets/distin dev, and copies them intodist/on build.These consumers use it correctly:
index.html— links/tokens/web/alaska.min.cssand/styles/bundled/themes/alaska.global.min.css.src/components/header/ThemeSwitcher.js— swaps/tokens/web/{theme}.min.cssand/styles/bundled/themes/{theme}.global.min.css(installed versions).src/App.js— imports token CSS directly fromnode_modules.2.2 Violations — CDN
@latestfetches (runtime)The typography preview path fetches from CDN
@latest, so it can render against tokens/WCSS that are notdeployed:
@latestsrc/config/themes.jsCDN_URL+webcorestylesheets@latest/dist/bundled/themes(WCSS_THEME_PATH, used bygetThemeCssUrl)src/content/dynamic/typography/ThemedPreviewFrame.jsdesign-tokens@latest/.../CSSCustomProperties--bundled.csswebcorestylesheets@latest/dist/elementDemoStyles.cssauro-header@latest/dist/auro-header__bundled.jsThemedPreviewFramerenders inside an<iframe>and injects these links/scripts into it, plus the WCSStheme URL from
config/themes.js(getThemeCssUrl). All resolve to@latest.2.3 Displayed code samples that teach
@latest(documentation quality)src/content/dynamic/typography/overview.js(lines 93–94, 136–137) shows<link … webcorestylesheets@latest …>/design-tokens@latestinside<pre><code>blocks. These are not runtime loads, but theydocument the wrong pattern to consumers and should be corrected for consistency.
2.4 Pinned-version CDN fallbacks (in scope — AC forbids any CDN reference)
renderComponentPage.js(lines 175, 231) andrenderFormkitComponentPage.js(lines 168, 210) buildcdn.jsdelivr.net/...@{installedVersion}URLs for demo markdown and acustom-{name}bundle. They arepinned to the installed version (not
@latest) and largely dead — component pages setmarkdownContentvia a local
import, andregisterCustomComponentis a no-op (never assigns.src). Even so, the AC("no CDN reference in any case") requires their removal.
2.5 Other CDN references (decision needed)
index.html(line 76) loads the@webcomponents/webcomponentsjspolyfill fromunpkg.com(pinned@2).It is not DesignTokens/WCSS, so it is outside the AC's literal subject — but "no CDN reference in any
case" may be intended literally. Flag for a decision: leave as-is, or vendor it from the installed
dependency. The
auro-header@latestscript in §2.2 is a component (not tokens/WCSS) but is on@latestand must be addressed regardless.
3. Proposed Work
ThemedPreviewFrame.jsandconfig/themes.js, replace the@latestCDN URLs with the locally-served paths already provided by thecopyDepFilesplugin (/tokens/...,/styles/...) or directnode_modulesimports. Covers the tokensbundle, WCSS theme CSS, and
elementDemoStyles. (~1 day.)auro-headerin the iframe from the installed package rather than theauro-header@latestCDN script (the component is already a dev dependency and registered in the main document; the iframe
needs it defined in its own context). (~0.5 day — iframe custom-element registration is the fiddly part.)
renderComponentPage.js/renderFormkitComponentPage.js(and the no-op
registerCustomComponent) — required by the AC, not optional. (~0.25 day.)overview.jscode samples to show the installed-dependency pattern instead of@latest.(~0.25 day.)
unpkgwebcomponentsjs polyfill (§2.5); confirm whether theAC's "no CDN in any case" applies and vendor from the installed dependency if so. (~0.25 day if in scope.)
vite buildships local/tokensand/stylesin
dist/, and add a CI check (grep/lint) that fails on anycdn.jsdelivr.net/unpkg.comURLreferencing
design-tokensorwebcorestylesheetsinsrc— not just@latest. (~0.5 day.)testscript is ano-op (
echo "No tests specified" && exit 0) — so theme/visual regression is necessarily manual.The credible automated gate is the CI grep guard from step 6 (fails the build on any CDN token/WCSS
URL); pair it with a manual pass over the typography preview and the switcher across themes. (~0.5 day
manual; establishing real visual-regression coverage is a larger, separate effort.)
Total: ~2–3 days for the docsite loading fix. No per-component docsite changes are required; the change
is confined to the typography path plus shared build/config. Standing up automated visual-regression testing
is explicitly not included and would be a separate effort.
4. Reference Implementation (
auro-formkit)FormKit pins tokens/WCSS to the installed dev dependency in its test/dev harness — the pattern to mirror:
packages/config/src/web-test-runner.config.mjs(and…-global.mjs) inject:packages/config/src/demo-styles.scssimports WCSS from the installed package(
@aurodesignsystem/webcorestylesheets/dist/...), not a CDN.The docsite's equivalent of "serve from
node_modules" is the existingcopyDepFilesVite plugin; the fixis to route the typography path through it instead of CDN
@latest.5. Related / Out of Scope
installed-dev-dependency loading. That work lives in each component repo, not this one — track separately,
using the FormKit harness as the template. This TRD covers the docsite only.
rendering-content-sdk(strategic follow-up). Once this fix lands, the docsite couldadopt the Content team's rendering SDK so tokens load the same way production actually resolves them,
rather than the docsite maintaining its own local-serving mechanism. Tracked under
ADO #1603135. A longer-term
alignment, not required to satisfy this ticket's AC.
Future theming improvements (not this ticket)
A few adjacent items worth a follow-up:
(the themed files expose
--ds-basic-color/--ds-advanced-colorseparately from--ds-basic-type).The theme switcher should offer the same choice — apply an entire theme, just the colors, or just the
type.
ThemeSwitcherswaps:roottoken files but never sets adata-aag-themeattribute or swaps the typography type classes (classes.{theme}.css), so type stylesdo not currently re-theme on switch. (This is a prerequisite for the type-only option above.)
:rootfile-swap and the typography preview's attribute model — that could be unified to prevent drift.
6. Appendix — key files
vite.config.js(copyDepFiles)index.html,src/components/header/ThemeSwitcher.js,src/App.js@latestviolations (fix target)src/config/themes.js,src/content/dynamic/typography/ThemedPreviewFrame.js@latestin displayed code samplessrc/content/dynamic/typography/overview.jssrc/functions/renderComponentPage.js,renderFormkitComponentPage.js,src/content/utils/registerCustomComponent.jsindex.html(unpkg webcomponentsjs polyfill)auro-formkit/packages/config/src/web-test-runner.config.mjs,demo-styles.scssAll reactions