Skip to content

Commit

Permalink
Update getCustomisations function
Browse files Browse the repository at this point in the history
  • Loading branch information
Nirmay15 committed Dec 17, 2022
1 parent 7593013 commit 2ebde73
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
2 changes: 2 additions & 0 deletions src/embed/ts-embed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ beforeAll(() => {

const customisations = {
style: {
customCSS: {},
customCSSUrl: 'http://localhost:3000',
},
content: {},
};

const customisationsView = {
style: {
customCSS: {},
customCSSUrl: 'http://localhost:8000',
},
content: {},
Expand Down
36 changes: 22 additions & 14 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,22 +182,30 @@ export const getCustomisations = (
embedConfig: EmbedConfig,
viewConfig: ViewConfig,
): CustomisationsInterface => {
const customCssFromEmbedConfig = embedConfig.customCssUrl;
const customizationsFromViewConfig =
viewConfig.customizations ||
((viewConfig as any).customisations as CustomisationsInterface);
let customizations =
const customCssUrlFromEmbedConfig = embedConfig.customCssUrl;
const customizationsFromViewConfig = viewConfig.customizations;
const customizationsFromEmbedConfig =
embedConfig.customizations ||
((embedConfig as any).customisations as CustomisationsInterface);
customizations = customizations || ({} as CustomisationsInterface);
customizations.style = customizations.style || {};
customizations.style.customCSSUrl =
customizationsFromViewConfig?.style.customCSSUrl ||
customizations.style.customCSSUrl ||
customCssFromEmbedConfig;
customizations.style.customCSS =
customizationsFromViewConfig?.style.customCSS ||
customizations.style.customCSS;

const customizations: CustomisationsInterface = {
style: {
...customizationsFromEmbedConfig?.style,
...customizationsFromViewConfig?.style,
customCSS: {
...customizationsFromEmbedConfig?.style?.customCSS,
...customizationsFromViewConfig?.style?.customCSS,
},
customCSSUrl:
customizationsFromViewConfig?.style?.customCSSUrl ||
customizationsFromEmbedConfig?.style?.customCSSUrl ||
customCssUrlFromEmbedConfig,
},
content: {
...customizationsFromEmbedConfig?.content,
...customizationsFromViewConfig?.content,
},
};
return customizations;
};

Expand Down

0 comments on commit 2ebde73

Please sign in to comment.