@financial-times/n-myft-ui 28.2.1 → 28.2.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,8 @@
|
|
4
4
|
data-myft-ui="saved"
|
5
5
|
action="/myft/save/{{contentId}}"
|
6
6
|
data-js-action="/__myft/api/core/saved/content/{{contentId}}?method=put"
|
7
|
-
{{#if @root.flags.manageArticleLists}}data-myft-ui-save-new="manageArticleLists"{{/if}}
|
7
|
+
{{#if @root.flags.manageArticleLists}}data-myft-ui-save-new="manageArticleLists"{{/if}}
|
8
|
+
{{#if @root.flags.manageArticleLists}}data-myft-ui-save-new-config="{{#if @root.flags.myftListPublicPrivateToggle}}showPublicToggle{{/if}}"{{/if}}>
|
8
9
|
{{> n-myft-ui/components/csrf-token/input}}
|
9
10
|
<div
|
10
11
|
class="n-myft-ui__announcement o-normalise-visually-hidden"
|
package/myft/main.scss
CHANGED
@@ -183,6 +183,26 @@ $spacing-unit: 20px;
|
|
183
183
|
}
|
184
184
|
}
|
185
185
|
|
186
|
+
.myft-ui-create-list-variant-message {
|
187
|
+
border-radius: 10px;
|
188
|
+
border: 1px solid oColorsByName('black-5');
|
189
|
+
background: oColorsByName('white-80');
|
190
|
+
|
191
|
+
&-content {
|
192
|
+
display: flex;
|
193
|
+
flex-direction: column;
|
194
|
+
|
195
|
+
h3 {
|
196
|
+
margin: 0;
|
197
|
+
}
|
198
|
+
}
|
199
|
+
|
200
|
+
&-buttons {
|
201
|
+
text-align: center;
|
202
|
+
}
|
203
|
+
}
|
204
|
+
|
205
|
+
|
186
206
|
.myft-ui-create-list-variant {
|
187
207
|
border-radius: 10px;
|
188
208
|
border: 1px solid oColorsByName('black-5');
|
@@ -219,13 +239,12 @@ $spacing-unit: 20px;
|
|
219
239
|
color: oColorsByName('black-80');
|
220
240
|
|
221
241
|
padding-left: 0;
|
222
|
-
margin-left: -8px;
|
223
242
|
|
224
243
|
&:hover {
|
225
244
|
text-decoration: underline;
|
226
245
|
}
|
227
246
|
|
228
|
-
|
247
|
+
&-collapsed::before {
|
229
248
|
content: '';
|
230
249
|
@include oIconsContent(
|
231
250
|
'plus',
|
@@ -235,11 +254,12 @@ $spacing-unit: 20px;
|
|
235
254
|
);
|
236
255
|
vertical-align: middle;
|
237
256
|
margin-top: -2px;
|
257
|
+
margin-left: -8px;
|
238
258
|
}
|
239
259
|
}
|
240
260
|
|
241
261
|
&-add-description {
|
242
|
-
margin:
|
262
|
+
margin: oSpacingByName('s1') 0;
|
243
263
|
}
|
244
264
|
|
245
265
|
&-heading {
|
@@ -258,7 +278,7 @@ $spacing-unit: 20px;
|
|
258
278
|
|
259
279
|
&-footer {
|
260
280
|
border-top: 1px solid oColorsByName('black-5');
|
261
|
-
padding:
|
281
|
+
padding: oSpacingByName('s4');
|
262
282
|
}
|
263
283
|
|
264
284
|
&-icon {
|
@@ -288,34 +308,54 @@ $spacing-unit: 20px;
|
|
288
308
|
}
|
289
309
|
|
290
310
|
&-form {
|
311
|
+
$field-spacing: 's4';
|
291
312
|
display: flex;
|
313
|
+
flex-direction: column;
|
292
314
|
width: calc(100% - 32px);
|
293
|
-
|
294
|
-
|
295
|
-
gap: 8px;
|
296
|
-
padding: 0 16px 16px;
|
315
|
+
gap: oSpacingByName($field-spacing);
|
316
|
+
padding: 0 oSpacingByName($field-spacing) oSpacingByName('s3');
|
297
317
|
|
298
318
|
& > * {
|
299
319
|
flex: 1 1 auto;
|
320
|
+
margin-bottom: 0;
|
300
321
|
}
|
301
322
|
|
302
323
|
.o-forms-input {
|
303
324
|
margin-top: 0;
|
304
325
|
}
|
326
|
+
|
327
|
+
&-toggle {
|
328
|
+
position: absolute;
|
329
|
+
}
|
330
|
+
|
331
|
+
&-toggle-label::after {
|
332
|
+
background-color: oColorsByName('white');
|
333
|
+
}
|
334
|
+
|
335
|
+
&-buttons {
|
336
|
+
display: flex;
|
337
|
+
justify-content: flex-end;
|
338
|
+
@include oTypographySans($scale: 2);
|
339
|
+
}
|
340
|
+
|
341
|
+
&-public {
|
342
|
+
max-width: 300px;
|
343
|
+
padding: 0 3px;
|
344
|
+
}
|
305
345
|
}
|
306
346
|
|
307
347
|
&-lists {
|
308
|
-
padding:
|
348
|
+
padding: oSpacingByName('s4') oSpacingByName('s4') 0;
|
309
349
|
@include oTypographySans($scale: 1);
|
310
350
|
&-text {
|
311
351
|
@include oTypographySans($weight: 'semibold');
|
312
352
|
color: oColorsByName('black-80');
|
313
|
-
margin-bottom:
|
353
|
+
margin-bottom: oSpacingByName('s3');
|
314
354
|
}
|
315
355
|
&-container {
|
316
356
|
margin-top: 0;
|
317
357
|
max-height: 92px;
|
318
|
-
padding
|
358
|
+
padding: 4px 2px;
|
319
359
|
overflow-y: auto;
|
320
360
|
@include oGridRespondTo($from: M) {
|
321
361
|
max-height: 126px;
|
package/myft/ui/lists.js
CHANGED
@@ -180,8 +180,13 @@ function showArticleSavedOverlay (contentId) {
|
|
180
180
|
showListsOverlay('Article saved', `/myft/list?fragment=true&fromArticleSaved=true&contentId=${contentId}`, contentId);
|
181
181
|
}
|
182
182
|
|
183
|
-
function showCreateListAndAddArticleOverlay (contentId,
|
184
|
-
|
183
|
+
function showCreateListAndAddArticleOverlay (contentId, config) {
|
184
|
+
const options = {
|
185
|
+
name: 'myft-ui-create-list-variant',
|
186
|
+
...config
|
187
|
+
};
|
188
|
+
|
189
|
+
return openSaveArticleToListVariant(contentId, options);
|
185
190
|
}
|
186
191
|
|
187
192
|
function handleArticleSaved (contentId) {
|
@@ -194,11 +199,11 @@ function handleArticleSaved (contentId) {
|
|
194
199
|
});
|
195
200
|
}
|
196
201
|
|
197
|
-
function openCreateListAndAddArticleOverlay (contentId) {
|
202
|
+
function openCreateListAndAddArticleOverlay (contentId, config) {
|
198
203
|
return myFtClient.getAll('created', 'list')
|
199
204
|
.then(createdLists => createdLists.filter(list => !list.isRedirect))
|
200
205
|
.then(() => {
|
201
|
-
return showCreateListAndAddArticleOverlay(contentId);
|
206
|
+
return showCreateListAndAddArticleOverlay(contentId, config);
|
202
207
|
});
|
203
208
|
}
|
204
209
|
|
@@ -269,7 +274,23 @@ function initialEventListeners () {
|
|
269
274
|
// otherwise it will show the classic overlay
|
270
275
|
const newListDesign = event.currentTarget.querySelector('[data-myft-ui-save-new="manageArticleLists"]');
|
271
276
|
if (newListDesign) {
|
272
|
-
|
277
|
+
const configKeys = newListDesign.dataset.myftUiSaveNewConfig.split(',');
|
278
|
+
const config = configKeys.reduce((configObj, key) => (key ? { ...configObj, [key]: true} : configObj), {});
|
279
|
+
|
280
|
+
// Temporary events on the public toggle feature.
|
281
|
+
// These will be used to build a sanity check dashboard, and will be removed after we get clean-up this test.
|
282
|
+
document.body.dispatchEvent(new CustomEvent('oTracking.event', {
|
283
|
+
detail: {
|
284
|
+
category: 'publicToggle',
|
285
|
+
action: 'savedArticle',
|
286
|
+
article_id: contentId,
|
287
|
+
teamName: 'customer-products-us-growth',
|
288
|
+
amplitudeExploratory: true
|
289
|
+
},
|
290
|
+
bubbles: true
|
291
|
+
}));
|
292
|
+
|
293
|
+
return openCreateListAndAddArticleOverlay(contentId, config);
|
273
294
|
}
|
274
295
|
|
275
296
|
handleArticleSaved(contentId);
|
@@ -11,29 +11,26 @@ let lists = [];
|
|
11
11
|
let haveLoadedLists = false;
|
12
12
|
let createListOverlay;
|
13
13
|
|
14
|
-
export default async function openSaveArticleToListVariant (
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
export default async function openSaveArticleToListVariant (contentId, options = {}) {
|
15
|
+
const { name, showPublicToggle = false } = options;
|
16
|
+
|
17
|
+
function createList (newList, cb) {
|
18
|
+
if(!newList || !newList.name) {
|
19
|
+
return restoreContent();
|
19
20
|
}
|
20
21
|
|
21
|
-
myFtClient.add('user', null, 'created', 'list', uuid(), { name:
|
22
|
+
myFtClient.add('user', null, 'created', 'list', uuid(), { name: newList.name, token: csrfToken })
|
22
23
|
.then(detail => {
|
23
|
-
myFtClient.add('list', detail.subject, 'contained', 'content', contentId, { token: csrfToken }).then((
|
24
|
-
|
25
|
-
|
26
|
-
const overlayContent = document.querySelector('.o-overlay__content');
|
27
|
-
overlayContent.insertAdjacentElement('afterbegin', listElement);
|
24
|
+
myFtClient.add('list', detail.subject, 'contained', 'content', contentId, { token: csrfToken }).then((data) => {
|
25
|
+
const createdList = { name: newList.name, uuid: data.actorId, checked: true, isShareable: !!newList.isShareable };
|
26
|
+
lists.unshift(createdList);
|
28
27
|
const announceListContainer = document.querySelector('.myft-ui-create-list-variant-announcement');
|
29
|
-
announceListContainer.textContent = `${
|
30
|
-
|
31
|
-
cb(contentId, createdList.actorId);
|
28
|
+
announceListContainer.textContent = `${newList.name} created`;
|
29
|
+
cb(contentId, createdList);
|
32
30
|
});
|
33
31
|
})
|
34
32
|
.catch(() => {
|
35
|
-
|
36
|
-
return contentElement.addEventListener('click', openFormHandler, { once: true });
|
33
|
+
return restoreContent();
|
37
34
|
});
|
38
35
|
}
|
39
36
|
|
@@ -59,6 +56,13 @@ export default async function openSaveArticleToListVariant (name, contentId) {
|
|
59
56
|
});
|
60
57
|
}
|
61
58
|
|
59
|
+
function restoreContent () {
|
60
|
+
if (!lists.length) attachDescription();
|
61
|
+
refreshListElement();
|
62
|
+
showListElement();
|
63
|
+
return restoreFormHandler();
|
64
|
+
}
|
65
|
+
|
62
66
|
if (!haveLoadedLists) {
|
63
67
|
lists = await getLists(contentId);
|
64
68
|
haveLoadedLists = true;
|
@@ -71,7 +75,8 @@ export default async function openSaveArticleToListVariant (name, contentId) {
|
|
71
75
|
}
|
72
76
|
|
73
77
|
const headingElement = HeadingElement();
|
74
|
-
let [contentElement, removeDescription, attachDescription] = ContentElement(!lists.length);
|
78
|
+
let [contentElement, removeDescription, attachDescription, restoreFormHandler] = ContentElement(!lists.length, openFormHandler);
|
79
|
+
const [listElement, refreshListElement, hideListElement, showListElement] = ListsElement(lists, addToList, removeFromList);
|
75
80
|
|
76
81
|
createListOverlay = new Overlay(name, {
|
77
82
|
html: contentElement,
|
@@ -92,36 +97,40 @@ export default async function openSaveArticleToListVariant (name, contentId) {
|
|
92
97
|
}
|
93
98
|
}
|
94
99
|
|
100
|
+
function onFormCancel () {
|
101
|
+
showListElement();
|
102
|
+
restoreFormHandler();
|
103
|
+
}
|
104
|
+
|
105
|
+
function onFormListCreated () {
|
106
|
+
refreshListElement();
|
107
|
+
showListElement();
|
108
|
+
restoreFormHandler();
|
109
|
+
}
|
110
|
+
|
95
111
|
function openFormHandler () {
|
96
|
-
|
112
|
+
hideListElement();
|
113
|
+
const formElement = FormElement(createList, showPublicToggle, attachDescription, onFormListCreated, onFormCancel);
|
97
114
|
const overlayContent = document.querySelector('.o-overlay__content');
|
98
115
|
removeDescription();
|
99
116
|
overlayContent.insertAdjacentElement('beforeend', formElement);
|
100
117
|
formElement.elements[0].focus();
|
101
118
|
}
|
102
119
|
|
103
|
-
function getScrollHandler (target) {
|
104
|
-
return realignOverlay(window.scrollY, target);
|
105
|
-
}
|
106
|
-
|
107
|
-
function resizeHandler () {
|
108
|
-
positionOverlay(createListOverlay.wrapper);
|
109
|
-
}
|
110
|
-
|
111
120
|
createListOverlay.open();
|
112
121
|
|
113
122
|
const scrollHandler = getScrollHandler(createListOverlay.wrapper);
|
123
|
+
const resizeHandler = getResizeHandler(createListOverlay.wrapper);
|
114
124
|
|
115
125
|
createListOverlay.wrapper.addEventListener('oOverlay.ready', (data) => {
|
116
126
|
if (lists.length) {
|
117
|
-
const listElement = ListsElement(lists, addToList, removeFromList);
|
118
127
|
const overlayContent = document.querySelector('.o-overlay__content');
|
119
128
|
overlayContent.insertAdjacentElement('afterbegin', listElement);
|
120
129
|
}
|
121
130
|
|
122
131
|
positionOverlay(data.currentTarget);
|
123
132
|
|
124
|
-
|
133
|
+
restoreFormHandler();
|
125
134
|
|
126
135
|
document.querySelector('.article-content').addEventListener('click', outsideClickHandler);
|
127
136
|
|
@@ -139,17 +148,90 @@ export default async function openSaveArticleToListVariant (name, contentId) {
|
|
139
148
|
});
|
140
149
|
}
|
141
150
|
|
142
|
-
function
|
151
|
+
function showMessageOverlay () {
|
152
|
+
function onContinue () {
|
153
|
+
messageOverlay.destroy();
|
154
|
+
createListOverlay.show();
|
155
|
+
triggerAcknowledgeMessageEvent();
|
156
|
+
}
|
157
|
+
|
158
|
+
const messageElement = MessageElement(onContinue);
|
159
|
+
|
160
|
+
const messageOverlay = new Overlay('myft-ui-create-list-variant-message', {
|
161
|
+
html: messageElement,
|
162
|
+
modal: false,
|
163
|
+
parentnode: isMobile() ? '.o-share--horizontal' : '.o-share--vertical',
|
164
|
+
class: 'myft-ui-create-list-variant-message',
|
165
|
+
});
|
166
|
+
|
167
|
+
const scrollHandler = getScrollHandler(messageOverlay.wrapper);
|
168
|
+
const resizeHandler = getResizeHandler(messageOverlay.wrapper);
|
169
|
+
|
170
|
+
messageOverlay.open();
|
171
|
+
|
172
|
+
messageOverlay.wrapper.addEventListener('oOverlay.ready', (data) => {
|
173
|
+
positionOverlay(data.currentTarget);
|
174
|
+
|
175
|
+
window.addEventListener('scroll', scrollHandler);
|
176
|
+
|
177
|
+
window.addEventListener('oViewport.resize', resizeHandler);
|
178
|
+
});
|
179
|
+
|
180
|
+
messageOverlay.wrapper.addEventListener('oOverlay.destroy', () => {
|
181
|
+
window.removeEventListener('scroll', scrollHandler);
|
182
|
+
|
183
|
+
window.removeEventListener('oViewport.resize', resizeHandler);
|
184
|
+
});
|
185
|
+
|
186
|
+
return messageOverlay;
|
187
|
+
}
|
188
|
+
|
189
|
+
function getScrollHandler (target) {
|
190
|
+
return realignOverlay(window.scrollY, target);
|
191
|
+
}
|
192
|
+
|
193
|
+
function getResizeHandler (target) {
|
194
|
+
return function resizeHandler () {
|
195
|
+
positionOverlay(target);
|
196
|
+
};
|
197
|
+
}
|
198
|
+
|
199
|
+
function FormElement (createList, showPublicToggle, attachDescription, onListCreated, onCancel) {
|
143
200
|
const formString = `
|
144
201
|
<form class="myft-ui-create-list-variant-form">
|
145
|
-
<label class="o-forms-field">
|
202
|
+
<label class="myft-ui-create-list-variant-form-name o-forms-field">
|
146
203
|
<span class="o-forms-input o-forms-input--text">
|
147
|
-
<input type="text" name="list-name" aria-label="List name">
|
204
|
+
<input class="myft-ui-create-list-variant-text" type="text" name="list-name" aria-label="List name">
|
148
205
|
</span>
|
149
206
|
</label>
|
150
|
-
|
151
|
-
|
152
|
-
|
207
|
+
|
208
|
+
${showPublicToggle ?
|
209
|
+
`<div class="myft-ui-create-list-variant-form-public o-forms-field" role="group">
|
210
|
+
<span class="o-forms-input o-forms-input--toggle">
|
211
|
+
<label>
|
212
|
+
<input class="myft-ui-create-list-variant-form-toggle" type="checkbox" name="is-shareable" value="public" checked data-trackable="private-link" text="private">
|
213
|
+
<span class="myft-ui-create-list-variant-form-toggle-label o-forms-input__label">
|
214
|
+
<span class="o-forms-input__label__main">
|
215
|
+
Public
|
216
|
+
</span>
|
217
|
+
<span id="myft-ui-create-list-variant-form-public-description" class="o-forms-input__label__prompt">
|
218
|
+
Your profession & list will be visible to others
|
219
|
+
</span>
|
220
|
+
</span>
|
221
|
+
</label>
|
222
|
+
</span>
|
223
|
+
</div>` :
|
224
|
+
''
|
225
|
+
}
|
226
|
+
|
227
|
+
<div class="myft-ui-create-list-variant-form-buttons">
|
228
|
+
<button class="o-buttons o-buttons--primary o-buttons--inverse o-buttons--big" type="button" data-trackable="cancel-link" text="cancel">
|
229
|
+
Cancel
|
230
|
+
</button>
|
231
|
+
<button class="o-buttons o-buttons--big o-buttons--secondary" type="submit">
|
232
|
+
Add
|
233
|
+
</button>
|
234
|
+
</div>
|
153
235
|
</form>
|
154
236
|
`;
|
155
237
|
|
@@ -159,26 +241,63 @@ function FormElement (createList) {
|
|
159
241
|
event.preventDefault();
|
160
242
|
event.stopPropagation();
|
161
243
|
const inputListName = formElement.querySelector('input[name="list-name"]');
|
162
|
-
|
163
|
-
|
164
|
-
|
244
|
+
const inputIsShareable = formElement.querySelector('input[name="is-shareable"]');
|
245
|
+
|
246
|
+
const newList = {
|
247
|
+
name: inputListName.value,
|
248
|
+
isShareable: inputIsShareable ? inputIsShareable.checked : false
|
249
|
+
};
|
250
|
+
|
251
|
+
createList(newList, ((contentId, createdList) => {
|
252
|
+
triggerCreateListEvent(contentId, createdList.uuid);
|
253
|
+
triggerAddToListEvent(contentId, createdList.uuid);
|
165
254
|
positionOverlay(createListOverlay.wrapper);
|
255
|
+
triggerCancelEvent();
|
256
|
+
|
257
|
+
if (createdList.isShareable) {
|
258
|
+
createListOverlay.close();
|
259
|
+
showMessageOverlay();
|
260
|
+
}
|
261
|
+
|
262
|
+
onListCreated();
|
166
263
|
}));
|
167
|
-
inputListName.value = '';
|
168
264
|
formElement.remove();
|
169
265
|
}
|
170
266
|
|
267
|
+
function handleCancelClick (event) {
|
268
|
+
event.preventDefault();
|
269
|
+
event.stopPropagation();
|
270
|
+
formElement.remove();
|
271
|
+
if (!lists.length) attachDescription();
|
272
|
+
onCancel();
|
273
|
+
}
|
274
|
+
|
171
275
|
formElement.querySelector('button[type="submit"]').addEventListener('click', handleSubmit);
|
276
|
+
formElement.querySelector('button[type="button"]').addEventListener('click', handleCancelClick);
|
277
|
+
|
278
|
+
if (showPublicToggle) {
|
279
|
+
addPublicToggleListener(formElement);
|
280
|
+
}
|
172
281
|
|
173
282
|
return formElement;
|
174
283
|
}
|
175
284
|
|
176
|
-
function
|
285
|
+
function addPublicToggleListener (formElement) {
|
286
|
+
function onPublicToggleClick (event) {
|
287
|
+
event.target.setAttribute('data-trackable', event.target.checked ? 'private-link' : 'public-link');
|
288
|
+
event.target.setAttribute('text', event.target.checked ? 'private' : 'public');
|
289
|
+
triggerPublicToggleEvent(event.target.checked);
|
290
|
+
}
|
291
|
+
|
292
|
+
formElement.querySelector('input[name="is-shareable"]').addEventListener('click', onPublicToggleClick);
|
293
|
+
}
|
294
|
+
|
295
|
+
function ContentElement (hasDescription, onClick) {
|
177
296
|
const description = '<p class="myft-ui-create-list-variant-add-description">Lists are a simple way to curate your content</p>';
|
178
297
|
|
179
298
|
const content = `
|
180
299
|
<div class="myft-ui-create-list-variant-footer">
|
181
|
-
<button class="myft-ui-create-list-variant-add" data-trackable="add-to-new-list" text="
|
300
|
+
<button class="myft-ui-create-list-variant-add myft-ui-create-list-variant-add-collapsed" data-trackable="add-to-new-list" text="add to new list">Add to a new list</button>
|
182
301
|
${hasDescription ? `
|
183
302
|
${description}
|
184
303
|
` : ''}
|
@@ -187,6 +306,8 @@ function ContentElement (hasDescription) {
|
|
187
306
|
|
188
307
|
const contentElement = stringToHTMLElement(content);
|
189
308
|
|
309
|
+
contentElement.querySelector('.myft-ui-create-list-variant-add').addEventListener('click', triggerAddToNewListEvent);
|
310
|
+
|
190
311
|
function removeDescription () {
|
191
312
|
const descriptionElement = contentElement.querySelector('.myft-ui-create-list-variant-add-description');
|
192
313
|
if (descriptionElement) {
|
@@ -199,7 +320,17 @@ function ContentElement (hasDescription) {
|
|
199
320
|
contentElement.insertAdjacentElement('beforeend', descriptionElement);
|
200
321
|
}
|
201
322
|
|
202
|
-
|
323
|
+
function restoreFormHandler () {
|
324
|
+
contentElement.querySelector('.myft-ui-create-list-variant-add').classList.add('myft-ui-create-list-variant-add-collapsed');
|
325
|
+
return contentElement.addEventListener('click', clickHandler, { once: true });
|
326
|
+
}
|
327
|
+
|
328
|
+
function clickHandler (event) {
|
329
|
+
contentElement.querySelector('.myft-ui-create-list-variant-add').classList.remove('myft-ui-create-list-variant-add-collapsed');
|
330
|
+
onClick(event);
|
331
|
+
}
|
332
|
+
|
333
|
+
return [contentElement, removeDescription, attachDescription, restoreFormHandler];
|
203
334
|
}
|
204
335
|
|
205
336
|
function HeadingElement () {
|
@@ -220,7 +351,7 @@ function ListsElement (lists, addToList, removeFromList) {
|
|
220
351
|
|
221
352
|
const listsTemplate = `
|
222
353
|
<div class="myft-ui-create-list-variant-lists o-forms-field o-forms-field--optional" role="group">
|
223
|
-
<span class="myft-ui-create-list-variant-lists-text">Add to
|
354
|
+
<span class="myft-ui-create-list-variant-lists-text">Add to list</span>
|
224
355
|
<span class="myft-ui-create-list-variant-lists-container o-forms-input o-forms-input--checkbox">
|
225
356
|
</span>
|
226
357
|
</div>
|
@@ -229,9 +360,21 @@ function ListsElement (lists, addToList, removeFromList) {
|
|
229
360
|
|
230
361
|
const listsElementContainer = listsElement.querySelector('.myft-ui-create-list-variant-lists-container');
|
231
362
|
|
232
|
-
|
363
|
+
function refresh () {
|
364
|
+
listsElementContainer.replaceChildren(...lists.map(list => listCheckboxElement(list)));
|
365
|
+
}
|
366
|
+
|
367
|
+
function hide () {
|
368
|
+
listsElement.style.display = 'none';
|
369
|
+
}
|
233
370
|
|
234
|
-
|
371
|
+
function show () {
|
372
|
+
listsElement.style.display = 'flex';
|
373
|
+
}
|
374
|
+
|
375
|
+
refresh();
|
376
|
+
|
377
|
+
return [listsElement, refresh, hide, show];
|
235
378
|
}
|
236
379
|
|
237
380
|
function ListCheckboxElement (addToList, removeFromList) {
|
@@ -271,6 +414,28 @@ function ListCheckboxElement (addToList, removeFromList) {
|
|
271
414
|
};
|
272
415
|
}
|
273
416
|
|
417
|
+
function MessageElement (onContinue) {
|
418
|
+
const message = `
|
419
|
+
<div class="myft-ui-create-list-variant-message-content" >
|
420
|
+
<div class="myft-ui-create-list-variant-message-text" aria-live="polite">
|
421
|
+
<h3>Thank you for your interest in making a public list</h3>
|
422
|
+
<p>We're currently testing this feature. For now, your list remains private and isn't visible to others.</p>
|
423
|
+
</div>
|
424
|
+
<div class="myft-ui-create-list-variant-message-buttons">
|
425
|
+
<button class="o-buttons o-buttons--big o-buttons--secondary" data-trackable="continue-link" text="continue">
|
426
|
+
Continue
|
427
|
+
</button>
|
428
|
+
</div>
|
429
|
+
</div>
|
430
|
+
`;
|
431
|
+
|
432
|
+
const messageElement = stringToHTMLElement(message);
|
433
|
+
|
434
|
+
messageElement.querySelector('button').addEventListener('click', onContinue);
|
435
|
+
|
436
|
+
return messageElement;
|
437
|
+
}
|
438
|
+
|
274
439
|
function realignOverlay (originalScrollPosition, target) {
|
275
440
|
return function () {
|
276
441
|
const currentScrollPosition = window.scrollY;
|
@@ -290,20 +455,19 @@ function realignOverlay (originalScrollPosition, target) {
|
|
290
455
|
function positionOverlay (target) {
|
291
456
|
target.style['min-width'] = '340px';
|
292
457
|
target.style['width'] = '100%';
|
293
|
-
target.style['margin-top'] =
|
458
|
+
target.style['margin-top'] = 0;
|
294
459
|
target.style['left'] = 0;
|
460
|
+
target.style['top'] = 0;
|
295
461
|
|
296
462
|
if (isMobile()) {
|
297
463
|
const shareNavComponent = document.querySelector('.share-nav__horizontal');
|
298
464
|
const topHalfOffset = target.clientHeight + 10;
|
299
465
|
target.style['position'] = 'absolute';
|
300
466
|
target.style['margin-left'] = 0;
|
301
|
-
target.style['margin-top'] = 0;
|
302
467
|
target.style['top'] = calculateLargerScreenHalf(shareNavComponent) === 'ABOVE' ? `-${topHalfOffset}px` : '50px';
|
303
468
|
} else {
|
304
469
|
target.style['position'] = 'absolute';
|
305
470
|
target.style['margin-left'] = '45px';
|
306
|
-
target.style['top'] = '220px';
|
307
471
|
}
|
308
472
|
}
|
309
473
|
|
@@ -325,7 +489,7 @@ async function getLists (contentId) {
|
|
325
489
|
return myFtClient.getListsContent()
|
326
490
|
.then(results => results.items.map(list => {
|
327
491
|
const isChecked = Array.isArray(list.content) && list.content.some(content => content.uuid === contentId);
|
328
|
-
return { name: list.name, uuid: list.uuid, checked: isChecked, content: list.content };
|
492
|
+
return { name: list.name, uuid: list.uuid, checked: isChecked, content: list.content, isShareable: false };
|
329
493
|
}));
|
330
494
|
}
|
331
495
|
|
@@ -370,3 +534,59 @@ function triggerCreateListEvent (contentId, listId) {
|
|
370
534
|
bubbles: true
|
371
535
|
}));
|
372
536
|
}
|
537
|
+
|
538
|
+
// Temporary event on the public toggle feature.
|
539
|
+
// These will be used to build a sanity check dashboard, and will be removed after we get clean-up this test.
|
540
|
+
function triggerPublicToggleEvent (isPublic) {
|
541
|
+
document.body.dispatchEvent(new CustomEvent('oTracking.event', {
|
542
|
+
detail: {
|
543
|
+
category: 'publicToggle',
|
544
|
+
action: `${isPublic ? 'setPublic' : 'setPrivate'}`,
|
545
|
+
teamName: 'customer-products-us-growth',
|
546
|
+
amplitudeExploratory: true
|
547
|
+
},
|
548
|
+
bubbles: true
|
549
|
+
}));
|
550
|
+
}
|
551
|
+
|
552
|
+
// Temporary event on the public toggle feature.
|
553
|
+
// These will be used to build a sanity check dashboard, and will be removed after we get clean-up this test.
|
554
|
+
function triggerAddToNewListEvent () {
|
555
|
+
document.body.dispatchEvent(new CustomEvent('oTracking.event', {
|
556
|
+
detail: {
|
557
|
+
category: 'publicToggle',
|
558
|
+
action: 'addToNewList',
|
559
|
+
teamName: 'customer-products-us-growth',
|
560
|
+
amplitudeExploratory: true
|
561
|
+
},
|
562
|
+
bubbles: true
|
563
|
+
}));
|
564
|
+
}
|
565
|
+
|
566
|
+
// Temporary event on the public toggle feature.
|
567
|
+
// These will be used to build a sanity check dashboard, and will be removed after we get clean-up this test.
|
568
|
+
function triggerAcknowledgeMessageEvent () {
|
569
|
+
document.body.dispatchEvent(new CustomEvent('oTracking.event', {
|
570
|
+
detail: {
|
571
|
+
category: 'publicToggle',
|
572
|
+
action: 'acknowledgeMessage',
|
573
|
+
teamName: 'customer-products-us-growth',
|
574
|
+
amplitudeExploratory: true
|
575
|
+
},
|
576
|
+
bubbles: true
|
577
|
+
}));
|
578
|
+
}
|
579
|
+
|
580
|
+
// Temporary event on the public toggle feature.
|
581
|
+
// These will be used to build a sanity check dashboard, and will be removed after we get clean-up this test.
|
582
|
+
function triggerCancelEvent () {
|
583
|
+
document.body.dispatchEvent(new CustomEvent('oTracking.event', {
|
584
|
+
detail: {
|
585
|
+
category: 'publicToggle',
|
586
|
+
action: 'cancel ',
|
587
|
+
teamName: 'customer-products-us-growth',
|
588
|
+
amplitudeExploratory: true
|
589
|
+
},
|
590
|
+
bubbles: true
|
591
|
+
}));
|
592
|
+
}
|