Skip to content

Commit 976fc36

Browse files
[MP-2044] Add support for theme data (#32)
1 parent 05e1090 commit 976fc36

File tree

12 files changed

+95
-13
lines changed

12 files changed

+95
-13
lines changed

packages/agent-app-sdk/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @livechat/agent-app-sdk
22

3+
## 1.12.0
4+
5+
### Minor Changes
6+
7+
- aab5da0: Added support for retrieving theme values via the `getTheme` method or by listening to the `change_theme` event
8+
39
## 1.11.0
410

511
### Minor Changes

packages/agent-app-sdk/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@livechat/agent-app-sdk",
3-
"version": "1.11.0",
3+
"version": "1.12.0",
44
"description": "SDK for extending LiveChat's Agent App",
55
"license": "MIT",
66
"repository": {
@@ -28,8 +28,6 @@
2828
},
2929
"dependencies": {
3030
"@babel/runtime": "^7.2.0",
31-
"@livechat/mitt": "0.1.2",
32-
"@livechat/postmessage": "^0.3.2",
3331
"@livechat/widget-core-sdk": "^1.1.0"
3432
},
3533
"devDependencies": {

packages/agent-app-sdk/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ export * from './widgets/fullscreen';
44
export * from './widgets/messagebox';
55
export * from './widgets/settings';
66
export * from './widgets/shared/customer-profile';
7-
7+
export { IThemeData, Theme } from './widgets/shared/theme';

packages/agent-app-sdk/src/widgets/details/details-widget.spec.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ jest.mock('../shared/rich-messages', () => {
3131
};
3232
});
3333

34+
jest.mock('../shared/theme', () => {
35+
return {
36+
withTheme: jest.fn().mockImplementation(widget => ({
37+
...widget,
38+
getTheme: jest.fn()
39+
}))
40+
};
41+
});
42+
3443
describe('DetailsWidget', () => {
3544
it('has a correct methods', () => {
3645
const connection = createMockConnection();
@@ -107,7 +116,7 @@ describe('createDetailsWidget', () => {
107116
});
108117

109118
it('returns the correct object with correct properties', async () => {
110-
expect.assertions(5);
119+
expect.assertions(6);
111120

112121
const widget = await createDetailsWidget();
113122

@@ -116,5 +125,6 @@ describe('createDetailsWidget', () => {
116125
expect(widget).toHaveProperty('on');
117126
expect(widget).toHaveProperty('off');
118127
expect(widget).toHaveProperty('sendMessage');
128+
expect(widget).toHaveProperty('getTheme');
119129
});
120130
});

packages/agent-app-sdk/src/widgets/details/details-widget.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { createConnection, createWidget, IConnection, withAmplitude, withPayments } from '@livechat/widget-core-sdk';
22
import { withCustomerProfile } from '../shared/customer-profile';
33
import { withRichMessages } from '../shared/rich-messages';
4+
import { withTheme } from '../shared/theme';
45
import assertSection from './custom-sections';
56
import { IDetailsWidgetApi, IDetailsWidgetEvents, ISection } from './interfaces';
67

7-
88
export function DetailsWidget(connection: IConnection<IDetailsWidgetEvents>) {
99
const base = createWidget<IDetailsWidgetApi, IDetailsWidgetEvents>(
1010
connection,
@@ -25,7 +25,7 @@ export function DetailsWidget(connection: IConnection<IDetailsWidgetEvents>) {
2525
}
2626
);
2727

28-
const widget = withAmplitude(withRichMessages(withCustomerProfile(withPayments(base))));
28+
const widget = withAmplitude(withRichMessages(withCustomerProfile(withTheme(withPayments(base)))));
2929

3030
return widget;
3131
}

packages/agent-app-sdk/src/widgets/fullscreen/fullscreen-widget.spec.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ jest.mock('../shared/page-data', () => {
2727
};
2828
});
2929

30+
jest.mock('../shared/theme', () => {
31+
return {
32+
withTheme: jest.fn().mockImplementation(widget => ({
33+
...widget,
34+
getTheme: jest.fn()
35+
}))
36+
};
37+
});
38+
3039
describe('FullscreenWidget', () => {
3140
it('has a `setNotificationBadge` method', () => {
3241
const connection = createMockConnection();
@@ -117,13 +126,14 @@ describe('createFullscreenWidget', () => {
117126
});
118127

119128
it('returns the correct object with correct properties', async () => {
120-
expect.assertions(5);
129+
expect.assertions(6);
121130

122131
const widget = await createFullscreenWidget();
123132
expect(widget).toHaveProperty('setNotificationBadge');
124133
expect(widget).toHaveProperty('on');
125134
expect(widget).toHaveProperty('off');
126135
expect(widget).toHaveProperty('sendMessage');
127136
expect(widget).toHaveProperty('getPageData');
137+
expect(widget).toHaveProperty('getTheme');
128138
});
129139
});

packages/agent-app-sdk/src/widgets/fullscreen/fullscreen-widget.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createConnection, createWidget, IConnection, withAmplitude, withPayments } from '@livechat/widget-core-sdk';
22
import { withPageData } from '../shared/page-data';
3+
import { withTheme } from '../shared/theme';
34
import { IFullscreenWidgetApi, IFullscreenWidgetEvents, ReportsFilters } from './interfaces';
45

56
export { ReportsFilters } from './interfaces';
@@ -28,7 +29,7 @@ export function FullscreenWidget(
2829
}
2930
);
3031

31-
return withAmplitude(withPageData(withPayments(base)));
32+
return withAmplitude(withPageData(withTheme(withPayments(base))));
3233
}
3334

3435
export type IFullscreenWidget = ReturnType<typeof FullscreenWidget>;

packages/agent-app-sdk/src/widgets/messagebox/messagebox-widget.spec.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ jest.mock('../shared/customer-profile', () => {
2424
};
2525
});
2626

27+
jest.mock('../shared/theme', () => {
28+
return {
29+
withTheme: jest.fn().mockImplementation(widget => ({
30+
...widget,
31+
getTheme: jest.fn()
32+
}))
33+
};
34+
});
35+
2736
jest.mock('../shared/rich-messages', () => {
2837
return {
2938
withRichMessages: jest.fn().mockImplementation(widget => widget)
@@ -72,7 +81,7 @@ describe('createMessageBoxWidget', () => {
7281
});
7382

7483
it('returns the correct object with correct properties', async () => {
75-
expect.assertions(5);
84+
expect.assertions(6);
7685

7786
const widget = await createMessageBoxWidget();
7887

@@ -81,5 +90,6 @@ describe('createMessageBoxWidget', () => {
8190
expect(widget).toHaveProperty('off');
8291
expect(widget).toHaveProperty('sendMessage');
8392
expect(widget).toHaveProperty('trackEvent');
93+
expect(widget).toHaveProperty('getTheme');
8494
});
8595
});

packages/agent-app-sdk/src/widgets/messagebox/messagebox-widget.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createConnection, createWidget, IConnection, withAmplitude, withPayments } from '@livechat/widget-core-sdk';
22
import { withCustomerProfile } from '../shared/customer-profile';
33
import { withRichMessages } from '../shared/rich-messages';
4+
import { withTheme } from '../shared/theme';
45
import { IMessageBoxWidgetApi, IMessageBoxWidgetEvents, IRichMessage } from './interfaces';
56

67
export function MessageBoxWidget(
@@ -21,7 +22,7 @@ export function MessageBoxWidget(
2122
}
2223
);
2324

24-
const widget = withAmplitude(withRichMessages(withCustomerProfile(withPayments(base))));
25+
const widget = withAmplitude(withRichMessages(withCustomerProfile(withTheme(withPayments(base)))));
2526

2627
return widget;
2728
}

packages/agent-app-sdk/src/widgets/settings/settings-widget.spec.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ jest.mock('../shared/page-data', () => {
2626
};
2727
});
2828

29+
jest.mock('../shared/theme', () => {
30+
return {
31+
withTheme: jest.fn().mockImplementation(widget => ({
32+
...widget,
33+
getTheme: jest.fn()
34+
}))
35+
};
36+
});
37+
2938
describe('SettingsWidget', () => {
3039
it('has a `redirect` method', () => {
3140
const connection = createMockConnection();
@@ -75,13 +84,14 @@ describe('createSettingsWidget', () => {
7584
});
7685

7786
it('returns the correct object with correct properties', async () => {
78-
expect.assertions(5);
87+
expect.assertions(6);
7988

8089
const widget = await createSettingsWidget();
8190
expect(widget).toHaveProperty('redirect');
8291
expect(widget).toHaveProperty('on');
8392
expect(widget).toHaveProperty('off');
8493
expect(widget).toHaveProperty('sendMessage');
8594
expect(widget).toHaveProperty('getPageData');
95+
expect(widget).toHaveProperty('getTheme');
8696
});
8797
});

0 commit comments

Comments
 (0)