diff --git a/.changelog/6052-fix-css-modules-small-components.md b/.changelog/6052-fix-css-modules-small-components.md new file mode 100644 index 0000000000..ad66e2e40a --- /dev/null +++ b/.changelog/6052-fix-css-modules-small-components.md @@ -0,0 +1,3 @@ +### Changed + +- Converted the screen reader text, live region activity, fixed-width image and send failed retry link to CSS Modules with `webchat__` class names; in the Fluent theme, the send failed retry link now uses Fluent's accent color, in PR [#6052](https://github.com/microsoft/BotFramework-WebChat/pull/6052), by [@OEvgeny](https://github.com/OEvgeny) diff --git a/__tests__/html2/activityStatus/sendFailedRetry.accent.html b/__tests__/html2/activityStatus/sendFailedRetry.accent.html new file mode 100644 index 0000000000..ab7223d650 --- /dev/null +++ b/__tests__/html2/activityStatus/sendFailedRetry.accent.html @@ -0,0 +1,71 @@ + + +
+ + + + + + + + diff --git a/__tests__/html2/activityStatus/sendFailedRetry.accent.html.snap-1.png b/__tests__/html2/activityStatus/sendFailedRetry.accent.html.snap-1.png new file mode 100644 index 0000000000..8ab09bc90b Binary files /dev/null and b/__tests__/html2/activityStatus/sendFailedRetry.accent.html.snap-1.png differ diff --git a/__tests__/html2/activityStatus/sendFailedRetry.accent.html.snap-2.png b/__tests__/html2/activityStatus/sendFailedRetry.accent.html.snap-2.png new file mode 100644 index 0000000000..1b0e139ef9 Binary files /dev/null and b/__tests__/html2/activityStatus/sendFailedRetry.accent.html.snap-2.png differ diff --git a/packages/component/src/LiveRegion/LiveRegionActivity.module.css b/packages/component/src/LiveRegion/LiveRegionActivity.module.css new file mode 100644 index 0000000000..9fdb56c3e5 --- /dev/null +++ b/packages/component/src/LiveRegion/LiveRegionActivity.module.css @@ -0,0 +1,10 @@ +:global(.webchat) .live-region-activity { + color: transparent; + height: 1px; + opacity: 0; + overflow: hidden; + position: absolute; + top: 0; + white-space: nowrap; + width: 1px; +} diff --git a/packages/component/src/LiveRegion/LiveRegionActivity.tsx b/packages/component/src/LiveRegion/LiveRegionActivity.tsx index 2a0f235748..8115a85c92 100644 --- a/packages/component/src/LiveRegion/LiveRegionActivity.tsx +++ b/packages/component/src/LiveRegion/LiveRegionActivity.tsx @@ -1,30 +1,17 @@ /* eslint no-magic-numbers: ["error", { "ignore": [2] }] */ import { validateProps, type InferReactProps } from '@msinternal/botframework-webchat-react-valibot'; -import classNames from 'classnames'; +import { useStyles, webChatPrefixedClassName } from '@msinternal/botframework-webchat-styles/react'; import React, { Fragment, useMemo } from 'react'; import { any, object, pipe, readonly } from 'valibot'; -import { useStyleToEmotionObject } from '../hooks/internal/styleToEmotionObject'; import useLocalizeActivityGreetingAlt from '../hooks/internal/useLocalizeActivityGreetingAlt.js'; import useRenderMarkdownAsHTML from '../hooks/useRenderMarkdownAsHTML'; import activityAltText from '../Utils/activityAltText'; +import styles from './LiveRegionActivity.module.css'; import LiveRegionAttachments from './private/LiveRegionAttachments'; import LiveRegionSuggestedActions from './private/LiveRegionSuggestedActions'; -const ROOT_STYLE = { - '&.webchat__live-region-activity': { - color: 'transparent', - height: 1, - opacity: 0, - overflow: 'hidden', - position: 'absolute', - top: 0, - whiteSpace: 'nowrap', - width: 1 - } -}; - const liveRegionActivityPropsSchema = pipe( object({ activity: any() @@ -41,8 +28,8 @@ function LiveRegionActivity(props: LiveRegionActivityProps) { const fallbackText: string | undefined = type === 'message' ? activity.channelData['webchat:fallback-text'] : undefined; const [greetingAlt] = useLocalizeActivityGreetingAlt()(activity); + const classNames = useStyles(styles, webChatPrefixedClassName); const renderMarkdownAsHTML = useRenderMarkdownAsHTML('accessible name'); - const rootClassName = useStyleToEmotionObject()(ROOT_STYLE) + ''; const textAlt = useMemo(() => activityAltText(activity, renderMarkdownAsHTML), [activity, renderMarkdownAsHTML]); const validFallbackText = fallbackText && typeof fallbackText === 'string'; @@ -50,7 +37,7 @@ function LiveRegionActivity(props: LiveRegionActivityProps) { // Lines are `role="none"`: on Windows, generic `` are exposed as "group", screen readers would read "group" before each line. // The message itself stays in the accessibility tree, as required by `aria-atomic`. return ( -