Skip to content

Commit eda47b9

Browse files
committed
Attend PR comments:
- Add comment explaining new custom element - Rename DDGCtlPlaceholderBlocked -> DDGCtlPlaceholderBlockedElement - General fixes to CSS - reset styles from host element, clean up styles, etc
1 parent e5bb71f commit eda47b9

File tree

3 files changed

+47
-27
lines changed

3 files changed

+47
-27
lines changed

src/features/click-to-load.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createCustomEvent, sendMessage, originalWindowDispatchEvent } from '../
22
import { logoImg, loadingImages, closeIcon } from './click-to-load/ctl-assets.js'
33
import { getStyles, getConfig } from './click-to-load/ctl-config.js'
44
import ContentFeature from '../content-feature.js'
5-
import { DDGCtlPlaceholderBlocked } from './click-to-load/components/ctl-placeholder-blocked.js'
5+
import { DDGCtlPlaceholderBlockedElement } from './click-to-load/components/ctl-placeholder-blocked.js'
66

77
/**
88
* @typedef {'darkMode' | 'lightMode' | 'loginMode' | 'cancelMode'} displayMode
@@ -550,7 +550,12 @@ function createPlaceholderElementAndReplace (widget, trackingElement) {
550550
// Facebook
551551
if (widget.replaceSettings.type === 'dialog') {
552552
if (isMobileApp) {
553-
const mobileBlockedPlaceholder = new DDGCtlPlaceholderBlocked({
553+
/**
554+
* Creates a custom HTML element with the placeholder element for blocked
555+
* embedded content. The constructor gets a list of parameters with the
556+
* content and event handlers for this HTML element.
557+
*/
558+
const mobileBlockedPlaceholder = new DDGCtlPlaceholderBlockedElement({
554559
devMode,
555560
isMobileApp,
556561
title: widget.replaceSettings.infoTitle, // Card title text
@@ -621,7 +626,12 @@ function replaceYouTubeCTL (trackingElement, widget) {
621626
const oldPlaceholder = widget.placeholderElement
622627

623628
if (isMobileApp) {
624-
const mobileBlockedPlaceholder = new DDGCtlPlaceholderBlocked({
629+
/**
630+
* Creates a custom HTML element with the placeholder element for blocked
631+
* embedded content. The constructor gets a list of parameters with the
632+
* content and event handlers for this HTML element.
633+
*/
634+
const mobileBlockedPlaceholderElement = new DDGCtlPlaceholderBlockedElement({
625635
devMode,
626636
isMobileApp,
627637
title: widget.replaceSettings.infoTitle, // Card title text
@@ -641,11 +651,11 @@ function replaceYouTubeCTL (trackingElement, widget) {
641651
},
642652
onButtonClick: widget.clickFunction.bind(widget)
643653
})
644-
mobileBlockedPlaceholder.appendChild(makeFontFaceStyleElement())
645-
mobileBlockedPlaceholder.id = trackingElement.id
646-
resizeElementToMatch(oldPlaceholder || trackingElement, mobileBlockedPlaceholder)
647-
replaceTrackingElement(widget, trackingElement, mobileBlockedPlaceholder)
648-
showExtraUnblockIfShortPlaceholder(null, mobileBlockedPlaceholder)
654+
mobileBlockedPlaceholderElement.appendChild(makeFontFaceStyleElement())
655+
mobileBlockedPlaceholderElement.id = trackingElement.id
656+
resizeElementToMatch(oldPlaceholder || trackingElement, mobileBlockedPlaceholderElement)
657+
replaceTrackingElement(widget, trackingElement, mobileBlockedPlaceholderElement)
658+
showExtraUnblockIfShortPlaceholder(null, mobileBlockedPlaceholderElement)
649659
} else {
650660
const { blockingDialog, shadowRoot } = createYouTubeBlockingDialog(trackingElement, widget)
651661
resizeElementToMatch(oldPlaceholder || trackingElement, blockingDialog)

src/features/click-to-load/assets/ctl-placeholder-block.css

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
:host,
12
* {
23
font-family: DuckDuckGoPrivacyEssentials, system, -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto,
34
Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
45
box-sizing: border-box;
6+
font-weight: normal;
7+
font-style: normal;
8+
margin: 0;
9+
padding: 0;
10+
text-align: left;
511
}
612

713
:host,
814
.DuckDuckGoSocialContainer {
915
display: inline-block;
10-
box-sizing: border-box;
1116
border: 0;
1217
padding: 0;
1318
margin: auto;
@@ -20,7 +25,6 @@
2025
/* Button */
2126
.DuckDuckGoButton {
2227
border-radius: 8px;
23-
box-sizing: border-box;
2428
padding: 11px 22px;
2529
margin: 0px auto;
2630
border-color: #3969ef;
@@ -189,7 +193,6 @@
189193
.ddg-ctl-placeholder-card {
190194
height: 100%;
191195
overflow: auto;
192-
box-sizing: border-box;
193196
padding: 16px;
194197
color: rgba(0, 0, 0, 0.84);
195198
background: #ffffff;
@@ -223,26 +226,26 @@
223226
align-items: center;
224227
margin: auto;
225228
margin-bottom: 8px;
229+
text-align: left;
226230
}
227231
.DuckDuckGoSocialContainer:not(.size-sm) .ddg-ctl-placeholder-card-header {
228232
flex-direction: column;
229233
align-items: center;
230234
justify-content: center;
231235
margin-bottom: 12px;
232-
text-align: left;
236+
width: 80%;
237+
text-align: center;
233238
}
234239

235-
.DuckDuckGoSocialContainer:not(.size-sm) .ddg-ctl-placeholder-card-header,
240+
.DuckDuckGoSocialContainer:not(.size-sm) .ddg-ctl-placeholder-card-header .ddg-ctl-placeholder-card-title,
236241
.DuckDuckGoSocialContainer:not(.size-sm) .ddg-ctl-placeholder-card-header .ddg-text-link {
237242
text-align: center;
238-
width: 80%;
239243
}
240244

241245
/* Show Learn More link in the header on mobile and
242246
* tablet size screens and hide it on desktop size */
243247
.DuckDuckGoSocialContainer.size-lg .ddg-ctl-placeholder-card-header .ddg-learn-more {
244248
display: none;
245-
visibility: hidden;
246249
}
247250

248251
.ddg-ctl-placeholder-card-title,
@@ -279,34 +282,28 @@
279282
margin: 0 auto 12px;
280283

281284
display: none;
282-
visibility: hidden;
283285
}
284286
.DuckDuckGoSocialContainer.size-lg .ddg-ctl-placeholder-card-body-text {
285287
width: 80%;
286288
display: block;
287-
visibility: visible;
288289
}
289290

290291
.ddg-ctl-placeholder-card-footer {
291292
width: 100%;
292293
display: flex;
293294
align-items: center;
294295
justify-content: flex-start;
295-
justify-self: flex-end;
296-
margin-top: auto;
296+
align-self: end;
297297
}
298298

299299
.ddg-ctl-feedback-row {
300300
display: none;
301-
visibility: hidden;
302301
}
303302
.DuckDuckGoSocialContainer:not(.size-sm) .ddg-ctl-feedback-row {
304303
height: 30px;
305304
justify-content: flex-end;
306305
align-items: center;
307306
display: flex;
308-
display: flex;
309-
visibility: visible;
310307
}
311308

312309
.ddg-ctl-feedback-link {
@@ -316,4 +313,9 @@
316313
line-height: 12px;
317314
color: #ababab;
318315
text-decoration: none;
316+
display: inline;
317+
background-color: transparent;
318+
border: 0;
319+
padding: 0;
320+
cursor: pointer;
319321
}

src/features/click-to-load/components/ctl-placeholder-blocked.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import { html } from '../../../dom-utils'
22
import css from '../assets/ctl-placeholder-block.css'
33
import { logoImg as daxImg } from '../ctl-assets'
44

5-
export class DDGCtlPlaceholderBlocked extends HTMLElement {
5+
/**
6+
* The custom HTML element (Web Component) template with the placeholder for blocked
7+
* embedded content. The constructor gets a list of parameters with the
8+
* content and event handlers for this template.
9+
* This is currently only used in our Mobile Apps, but can be expanded in the future.
10+
*/
11+
export class DDGCtlPlaceholderBlockedElement extends HTMLElement {
612
static CUSTOM_TAG_NAME = 'ddg-ctl-placeholder-blocked'
713

814
/**
@@ -99,12 +105,14 @@ export class DDGCtlPlaceholderBlocked extends HTMLElement {
99105
class="ddg-ctl-placeholder-card${useSlimCard ? ' slim-card' : ''}${withFeedback ? ' with-feedback-link' : ''}"
100106
>
101107
<div class="ddg-ctl-placeholder-card-header">
102-
<img class="ddg-ctl-placeholder-card-header-dax" src=${daxImg} />
108+
<img class="ddg-ctl-placeholder-card-header-dax" src=${daxImg} alt="DuckDuckGo Dax" />
103109
<div class="ddg-ctl-placeholder-card-title">${title}. ${learnMoreLink}</div>
104110
</div>
105111
<div class="ddg-ctl-placeholder-card-body">
106112
<div class="ddg-ctl-placeholder-card-body-text">${body} ${learnMoreLink}</div>
107-
<button class="DuckDuckGoButton tertiary ddg-ctl-unblock-btn"><div>${unblockBtnText}</div></button>
113+
<button class="DuckDuckGoButton tertiary ddg-ctl-unblock-btn" type="button">
114+
<div>${unblockBtnText}</div>
115+
</button>
108116
</div>
109117
${withToggle
110118
? html`<div class="ddg-ctl-placeholder-card-footer">${this.createToggleButton()}</div> `
@@ -142,7 +150,7 @@ export class DDGCtlPlaceholderBlocked extends HTMLElement {
142150
container.classList.add('ddg-ctl-feedback-row')
143151

144152
container.innerHTML = html`
145-
<a class="ddg-ctl-feedback-link" target="_blank" href="#">${sharedStrings.shareFeedback}</a>
153+
<button class="ddg-ctl-feedback-link" type="button">${sharedStrings.shareFeedback}</button>
146154
`.toString()
147155

148156
return container
@@ -239,4 +247,4 @@ export class DDGCtlPlaceholderBlocked extends HTMLElement {
239247
}
240248
}
241249

242-
customElements.define(DDGCtlPlaceholderBlocked.CUSTOM_TAG_NAME, DDGCtlPlaceholderBlocked)
250+
customElements.define(DDGCtlPlaceholderBlockedElement.CUSTOM_TAG_NAME, DDGCtlPlaceholderBlockedElement)

0 commit comments

Comments
 (0)