Skip to content

Commit b62d52e

Browse files
committed
Replace darkMode with theme
1 parent 9741957 commit b62d52e

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ declare module '@chatwoot/react-native-widget' {
55
websiteToken: string;
66
locale?: string;
77
baseUrl: string;
8-
darkMode?: string;
8+
theme?: string;
99
closeModal: () => void;
1010
isModalVisible: boolean;
1111
user?: {

src/App.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const propTypes = {
1919
identifier_hash: PropTypes.string,
2020
}),
2121
locale: PropTypes.string,
22-
darkMode: PropTypes.string,
22+
theme: PropTypes.string,
2323
customAttributes: PropTypes.shape({}),
2424
closeModal: PropTypes.func,
2525
};
@@ -28,7 +28,7 @@ const defaultProps = {
2828
cwCookie: '',
2929
user: {},
3030
locale: 'en',
31-
darkMode: 'light',
31+
theme: 'light',
3232
customAttributes: {},
3333
};
3434

@@ -38,7 +38,7 @@ const ChatWootWidget = ({
3838
websiteToken,
3939
user,
4040
locale,
41-
darkMode,
41+
theme,
4242
customAttributes,
4343
closeModal,
4444
}) => {
@@ -67,7 +67,7 @@ const ChatWootWidget = ({
6767
user={user}
6868
baseUrl={baseUrl}
6969
locale={locale}
70-
darkMode={darkMode}
70+
theme={theme}
7171
customAttributes={customAttributes}
7272
closeModal={closeModal}
7373
/>

src/WebView.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const propTypes = {
77
websiteToken: PropTypes.string.isRequired,
88
baseUrl: PropTypes.string.isRequired,
99
cwCookie: PropTypes.string,
10-
darkMode: PropTypes.string,
10+
theme: PropTypes.string,
1111
user: PropTypes.shape({
1212
name: PropTypes.string,
1313
avatar_url: PropTypes.string,
@@ -24,15 +24,15 @@ const defaultProps = {
2424
user: {},
2525
locale: 'en',
2626
customAttributes: {},
27-
darkMode: 'light',
27+
theme: 'light',
2828
};
2929

3030
const WebViewComponent = ({
3131
baseUrl,
3232
websiteToken,
3333
cwCookie,
3434
locale,
35-
darkMode,
35+
theme,
3636
user,
3737
customAttributes,
3838
closeModal,
@@ -46,7 +46,7 @@ const WebViewComponent = ({
4646
user,
4747
locale,
4848
customAttributes,
49-
darkMode,
49+
theme,
5050
});
5151

5252
const onShouldStartLoadWithRequest = (request) => {

src/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export const POST_MESSAGE_EVENTS = {
33
SET_LOCALE: 'set-locale',
44
SET_CUSTOM_ATTRIBUTES: 'set-custom-attributes',
55
SET_USER: 'set-user',
6-
SET_DARK_MODE: 'set-dark-mode',
6+
SET_THEME: 'set-theme',
77
};
88
export const BG_COLOR = '#f1f5f8';
99
export const COLOR_WHITE = '#fff';

src/utils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const createWootPostMessage = (object) => {
1919

2020
export const getMessage = (data) => data.replace(WOOT_PREFIX, '');
2121

22-
export const generateScripts = ({ darkMode, user, locale, customAttributes }) => {
22+
export const generateScripts = ({ theme, user, locale, customAttributes }) => {
2323
let script = '';
2424
if (user) {
2525
const userObject = {
@@ -40,9 +40,9 @@ export const generateScripts = ({ darkMode, user, locale, customAttributes }) =>
4040
};
4141
script += createWootPostMessage(attributeObject);
4242
}
43-
if (darkMode) {
44-
const darkModeObject = { event: POST_MESSAGE_EVENTS.SET_DARK_MODE, darkMode };
45-
script += createWootPostMessage(darkModeObject);
43+
if (theme) {
44+
const themeObject = { event: POST_MESSAGE_EVENTS.SET_THEME, theme };
45+
script += createWootPostMessage(themeObject);
4646
}
4747
return script;
4848
};

0 commit comments

Comments
 (0)