diff --git a/change/@fluentui-react-a39133e5-d27c-4a7e-8493-1324e7905f01.json b/change/@fluentui-react-a39133e5-d27c-4a7e-8493-1324e7905f01.json new file mode 100644 index 00000000000000..10a3a2791f9224 --- /dev/null +++ b/change/@fluentui-react-a39133e5-d27c-4a7e-8493-1324e7905f01.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix: added border with correct contrast ratio in HC in MessageBar", + "packageName": "@fluentui/react", + "email": "vkozlova@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/packages/react/src/components/MessageBar/MessageBar.styles.ts b/packages/react/src/components/MessageBar/MessageBar.styles.ts index 2bdf67fdff79c0..5fca8a237c7bb9 100644 --- a/packages/react/src/components/MessageBar/MessageBar.styles.ts +++ b/packages/react/src/components/MessageBar/MessageBar.styles.ts @@ -1,5 +1,6 @@ import { HighContrastSelector, + HighContrastSelectorWhite, ScreenWidthMaxSmall, getScreenSelector, getGlobalClassNames, @@ -43,15 +44,6 @@ const backgroundColor: { [key: string]: keyof ISemanticColors } = { [MessageBarType.info]: 'infoBackground', }; -const highContrastBackgroundColor: { [key: string]: string } = { - [MessageBarType.error]: 'rgba(255, 0, 0, 0.3)', - [MessageBarType.blocked]: 'rgba(255, 0, 0, 0.3)', - [MessageBarType.success]: 'rgba(48, 241, 73, 0.3)', - [MessageBarType.warning]: 'rgba(255, 254, 57, 0.3)', - [MessageBarType.severeWarning]: 'rgba(255, 0, 0, 0.3)', - [MessageBarType.info]: 'Window', -}; - const iconColor: { [key: string]: keyof ISemanticColors } = { [MessageBarType.error]: 'errorIcon', [MessageBarType.blocked]: 'errorIcon', @@ -61,6 +53,24 @@ const iconColor: { [key: string]: keyof ISemanticColors } = { [MessageBarType.info]: 'infoIcon', }; +const highContrastBorderColor: { [key: string]: string } = { + [MessageBarType.error]: '#ff0000', + [MessageBarType.blocked]: '#ff0000', + [MessageBarType.success]: '#bad80a', + [MessageBarType.warning]: '#fff100', + [MessageBarType.severeWarning]: '#ff0000', + [MessageBarType.info]: 'WindowText', +}; + +const highContrastWhiteBorderColor: { [key: string]: string } = { + [MessageBarType.error]: '#e81123', + [MessageBarType.blocked]: '#e81123', + [MessageBarType.success]: '#107c10', + [MessageBarType.warning]: '#966400', + [MessageBarType.severeWarning]: '#d83b01', + [MessageBarType.info]: 'WindowText', +}; + export const getStyles = (props: IMessageBarStyleProps): IMessageBarStyles => { const { theme, @@ -130,6 +140,7 @@ export const getStyles = (props: IMessageBarStyleProps): IMessageBarStyles => { !isMultiline && truncated && classNames.expandingSingleLine, { background: semanticColors[backgroundColor[messageBarType]], + boxSizing: 'border-box', color: semanticColors.messageText, minHeight: 32, width: '100%', @@ -146,10 +157,13 @@ export const getStyles = (props: IMessageBarStyleProps): IMessageBarStyles => { }, [HighContrastSelector]: { ...getHighContrastNoAdjustStyle(), - background: highContrastBackgroundColor[messageBarType], - border: '1px solid WindowText', + background: 'transparent', + border: `1px solid ${highContrastBorderColor[messageBarType]}`, color: 'WindowText', }, + [HighContrastSelectorWhite]: { + border: `1px solid ${highContrastWhiteBorderColor[messageBarType]}`, + }, }, }, isMultiline && { diff --git a/packages/react/src/components/MessageBar/__snapshots__/MessageBar.test.tsx.snap b/packages/react/src/components/MessageBar/__snapshots__/MessageBar.test.tsx.snap index 745a3ac67ac6fb..323192151eed1f 100644 --- a/packages/react/src/components/MessageBar/__snapshots__/MessageBar.test.tsx.snap +++ b/packages/react/src/components/MessageBar/__snapshots__/MessageBar.test.tsx.snap @@ -9,6 +9,7 @@ exports[`MessageBar snapshots renders MessageBar correctly 1`] = ` -moz-osx-font-smoothing: grayscale; -webkit-font-smoothing: antialiased; background: #f3f2f1; + box-sizing: border-box; color: #323130; display: flex; flex-direction: column; @@ -27,11 +28,14 @@ exports[`MessageBar snapshots renders MessageBar correctly 1`] = ` } @media screen and (-ms-high-contrast: active), screen and (forced-colors: active){& { -ms-high-contrast-adjust: none; - background: Window; + background: transparent; border: 1px solid WindowText; color: WindowText; forced-color-adjust: none; } + @media screen and (-ms-high-contrast: black-on-white), screen and (forced-colors: active) and (prefers-color-scheme: light){& { + border: 1px solid WindowText; + } >