sethlopezme / atom-css-unit-converter

Performs conversions between different CSS units.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tooltip to show conversion

onetrev opened this issue · comments

Just wondered if it would be possible to integrate, or create something similar, to this package in order to have an all in one conversion solution? https://github.com/tbremer/px-rem-tooltip-atom

I ask because I prefer to turn of the "comment conversion math option" nowadays, because it leaves you at risk that if for some reason you change your base font, then all the comments are wrong. Plus keeps things cleaner without it.

Otherwise, thanks for creating this super helpful package!

Interesting. This is something that I hadn't thought about before. To be honest, I also dislike the comments at the end of the line for the exact reason that you stated, but I haven't given much thought as to how it can be improved. Showing a tooltip would be very nice.

atom-css-unit-converter is able to convert between many units. How do you think that should be handled with regard to the tooltips? Say you're working on a print stylesheet and for whatever reason you need to specify lengths in metric units, but you want to know their imperial equivalent. This could be a setting in the settings panel for the plugin, of course, but that seems like a hassle to change.

Anyway, great suggestion! Let me know if you have any thoughts on this! I'll definitely give it some thought as well, and we can figure out a good way to implement this.

Hmm, a good point about how to handle the many different types of conversions your package can do. I was thinking all conversion would just be various units to px, but you are right folks may want different types of conversion.

I do have an idea though! I wonder if you could enable it so that a comment at the top of the document would override the default conversion tooltip the user would set in the settings? It could make things a bit easier for folks. So for example in the print stylesheet the user could go:

/* conversion-tooltip: inches */

So this would mean all conversion in this document would be X unit to inches.

Not sure how feasible it is, but it's an idea. ;)

Your suggestion would work, but I don't want the user to have to modify their files just for this plugin.

One thing I'm going to look into is maybe creating some sort of custom tooltip that has a <select> or something in it so you can choose the common unit you want to see. If that's feasible, what would you think of that approach?

Good point, it is annoying to have to put in custom junk into your files that are just for single packages. So I do like your idea better!

But just to clarify, you wouldn't have to select the option each time, but rather say once you select "REM" it will stay as that until you change to another option? In other words there would be spot in the tooltip area to re-open / expand the select list to change conversion unit displayed? If so, I'm 100% down with that, it would be awesome!

Yep, that's what I was thinking. I'll take a look at the Atom APIs some time this week and see if it's feasible. Hopefully it'll be pretty easy!

I know you are totally just working on this on your own time, but I just wanted to see if you had any luck checking out the Atom APIs? Is your tooltip <select> idea feasible? Hope so, as it sure would be handy!

I did take a look at the Atom APIs and it does look like custom HTML can be provided for the inner content of a tooltip. I haven't checked on the <select> yet because I've been trying to figure out a good way to handle the base pixel size when viewing the conversions. It looks like the package you linked to uses a setting, but that feels like it would be tedious to change. I also think that I might be able to just show all 8 conversions in the tooltip, instead of using a <select>.

If you're still thinking about this, I wonder if instead of a tooltip solution it might be an idea to tie into Atom's autocomplete? Like so: https://github.com/gmendonca/px-to-rem Not 100% sure I like it, because it can feel a bit much to have an autocomplete popup every single time your write a PX value. But it's an idea anyway.....