Skip to content

Commit a061a7a

Browse files
committed
Fix media-queries for Firefox | Change DDGCtlPlaceholderBlocked to use arrow functions and keep reference on Firefox
1 parent cbbdbf7 commit a061a7a

File tree

3 files changed

+63
-28
lines changed

3 files changed

+63
-28
lines changed

src/features/click-to-load.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,8 +1682,7 @@ export default class ClickToLoad extends ContentFeature {
16821682
sharedStrings = localizedConfig.sharedStrings
16831683
// update styles if asset config was sent
16841684
styles = getStyles(this.assetConfig)
1685-
this.isMobileApp = this.platform.name === 'ios' || this.platform.name === 'android'
1686-
isMobileApp = this.isMobileApp
1685+
isMobileApp = this.platform.name === 'ios' || this.platform.name === 'android'
16871686

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

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

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,29 @@
4848
padding: 0px 16px;
4949
border: 1px solid rgba(0, 0, 0, 0.12);
5050
border-radius: 8px;
51-
@media (prefers-color-scheme: dark) {
51+
}
52+
@media (prefers-color-scheme: dark) {
53+
.DuckDuckGoButton.tertiary {
5254
color: #ffffff;
5355
border: 1px solid rgba(255, 255, 255, 0.24);
5456
}
5557
}
5658
.DuckDuckGoButton.tertiary:hover {
5759
background: rgba(0, 0, 0, 0.06);
5860
border: 1px solid rgba(0, 0, 0, 0.18);
59-
@media (prefers-color-scheme: dark) {
61+
}
62+
@media (prefers-color-scheme: dark) {
63+
.DuckDuckGoButton.tertiary:hover {
6064
background: rgba(255, 255, 255, 0.18);
6165
border: 1px solid rgba(255, 255, 255, 0.24);
6266
}
6367
}
6468
.DuckDuckGoButton.tertiary:active {
6569
background: rgba(0, 0, 0, 0.12);
6670
border: 1px solid rgba(0, 0, 0, 0.36);
67-
@media (prefers-color-scheme: dark) {
71+
}
72+
@media (prefers-color-scheme: dark) {
73+
.DuckDuckGoButton.tertiary:active {
6874
background: rgba(255, 255, 255, 0.24);
6975
border: 1px solid rgba(255, 255, 255, 0.24);
7076
}
@@ -105,13 +111,17 @@
105111
}
106112
.ddg-toggle-button.active .ddg-toggle-button-bg {
107113
background: #3969ef;
108-
@media (prefers-color-scheme: dark) {
114+
}
115+
@media (prefers-color-scheme: dark) {
116+
.ddg-toggle-button.active .ddg-toggle-button-bg {
109117
background: #7295f6;
110118
}
111119
}
112120
.ddg-toggle-button.inactive .ddg-toggle-button-bg {
113121
background: #ababab;
114-
@media (prefers-color-scheme: dark) {
122+
}
123+
@media (prefers-color-scheme: dark) {
124+
.ddg-toggle-button.inactive .ddg-toggle-button-bg {
115125
background: #444444;
116126
}
117127
}
@@ -144,7 +154,9 @@
144154
line-height: 20px;
145155
color: rgba(0, 0, 0, 0.84);
146156
margin-left: 12px;
147-
@media (prefers-color-scheme: dark) {
157+
}
158+
@media (prefers-color-scheme: dark) {
159+
.ddg-toggle-button-label {
148160
color: rgba(255, 255, 255, 0.84);
149161
}
150162
}
@@ -157,34 +169,41 @@
157169
cursor: pointer;
158170
text-decoration: none;
159171
color: #3969ef;
160-
@media (prefers-color-scheme: dark) {
172+
}
173+
@media (prefers-color-scheme: dark) {
174+
.ddg-text-link {
161175
color: #7295f6;
162176
}
163177
}
164178

165179
/* Styles for DDGCtlPlaceholderBlocked */
166180
.DuckDuckGoButton.ddg-ctl-unblock-btn {
167181
width: 100%;
168-
@media (min-width: 480px) {
182+
}
183+
@media (min-width: 480px) {
184+
.DuckDuckGoButton.ddg-ctl-unblock-btn {
169185
width: auto;
170186
}
171187
}
172188

173189
.ddg-ctl-placeholder-card {
190+
min-height: 180px;
191+
height: 100%;
192+
overflow: auto;
174193
box-sizing: border-box;
175194
padding: 16px;
176195
color: rgba(0, 0, 0, 0.84);
177196
background: #ffffff;
178197
border: 1px solid rgba(0, 0, 0, 0.12);
179198
border-radius: 12px;
180-
max-width: 600px;
181-
min-height: 180px;
182199
margin: auto;
183200
display: grid;
184201
justify-content: center;
185202
align-items: center;
186203
line-height: 1;
187-
@media (prefers-color-scheme: dark) {
204+
}
205+
@media (prefers-color-scheme: dark) {
206+
.ddg-ctl-placeholder-card {
188207
color: rgba(255, 255, 255, 0.84);
189208
background: #222222;
190209
border: 1px solid rgba(255, 255, 255, 0.24);
@@ -193,8 +212,8 @@
193212
.ddg-ctl-placeholder-card.slim-card {
194213
padding: 12px;
195214
}
196-
.ddg-ctl-placeholder-card.with-feedback-link {
197-
@media (min-width: 480px) {
215+
@media (min-width: 480px) {
216+
.ddg-ctl-placeholder-card.with-feedback-link {
198217
height: calc(100% - 30px);
199218
max-width: initial;
200219
min-height: initial;
@@ -207,11 +226,17 @@
207226
align-items: center;
208227
margin: auto;
209228
margin-bottom: 8px;
210-
@media (min-width: 480px) {
229+
}
230+
@media (min-width: 480px) {
231+
.ddg-ctl-placeholder-card-header {
211232
flex-direction: column;
212233
align-items: center;
213234
justify-content: center;
214235
margin-bottom: 12px;
236+
}
237+
}
238+
@media (min-width: 720px) {
239+
.ddg-ctl-placeholder-card-header {
215240
width: 70%;
216241
}
217242
}
@@ -230,7 +255,10 @@
230255
font-weight: 700;
231256
font-size: 16px;
232257
line-height: 24px;
233-
@media (min-width: 480px) {
258+
}
259+
@media (min-width: 480px) {
260+
.ddg-ctl-placeholder-card-title,
261+
.ddg-ctl-placeholder-card-title .ddg-text-link {
234262
text-align: center;
235263
}
236264
}
@@ -240,11 +268,15 @@
240268
width: 48px;
241269
height: 48px;
242270
margin: 0 8px 0 0;
243-
@media (min-width: 480px) {
271+
}
272+
@media (min-width: 480px) {
273+
.ddg-ctl-placeholder-card-header-dax {
244274
align-self: inherit;
245275
margin: 0 0 12px 0;
246276
}
247-
@media (min-width: 720px) {
277+
}
278+
@media (min-width: 720px) {
279+
.ddg-ctl-placeholder-card-header-dax {
248280
width: 56px;
249281
height: 56px;
250282
}
@@ -262,7 +294,9 @@
262294

263295
display: none;
264296
visibility: hidden;
265-
@media (min-width: 720px) {
297+
}
298+
@media (min-width: 720px) {
299+
.ddg-ctl-placeholder-card-body-text {
266300
display: block;
267301
visibility: visible;
268302
}
@@ -280,7 +314,9 @@
280314
.ddg-ctl-feedback-row {
281315
display: none;
282316
visibility: hidden;
283-
@media (min-width: 480px) {
317+
}
318+
@media (min-width: 480px) {
319+
.ddg-ctl-feedback-row {
284320
height: 30px;
285321
justify-content: flex-end;
286322
align-items: center;

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class DDGCtlPlaceholderBlocked extends HTMLElement {
7373
* Creates a placeholder for content blocked by Click to Load.
7474
* @returns {HTMLDivElement}
7575
*/
76-
createPlaceholder () {
76+
createPlaceholder = () => {
7777
const { title, body, unblockBtnText, useSlimCard, withToggle, withFeedback } = this.params
7878

7979
const container = document.createElement('div')
@@ -105,7 +105,7 @@ export class DDGCtlPlaceholderBlocked extends HTMLElement {
105105
/**
106106
* Creates a template string for Learn More link.
107107
*/
108-
createLearnMoreLink () {
108+
createLearnMoreLink = () => {
109109
const { sharedStrings } = this.params
110110

111111
return html`<a
@@ -122,7 +122,7 @@ export class DDGCtlPlaceholderBlocked extends HTMLElement {
122122
* Creates a Feedback Link container row
123123
* @returns {HTMLDivElement}
124124
*/
125-
createShareFeedbackLink () {
125+
createShareFeedbackLink = () => {
126126
const { sharedStrings } = this.params
127127

128128
const container = document.createElement('div')
@@ -138,7 +138,7 @@ export class DDGCtlPlaceholderBlocked extends HTMLElement {
138138
/**
139139
* Creates a template string for a toggle button with text.
140140
*/
141-
createToggleButton () {
141+
createToggleButton = () => {
142142
const { withToggle, isMobileApp } = this.params
143143
if (!withToggle) return
144144

@@ -164,9 +164,9 @@ export class DDGCtlPlaceholderBlocked extends HTMLElement {
164164
/**
165165
*
166166
* @param {HTMLElement} containerElement
167-
* @param {HTMLElement} feedbackLink
167+
* @param {HTMLElement?} feedbackLink
168168
*/
169-
setupEventListeners (containerElement, feedbackLink) {
169+
setupEventListeners = (containerElement, feedbackLink) => {
170170
const { withToggle, withFeedback, originalElement, onButtonClick } = this.params
171171

172172
containerElement
@@ -178,7 +178,7 @@ export class DDGCtlPlaceholderBlocked extends HTMLElement {
178178
.querySelector('.ddg-toggle-button-container')
179179
?.addEventListener('click', withToggle.onClick)
180180
}
181-
if (withFeedback) {
181+
if (withFeedback && feedbackLink) {
182182
feedbackLink.querySelector('.ddg-ctl-feedback-link')?.addEventListener('click', withFeedback.onClick)
183183
}
184184
}

0 commit comments

Comments
 (0)