Skip to content

feat(apollo-wind): expose --apollo-wind-version CSS variable#939

Draft
david-rios-uipath wants to merge 1 commit into
mainfrom
wind-version-css-var
Draft

feat(apollo-wind): expose --apollo-wind-version CSS variable#939
david-rios-uipath wants to merge 1 commit into
mainfrom
wind-version-css-var

Conversation

@david-rios-uipath

Copy link
Copy Markdown
Contributor

Summary

Adds a --apollo-wind-version CSS custom property to the apollo-wind stylesheet, carrying the current package version (e.g. "2.29.0"). Consumers can read it at runtime to detect both that apollo-wind's styles are loaded and which version is present.

Motivation: traceview-ui#413 auto-injects traceview's utility sheet in light-DOM hosts, gated on detecting whether apollo-wind is loaded. The reviewer noted the token being probed is too generic (easy to get a false positive, and no way to check version matching) and suggested a dedicated --apollo-wind-version token. This adds it.

How it stays in sync

package.json is the single source of truth. scripts/generate-version-css.mjs reads the version and regenerates src/styles/version.generated.css, and it runs as the first step of build — so the published token can never drift from the released version (semantic-release bumps package.json before the build/publish step).

The generated file is committed as well, because the source CSS (tailwind.consumer.css) is imported directly by Storybook and by apollo-react's canvas styles, which don't run the build script. A vitest guard (version.test.ts) fails if the committed value drifts from package.json.

Where it lands

  • dist/styles.css (precompiled sheet consumers import) — token inlined by the Tailwind CLI ✅
  • dist/tailwind.css (source-style export) — @import "./version.generated.css", with the file copied to dist/ via rslib ✅

Changes

  • scripts/generate-version-css.mjs — generator (reads package.jsonversion.generated.css)
  • src/styles/version.generated.css — generated token file (committed, auto-regenerated on build)
  • src/styles/tailwind.consumer.css@import "./version.generated.css"
  • rslib.config.ts — copy the generated file into dist
  • package.json — run the generator as the first build step
  • src/styles/version.test.ts — drift/presence guard

Consumer usage

const version = getComputedStyle(document.documentElement)
  .getPropertyValue('--apollo-wind-version')
  .trim()
  .replace(/^"|"$/g, '');
// "" → apollo-wind styles not loaded; else the loaded version

Test plan

  • pnpm build — token present in dist/styles.css and generated file copied to dist/
  • vitest run src/styles/version.test.ts passes
  • biome clean on new files
  • Coordinate the follow-up traceview-ui#413 change to probe this token

🤖 Generated with Claude Code

Adds a `--apollo-wind-version` CSS custom property to the Wind stylesheet
so consumers can detect at runtime both that apollo-wind's styles are
loaded and which version is present. Motivated by traceview-ui#413, where
a dedicated, non-generic token is needed to reliably probe for the sheet
(and enable version-matching) instead of reusing a common token.

The value is generated from package.json by scripts/generate-version-css.mjs
as the first step of `build`, so package.json remains the single source of
truth and the published token can never drift from the released version. The
generated file is committed as well because the source CSS is imported
directly by Storybook and apollo-react's canvas styles, which don't run the
build script. A vitest guard fails if the committed value drifts from
package.json.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 20, 2026 18:17
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (PT)
apollo-design 🟢 Ready Preview, Logs Jul 20, 2026, 11:24:02 AM
apollo-docs 🟢 Ready Preview, Logs Jul 20, 2026, 11:24:02 AM
apollo-landing 🟢 Ready Preview, Logs Jul 20, 2026, 11:24:02 AM
apollo-vertex 🟢 Ready Preview, Logs Jul 20, 2026, 11:24:02 AM

@github-actions

Copy link
Copy Markdown
Contributor

Dependency License Review

  • 1950 package(s) scanned
  • ✅ No license issues found
  • ⚠️ 2 package(s) excluded (see details below)
License distribution
License Packages
MIT 1720
ISC 89
Apache-2.0 55
BSD-3-Clause 27
BSD-2-Clause 23
BlueOak-1.0.0 8
MPL-2.0 4
MIT-0 3
CC0-1.0 3
MIT OR Apache-2.0 2
(MIT OR Apache-2.0) 2
Unlicense 2
LGPL-3.0-or-later 1
Python-2.0 1
CC-BY-4.0 1
(MPL-2.0 OR Apache-2.0) 1
Unknown 1
Artistic-2.0 1
(WTFPL OR MIT) 1
(BSD-2-Clause OR MIT OR Apache-2.0) 1
CC-BY-3.0 1
0BSD 1
(MIT OR CC0-1.0) 1
MIT AND ISC 1
Excluded packages
Package Version License Reason
@img/sharp-libvips-linux-x64 1.2.4 LGPL-3.0-or-later LGPL pre-built binary, not linked
khroma 2.1.0 Unknown MIT per GitHub repo, missing license field in package.json

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a dedicated --apollo-wind-version CSS custom property to @uipath/apollo-wind so consumers can reliably detect that Wind styles are loaded and which version is present at runtime. This fits the design system’s distribution model by embedding a lightweight “presence + version” marker directly into the exported stylesheet(s).

Changes:

  • Introduces a build-time generator that renders src/styles/version.generated.css from package.json’s version.
  • Imports the generated CSS into the consumer Tailwind entrypoint and ensures it’s copied into dist/.
  • Adds a Vitest guard to ensure the committed generated CSS matches package.json (prevents drift).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/apollo-wind/src/styles/version.test.ts Adds a Vitest drift/presence test for the generated --apollo-wind-version token.
packages/apollo-wind/src/styles/version.generated.css Adds the committed, generated stylesheet defining --apollo-wind-version.
packages/apollo-wind/src/styles/tailwind.consumer.css Imports version.generated.css so the token ships with the source-style export.
packages/apollo-wind/scripts/generate-version-css.mjs Adds the generator script (reads package.json → writes version.generated.css).
packages/apollo-wind/rslib.config.ts Copies version.generated.css into dist/ alongside other CSS dependencies.
packages/apollo-wind/package.json Runs the generator as the first step of build to keep published output in sync.

Comment on lines +1 to +10
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { describe, expect, it } from 'vitest';

import { renderVersionCss } from '../../scripts/generate-version-css.mjs';

const packageRoot = resolve(__dirname, '../..');
const version = JSON.parse(readFileSync(resolve(packageRoot, 'package.json'), 'utf8'))
.version as string;
const generatedCss = readFileSync(resolve(packageRoot, 'src/styles/version.generated.css'), 'utf8');
Comment on lines +45 to +50
// Run when invoked directly (e.g. `node scripts/generate-version-css.mjs`),
// but not when imported by a test.
if (import.meta.url === `file://${process.argv[1]}`) {
const version = generateVersionCss();
console.log(`Wrote --apollo-wind-version: "${version}" to src/styles/version.generated.css`);
}
@github-actions

Copy link
Copy Markdown
Contributor

📊 Coverage + size by package

Per-package coverage and bundle size on this PR. New-line coverage = of the source lines this PR adds or changes, the % hit by tests.

Package Coverage New-line coverage Packed (gzip) Unpacked vs main
@uipath/apollo-core 9.0% 43.82 MB 57.31 MB ±0
@uipath/apollo-react 37.3% 7.38 MB 28.15 MB +22 B
@uipath/apollo-wind 41.0% — (2 untracked) 397.7 KB 2.58 MB +239 B
@uipath/ap-chat 85.8% 43.43 MB 55.92 MB ±0

"Coverage" is each package's own coverage.include scope (e.g. apollo-core instruments only scripts/). "Packed"/"Unpacked" come from npm pack --dry-run and only cover built packages — "—" means not measured this run (package not affected / not built). "vs main" is the packed (gzipped) delta against the last successful main build (the package-sizes artifact from the Release workflow); "—" there means no main baseline was available this run. The baseline is main's latest build, not this PR's exact merge-base, so it includes any drift since the branch diverged. Packages with no vitest config are omitted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:apollo-wind size:M 30-99 changed lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants