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

css! removes spaces with multi-values. #104

Open
simbleau opened this issue Jan 7, 2023 · 4 comments
Open

css! removes spaces with multi-values. #104

simbleau opened this issue Jan 7, 2023 · 4 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation postponed

Comments

@simbleau
Copy link
Contributor

simbleau commented Jan 7, 2023

Using the css! macro provided by styled_component, I am seeing the spaces omitted which is resulting in faulty css.

The problem is with: border: ${BORDER_WIDTH} solid ${border};

image

image

@simbleau
Copy link
Contributor Author

simbleau commented Jan 7, 2023

For anyone who may experience this, just separate your css for the time being, e.g.

        border-width: ${BORDER_WIDTH};
        border-style: solid;
        border-color: ${border};

@futursolo
Copy link
Owner

futursolo commented Jan 8, 2023

This is expected as we current do not have a way to know the spacing between tokens. So inline syntax will make a guess about whether spacing should present until proc_macro_span is stablised which is not 100% accurate.

Trying to insert spacing in the value position also does not work because it can also be used like: width: ${width}px or width: 200${dim}.

You can use the string literal syntax to avoid this issue.

@futursolo futursolo added bug Something isn't working postponed documentation Improvements or additions to documentation labels Jan 8, 2023
@futursolo
Copy link
Owner

I am labeling this as documentation as this should be documented until a solution is available.

@WorldSEnder
Copy link
Collaborator

It should be made more clear that the whitespace issue does not only apply to descendent selectors. Nowadays, source_text has been stabilized, but there's a warning:

Note: The observable result of a macro should only rely on the tokens and not on this source text. The result of this function is a best effort to be used for diagnostics only.

I'm not 100% sure if every compiler stage preserves the original source text, or if a synthetized string might mess things up and lead to inconsistent compilations. I'm almost sure that the returned string is not considered a cache key for incremental compilation, so relying on it's value could also lead to non-reproducible builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation postponed
Projects
None yet
Development

No branches or pull requests

3 participants