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

Fix paper-slider pin style #1022

Merged
merged 9 commits into from
Apr 17, 2018
Merged

Conversation

NovapaX
Copy link
Contributor

@NovapaX NovapaX commented Mar 23, 2018

This was supposed to be a simple fix for two simple shortcomings:

  • paper-slider sets a fixed font-size on the pin, but inherits the line-height. Which kind of messes up the alignment.
  • paper-sliders pin is pretty small, with a pretty small hardcoded font-size of 10px. This hides it almost completely under your thumb while dragging. So I thought I'd make it em-based.

However, paper-elements is currently in feature-ice-age (see: PolymerElements/paper-slider#212)
So I extended paper-slider via the following methods:

now we have an almost exact copy of paper-slider, with its exact DOM template but a modified <style> element in it.

Fixes: #390

@balloob
Copy link
Member

balloob commented Mar 27, 2018

I am impressive with how you elegantly hacked this together. However, I also think that this guaranteed will break in the future. I know they are in feature freeze now, but won't be forever.

I think that we should just copy paste the component into our repo and make the changes.

@NovapaX
Copy link
Contributor Author

NovapaX commented Mar 29, 2018

That way it will also be a bit harder to get bug fixes.
(new release of paper-slider released an hour ago)
I doubt this will break spontaneously, and as soon as it does it's catched pretty quick in dev, and the fix will be just as easy.
I don't mind either way, it's your call! ;)

@balloob
Copy link
Member

balloob commented Mar 30, 2018

Let's fork.

</template>

<script>
customElements.whenDefined('paper-slider').then(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need "whenDefined"? There is no async here, as you import paper-slider.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See this comment. Polymer/polymer#4556 (comment)
But maybe I misunderstood that.

But we don’t need this anyway because we’ll clone the whole element instead of extending it (see balloobs comment above.)

Copy link
Contributor

Choose a reason for hiding this comment

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

Just for the record, according to Polymer/polymer#4556 (comment) whenDefined wasn't needed. (Unless used from the index doc, which AFAIU is not our case)

static get template() {
if (!myTemplate) {
// Retrieve this element's dom-module template
myTemplate = Polymer.DomModule.import(this.is, 'template');
Copy link
Contributor

Choose a reason for hiding this comment

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

I think HaPaperSlider.is is more clear than this.is in a static context.

Copy link
Contributor Author

@NovapaX NovapaX Mar 30, 2018

Choose a reason for hiding this comment

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

In this case the target is actually to get the parents class (PaperSlider) template.
So I think then it it would be more clear to use PaperSlider.is

P.S. I like little discussions like this, I learn a lot from them 👍

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 are right. I responded without taking a good look at the code. Fixed.

@balloob
Copy link
Member

balloob commented Mar 31, 2018

@andrey-git what do you think we should do, fork or compose a new component off the old one on the fly?

@andrey-git
Copy link
Contributor

I think generally extending is better. If we see that an update breaks us - we can work then.

@balloob
Copy link
Member

balloob commented Apr 1, 2018

Alright, let's not fork and keep the current approach.

@NovapaX
Copy link
Contributor Author

NovapaX commented Apr 3, 2018

@armills I could use a little help with the JSdoc directives ;)
I tried, but I failed....

@balloob
Copy link
Member

balloob commented Apr 3, 2018

I think the problem is that polymer lint does not know the type when you fetch the class from the registry.

@balloob balloob merged commit 0a60ec2 into home-assistant:master Apr 17, 2018
@NovapaX NovapaX deleted the fix/slider-pin-style branch April 17, 2018 21:27
@balloob
Copy link
Member

balloob commented May 21, 2018

And so it broke…

@balloob
Copy link
Member

balloob commented May 21, 2018

image

@balloob
Copy link
Member

balloob commented May 21, 2018

Issue #1190

@github-actions github-actions bot locked and limited conversation to collaborators Jul 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants