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

rgba() support for cleanupListOfValues #628

Open
peternowell opened this issue Nov 30, 2016 · 8 comments
Open

rgba() support for cleanupListOfValues #628

peternowell opened this issue Nov 30, 2016 · 8 comments

Comments

@peternowell
Copy link

It would be nice if cleanupListOfValues could work on rgba() values... removing unnecessary spaces and leading zeros. Not sure if rounding to the specified precision would be necessary, but it would be nice if rgba(10, 20, 30, 0.4) could turn into rgba(10,20,30,.4) .

@strarsis
Copy link
Contributor

strarsis commented Apr 5, 2017

Isn't this CSS? The minifyStyles plugin uses csso which can also minify color values like rgba(...) in CSS.

@GreLI
Copy link
Member

GreLI commented Apr 6, 2017

Yep, it's defined in CSS Colors Module level 3 and many browser supports it, but it wasn't defined in SVG 1 and thus not supported in SVGO.

@peternowell
Copy link
Author

So does that mean that the SVGO's CSS colors minifier couldn't be augmented with this feature? Given that there are a very limited number of color formats in this scenario, couldn't this just be written from scratch pretty quickly? Just remove spaces, round numbers to specified level of precision, and remove any zeros preceeding decimals?

@strarsis
Copy link
Contributor

strarsis commented Apr 6, 2017

@GreLI: So plain CSS is optimized by CSSO in minifyStyles plugin. -
But rgba values in element attributes are not supported currently?

@GreLI
Copy link
Member

GreLI commented Apr 6, 2017

@peternowell, it totally can, I just described reason why it doesn't now.

@strarsis, it doesn't supported for now in SVGO. What processed through CSSO depends on CSSO support (I guess it does.)

@strarsis
Copy link
Contributor

strarsis commented Apr 6, 2017

@peternowell : But because CSSO handles the CSS minification, it already minifies rgba values.

So this issue makes no sense then?

@GreLI
Copy link
Member

GreLI commented Apr 6, 2017

I believe the issue is about rgba values outside of CSS or style attribute.

@strarsis
Copy link
Contributor

strarsis commented Apr 6, 2017

It is possible reusing the CSSO routines, also for other attribute values than just for color,
see https://github.com/css/csso/tree/f381f09436d66572df0ccbca45c39aa84709269f/lib/replace.

For color values, besides minifying rgba(...) values, CSSO also replaces generic colors with
their keyword counterparts (which is usually also more efficient), see https://github.com/css/csso/blob/f381f09436d66572df0ccbca45c39aa84709269f/lib/replace/color.js .

There is already the convertColors plugin but it doesn't support rgba yet.

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

3 participants