-
Notifications
You must be signed in to change notification settings - Fork 2
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
Circular reference created when reusing keyword #12
Comments
I see - yes its an infinite loop. Can you try
|
Doesn't crash, but doesn't pick up the color either. Browser shows the text as:
|
Thanks for checking, I will get to it now and will post back asap. |
Changing the primary color to a direct color doesn't work either. Is it possible this is in fact already a level 3 reference, counting the color itself, and perhaps you went only as far as allowing for 2 steps?
|
Thanks @jorisw - just released 0.8.1 with a fix for recursive keys. However you would still need to use full reference
Here is the full test as per your example: |
Thanks, your test output looks correct however my h1 that uses it, stilll shows: color: var(--theme-ui-colors-text, colors.primary); My theme: colors: {
content: {
primary: 'colors.primary',
},
primary: 'cobalt.600',
text: 'content.primary',
} |
beats me - do you have any ideas? What if you console.log the them at run-time - are the other vales correctly updated by the plugin? |
Doesn't seem like it, so this could be a separate issue entirely. Not sure if this helps, but if I add the following console logs: if (lookup) {
const { __value, __path, scale } = lookup;
switch (typeof __value) {
case "object":
if (!Array.isArray(__value)) {
item.__path.node.value = transformValue(spaceFormats, scale, __path.node.value);
console.log("object became", item.__path.node.value)
}
else {
item.__path.node.value.elements = item.__path.node.value.elements.map((e, idx) => (Object.assign(Object.assign({}, e), { value: __value[idx] !== undefined
? transformValue(spaceFormats, scale, __value[idx].__value)
: transformValue(spaceFormats, scale, e.value) })));
console.log("array became", item.__path.node.value.elements.map(({value})=>value).join(', '))
}
break;
case "string":
case "number":
item.__path.node.value.value = transformValue(spaceFormats, scale, __value);
console.log("string or number", __value, "became", item.__path.node.value.value)
break;
}
} ... it logs:
|
What I'm seeing now is that when I build my full app, the output is also limited to the above, while my theme is much more extensive. My hunch now is that the transformer is not matching objects and therefore not transforming nested fields such as |
I'm also noticing that const transformValue = (spaceFormats, key, value) => {
if (spaceFormats[key]) { For all of my styles that aren't being transformed, this if-statement evaluates falsy. |
thanks, great suggestion, I will take a look again |
When I define the following colors in my theme file:
My Next.js stack crashes with error:
If I skip the indirect reference and refer the color directly:
... all is fine.
The reason I have
primary
defined both directly undercolor
and undercontent
, is because primary color is a required setting in ThemeUI, while we have a collection of colors for different classes of content.The text was updated successfully, but these errors were encountered: