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

[Feature Request] Collapse font properties #1164

Open
keganlance opened this issue Jul 13, 2021 · 5 comments
Open

[Feature Request] Collapse font properties #1164

keganlance opened this issue Jul 13, 2021 · 5 comments

Comments

@keganlance
Copy link

Is your feature request related to a problem? Please describe.
When having some code like this:
font: 16px Arial, sans-serif;
font-weight: 600;
line-height: 1.5;

It doesn't collapse into one font property

Describe the solution you'd like
This code should collapse into:
font:600 16px/1.5 Arial,sans-serif;

@sigveio
Copy link
Collaborator

sigveio commented Jul 14, 2021

Thank you for submitting a feature request, keganlance. :-)

I believe you are right in that this is not done by any of cssnano's included presets/plugins today.

Since the shorthand for font has clearly defined rules when it comes to which values are mandatory, and the order they have to be in, it seems like something that should be doable to implement.

But someone more experienced than me with the tool/ecosystem might be able to shine more light on whether this has been discussed before, and if there are any potential issues with it.

Would you be willing and able to work on this yourself if the maintainers were to welcome a PR?

@keganlance
Copy link
Author

The same could be done for the background shorthand. This has been discussed before and is still open: #598

As with you I'm also not as experienced with the tool. Tho would love to help where possible.

@sigveio
Copy link
Collaborator

sigveio commented Jul 16, 2021

Alright, cool. :-)

If it would be okay for you, and the maintainers are interested in such a feature, I wouldn't mind doing some groundwork on this to get it started. And perhaps we could collaborate on refining it?

@ludofischer
Copy link
Collaborator

I suppose the rule should go into this package https://github.com/cssnano/cssnano/tree/master/packages/postcss-merge-longhand, you can take a look inside to get an idea of the kind of work required. The main issue I see is that the merged rules behave differently in regard to overrides, so there are a bunch of bugs for it already https://github.com/cssnano/cssnano/projects/4 I think it would be more interesting to solve the existing issues first before adding more optimizations.

@sigveio
Copy link
Collaborator

sigveio commented Jul 17, 2021

Ah, yes, I agree 💯 with the notion of addressing existing bugs before adding new features 👍

Once I have finished with the refactoring of the postcss-reduce-initial script (I'll try and get back to that tomorrow and tie it up) - I would be happy to shift my attention towards postcss-merge-longhand and see if I can help with attacking that list of issues.

I posted a follow up in #1167

@sigveio sigveio removed the triage label Jul 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants