Skip to content

fix LitElement and replace paper-button with mwc-button#60

Closed
iantrich wants to merge 3 commits into
custom-cards:masterfrom
iantrich:patch-1
Closed

fix LitElement and replace paper-button with mwc-button#60
iantrich wants to merge 3 commits into
custom-cards:masterfrom
iantrich:patch-1

Conversation

@iantrich
Copy link
Copy Markdown
Member

@iantrich iantrich commented Feb 18, 2019

  • hui-error-entity-row has been removed from core
  • paper-button has been removed from core

Should just be a one-to-one swap for their replacements

This becomes true in 0.88

paper-button has been removed from the HA project and replaced with mwc-button
@iantrich iantrich changed the title fix LitElement fix LitElement and replace paper-button with mwc-button Feb 20, 2019
@kuuji
Copy link
Copy Markdown
Contributor

kuuji commented Feb 20, 2019

Was about to ask if it's backward compatible and then I saw your last commit. Thanks a lot for that @iantrich

@iantrich
Copy link
Copy Markdown
Member Author

hold off on merging. I actually haven't had time to test and some in beta say it doesn't work completely :)

@DavidFW1960
Copy link
Copy Markdown

The formatting is the problem... see the thread on the Home Assistant forum. I had already tried a 1:1 replacement of the paper-button and it didn't really help.

@DavidFW1960
Copy link
Copy Markdown

DavidFW1960 commented Feb 20, 2019

image
image

This is using Ian's changed file

@ammmze
Copy link
Copy Markdown
Contributor

ammmze commented Feb 21, 2019

So ... I see the note in the release notes about replacing paper-button with mwc-button, but in my instance paper-button is still valid. We sure its removed from core? 🤷‍♂️ I've got a modified version still using paper-button that is working in my 0.88 instance here. Unfortunately the mwc-button looks to have a fixed height in my testing and per this open issue.

@bbbenji
Copy link
Copy Markdown

bbbenji commented Feb 21, 2019

@ammmze it's probably just your cache.

@MatteGary
Copy link
Copy Markdown

I tried this file version in my HA installation with 0.88 but the buttons look as in the image above, with the wrong size

@DavidFW1960
Copy link
Copy Markdown

@ammmze it's probably just your cache.

It's not the cache.

@iantrich
Copy link
Copy Markdown
Member Author

@DavidFW1960 he's referring to paper-button still working

@ammmze
Copy link
Copy Markdown
Contributor

ammmze commented Feb 22, 2019

Is there a server side cache that may be holding onto the paper-button? Because it's definitely not client side holding onto it. I've cleared browser cache and using different browsers. I'd never pulled up home assistant in firefox until this update came in and i started testing my changes on it. @iantrich I assume you can confirm that paper-button is NOT loading on your instance?

@DavidFW1960
Copy link
Copy Markdown

It isn't loading for sure in Ian's - he has replaced all instances of paper with mwc

@iantrich
Copy link
Copy Markdown
Member Author

I should have some time tonight to look into styling

@ammmze
Copy link
Copy Markdown
Contributor

ammmze commented Feb 22, 2019

Okay...I confirmed paper-button doesn't exist. I had assumed it would error out if it didn't exist. But instead it just renders which explains why I was needing additional styles.

@ammmze
Copy link
Copy Markdown
Contributor

ammmze commented Feb 22, 2019

Unfortunately using mwc-button, I don't see a way to remove the fixed 36px height. Looks chrome no longer allows for shadow piercing selectors. https://developers.google.com/web/updates/2017/10/remove-shadow-piercing

@ammmze
Copy link
Copy Markdown
Contributor

ammmze commented Feb 22, 2019

Sorry for the spam...but I figured out how we can get around it...

((ButtonBase) => {
  customElements.define(
    'button-card-button',
    class extends ButtonBase {
      static get styles() {
        return css`
          ${ButtonBase.styles}
          .mdc-button {
            height: auto;
            padding: 8px;
            color: inherit !important;
          }
        `
      }
    },
  );
})(customElements.get('mwc-button') || customElements.get('paper-button'))

Basically just create our own button-card-button that extends either mwc-button or paper-button

I've updated my copy here

@iantrich
Copy link
Copy Markdown
Member Author

Good approach. Applying it back to this repo? @kuuji will no doubt merge it after some testing of his own.

@DavidFW1960
Copy link
Copy Markdown

Awesome work guys! I can’t test this till tomorrow but sounds promising. Thanks.

@ammmze
Copy link
Copy Markdown
Contributor

ammmze commented Feb 22, 2019

FYI ... i've officially opened PR #63 with my changes

@iantrich
Copy link
Copy Markdown
Member Author

I’ll check it out later tonight, hopefully

@DavidFW1960
Copy link
Copy Markdown

Ok so on my mobile... iOS...
Gaaaa can’t paste it now.... but icon/text is small

@DavidFW1960
Copy link
Copy Markdown

Actually... it’s pretty goo.... only slightly smaller than an adjacent entity-button..... much better than before... Awesome work..

@dustins1983
Copy link
Copy Markdown

I only use 2 buttons for this card but with this fix I can verify my 2 buttons look exactly the same as it did before. Thanks!!

@MatteGary
Copy link
Copy Markdown

I tried on my installation, seems to work fine. I've several button on different views.

@iantrich
Copy link
Copy Markdown
Member Author

This is not

@iantrich iantrich closed this Feb 22, 2019
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.

7 participants