Skip to content

Add an internal CSS module theme context to useStyles(), shared by all packages - #5984

Merged
Eugene (OEvgeny) merged 4 commits into
mainfrom
OEvgeny/fix-css-module-theme-context
Oct 30, 2026
Merged

Eugene (OEvgeny) merged 4 commits into
mainfrom
OEvgeny/fix-css-module-theme-context

Conversation

@OEvgeny

Copy link
Copy Markdown
Collaborator

Lets a theme style CSS Modules elements without readable class names.

Changelog Entry

None: internal plumbing with no visible change, label no-changelog.

Description

Fluent can only style Web Chat elements through readable class names (:global(.bubble)). useStyles() now also adds the classes an internal <CSSModuleThemeComposer> above it provides for the same local name; without one, output is unchanged.

Design

  • Each package bundles its own copy of the styles package (own context), so bundle and Fluent now use the component's copy via internal.js, like InjectStyleElements; publishing the private package was the alternative.
  • The default useStyles transform keeps <local> <hashed>; webChatPrefixedClassName is ready for dropping plain names.

Specific Changes

  • styles/react: CSSModuleThemeContext, combineCSSModules() (concatenates, frozen), CSSModuleThemeComposer, transforms, useStyles()
  • bundle cards, Fluent: shared copy, guarded by no-restricted-imports
  • unit specs for the above; sharedStylesRuntime.spec.js: one copy in the builds
  • typed with CSSModuleTheme: published typings check with skipLibCheck: false
  • cssModuleTheme.fluent.html: snapshot 1, a composer above Fluent outlines bubbles, Adaptive Card and send box
  • I have added tests and executed them locally
  • I have added .changelog/<PR#>-<slug>.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

Eugene Olonov added 2 commits October 29, 2026 16:04
…l packages

- styles/react: CSSModuleThemeContext, combineCSSModules() (concatenates class names of the same local name),
  <CSSModuleThemeComposer> (combines its theme with the one from a composer above), and
  useStyles(styles, transform?) adding the theme classes of the same local name. The default transform keeps
  today's output ("<local name> <hashed name>"); webChatPrefixedClassName() gives "webchat__<local name>".
- One runtime copy: the styles package is bundled into every package that imports it and each copy has its own
  context. botframework-webchat-component/internal.js re-exports it (like InjectStyleElements), botframework-webchat
  re-exports that, and bundle/Fluent use it instead of their own copy (enforced by no-restricted-imports).
- Tests: unit tests for combine/useStyles/composer, a dist test for one runtime copy, and an html2 test where a
  composer above Fluent reaches component, bundle and Fluent elements.
…do not use the ambient CSSModuleClasses

The typings of botframework-webchat/internal.js referred to CSSModuleClasses, which is declared only in the styles package's env.d.ts: consumers with skipLibCheck: false got TS2304.
@OEvgeny Eugene (OEvgeny) added the no-changelog No .changelog/ fragment needed (development environment or test-only change) label Oct 30, 2026
…the styles runtime

The package does not publish its esbuild metafiles ("files" in package.json), so the test found
none in CI, where packages are unpacked from npm pack tarballs.
Comment thread packages/styles/src/react/private/classNameTransforms.ts
@OEvgeny
Eugene (OEvgeny) marked this pull request as ready for review October 30, 2026 05:59
Copilot AI balanced review requested due to automatic review settings October 30, 2026 05:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@OEvgeny
Eugene (OEvgeny) merged commit b1c6d98 into main Oct 30, 2026
45 checks passed
@OEvgeny
Eugene (OEvgeny) deleted the OEvgeny/fix-css-module-theme-context branch October 30, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog No .changelog/ fragment needed (development environment or test-only change)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants