-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix citation modal width on mobile device (#4867)
* Modal width for mobile device * Fix citation button font * Add tests * Style citation button * Use calculated width * Update tests * Fit and finish * Update snapshots * Update entry * Fix ESLint
- Loading branch information
Showing
27 changed files
with
199 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+11 Bytes
(100%)
...-accordion-js-citation-accordion-should-expand-and-collapse-on-click-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+11 Bytes
(100%)
...-accordion-js-citation-accordion-should-expand-and-collapse-on-click-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+11 Bytes
(100%)
...-accordion-js-citation-accordion-should-expand-and-collapse-on-click-3-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+11 Bytes
(100%)
..._/__image_snapshots__/html/citation-basic-js-citation-should-display-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-4.78 KB
(90%)
...-js-citation-modal-dialog-should-close-when-clicking-on-close-button-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+74 Bytes
(100%)
...-js-citation-modal-dialog-should-close-when-clicking-on-close-button-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-4.78 KB
(90%)
...ape-js-citation-modal-dialog-should-close-when-escape-key-is-pressed-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+74 Bytes
(100%)
...ape-js-citation-modal-dialog-should-close-when-escape-key-is-pressed-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-4.78 KB
(90%)
...dal-dialog-should-show-when-clicking-on-citation-in-link-definitions-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-4.79 KB
(90%)
...dal-dialog-should-show-when-clicking-on-citation-in-link-definitions-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-4.78 KB
(90%)
...ation-modal-dialog-should-show-when-clicking-on-citation-in-markdown-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-4.79 KB
(90%)
...ation-modal-dialog-should-show-when-clicking-on-citation-in-markdown-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+36.7 KB
...dal-width-desktop-js-citation-modal-dialog-should-show-60-on-desktop-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+64.8 KB
...dal-width-desktop-js-citation-modal-dialog-should-show-60-on-desktop-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29 KB
...ile-js-citation-modal-dialog-should-show-full-width-on-mobile-device-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+44.7 KB
...ile-js-citation-modal-dialog-should-show-full-width-on-mobile-device-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
<script crossorigin="anonymous" src="/test-harness.js"></script> | ||
<script crossorigin="anonymous" src="/test-page-object.js"></script> | ||
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> | ||
</head> | ||
<body> | ||
<main id="webchat"></main> | ||
<script> | ||
run(async function () { | ||
const { directLine, store } = testHelpers.createDirectLineEmulator(); | ||
|
||
WebChat.renderWebChat( | ||
{ | ||
directLine, | ||
store | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
await host.windowSize(1024, 768, document.getElementById('webchat')); | ||
await pageConditions.uiConnected(); | ||
|
||
await directLine.emulateIncomingActivity({ | ||
entities: [ | ||
{ | ||
'@context': 'https://schema.org', | ||
'@id': 'cite:1', | ||
'@type': 'Claim', | ||
type: 'https://schema.org/Claim', | ||
text: 'Reprehenderit exercitation laborum labore ut. Nostrud do et ut nostrud nisi excepteur labore adipisicing nostrud nostrud ipsum id dolore. Anim aliquip incididunt incididunt sunt sit proident consectetur exercitation qui aliqua aliquip adipisicing nisi et. Id commodo labore sunt quis do aute cillum laborum veniam [proident](https://bing.com/).' | ||
} | ||
], | ||
text: `Sure, you should override the default proxy settings[1]\u200C[2], when your proxy server requires authentication[3]. | ||
[1]: https://support.microsoft.com/en-us/windows/use-a-proxy-server-in-windows-03096c53-0554-4ffe-b6ab-8b1deee8dae1 | ||
[2]: https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/configure-proxy-server-settings "Configure proxy server settings - Windows Server" | ||
[3]: cite:1 "Citation-1" | ||
`, | ||
type: 'message' | ||
}); | ||
|
||
await host.snapshot(); | ||
|
||
const markdownElement = pageElements.activities()[0].querySelector('.webchat__text-content__markdown'); | ||
const markdownButtons = markdownElement.querySelectorAll('button'); | ||
|
||
await host.click(markdownButtons[0]); | ||
|
||
await host.snapshot(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ | ||
|
||
describe('citation modal dialog', () => { | ||
test('should show 60% on desktop', () => runHTML('citation.showModal.width.desktop.html')); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
<script crossorigin="anonymous" src="/test-harness.js"></script> | ||
<script crossorigin="anonymous" src="/test-page-object.js"></script> | ||
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> | ||
</head> | ||
<body> | ||
<main id="webchat"></main> | ||
<script> | ||
run(async function () { | ||
const { directLine, store } = testHelpers.createDirectLineEmulator(); | ||
|
||
WebChat.renderWebChat( | ||
{ | ||
directLine, | ||
store | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
await pageConditions.uiConnected(); | ||
|
||
await directLine.emulateIncomingActivity({ | ||
entities: [ | ||
{ | ||
'@context': 'https://schema.org', | ||
'@id': 'cite:1', | ||
'@type': 'Claim', | ||
type: 'https://schema.org/Claim', | ||
text: 'Reprehenderit exercitation laborum labore ut. Nostrud do et ut nostrud nisi excepteur labore adipisicing nostrud nostrud ipsum id dolore. Anim aliquip incididunt incididunt sunt sit proident consectetur exercitation qui aliqua aliquip adipisicing nisi et. Id commodo labore sunt quis do aute cillum laborum veniam [proident](https://bing.com/).' | ||
} | ||
], | ||
text: `Sure, you should override the default proxy settings[1]\u200C[2], when your proxy server requires authentication[3]. | ||
[1]: https://support.microsoft.com/en-us/windows/use-a-proxy-server-in-windows-03096c53-0554-4ffe-b6ab-8b1deee8dae1 | ||
[2]: https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/configure-proxy-server-settings "Configure proxy server settings - Windows Server" | ||
[3]: cite:1 "Citation-1" | ||
`, | ||
type: 'message' | ||
}); | ||
|
||
await host.snapshot(); | ||
|
||
const markdownElement = pageElements.activities()[0].querySelector('.webchat__text-content__markdown'); | ||
const markdownButtons = markdownElement.querySelectorAll('button'); | ||
|
||
await host.click(markdownButtons[0]); | ||
|
||
await host.snapshot(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ | ||
|
||
describe('citation modal dialog', () => { | ||
test('should show full-width on mobile device', () => runHTML('citation.showModal.width.mobile.html')); | ||
}); |
39 changes: 39 additions & 0 deletions
39
packages/component/src/Attachment/Text/private/CitationModalContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import classNames from 'classnames'; | ||
import React, { Fragment, memo } from 'react'; | ||
|
||
import useRenderMarkdownAsHTML from '../../../hooks/useRenderMarkdownAsHTML'; | ||
import useStyleSet from '../../../hooks/useStyleSet'; | ||
|
||
type Props = Readonly<{ | ||
headerText?: string; | ||
markdown: string; | ||
}>; | ||
|
||
const CitationModalContent = memo(({ headerText, markdown }: Props) => { | ||
const [{ renderMarkdown: renderMarkdownStyleSet }] = useStyleSet(); | ||
const renderMarkdownAsHTML = useRenderMarkdownAsHTML(); | ||
|
||
return ( | ||
<Fragment> | ||
{headerText && <h2 className="webchat__citation-modal-dialog__header">{headerText}</h2>} | ||
{renderMarkdownAsHTML ? ( | ||
<div | ||
className={classNames( | ||
'webchat__citation-modal-dialog__body', | ||
'webchat__render-markdown', | ||
renderMarkdownStyleSet + '' | ||
)} | ||
// The content rendered by `renderMarkdownAsHTML` is sanitized. | ||
// eslint-disable-next-line react/no-danger | ||
dangerouslySetInnerHTML={{ __html: renderMarkdownAsHTML(markdown) }} | ||
/> | ||
) : ( | ||
<div className={classNames('webchat__render-markdown', renderMarkdownStyleSet + '')}>{markdown}</div> | ||
)} | ||
</Fragment> | ||
); | ||
}); | ||
|
||
CitationModalContent.displayName = 'CitationModalContent'; | ||
|
||
export default CitationModalContent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/component/src/Styles/StyleSet/CitationModalDialog.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default function createCitationModalDialogStyle() { | ||
return { | ||
'&.webchat__citation-modal-dialog': { | ||
'& .webchat__citation-modal-dialog__body': { | ||
lineHeight: '20px' | ||
} | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters