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

Added SuggestedAction Image Functionality #1909

Merged
merged 5 commits into from
Apr 17, 2019
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -56,6 +56,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `component`: Added `cardActionMiddleware` to customize the behavior of card action, by [@compulim](https://github.com/compulim), in PR [#1704](https://github.com/Microsoft/BotFramework-WebChat/pull/1704)
- `bundle`: Add `watermark` and `streamUrl` parameters to createDirectLine, by [@corinagum](https://github.com/corinagum), in PR [#1817](https://github.com/Microsoft/BotFramework-WebChat/pull/1817)
- `component`: Added `textarea` option to `SendBox` per issues [#17](https://github.com/Microsoft/BotFramework-WebChat/issues/17) and [#124](https://github.com/Microsoft/BotFramework-WebChat/issues/124), by [@tdurnford](https://github.com/tdurnford), in PR [#1889](https://github.com/Microsoft/BotFramework-WebChat/pull/1889)
- `component`: Added `suggestedAction` images per issue [#1739](https://github.com/Microsoft/BotFramework-WebChat/issues/1739), by [@tdurnford](https://github.com/tdurnford), in PR [#1909](https://github.com/Microsoft/BotFramework-WebChat/pull/1909)

### Changed

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.
32 changes: 32 additions & 0 deletions __tests__/suggestedActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { By } from 'selenium-webdriver';

import { imageSnapshotOptions, timeouts } from './constants.json';

import allImagesLoaded from './setup/conditions/allImagesLoaded';
import allOutgoingActivitiesSent from './setup/conditions/allOutgoingActivitiesSent';
import minNumActivitiesShown from './setup/conditions/minNumActivitiesShown';
import suggestedActionsShowed from './setup/conditions/suggestedActionsShowed';
Expand All @@ -20,6 +21,7 @@ describe('suggested-actions command', async () => {
await pageObjects.sendMessageViaSendBox('suggested-actions');

await driver.wait(suggestedActionsShowed(), timeouts.directLine);
await driver.wait( allImagesLoaded(), 2000 );

const base64PNG = await driver.takeScreenshot();

Expand Down Expand Up @@ -143,4 +145,34 @@ describe('suggested-actions command', async () => {

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

test('should show suggested actions with images', async () => {
const { driver, pageObjects } = await setupWebDriver();

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('emptycard');

await driver.wait(minNumActivitiesShown(1), timeouts.directLine);
await driver.wait( allImagesLoaded(), 2000 );

const base64PNG = await driver.takeScreenshot();

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

test('should show suggested actions with larger images', async () => {

const styleOptions = { suggestedActionHeight: 80, suggestedActionImageHeight: 60 };
const { driver, pageObjects } = await setupWebDriver({ props: { styleOptions } });

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('emptycard');

await driver.wait(minNumActivitiesShown(1), timeouts.directLine);
await driver.wait( allImagesLoaded(), 2000 );

const base64PNG = await driver.takeScreenshot();

expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions);
});
});
4 changes: 3 additions & 1 deletion packages/component/src/SendBox/SuggestedAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ export default connectSuggestedAction(
)(
({
buttonText,
disabled,
click,
disabled,
image,
styleSet
}) =>
<div className={ classNames(styleSet.suggestedAction + '', SUGGESTED_ACTION_CSS) }>
<button
disabled={ disabled }
onClick={ click }
>
{image && <img src={ image } />}
<nobr>{ buttonText }</nobr>
</button>
</div>
Expand Down
2 changes: 2 additions & 0 deletions packages/component/src/SendBox/SuggestedActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default connectSuggestedActions(
suggestedActions.map((
{
displayText,
image,
text,
title,
type,
Expand All @@ -61,6 +62,7 @@ export default connectSuggestedActions(
suggestedActionText({ displayText, title, type, value })
}
displayText={ displayText }
image={ image }
key={ index }
text={ text }
type={ type }
Expand Down
10 changes: 9 additions & 1 deletion packages/component/src/Styles/StyleSet/SuggestedAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default function createSuggestedActionStyle({
suggestedActionBackground,
suggestedActionBorder,
suggestedActionBorderRadius,
suggestedActionImageHeight,
suggestedActionTextColor,
suggestedActionDisabledBackground,
suggestedActionDisabledBorder,
Expand All @@ -18,12 +19,14 @@ export default function createSuggestedActionStyle({
paddingTop: paddingRegular,

'& > button': {
alignItems: 'center',
borderRadius: suggestedActionBorderRadius,
display: 'flex',
fontFamily: primaryFont,
fontSize: 'inherit',
height: suggestedActionHeight,
paddingLeft: paddingWide,
paddingRight: paddingWide,
borderRadius: suggestedActionBorderRadius,

'&:disabled': {
background: suggestedActionDisabledBackground,
Expand All @@ -35,6 +38,11 @@ export default function createSuggestedActionStyle({
background: suggestedActionBackground,
border: suggestedActionBorder,
color: suggestedActionTextColor
},

'& > img': {
height: suggestedActionImageHeight,
paddingRight: paddingRegular
}
}
};
Expand Down
1 change: 1 addition & 0 deletions packages/component/src/Styles/defaultStyleSetOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const DEFAULT_OPTIONS = {
suggestedActionBackground: 'White',
suggestedActionBorder: `solid 2px ${ DEFAULT_ACCENT }`,
suggestedActionBorderRadius: 0,
suggestedActionImageHeight: 20,
suggestedActionTextColor: DEFAULT_ACCENT,
suggestedActionDisabledBackground: 'White',
suggestedActionDisabledBorder: `solid 2px #E6E6E6`,
Expand Down