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

Variable fallback not working #102

Open
alexhaines123 opened this issue Jun 26, 2019 · 1 comment
Open

Variable fallback not working #102

alexhaines123 opened this issue Jun 26, 2019 · 1 comment

Comments

@alexhaines123
Copy link

I'm using postcss-css-variables with a JSON file with this data:

{
    "variables" : {
        "--color-form-selected" : "red",
        "--color-positive-green" : "green"
   }
}

On this css which uses variable fallbacks but oddly it chooses the last variable provided instead of the first.

.a-checkbox__input:checked ~ .a-checkbox__label {
    background-color: var(--color-form-selected);
    border-color: var(--color-positive-green, var(--color-form-selected));
}

But it outputs

.a-checkbox__input:checked ~ .a-checkbox__label {
    background-color: red;
     border-color: red;
}

Expected

.a-checkbox__input:checked ~ .a-checkbox__label {
    background-color: red;
    border-color: green;
}
@MadLittleMods
Copy link
Owner

For reference, the following example works as expected. I would expect that #37 fixed the problem which was released in v0.7.0. Which version are you using?

Input:

:root {
	--color-form-selected: red;
	--color-positive-green: green;
}

.a-checkbox__input:checked ~ .a-checkbox__label {
    background-color: var(--color-form-selected);
    border-color: var(--color-positive-green, var(--color-form-selected));
}

Output:

.a-checkbox__input:checked ~ .a-checkbox__label {
    background-color: red;
    border-color: green;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants