Skip to content

Commit eaa8be0

Browse files
committed
Populate default styles on load
1 parent ccda1e0 commit eaa8be0

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/features/click-to-load.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const titleID = 'DuckDuckGoPrivacyEssentialsCTLElementTitle'
2222
// @see {getConfig}
2323
let config = null
2424
let sharedStrings = null
25-
let styles = null
25+
let styles = getStyles()
2626

2727
// TODO: Remove these redundant data structures and refactor the related code.
2828
// There should be no need to have the entity configuration stored in two
@@ -1613,10 +1613,13 @@ export default class ClickToLoad extends ContentFeature {
16131613
const websiteOwner = args?.site?.parentEntity
16141614
const settings = args?.featureSettings?.clickToLoad || {}
16151615
const locale = args?.locale || 'en'
1616-
const localizedConfig = getConfig(locale, args?.assets)
1616+
const localizedConfig = getConfig(locale)
16171617
config = localizedConfig.config
16181618
sharedStrings = localizedConfig.sharedStrings
1619-
styles = localizedConfig.styles
1619+
// update styles if asset config was sent
1620+
if (args?.assets) {
1621+
styles = getStyles(args.assets)
1622+
}
16201623

16211624
for (const entity of Object.keys(config)) {
16221625
// Strip config entities that are first-party, or aren't enabled in the

src/features/click-to-load/ctl-config.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import localesJSON from '../../../build/locales/ctl-locales.js'
1616
/**
1717
* Get CSS style defintions for CTL, using the provided AssetConfig for any non-embedded assets
1818
* (e.g. fonts.)
19-
* @param {AssetConfig} assets
19+
* @param {AssetConfig} [assets]
2020
*/
2121
export function getStyles (assets) {
2222
let fontStyle = ''
@@ -616,15 +616,13 @@ export function getStyles (assets) {
616616

617617
/**
618618
* @param {string} locale UI locale
619-
* @param {AssetConfig} assets Config for UI assets
620619
*/
621-
export function getConfig (locale, assets) {
620+
export function getConfig (locale) {
622621
const locales = JSON.parse(localesJSON)
623622
const fbStrings = locales[locale]['facebook.json']
624623
const ytStrings = locales[locale]['youtube.json']
625624

626625
const sharedStrings = locales[locale]['shared.json']
627-
const styles = getStyles(assets)
628626
const config = {
629627
'Facebook, Inc.': {
630628
informationalModal: {
@@ -1033,5 +1031,5 @@ export function getConfig (locale, assets) {
10331031
}
10341032
}
10351033

1036-
return { config, sharedStrings, styles }
1034+
return { config, sharedStrings }
10371035
}

0 commit comments

Comments
 (0)