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

Classify things #70

Merged
merged 7 commits into from
Jul 8, 2019
Merged

Classify things #70

merged 7 commits into from
Jul 8, 2019

Conversation

catwomey
Copy link
Contributor

@catwomey catwomey commented Jul 8, 2019

I need to do a bit of work on the navigation for Consortiums, however I didn't want to work on code that is just the output of polymer modulizer.

So I took a bit of time to update everything to modern polymer 3. Most things were straight forward ports, my biggest changes are in d2l-navigation-immersive.js (attached and detached > connected/disconnected callbacks), and in the way styles are shared (exported const instead of include="").

Please let me know what you think. My hope was that this code would be easier to work with now, and potentially easier to port to lit.

Copy link
Contributor

@dlockhart dlockhart left a comment

Choose a reason for hiding this comment

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

Cool, definitely a lot cleaner -- thanks for doing this!

A couple things to keep in mind:

  • This open pull request, so conflicts will happen
  • We are on the cusp of moving to Lit Element -- just trying to get everything in place first before sounding the trumpets -- which is why we've mostly held off on doing these conversions so far. The Polymer 3 code will definitely be easier to move to Lit, but just wanted you to not be surprised if in a couple weeks that announcement happens. :)

D2L.PolymerBehaviors.FocusableBehavior,
D2L.PolymerBehaviors.LocalizeBehavior], PolymerElement) {
static get is() {
return 'd2l-navigation-button-close';
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I believe the is business is no longer needed (I can't find it in the Polymer 3 docs), so you could just remove these 3 lines and have d2l-element-name down where you register it below.


$_documentContainer.innerHTML = `<dom-module id="d2l-navigation-button-close">
<template strip-whitespace="">
Copy link
Contributor

Choose a reason for hiding this comment

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

Polymer 3 doesn't appear to have an equivalent. I'm curious what you're seeing in the browser with these changes -- is the whitespace gone?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to this Polymer/polymer#4731 it seems like you can just add the attribute to the template.

I didn't specifically notice anything with whitespace, but i wasn't really looking hard either. Feels like an easy enough thing to add

`;
}
}
window.customElements.define(D2LNavigationBand.is, D2LNavigationBand);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: window things are in the global namespace so it's not needed.

}
static get template() {
return html`
${highlightStyles}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little worried that this is going to result in those styles being copied into every single instance of the button. Lit has solved this using constructable stylesheets... but I'm not sure if there's an elegant Polymer 3 solution. We're on the cusp of moving to Lit anyway, so maybe this isn't a big deal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right that it will be stamped into each shadow root. But based on this issue Polymer/polymer#4940 (comment) it sounds like browsers do optimize for that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sweet, that makes me feel better. :)

import 'd2l-colors/d2l-colors.js';
import 'fastdom/fastdom.js';
import ResizeObserver from 'resize-observer-polyfill/dist/ResizeObserver.es.js';
import 'd2l-typography/d2l-typography-shared-styles.js';
import './d2l-navigation.js';
import './d2l-navigation-link-back.js';
import './d2l-navigation-shared-styles.js';
import { Polymer } from '@polymer/polymer/lib/legacy/polymer-fn.js';
import { navigationSharedSytle } from './d2l-navigation-shared-styles.js';
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: Style

@catwomey catwomey merged commit 74425b5 into master Jul 8, 2019
@catwomey catwomey deleted the ctwomey/classify-polymer branch July 8, 2019 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants