facelessuser / ColorHelper

Sublime plugin that provides helpful color previews and tooltips
https://facelessuser.github.io/ColorHelper/
MIT License
254 stars 30 forks source link

No settings option to output uppercase hex colors #180

Closed MattDMo closed 3 years ago

MattDMo commented 3 years ago

Please read and fill out this template by replacing the instructions with appropriate information. If the template is not followed, the issue will be marked Invalid and closed.

Before submitting an issue search past issues and read the area of the documentation related to your specific question, issue, or request.


Description

... what is the issue / request ?

74 was an issue with "upper_case_hex": true not working in the 2.x series, and it was fixed by 4d03c04. However, that code seems to have been completely removed in 3.x. I fixed it by editing line 62 in custom/ahex.py to the following:

template = "#{:02X}{:02X}{:02X}{:02X}" if show_alpha else "#{:02X}{:02X}{:02X}"

(changing the lowercase {:02x}s to {:02X}).

This won't work for everyone, as it now forces all hex output to be uppercase. Adding extra code to look for "upper_case_hex" in the settings as well as in the parameters passed to the function hopefully won't be too difficult, I just haven't had a chance to do it yet.

Vague issues/requests will be marked with Insufficient Details for about a week. If not corrected, they will be marked Stale for about a week and then closed.

For feature requests or proposals:

  • Clearly define in as much detail as possible how you imagine the feature to work.
  • Examples are also appreciated.

For bugs and support questions:

  • Describe the bug/question in as much detail as possible to make it clear what is wrong or what you do not > understand.
  • Provide errors from console (if available).
  • Pictures or screencasts can also be used to clarify what the issue is or what the question is.
  • Provide links to 3rd party syntax highlighting package you are using if applicable.

Support Info

...

Run the following command from the menu: Preferences->Package Settings->ColorHelper->Support Info. Post the result here.

Steps to Reproduce Issue

  1. First step...
  2. Second step...
  3. Third step...

Provide steps to reproduce the issue. Pictures are fine, but also provide code/text I can copy and paste in order to reproduce. Omit for feature requests and feature proposals.

facelessuser commented 3 years ago

No not removed, just different.

Here we override the css-level-4 color class options to export hex with uppercase.

    "user_color_classes": {
        "css-level-4": {
            "output": [
                {"space": "srgb", "format": {"hex": true, "upper": true}}, // <--- make hex upper case
                {"space": "srgb", "format": {"comma": true}},
                {"space": "hsl", "format": {"comma": true}},
                {"space": "hwb", "format": {"comma": false}},
                {"space": "lch", "format": {"comma": false}},
                {"space": "lab", "format": {"comma": false}},
                {"space": "display-p3", "format": {}},
                {"space": "rec2020", "format": {}},
                {"space": "prophoto-rgb", "format": {}},
                {"space": "a98-rgb", "format": {}},
                {"space": "xyz", "format": {}}
            ]
        }
    },

@gir-bot remove s: triage @gir-bot add T: support

facelessuser commented 3 years ago

String output options are discussed in coloraide documentation. ColorAide is used to provide color conversion, CSS string parsing, and CSS output.

facelessuser commented 3 years ago

I should probably do a better job at documenting this area... 🤔

facelessuser commented 3 years ago

I'm sorry, I see you are are talking about ahex, so maybe update argb color class.

I also need to rename the color class 0xahex to 0xhex...that was a typo.

facelessuser commented 3 years ago

I think I'll add a FAQ section in the docs that explains things like this a bit more. I imagine this will be a somewhat common question.

MattDMo commented 3 years ago

So I put this in my user settings:

    "user_color_classes":
    {
        "css-level-4": {
            "output": [
                {"space": "srgb", "format": {"hex": true, "upper": true}}, // <--- make hex upper case
            ]
        }
    }

but it's still outputting lowercase.

image

This is a .sublime-color-scheme file, if it matters.

facelessuser commented 3 years ago

I need maybe some more info. Looks like you are using color schemes? If so, you'll want to specify sublime-colormod as the color class, and provide all the output options. It overrides at the top level (output) not down at the individual level of each value in options.

facelessuser commented 3 years ago

For clarity:

        "sublime-colormod": {
            "output": [
                {"space": "srgb", "format": {"hex": true, "upper": true}},
                {"space": "srgb", "format": {"comma": true, "precision": 3}},
                {"space": "hsl", "format": {"comma": true, "precision": 3}}
            ]
        },
MattDMo commented 3 years ago

That doesn't seem to be working either...

facelessuser commented 3 years ago

Let me confirm as I confirmed the first example worked.

facelessuser commented 3 years ago

Settings:

    "user_color_classes": {
        "sublime-colormod": {
            "output": [
                {"space": "srgb", "format": {"hex": true, "upper": true}},
                {"space": "srgb", "format": {"comma": true, "precision": 3}},
                {"space": "hsl", "format": {"comma": true, "precision": 3}}
            ]
        }
    },

Results:

Screen Shot 2021-04-01 at 10 51 52 AM
facelessuser commented 3 years ago

@MattDMo please let me know what files you are editing and what the rule for the file you are editing looks like.

Your screenshot looks like a sublime-color-scheme file which is why I suggested sublime-colormod, but then you mentioned in the opening post you modified ahex.py, so I don't know which color class to suggest you edit.

facelessuser commented 3 years ago

Also, check out https://github.com/facelessuser/ColorHelper/pull/182 which has a draft that explains all of this a bit better and maybe will help you figure out what you are getting wrong.

MattDMo commented 3 years ago

OK, I got it. It was an issue with braces in my settings, the "sublime_colormod" key ended up syntactically being outside of "user_color_classes". It's working great now, thanks!

I'll check out #182 when I get a chance.