Skip to content

Stylelint coverage for Lit + Vue; retire raw hex from web components#13110

Closed
lokesh wants to merge 2 commits into
internetarchive:masterfrom
lokesh:design/feat/style-enforcement
Closed

Stylelint coverage for Lit + Vue; retire raw hex from web components#13110
lokesh wants to merge 2 commits into
internetarchive:masterfrom
lokesh:design/feat/style-enforcement

Conversation

@lokesh

@lokesh lokesh commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Stylelint coverage for Lit + Vue; retire raw hex from web components

Final PR of the visual modernization series. Stacked on #13102 only (the color tokens) — independent of the page-by-page PRs (#13103#13109) and can land in parallel with them.

What changes

1. Enforcement — stylelint previously saw only .css files, so the Lit CSS-in-JS layer (26 raw hex) and Vue SFCs drifted unchecked:

  • Lit components (openlibrary/components/lit/*.js) are linted with customSyntax: postcss-lit under the full rule set.
  • Vue SFCs start with color-no-hex/color-named via postcss-html, scoped to ObservationForm/** (now clean). LibraryExplorer/MergeUI/BulkSearch carry ~120 pre-existing literals and are explicitly out of redesign scope — their glob joins the override once cleaned, ratchet-style.
  • devDeps: postcss-lit, postcss-html (compatible with stylelint 16). lint:css/lint-fix:css globs extended.

2. Lit hex retirement (tokens inherit through the shadow boundary, so fallbacks are unnecessary):

  • OlCarousel arrow/indicator fallbacks → --color-text / --color-surface / --neutral-300; @cssprop JSDoc updated and custom-elements.json regenerated (npx cem analyze).
  • OlPagination text/hover/disabled → semantic tokens; OLChip/OlToggle internal slots → --color-text/-muted/--color-primary.
  • OpenLibraryOTP: dialog/input/button → semantic tokens; the IA-purple #4b4bdf fallbacks → --color-primary. The --color-success/--color-danger/--link-color properties set on ia-otp-form are that component's own API — names kept, now fed --color-success-fg/--color-error-fg/--color-link.
  • Cleanups the new coverage surfaced: monospacevar(--font-family-mono) (OLMarkdownEditor), z-index literals → --z-index-level-* (relative order preserved), longhand→shorthand fixes, rule reordering.

3. OLChip.vue (ObservationForm): the duplicate Material-blue chip (#1976d2/#f6fafe) → --color-primary/--color-primary-subtle; #999--color-border; #e6e6e6--neutral-200. (Full <ol-chip> replacement stays out of scope.)

Verified

  • npm run lint (JS + extended CSS globs) clean; npx jest 495/495.
  • /developers/design component demos: pagination text, chip fg/bg, and carousel --_arrow-color/--_indicator-color slots all resolve to token values inside the shadow DOM (verified via getComputedStyle against the running dev site).
  • Intentionally near-zero visual drift: replacements map to the closest ramp step of each old literal.

🤖 Generated with Claude Code

lokesh added 2 commits July 2, 2026 15:01
…ted aliases

- Rewrite static/css/tokens/colors.css into three tiers: primitive ramps
  (warm neutrals, blue, red/green/amber), semantic tokens (--color-*,
  the dark-mode seam), and deprecated aliases that re-point every legacy
  token name so all ~2,100 existing var() consumers shift to the new
  palette with zero edits.
- Brand blues are bit-identical (--blue-500/600 == --primary-blue/--link-blue).
- Add tests/unit/js/token-contrast.test.js asserting the WCAG AA contrast
  matrix over the semantic tokens (runs in npm test).
- Add bundlesize budgets for tokens.css (6KB) and ol-components.css (8KB).
- Update docs/ai/design.md token documentation (fix nonexistent
  tokens/typography.css reference).
- Remove --beige-bright (zero consumers).
- stylelint now parses Lit components (customSyntax: postcss-lit, full
  rule set) and ObservationForm Vue SFCs (postcss-html; color-no-hex /
  color-named to start - LibraryExplorer/MergeUI join once their ~120
  legacy literals are cleaned). lint:css globs extended; devDeps
  postcss-lit + postcss-html added.
- Replace every raw hex in the Lit layer with tokens (they inherit
  through the shadow boundary): OlCarousel arrow/indicator fallbacks ->
  --color-text/--color-surface/--neutral-300 (@cssprop docs updated,
  manifest regenerated via cem analyze); OlPagination text/hover/
  disabled -> semantic tokens; OLChip + OlToggle internal slots ->
  --color-text/-muted/--color-primary; OpenLibraryOTP dialog/input/
  button -> semantic tokens, IA-purple #4b4bdf fallbacks ->
  --color-primary, and the ia-otp-form custom-property API now fed
  --color-success-fg/--color-error-fg/--color-link values.
- Auto-fixable cleanups the new coverage surfaced: monospace ->
  var(--font-family-mono) in OLMarkdownEditor, z-index literals ->
  --z-index-level-* (relative order preserved), margin-block/inset
  shorthands, rule-order fixes.
- ObservationForm: OLChip.vue Material-blue chip -> --color-primary/
  --color-primary-subtle; CardHeader/ValueCard internetarchive#999 borders ->
  --color-border; CategorySelector #505050 -> --color-text-secondary;
  SavedTags 'red' -> --color-error-fg.

Verified: /developers/design demos - pagination, chip, and carousel
color slots all resolve to token values in the shadow DOM.
@lokesh lokesh closed this Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant