sanity-io / color-input

Color input and schema for Sanity Studio
MIT License
15 stars 8 forks source link

Disable color picker and only select from predefined colors #62

Open nwazuo opened 9 months ago

nwazuo commented 9 months ago

Is your feature request related to a problem? Please describe. I want content editors to stick to the predefined colors so they don't pick colors on the picker that mess up the aesthetic of the page/content.

Describe the solution you'd like An option to disable the color picker(and input fields) so only the predefined colors are displayed and selectable.

Describe alternatives you've considered ...

Additional context ...

mig-hub commented 6 months ago

@nwazuo funny I came to post the exact same feature request. I have this project and I'm asked to have some color fields completely opened, and some others restricted to a color palette. I can replace the restricted field by a string field with hex options. But it does not give a color preview (only a name) and most importantly the data structure is not the same. One is a full color object and the other is just an hex string. That would force me to change my frontend. This is not ideal, especially if the clients change their mind along the way.

Anyway I had the the same requirement. If somebody has a work around, even if it's a bit hacky, I'd be interested.

nwazuo commented 6 months ago

@mig-hub Creating a fork and looking into the code to figure a way to hide it would be the way to go.

I remember inspecting CSS classes to try and write some custom CSS to hide the color picker but that didn't quite work out as the DOM structure and class names didn't lend itself to writing a selector that could target the color picker accurately.

Fakerko commented 3 months ago

I need exact the same thing. Any progress on it?

hacknug commented 3 months ago

I need exact the same thing. Any progress on it?

https://github.com/cositehq/sanity-plugin-simpler-color-input