Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Es6 projects common modules gallery lightbox #18113

Merged
merged 10 commits into from
Nov 3, 2017

Conversation

NataliaLKB
Copy link
Contributor

@NataliaLKB NataliaLKB commented Nov 1, 2017

What does this change?

ES6 conversion for lightbox.js. I tried my best not to rewrite, but just convert (as advised)

This is my first es6 conversion so please let me know everything I could do better :).

Please note, I know of 3 current production bugs in lightbox. They are:

  1. Closing the lightbox doesn't remove the hash from the url (this is now fixed in this conversion)
  2. Share buttons don't work on mobile (not sure why, but I didn't fix as part of this)
  3. Lightbox not working on articles (works now!)

What is the value of this and can you measure success?

More modern JS

Does this affect other platforms - Amp, Apps, etc?

Nope

Does this affect GLabs Paid Content Pages? Should it have support for Paid Content?

Nope

Screenshots

Everything looks the same

Tested in CODE?

Yes

@PRBuilds
Copy link

PRBuilds commented Nov 1, 2017

PRbuilds results:

Screenshots
desktop.pngtablet.pngmobile.pngwide.png

💚 Exceptions
thrown-exceptions.js

💚 A11y validation
a11y-report.txt

Apache Benchmark Load Testing
loadtesting.txt

💚 Microdata Validation
microdata.txt

--automated message

@NataliaLKB NataliaLKB force-pushed the es6-projects_common_modules_gallery_lightbox branch from 00bc5ad to 5d3e0ac Compare November 1, 2017 15:49
@SiAdcock
Copy link
Contributor

SiAdcock commented Nov 1, 2017

Wow, this one is a monster! Awesome work 🎉

As a general suggestion, how do you feel about adding return type annotations to the methods of the GalleryLightbox class?

this.endslate.endpoint = '/gallery/most-viewed.json';
this.endslate.prerender = function () {
bonzo(this.elem).addClass(this.componentClass);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the prerender functionality longer needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Not sure how I lost it. I brought it back though :)

});
};

export { init, GalleryLightbox };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GalleryLightbox doesn't appear to be imported anywhere. Can we remove it from the export object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used in the tests, so I followed the advice in the wiki to export it differently

Copy link
Contributor

@gu-stav gu-stav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oha, this module is painful. Thanks for picking it up! 👍

};

const galleryLightboxHtml: string =
`${'<div class="overlay gallery-lightbox gallery-lightbox--closed gallery-lightbox--hover">' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this a template literal you don't have to use concatenation and just use it as a multiline string.

// FSM CONFIG
this.fsm = new FiniteStateMachine({
initial: 'closed',
onChangeState(oldState, newState) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Types? 👍


generateImgHTML(img: Object, i: number) {
const blockShortUrl = config.get('page.shortUrl');
const urlPrefix = img.src.indexOf('//') === 0 ? 'http:' : '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

img.src.startsWith('//') ? 'http:' : '';

contentEl.style.mozTransform = `translate(${px + offset}px,0)`;
contentEl.style.msTransform = `translate(${px + offset}px,0)`;
contentEl.style.transform = `translate(${px +
offset}px,0) translateZ(0)`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does flow complain of you do

Object.assign(contentEl.style, {
 /* ... */
})

to avoid all the repetition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not! Great suggestions 👍

} else if (e.keyCode === 73) {
// 'i'
this.trigger('toggleInfo');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♀️


let res;

bean.on(document.body, 'click', '.js-gallerythumbs', e => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the callback is so big: could you add the :Event type definition here?

}
}

GalleryLightbox.prototype.states = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move all of these into the constructor()?

},
loadJson(json: GalleryJson) {
this.galleryJson = json;
this.images = json.images ? json.images : [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.images = json.images || [];

@paperboyo
Copy link
Contributor

paperboyo commented Nov 1, 2017

Thanks so much!

Closing the lightbox doesn't remove the hash from the url (this is now fixed in this conversion)

Maybe this will finally fix #6144? Bravo! 🎆

Lightbox not working on articles (works now!)

Hmm, don't know anything about that, works for me (desktop, mobile).

Please note, I know of 3 current production bugs in lightbox.

Not counting the enhancements. And not counting the ones not recorded as issues (broken zoom, do-not-dare-swiping-up-on-Android-only-pros-know-how-to-not-have-addressbar-shown, lack of FullscreenAPI, close button not automatically appearing on last item, long captions breaking experience, not appearing for liveblog images, shut-up-paperboyo and many more 😆).

And integrating this for (for starters) disconnected members of a series 😉.

@NataliaLKB NataliaLKB force-pushed the es6-projects_common_modules_gallery_lightbox branch from 83ae618 to ebd4e7b Compare November 2, 2017 16:52
Copy link
Contributor

@SiAdcock SiAdcock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LATM 👍

@NataliaLKB NataliaLKB merged commit 797bf03 into master Nov 3, 2017
@NataliaLKB NataliaLKB deleted the es6-projects_common_modules_gallery_lightbox branch November 3, 2017 11:21
@prout-bot
Copy link
Collaborator

Seen on PROD (merged by @NataliaLKB 21 minutes and 48 seconds ago)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants