Skip to content

Commit 2ca5f3c

Browse files
OEvgenyEugene Olonov
andauthored
Show a border around Fluent starter prompt cards in forced colors (#5954)
* Give Fluent starter prompt cards a border in forced colors * Add the changelog fragment --------- Co-authored-by: Eugene Olonov <eugeneolonov@microsoft.com>
1 parent 893c8f0 commit 2ca5f3c

10 files changed

Lines changed: 138 additions & 0 deletions
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Fixed
2+
3+
- Fixed Fluent starter prompt cards having no visible border in forced colors, in PR [#5954](https://github.com/microsoft/BotFramework-WebChat/pull/5954), by [@OEvgeny](https://github.com/OEvgeny)
782 Bytes
Loading
787 Bytes
Loading
703 Bytes
Loading
702 Bytes
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<script>
5+
location = './starterPrompts.forcedColors?fluent-theme=dark';
6+
</script>
7+
</head>
8+
<body></body>
9+
</html>
23.3 KB
Loading
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<!doctype html>
2+
<html lang="en-US">
3+
<head>
4+
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
5+
<style>
6+
.fui-FluentProvider {
7+
height: 100%;
8+
}
9+
</style>
10+
</head>
11+
<body>
12+
<main id="webchat"></main>
13+
<script type="importmap">
14+
{
15+
"imports": {
16+
"@fluentui/react-provider": "/__dist__/packages/test/test-assets/out/@fluentui/react-provider.js",
17+
"@fluentui/tokens": "/__dist__/packages/test/test-assets/out/@fluentui/tokens.js",
18+
"botframework-webchat": "/__dist__/packages/bundle/static/botframework-webchat.js",
19+
"botframework-webchat/": "/__dist__/packages/bundle/static/botframework-webchat/",
20+
"botframework-webchat-fluent-theme": "/__dist__/packages/fluent-theme/static/botframework-webchat-fluent-theme.js",
21+
"react": "/__dist__/packages/bundle/static/react.js",
22+
"react-dom": "/__dist__/packages/bundle/static/react-dom.js",
23+
"react-dom/client": "/__dist__/packages/bundle/static/react-dom/client.js",
24+
"react-jsx-runtime": "/__dist__/packages/bundle/static/react/jsx-runtime.js"
25+
}
26+
}
27+
</script>
28+
<script type="module">
29+
import '/test-harness.mjs';
30+
import '/test-page-object.mjs';
31+
32+
import { FluentProvider } from '@fluentui/react-provider';
33+
import { webDarkTheme } from '@fluentui/tokens';
34+
import { createStoreWithOptions, ReactWebChat } from 'botframework-webchat';
35+
import { FluentThemeProvider, testIds } from 'botframework-webchat-fluent-theme';
36+
import { createElement } from 'react';
37+
import { createRoot } from 'react-dom/client';
38+
39+
// TODO: This is for `createDirectLineEmulator` only, should find ways to eliminate this line.
40+
window.WebChat = { createStoreWithOptions };
41+
42+
run(async function () {
43+
const colorScheme = new URLSearchParams(location.search).get('fluent-theme') === 'dark' ? 'dark' : 'light';
44+
45+
// GIVEN: A light or dark high contrast theme (such as "Desert" or "Aquatic" on Windows) is active before Web Chat renders.
46+
await host.sendDevToolsCommand('Emulation.setEmulatedMedia', {
47+
features: [
48+
{ name: 'forced-colors', value: 'active' },
49+
{ name: 'prefers-color-scheme', value: colorScheme },
50+
{ name: 'prefers-reduced-motion', value: 'reduce' }
51+
]
52+
});
53+
54+
expect(window.matchMedia(`(forced-colors: active) and (prefers-color-scheme: ${colorScheme})`).matches).toBe(
55+
true
56+
);
57+
58+
const { directLine, store } = testHelpers.createDirectLineEmulator();
59+
60+
const webChatElement = createElement(
61+
FluentThemeProvider,
62+
{ variant: 'fluent' },
63+
createElement(ReactWebChat, { directLine, store, styleOptions: { hideSendBox: true } })
64+
);
65+
66+
// GIVEN: With a dark color scheme, the page uses the dark Fluent UI theme.
67+
createRoot(document.getElementById('webchat')).render(
68+
colorScheme === 'dark'
69+
? createElement(FluentProvider, { theme: webDarkTheme }, webChatElement)
70+
: webChatElement
71+
);
72+
73+
await pageConditions.uiConnected();
74+
75+
// WHEN: The bot sends a pre-chat message with 2 starter prompts.
76+
await directLine.emulateIncomingActivity({
77+
entities: [
78+
{
79+
'@context': 'https://schema.org',
80+
'@id': '',
81+
'@type': 'Message',
82+
author: {
83+
'@context': 'https://schema.org',
84+
'@type': 'Person',
85+
description: 'Select one of the suggestions below to get started.',
86+
image: '/assets/bot-avatar.jpg',
87+
name: 'Onboarding Buddy',
88+
type: 'https://schema.org/Person'
89+
},
90+
keywords: ['PreChatMessage'],
91+
type: 'https://schema.org/Message'
92+
}
93+
],
94+
suggestedActions: {
95+
actions: [
96+
{ text: 'Track new hire tasks.', title: 'Checklist', type: 'messageBack' },
97+
{ text: 'Set up your laptop.', title: 'Equipment', type: 'messageBack' }
98+
],
99+
to: []
100+
},
101+
type: 'message'
102+
});
103+
104+
await pageConditions.numActivitiesShown(1);
105+
await pageConditions.allImagesLoaded();
106+
107+
// THEN: Both starter prompts should be shown as buttons.
108+
await expect(
109+
Promise.all(
110+
Array.from(
111+
document.querySelectorAll(`[data-testid="${testIds.preChatMessageActivityStarterPromptsCardAction}"]`)
112+
).map(element => testHelpers.getAccessibleName(element))
113+
)
114+
).resolves.toEqual(['Checklist Track new hire tasks.', 'Equipment Set up your laptop.']);
115+
116+
// THEN: Both starter prompts should have a visible border around them.
117+
await host.snapshot('local');
118+
});
119+
</script>
120+
</body>
121+
</html>
23.2 KB
Loading

‎packages/fluent-theme/src/components/preChatActivity/StarterPromptsCardAction.module.css‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
outline-offset: -2px;
4949
}
5050

51+
/* Forced colors remove the card shadow and fill, so draw a border as a native button does. */
52+
@media (forced-colors: active) {
53+
border: var(--webchat-strokeWidthThin) solid ButtonText;
54+
}
55+
5156
&:empty::after,
5257
&:empty::before {
5358
animation: blueprintAnimation 3s linear infinite;

0 commit comments

Comments
 (0)