Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add properties for stacked suggested actions height and overflow #3235

Merged
merged 5 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Resolves [#3205](https://github.com/microsoft/BotFramework-WebChat/issues/3205). Added Direct Line App Service Extension protocol, by [@compulim](https://github.com/compulim) in PR [#3206](https://github.com/microsoft/BotFramework-WebChat/pull/3206)
- Resolves [#3225](https://github.com/microsoft/BotFramework-WebChat/issues/3225). Support allowed scheme with `openUrl` card action, by [@compulim](https://github.com/compulim) in PR [#3226](https://github.com/microsoft/BotFramework-WebChat/pull/3226)
- Resolves [#3182](https://github.com/microsoft/BotFramework-WebChat/issues/3182). Added stacked suggested actions height properties, by [@corinagum](https://github.com/corinagum), in PR [#3235](https://github.com/microsoft/BotFramework-WebChat/pull/3235)

### Fixed

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions __tests__/suggestedActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,64 @@ describe('suggested-actions command', () => {

expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions);
});

test('should show stacked suggested actions with height of 50', async () => {
const { driver, pageObjects } = await setupWebDriver({
props: { styleOptions: { suggestedActionLayout: 'stacked', suggestedActionsStackedHeight: 50 } }
});

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('suggested-actions', { waitForSend: true });

await driver.wait(suggestedActionsShown(), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetchImage);

const base64PNG = await driver.takeScreenshot();

expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions);
});

test('should show stacked suggested actions with height of 50 with overflow hidden', async () => {
const { driver, pageObjects } = await setupWebDriver({
props: {
styleOptions: {
suggestedActionLayout: 'stacked',
suggestedActionsStackedHeight: 50,
suggestedActionsStackedOverflow: 'hidden'
}
}
});

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('suggested-actions', { waitForSend: true });

await driver.wait(suggestedActionsShown(), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetchImage);

const base64PNG = await driver.takeScreenshot();

expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions);
});

test('should show stacked suggested actions with height of 50 with overflow scroll', async () => {
const { driver, pageObjects } = await setupWebDriver({
props: {
styleOptions: {
suggestedActionLayout: 'stacked',
suggestedActionsStackedHeight: 50,
suggestedActionsStackedOverflow: 'scroll'
}
}
});

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('suggested-actions', { waitForSend: true });

await driver.wait(suggestedActionsShown(), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetchImage);

const base64PNG = await driver.takeScreenshot();

expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions);
});
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
/* eslint no-empty-pattern: "off" */
/* eslint no-magic-numbers: ["error", { "ignore": [2] }] */

export default function createSuggestedActionsStyle({ paddingRegular, suggestedActionLayout }) {
export default function createSuggestedActionsStyle({
paddingRegular,
suggestedActionLayout,
suggestedActionsStackedHeight,
suggestedActionsStackedOverflow
}) {
if (suggestedActionLayout === 'stacked') {
return {
height: suggestedActionsStackedHeight || 'auto',
overflowY: suggestedActionsStackedOverflow,
paddingBottom: paddingRegular / 2,
paddingLeft: paddingRegular / 2,
paddingRight: paddingRegular / 2,
Expand Down
6 changes: 5 additions & 1 deletion packages/component/src/Styles/defaultStyleOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@ const DEFAULT_OPTIONS = {
suggestedActionDisabledTextColor: undefined, // defaults to subtle
suggestedActionHeight: 40,
suggestedActionImageHeight: 20,
suggestedActionLayout: 'carousel', // either "carousel" or "stacked"
suggestedActionLayout: 'carousel', // either 'carousel' or 'stacked'
suggestedActionTextColor: null,

// Suggested actions 'stacked' layout
suggestedActionsStackedHeight: undefined, // defaults to 'auto'
suggestedActionsStackedOverflow: null,

// Timestamp
groupTimestamp: true,
sendTimeout: 20000,
Expand Down