Comments (9)
Sorry I totally thought I had replied to this. I've just released v2.0.0 and this feature is included (somewhat). As of 2.0.0 you can pass a synchronous function instead of a static array of colors. I'm still working on 2.0.1 which will support async, will release it as soon as I work out some kinks.
Thanks for the great idea!
from sanity-color-list.
@KimPaow any update on adding async support to this? I'm hoping to pull the list of colors from an array in a Settings document, where editors can choose their own pre-defined colors with color-input :)
here's what i'm trying to do in my schema:
{
title: 'Color List',
description: 'Pick a color',
name: 'colors',
type: 'colorlist', // required
options: {
list: async () => {
const response = await client.fetch(`*[_type == 'settings' && _id == '_settings'][0].colors`);
const colors = response.reduce(
(acc: any, color: any) => {
acc.push({
value: color.hex,
title: color.hex,
});
return acc;
}, []);
console.log(colors);
return colors
}
},
},
from sanity-color-list.
I was able to get my schema and groq query (as shown in my previous comment) working via a couple simple changes I've pushed as a branch here. I simply made createColors
an async function, then added a new async getColors()
function within ColorList
. Then I load the colors into component state within an effect. Gets the job done, but definitely not production ready for others.
EDIT: I downloaded the repo as of your last commit and pasted the files into my plugins/color-list
and everything works fine after installing the npm dependencies. Not sure why it would work locally but not with the published package.
Aside from the error I'm getting from the hosted package, 2.0.3-beta.0
is working great when added locally in my plugins
directory!! Awesome work, I love this package :)
from sanity-color-list.
Ah okay got it, seems like I need to set up some polyfills for babel (which is why the source files are fine and the build breaks). Nice that you got a temp fix though!
from sanity-color-list.
@devinhalladay sorry for the delay. I would like to fix this asap but have too much on my plate right now. I could probably fix it in another two weeks or so.
If you would like to put together a PR that would be very much appreciated! :)
from sanity-color-list.
I just hacked together a quick fix for this. @devinhalladay could you try and install 2.0.3-beta.0
and let me know how it works for you?
from sanity-color-list.
Wow, awesome @KimPaow — thanks for the quick work! Sadly I'm getting an uncaught error:
Uncaught ReferenceError: regeneratorRuntime is not defined
<anonymous> index.js:62
from sanity-color-list.
@KimPaow any idea when you may be able to action on this? If you're short on time, and could let me know what polyfills need to be added, I'd be down to try to put up a PR! Really appreciate your work, this project is awesome.
from sanity-color-list.
@KimPaow I put up a PR #26. I'm not 100% sure I added the polyfills you are referring to, but this change seems to have fixed the issue for me.
from sanity-color-list.
Related Issues (14)
- Label size HOT 3
- initialValue? HOT 1
- Show name and/or value next to RadioButton HOT 2
- initialValue is marked as invalid incorrectly when schema is composed into a different schema
- Visibility for very light colors HOT 2
- The option ‘borderradius outer’ has no effect HOT 1
- Studio v.3 compatibility HOT 14
- Crash when using validation HOT 4
- Deselecting colors HOT 3
- Doesn't support validation HOT 9
- Doesn't work inside an array HOT 6
- Choose to return title as well (Feature request) HOT 3
- Using within BlockContent results in unknown markdown type HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sanity-color-list.