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

Add default P3 post-process config to use html-tag #55

Merged
merged 1 commit into from
Nov 6, 2018

Conversation

web-padawan
Copy link
Member

@web-padawan web-padawan commented Aug 28, 2018

Description

As a developer, I want to use the tagged template literals (instead of usual template literals) when converting to Polymer 3, in order to get the proper support for modern tools and plugins.
Requested in Polymer/polymer-modulizer#449 but I was unable to quickly implement it there.

Current

const $_documentContainer = document.createElement('template');

$_documentContainer.innerHTML = `<custom-style>
  <style>
    html {
      --lumo-size-xs: 1.625rem;
      --lumo-size-s: 1.875rem;
      --lumo-size-m: 2.25rem;
      --lumo-size-l: 2.75rem;
      --lumo-size-xl: 3.5rem;

      /* Icons */
      --lumo-icon-size-s: 1.25em;
      --lumo-icon-size-m: 1.5em;
      --lumo-icon-size-l: 2.25em;
      /* For backwards compatibility */
      --lumo-icon-size: var(--lumo-icon-size-m);
    }
  </style>
</custom-style>`;

document.head.appendChild($_documentContainer.content);

Expected

import { html } from '@polymer/polymer/lib/utils/html-tag.js';

const $_documentContainer = html`<custom-style>
  <style>
    html {
      --lumo-size-xs: 1.625rem;
      --lumo-size-s: 1.875rem;
      --lumo-size-m: 2.25rem;
      --lumo-size-l: 2.75rem;
      --lumo-size-xl: 3.5rem;

      /* Icons */
      --lumo-icon-size-s: 1.25em;
      --lumo-icon-size-m: 1.5em;
      --lumo-icon-size-l: 2.25em;
      /* For backwards compatibility */
      --lumo-icon-size: var(--lumo-icon-size-m);
    }
  </style>
</custom-style>`;

document.head.appendChild($_documentContainer.content);

Possible benefits

Possible negative effects

  • code transpiled by Babel will get larger because of how it transpiles tagged template literals, but the outcome does not seem noticeable, especially when compared with benefit of CSS minifying

Note

We will have to make sure we do not have duplicate @polymer/polymer/lib/utils/html-tag.js import, happens at least in dropdown-menu.


This change is Reviewable

@web-padawan
Copy link
Member Author

Updated the PR to only use the suggested config for theme/**/*-styles.js as those files contain most of CSS and especially because it is safe to replace the $_documentContainer occurrences there.

For the files in src it is not safe, as we would end up with duplicate imports in cases then they also contain both component template and icons (happens for vaadin-select, vaadin-grid-sorter, vaadin-grid-tree-toggle etc) and the html tag is already added by modulizer.

@limonte limonte merged commit f5d21d0 into master Nov 6, 2018
@limonte limonte deleted the p3-post-default branch November 6, 2018 10:19
@limonte limonte removed the in review label Nov 6, 2018
limonte pushed a commit that referenced this pull request Nov 6, 2018
# [0.16.0](v0.15.1...v0.16.0) (2018-11-06)

### Features

* add default P3 post-process config for theme modules ([#55](#55)) ([f5d21d0](f5d21d0))
@limonte
Copy link

limonte commented Nov 6, 2018

🎉 This PR is included in version 0.16.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

3 participants