Replies: 11 comments 10 replies
-
This should be improved in v1.7.3, there was a bug (although I think it was a different bug than what you're seeing). I'd recommend defining closure-based colors like this: primary: ({ opacityValue, opacityVariable }) => {
if (opacityValue !== undefined) {
return `rgba(var(--color-primary), ${opacityValue})`
}
if (opacityVariable !== undefined) {
return `rgba(var(--color-primary), var(${opacityVariable}, 1))`
}
return `rgb(var(--color-primary))`
}, See related discussion here: #2185 |
Beta Was this translation helpful? Give feedback.
-
@adamwathan I copied and pasted this code and now I get this error:
|
Beta Was this translation helpful? Give feedback.
-
And this code does not work for me: primary: 'rgb(var(--color-primary))', It is defined in the inspector in the browser. And there is even a color icon. That is, in the inspector in the browser, the color seems to have been determined. But on the pages, the text is not painted over. Only the default color from the body. |
Beta Was this translation helpful? Give feedback.
-
Can you share a project that reproduces the issue please? We usually immediately close issues that don't contain a reproduction. |
Beta Was this translation helpful? Give feedback.
-
@adamwathan Unfortunately I can not. I just don't have one in the compiled code like in your documentation: .text-purple-600 {
--text-opacity: 1!important;
color: #805ad5!important;
color: rgba(128,90,213,var(--text-opacity)))!important;
} For some reason, mine is like in the screenshot above. I added this default code to my config file: purple: {
100: '#faf5ff',
200: '#e9d8fd',
300: '#d6bcfa',
400: '#b794f4',
500: '#9f7aea',
600: '#805ad5',
700: '#6b46c1',
800: '#553c9a',
900: '#44337a',
}, And for some reason, more properties appear in the compiled code: .text-purple-100 {
--text-opacity: 1;
color: #faf5ff;
color: rgba(250, 245, 255, var(--text-opacity));
} But I don't know whether these problems are related or not. |
Beta Was this translation helpful? Give feedback.
-
@adamwathan I only kept one color: colors: {
primary: ({ opacityValue, opacityVariable }) => {
return `rgb(var(--color-primary))`
},
},
|
Beta Was this translation helpful? Give feedback.
-
For: primary: '#ff0000', It turns out this: .text-primary {
--text-opacity: 1;
color: #ff0000;
color: rgba(255, 0, 0, var(--text-opacity));
} For: primary: 'var(--color-primary)', It turns out this: .text-primary {
color: var(--color-primary);
} |
Beta Was this translation helpful? Give feedback.
-
Can't help without a reproduction unfortunately. Please create a new GitHub repository that demonstrates the problem and provide a link so we can help. It doesn't have to be your real project, just a new demo project that actually shows the bug. Very good chance there is no bug here and just misconfiguration or a misunderstanding of how things are meant to work. |
Beta Was this translation helpful? Give feedback.
-
@afuno @adamwathan I ran into the same issue, and found out that, as far as I can tell, the color variable needs to be declared in RGB format for all of this to work.
|
Beta Was this translation helpful? Give feedback.
-
And I don't understand why, for example, in the documentation, the text has these styles: But my text only has this: But if I replace this code: primary: 'var(--color-primary)', On this: primary: '#ff0000',
// or
// primary: 'rgb(255, 0, 0)', But new attributes appear: But if we return to the problem, then, for example, this code: primary: ({ opacityValue, opacityVariable }) => {
if (opacityValue !== undefined) {
return `rgba(255, 0, 0, ${opacityValue})`
}
if (opacityVariable !== undefined) {
return `rgba(255, 0, 0, var(${opacityVariable}, 1))`
}
return `rgb(255, 0, 0)`
}, Will still throw an error:
|
Beta Was this translation helpful? Give feedback.
-
@adamwathan Does it have something to do with this #2515? |
Beta Was this translation helpful? Give feedback.
-
I'm using version 1.7.2.
There is an example on the release page:
In this code, there is an error in the variable.
This example has a link to Pull (#1676) which has this code:
Options using only
opacityVariable
or onlyvariable
do not work for me. I always get the error:When I return everything to my original code, then everything is fine:
My non-working options based on your recommendations:
Can you please tell me what I'm doing wrong?
Beta Was this translation helpful? Give feedback.
All reactions