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

Implement support for CSS at rules #238

Merged
merged 4 commits into from
Mar 31, 2020
Merged

Implement support for CSS at rules #238

merged 4 commits into from
Mar 31, 2020

Conversation

gdotdesign
Copy link
Member

This PR implements support for the @font-face, @keyframes and @supports CSS rules.

@font-face

It will compile into separate @font-face rules, sub selectors and interpolations are not allowed.

@keyframes

It will compile into separate @keyframes rules, sub selectors are not allowed, interpolations are allowed.

@supports

It works exactly like @media, interpolations and nested selectors are allowed.

@Sija
Copy link
Member

Sija commented Mar 31, 2020

@font-face

It will compile into separate @font-face rules, sub selectors and interpolations are not allowed.

I believe interpolations should be allowed. That might come handy when specifying paths prefixes and such.

@gdotdesign
Copy link
Member Author

@font-face rules are global and not part of the component so having interpolations there is somewhat weird: you would have access to constants and environment variables but not items in the scope of the component.

@Sija
Copy link
Member

Sija commented Mar 31, 2020

[...] you would have access to constants and environment variables

That's exactly my point since you'd use these for defining paths prefixes to the assets (think CDN for instance).

@gdotdesign
Copy link
Member Author

That's exactly my point since you'd use these for defining paths prefixes to the assets (think CDN for instance).

That would be great, but it's not trivial to implement.

Actually it's technically impossible right now because dynamic properties are converted into CSS variables and I don't think they work in @font-face rules: https://codepen.io/gdotdesign/pen/yLNwyWe

@Sija
Copy link
Member

Sija commented Mar 31, 2020

Wait, so interpolations are converted to CSS variables? Aren't they compiled into the resulting string?

@gdotdesign
Copy link
Member Author

Wait, so interpolations are converted to CSS variables? Aren't they compiled into the resulting string?

They are converted to CSS variables ➡️ https://github.com/mint-lang/mint/blob/master/spec/compilers/css_definition it's the most efficient way of making them dynamic and the only way to support them in sub selectors and pseudo elements.

Also all definitions inside a if or case are converted to variables as well, no matter if they are static or have interpolations ➡️ https://github.com/mint-lang/mint/blob/master/spec/compilers/css_with_if_and_case

@Sija
Copy link
Member

Sija commented Mar 31, 2020

Oh, I see. It makes sense then 👍

@gdotdesign gdotdesign changed the title 🚧 Implement support for CSS at rules Implement support for CSS at rules Mar 31, 2020
@gdotdesign gdotdesign merged commit 1f77cba into master Mar 31, 2020
@gdotdesign gdotdesign added this to the 0.9.0 milestone Mar 31, 2020
@gdotdesign gdotdesign deleted the css-at-rules branch April 11, 2020 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants