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

non-alpha picker #107

Closed
hermione3690 opened this issue Jun 17, 2019 · 6 comments
Closed

non-alpha picker #107

hermione3690 opened this issue Jun 17, 2019 · 6 comments
Labels
enhancement Specific enhancement feature request New feature requested

Comments

@hermione3690
Copy link

Do you want to request a feature or report a bug?

Feature

What is the current behavior?

All input types include alpha. While you can disable opacity in the options, the input will still allow you to enter an alpha value.

What is the expected behavior?

Is it possible for the picker to return hex instead of hexa, rgb instead of rgba etc, when opacity is disabled? Or for a specific setting to initiate the picker in a 'non-alpha' mode?

Your environment:

Pickr-version (see Pickr.version): 1.0.0-beta
Used Pickr-bundle (es5 or normal one): normal
Browser-version:  chrome 75.0.3770.90
Operating-system:  win10
@simonwep
Copy link
Owner

Good idea! I'll take a look at it :)

@simonwep simonwep added enhancement Specific enhancement feature request New feature requested labels Jun 17, 2019
@simonwep
Copy link
Owner

Okay, I think one solution would be to ignore the opacity part, though it's always possible to use rgb / hsl... without the a part. Forbidding all inputs which contain a alpha value (e.g. hsla, rgba...) would require a lot of more code - and therefore increase the code-base drastically (And I still try to keep it as small as possible).

My idea is to lock opacity at 1 if the user tries to enter something like rgba(32, 52, 122, 0.3), calling

pickr.getColor().toRGBA().toString(0) // 0 param is new: round values

would therefore result in rgba(32, 52, 122, 1). This could be implemented in a few lines and wouldn't require that many changes...

Any thoughts?

@simonwep simonwep added the opinions needed Unclear if this should be added label Jun 24, 2019
@hermione3690
Copy link
Author

that would work in theory. The problem would be with input enabled, that the users would see a fouth param to change, and seeing it default to 1. Without providing an explanation this could cause confusion.
I haven't looked into the picker code in detail yet, so please tell me if it's not possible (or way too much work),
But would it be possible to add input types? like you can dis/enable hex(a), rgba, hsla, hsva?
If hex, rgb, hsl, hsa were added, with it you could toggle separate input handling?

@simonwep
Copy link
Owner

Okay, I've added it. You can use lockOpacity: true in options to do so.
After it the user won't be able anymore to enter any type with alpha value, the buttons will show the schemas without an a and the opacity slider will be removed.

Checkout this demo: https://jsfiddle.net/Simonwep/psdokgr1/

It was a lot of refactoring and many changes must be done, please check it out and be sure everything works as you expect :)

@hermione3690
Copy link
Author

perfect. exactly what I was looking for 👍

@simonwep
Copy link
Owner

Available in 1.2.0 :)

@simonwep simonwep removed the opinions needed Unclear if this should be added label Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Specific enhancement feature request New feature requested
Projects
None yet
Development

No branches or pull requests

2 participants