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

How frequently is each color format used? #32

Open
LeaVerou opened this issue Jul 20, 2020 · 34 comments
Open

How frequently is each color format used? #32

LeaVerou opened this issue Jul 20, 2020 · 34 comments
Assignees
Labels
✅ Has algorithm (1/3) An implementable algorithm for how to measure this stat has been described in the issue ✅ Has JS (2/3) JS has been written to calculate this stat ✅ Has SQL (3/3) BigQuery SQL has been written to calculate this stat. proposed stat Proposed statistic to study Section: Color

Comments

@LeaVerou
Copy link
Owner

  • What percentage of colors used use what format? (rgb(), rgba(), hsl(), hsla(), #rgb, #rgba, #rrggbb, #rrggbbaa, color(...), named colors, currentColor.
  • What percentage of color functions use the new syntax? (e.g. rgb(r g b / a) instead of rgba(r, g, b, a) etc.

In a way, this is a generalization of #18.

@LeaVerou LeaVerou added the proposed stat Proposed statistic to study label Jul 20, 2020
@LeaVerou LeaVerou added ⚠️ Needs SQL Needs SQL to calculate this stat ⚠️ Needs JS Needs JS to calculate this stat ⚠️ Needs algorithm labels Aug 4, 2020
@LeaVerou
Copy link
Owner Author

LeaVerou commented Aug 22, 2020

Algorithm:

  1. Iterate over properties that could have a color as part of their value (properties ending in color, starting with border, background, background-image, ending in shadow, filter, as well as custom properties)
  2. On these values, extract colors by matching on /#([a-f]{3,4}){1,2}, extracting calls of the rgb(), rgba(), hsl(), hsla(), color() functions, and on a list of named colors. Store all these in an array
  3. Count color usage by format.
  4. For color():
    • count usage by color space (most likely to only find display-p3 across the board, since that's the only supported value, but there may be some optimistic usage for the future)
    • count how many are used with a fallback in the color() function vs none
    • for display-p3 colors, measure how many are outside the sRGB gamut (@svgeesus can provide a JS function to do that)

@LeaVerou LeaVerou added ✅ Has algorithm (1/3) An implementable algorithm for how to measure this stat has been described in the issue and removed ⚠️ Needs algorithm labels Aug 22, 2020
@LeaVerou
Copy link
Owner Author

LeaVerou commented Sep 8, 2020

Pushed an initial version of the JS, still needs some debugging, and @svgeesus to implement the inSRGBGamut() function

@svgeesus
Copy link
Collaborator

svgeesus commented Sep 9, 2020

for display-p3 colors, measure how many are outside the sRGB gamut (@svgeesus can provide a JS function to do that)

Yes. The function will do the following:

  1. Convert from gamma-corrected P3 to linear-light P3
  2. Matrix multiply to go from linear P3 to linear sRGB
  3. no-op
  4. Check for values outside [0.0-1.0]

Normally step 3 would be sRGB gamma-correction but for this specific use case, the results are the same so it can be skipped.

Oh and the matrix multiply can be the unreadable but short inlined multiplication, not using a function; it will always be a 3x3 matrix.

@LeaVerou LeaVerou added ✅ Has JS (2/3) JS has been written to calculate this stat and removed ⚠️ Needs JS Needs JS to calculate this stat labels Sep 25, 2020
@svgeesus
Copy link
Collaborator

I added the algorithm

LeaVerou added a commit that referenced this issue Sep 30, 2020
- Add system colors
- Separate currentColor and transparent from other keywords
- Fix perf bug (two objects were erroneously sorted on each declaration instead of once in the end!)
@rviscomi
Copy link
Collaborator

FYI @LeaVerou @svgeesus I'm only seeing 4 pages with p3 data. Could that be right?

@rviscomi rviscomi added ✅ Has SQL (3/3) BigQuery SQL has been written to calculate this stat. and removed ⚠️ Needs SQL Needs SQL to calculate this stat labels Oct 15, 2020
@LeaVerou
Copy link
Owner Author

I left a comment about this in the sheet.
So, it could be right, though it's a little too low. However, in the Color formats tab there are 4,271 instances of color(). If they are not P3 what color space are they using? I can't find stats on color space (it is included in the JS, under the spaces key), but that might be a good first step to figure out what's going on. If the 4,271 instances are of display-p3, then something is definitely wrong.

@rviscomi
Copy link
Collaborator

Added a tab for color space.

@LeaVerou
Copy link
Owner Author

Yeah, something is fishy here.

  • None of these are color spaces except display-p3. The rest are either parsing errors, or author errors, and I'll need URLs to check which one.
  • Are these the only ones? They most definitely do not add up to 4,271 color() calls. I'll need to look at some of these URLs to see if they're just using color() incorrectly, or if there's a bug in my code.

LeaVerou added a commit that referenced this issue Oct 15, 2020
@LeaVerou
Copy link
Owner Author

@rviscomi Could we prioritize these issues so that @svgeesus can start on his section after TPAC?

@rviscomi
Copy link
Collaborator

Sure, could you clarify if the resolution is to rerun all color queries with the updated JS or if there are any additional queries to write?

@LeaVerou
Copy link
Owner Author

I was still investigating. Did you see this comment?

@rviscomi
Copy link
Collaborator

I did, but it's not clear what the resolution is or if I'm blocked on anything. If you're still investigating, what can I help with?

@LeaVerou
Copy link
Owner Author

  • Are the color space results the only ones? They do not add up to anywhere near 4,271.
  • I need URLs of stylesheets that showed up as containing color(), especially those that weren't counted in color spaces.

If it makes it easier, here's some JS that should just return those as a list:

let ret = [];

walkDeclarations(ast, ({property, value}) => {
	// First remove url() references to avoid them mucking the results
	for (let f of extractFunctionCalls(value, {names: "url"})) {
		let [start, end] = f.pos;
		value = value.substring(0, start) + "url()" + " ".repeat(end - start - 5) + value.substring(end);
	}

	for (let f of extractFunctionCalls(value, {names: "color"})) {
		ret.push(value.substring(...f.pos));
	}
}, {
	properties: /^--|color$|^border|^background(-image)?$|\-shadow$|filter$/
});

return ret;

@rviscomi
Copy link
Collaborator

rviscomi commented Oct 22, 2020

Does this help?

client page url color
desktop http://ir.daveandbusters.com/ https://ir.daveandbusters.com/sites/g/files/knoqqb2776/files/css/css_SJWVqxooBqIWCiMX-tv4sOVcDnLTpF7lcpBgmLWVsw8.css color(blue)
desktop http://ir.daveandbusters.com/ https://ir.daveandbusters.com/sites/g/files/knoqqb2776/files/css/css_SJWVqxooBqIWCiMX-tv4sOVcDnLTpF7lcpBgmLWVsw8.css color(grey-dark)
desktop http://ir.daveandbusters.com/ https://ir.daveandbusters.com/sites/g/files/knoqqb2776/files/css/css_SJWVqxooBqIWCiMX-tv4sOVcDnLTpF7lcpBgmLWVsw8.css color(red)
desktop http://ir.daveandbusters.com/ https://ir.daveandbusters.com/sites/g/files/knoqqb2776/files/css/css_SJWVqxooBqIWCiMX-tv4sOVcDnLTpF7lcpBgmLWVsw8.css color(blue)
desktop http://ir.daveandbusters.com/ https://ir.daveandbusters.com/sites/g/files/knoqqb2776/files/css/css_SJWVqxooBqIWCiMX-tv4sOVcDnLTpF7lcpBgmLWVsw8.css color(xls-green)
desktop http://ir.daveandbusters.com/ https://ir.daveandbusters.com/sites/g/files/knoqqb2776/files/css/css_SJWVqxooBqIWCiMX-tv4sOVcDnLTpF7lcpBgmLWVsw8.css color("medium-blue")
desktop http://ir.daveandbusters.com/ https://ir.daveandbusters.com/sites/g/files/knoqqb2776/files/css/css_SJWVqxooBqIWCiMX-tv4sOVcDnLTpF7lcpBgmLWVsw8.css color("grey-dark")
desktop http://ir.daveandbusters.com/ https://ir.daveandbusters.com/sites/g/files/knoqqb2776/files/css/css_SJWVqxooBqIWCiMX-tv4sOVcDnLTpF7lcpBgmLWVsw8.css color("white")
desktop http://ir.daveandbusters.com/ https://ir.daveandbusters.com/sites/g/files/knoqqb2776/files/css/css_SJWVqxooBqIWCiMX-tv4sOVcDnLTpF7lcpBgmLWVsw8.css color("nir_toolbar_grey")
desktop http://ir.constellationpharma.com/ https://ir.constellationpharma.com/sites/g/files/knoqqb31636/files/css/css_PwTIQkQe9kvpDqZQfRXb_fNeZVjZmNplWFCkUCiTIgs.css color(blue)

A few more URLs:

https://betterthanbreadketo.com/wp-content/themes/bamboo-trellis/assets/dist/css/main.0.2.0.css
https://www.shieling.co.nz/wp-content/uploads/oxygen/css/main-10.css?cache=1585099797&ver=5.3.4
https://mybestcare.cz/wp-content/cache/autoptimize/css/autoptimize_single_0fa04d4ed7fc9869b50d23ca31b32d07.css?cache=1596226313&ver=5.4.2
https://artewhite.com/wp-content/uploads/oxygen/css/arte-white-920.css?cache=1596552900&ver=5.4.2
https://flashclad.co.nz/wp-content/uploads/oxygen/css/main-8.css?cache=1573445499&ver=5.3.4
https://www.lightcastmedia.com/assets/css/dist/main.min.css?v=cea4b888f2
https://westportlibrary.org/wp-content/uploads/oxygen/css/universal.css?cache=1596488756&ver=5.4.2
http://ppt-lms.in/ppt_dev_ver_11/css/style.css
https://ssbcrackexams.com/wp-content/themes/ssbcrack-exams/assets/css/blocks.css?ver=1577020599
https://www.assets.comehome.com/builds/208/vendor_styles.6bc6e554e32c3c0ac901.bundle.min.css

@LeaVerou
Copy link
Owner Author

Yes, this helps!

The good news is, this doesn't appear to be a bug in my code. 🎉
The bad news is, I'm at a loss at what these color() values are supposed to represent. Some are strings (e.g. color("cod-gray"), some are numbers (e.g. color(10)), some seem to be some elaborate syntax of color and adjuster (probably inspired from the old Color 4), like color(#b30a0a a(.5)). In one they're even used in filter, like color(100%)!

Are they syntax that was meant to be preprocessed and wasn't? Are they errors? They're too many in each stylesheet to be errors...

I suppose what we can do is make the code that detects color spaces more robust, so that at least that doesn't have false positives.
@rviscomi, could you give me some URLs for the stylesheets that not only have color(), but also produce color space results (which indicates that it's parsed incorrectly)? The ones above don't seem to. Let me know if you want me to make a script for you or you can use the original JS.

@rviscomi
Copy link
Collaborator

https://vibeche.cc/css/vibecheck.css
https://vibeche.cc/scripts/dist/vibecheck/app.css
https://www.panic.com/panic.css?2019-11-13
https://play.date/static/css/colors.css?2af0635dc0a4
https://ask.lynk.global/main.1e8583de7b0751c8b75f7f5ed9656e7b.css
https://acimotorfreight.com/css/custom.css
https://xcodebuildsettings.com/assets/main-1126bb19580d6012ca0c84f51b0e651780990d6ab46feedb9872dc267412755d.css
inline
https://www.acimotorfreight.com/css/custom.css
https://admin.vb.media/css/pure-css/_variables.css?v=20190606
https://www.visuallizard.com/css/layout.css?1579625685
https://www.courageousstudios.com/css/app.css
https://panic.com/panic.css?2019-11-13
https://cdn.lootvalley.com/loot/1.9/assets/css/min/landing.css
https://play.date/static/css/colors.css
https://starmatch.ru/front/resource/lib/onsen/theme.css
https://www.andersnoren.se/wp-content/themes/reset/style.min.css?ver=1.0.5
https://rsms.me/res/screen.css?v=20200716210017

@LeaVerou
Copy link
Owner Author

Thanks!

So it seems that from these, there are two categories:

  • color() used correctly with display-p3
  • color() which is essentially the old color-mod() syntax, a color modification proposal that was never actually supported by browsers.

I just pushed a change to make color() parsing less loose to prevent these being parsed as false positives.

@rviscomi
Copy link
Collaborator

rviscomi commented Oct 23, 2020

Thanks! I'll rerun the p3 and spaces queries with the updated JS. Let me know if there's anything else that needs to be rerun/added.

See the updated p3 and color space results.

@LeaVerou
Copy link
Owner Author

Thanks! Everything else is still valid. In fact, I don't even think the p3 query needed to be rerun, as there was nothing mistakenly recognized as P3.

@svgeesus
Copy link
Collaborator

svgeesus commented Oct 26, 2020

https://play.date/static/css/colors.css

Interesting. So they are using document order to to the fallback; all colors are specified in sRGB first and then again in display-p3 (regardless of whether the color is outside the sRGB gamut or not; the first few colors are white, black and some greys).

Here is one which is (slightly) outside sRGB: color(display-p3 1 0.80 0.25 / 1) and the fallback is rgba(255,205,63,1).

image

and another, color(display-p3 0.29 0.01 0.63 / 1) with fallback rgba(75,3,161,1)

image

Apart from a single use of P3 primary red, all of these are either inside sRGB or very slightly outside, and the color differences (I'm going to trust the deltaE 2000) are visible but really not that different. This looks like a careful exploration, to me.

@svgeesus
Copy link
Collaborator

svgeesus commented Oct 26, 2020

https://www.panic.com/panic.css?2019-11-13

Here the sRGB defaults are set as custom properties on :root and then the P3 values are assigned to the same custom properties, wrapped up in an @supports.

Despite the different approach to fallback though, the first color I checked was exactly the same as the play.date site: color(display-p3 1 0.80 0.25 / 1) and the fallback is rgba(255,205,63,1). Here is another pair, color(display-p3 1 0 0.2823 / 1) and rgb(255,0,72) with a deltaE 2000 of 3.5

image

@svgeesus
Copy link
Collaborator

https://vibeche.cc/css/vibecheck.css

Fascinating. One single example of a P3 color. Fallback is by document order. Here is that pair: color(display-p3 1 0.9882 0) and #fffc00. Okay, let's convert that hex color to decimal on the same 0 to 1 scale that color() uses: color(srgb 1 0.9882 0). Yes, it is the same component values, but in a different colorspace! deltaE 2000 is 5 here.

image

This looks like experimentation to me, without really understanding how colorspaces work.

@svgeesus
Copy link
Collaborator

@svgeesus
Copy link
Collaborator

https://acimotorfreight.com/css/custom.css

.light-shade
{background: linear-gradient(to right, white, color(blue blend(lime 50%)), black);
  /*  background-color:#f6f6f6;*/
}

Looks like an attempt to use the old color modification function, when it was called color(), before it was renamed to color-mod(), before it was renamed and re-specified as color-adjust(). Ans that commented-out value is not going to function as a fallback. A forgotten experiment?

@svgeesus
Copy link
Collaborator

https://www.courageousstudios.com/css/app.css

Some oddities there,

#nav-main-connect a:hover {
      color: color(#787878 lightness(+25%));
    }

and

#contact h1 {
  position: absolute;
  font-weight: bold;
  line-height: 0.8;
  font-family: "Conduit",sans-serif;
  left: 0;
  color: color(white alpha(10%));
  z-index: 20;
  text-transform: uppercase;
}

Again some color modification attempts.

@svgeesus
Copy link
Collaborator

svgeesus commented Oct 26, 2020

https://cdn.lootvalley.com/loot/1.9/assets/css/min/landing.css

color(display-p3 .427 .231 1) now this one will accidentally do the right thing, because If more <number>s or <percentage>s are provided than parameters that the colorspace takes, the excess <number>s at the end are ignored.
but this one won't: color(display-p3 .012 .839 .345) the alpha will be 1.0 there, not 0.345 as intended. The fallback is fully opaque though, #03d658. Here the P3 is a zingier green, with a deltaE 2000 from the fallback of 9.5

image

Oh and another pair where the P3 colors seems to be the sRGB component values changed to P3: color(display-p3 1 .224 0) and fallback #ff3900 which is color(srgb 1 0.2235 0) if rounded to 3 decimal places.

image

I haven't gone through all of the colors here, partly because of the minified code and many duplicates.

@svgeesus
Copy link
Collaborator

https://www.andersnoren.se/wp-content/themes/reset/style.min.css?ver=1.0.5

@supports (color:color(display-p3 0 0 0 / 1)){@media (color-gamut:p3){:root{--accent:color( display-p3 .905882353 .282352941 .196078431 / 1 )}}}

Belt and braces here, @supports for P3 syntax, followed by a gamut check to be sure P3 gamut is supported. Noble, but un-necessary as color(display-p3 .905882353 .282352941 .196078431 / 1) is rgb(98.41% 20.26% 12.45%) so inside the sRGB gamut. But maybe the fallback is less saturated still?

@svgeesus
Copy link
Collaborator

Also from https://docs.google.com/spreadsheets/d/1sMWXWjMujqfAREYxNbG_t1fOJKYCA6ASLwtz4pBQVTw/edit#gid=535285955

Astonishing that hsl() is way down there at 0.69%. hsla() is much higher, at 7.7% which is much lower than I would have expected given how much the usability benefits of HSL were (over) sold and how interoperable it is.

color() as expected is really rare due to lack of support (although I would have expected a few more iOS-specific pages using it) and everyone uses rgba() at 67%.

@LeaVerou
Copy link
Owner Author

LeaVerou commented Nov 3, 2020

Moving the discussion here to not clog HTTPArchive/almanac.httparchive.org#898

I believe that is 2.8% of colors are named color, not 2.8% of pages use named colors.

Yes, also each sheet should also have a comment with the intended interpretation.

Would it be possible to also have results on what % of pages have at least one of each, or would it require a second query?

That is a mistake of the query which has been fixed. @rviscomi ?

The query did need to be rerun but the results have only changed very slightly. Background on desktop is still used 2.3% of the time.

This is certainly wrong. I could debug if you give me some URLs, but I suspect it's probably the background property, parsed as a value due to some syntax error in the stylesheet.

@rviscomi
Copy link
Collaborator

rviscomi commented Nov 3, 2020

Would it be possible to also have results on what % of pages have at least one of each, or would it require a second query?

It's possible but it'd require another query. My suggestion would be to focus on fixing query bugs before augmenting with new data if there's still time. Let me know how you'd like to proceed.

This is certainly wrong. I could debug if you give me some URLs, but I suspect it's probably the background property, parsed as a value due to some syntax error in the stylesheet.

https://kudapostupat.com/wp-content/plugins/lightbox/css/frontend/lightbox.css?ver=5.4.2 has 108 instances of Background according to the JS:

image

Note that I had to paste the CSS directly because of a CORS issue

Access to fetch at 'https://cors-anywhere.herokuapp.com/https://kudapostupat.com/wp-content/plugins/lightbox/css/frontend/lightbox.css?ver=5.4.2' from origin 'https://projects.verou.me' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

The Swiper library and its various versions also comes up a lot in example URLs: https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/css/swiper.min.css

Hope that helps. Let me know if you need more debugging URLs.

@LeaVerou
Copy link
Owner Author

LeaVerou commented Nov 3, 2020

So it looks like this may be a Rework bug. Search for url('../../ and you will see that there are entire declarations parsed as a singular value, even though they contain semicolons, so Rework should have been able to parse them appropriately.

Actually, try inputting this:

a#rwd-share-facebook:not(.view7){background:url('../../images/share(1).png');background-position:0 0}a#rwd-share-facebook:not(.view7):hover{background:url('../../images/share(1).png');background-position:0 -30px}a#rwd-share-twitter:not(.view7){background:url('../../images/share(1).png');background-position:-31px 0}a#rwd-share-twitter:not(.view7):hover{background:url('../../images/share(1).png');background-position:-31px -30px}a#rwd-share-googleplus:not(.view7){background:url('../../images/share(1).png');background-position:-66px 0}a#rwd-share-googleplus:not(.view7):hover{background:url('../../images/share(1).png');background-position:-66px -30px}a#rwd-share-pinterest:not(.view7){background:url('../../images/share(1).png');background-position:-100px 0}a#rwd-share-pinterest:not(.view7):hover{background:url('../../images/share(1).png');background-position:-100px -30px}a#rwd-share-linkedin:not(.view7){background:url('../../images/share(1).png');background-position:-134px 0}a#rwd-share-linkedin:not(.view7):hover{background:url('../../images/share(1).png');background-position:-134px -30px}a#rwd-share-tumblr:not(.view7){background:url('../../images/share(1).png');background-position:-169px 0}a#rwd-share-tumblr:not(.view7):hover{background:url('../../images/share(1).png');background-position:-169px -30px}a#rwd-share-reddit:not(.view7){background:url('../../images/share(1).png');background-position:-204px 0}a#rwd-share-reddit:not(.view7):hover{background:url('../../images/share(1).png');background-position:-204px -30px}a#rwd-share-buffer:not(.view7){background:url('../../images/share(1).png');background-position:-239px 0}a#rwd-share-buffer:not(.view7):hover{background:url('../../images/share(1).png');background-position:-239px -30px}a#rwd-share-digg:not(.view7){background:url('../../images/share(1).png');background-position:-273px 0}a#rwd-share-digg:not(.view7):hover{background:url('../../images/share(1).png');background-position:-273px -30px}a#rwd-share-vk:not(.view7){background:url('../../images/share(1).png');background-position:-308px 0}a#rwd-share-vk:not(.view7):hover{background:url('../../images/share(1).png');background-position:-308px -30px}a#rwd-share-yummly:not(.view7){background:url('../../images/share(1).png');background-position:-344px 0}a#rwd-share-yummly:not(.view7):hover{background:url('../../images/share(1).png');background-position:-344px -30px}.rwd-view3 a#rwd-share-facebook, .rwd-view6 a#rwd-share-facebook{background:url('../../images/share0.png');background-position:0 0}.rwd-view3 a#rwd-share-facebook:hover, .rwd-view6 a#rwd-share-facebook:hover{background:url('../../images/share0.png');background-position:0 -30px}.rwd-view3 a#rwd-share-twitter, .rwd-view6 a#rwd-share-twitter{background:url('../../images/share0.png');background-position:-31px 0}.rwd-view3 a#rwd-share-twitter:hover, .rwd-view6 a#rwd-share-twitter:hover{background:url('../../images/share0.png');background-position:-31px -30px}.rwd-view3 a#rwd-share-googleplus, .rwd-view6 a#rwd-share-googleplus{background:url('../../images/share0.png');background-position:-66px 0}.rwd-view3 a#rwd-share-googleplus:hover, .rwd-view6 a#rwd-share-googleplus:hover{background:url('../../images/share0.png');background-position:-66px -30px}.rwd-view3 a#rwd-share-pinterest, .rwd-view6 a#rwd-share-pinterest{background:url('../../images/share0.png');background-position:-100px 0}.rwd-view3 a#rwd-share-pinterest:hover, .rwd-view6 a#rwd-share-pinterest:hover{background:url('../../images/share0.png');background-position:-100px -30px}.rwd-view3 a#rwd-share-linkedin, .rwd-view6 a#rwd-share-linkedin{background:url('../../images/share0.png');background-position:-134px 0}.rwd-view3 a#rwd-share-linkedin:hover, .rwd-view6 a#rwd-share-linkedin:hover{background:url('../../images/share0.png');background-position:-134px -30px}.rwd-view3 a#rwd-share-tumblr, .rwd-view6 a#rwd-share-tumblr{background:url('../../images/share0.png');background-position:-169px 0}.rwd-view3 a#rwd-share-tumblr:hover, .rwd-view6 a#rwd-share-tumblr:hover{background:url('../../images/share0.png');background-position:-169px -30px}.rwd-view3 a#rwd-share-reddit, .rwd-view6 a#rwd-share-reddit{background:url('../../images/share0.png');background-position:-204px 0}.rwd-view3 a#rwd-share-reddit:hover, .rwd-view6 a#rwd-share-reddit:hover{background:url('../../images/share0.png');background-position:-204px -30px}.rwd-view3 a#rwd-share-buffer, .rwd-view6 a#rwd-share-buffer{background:url('../../images/share0.png');background-position:-239px 0}.rwd-view3 a#rwd-share-buffer:hover, .rwd-view6 a#rwd-share-buffer:hover{background:url('../../images/share0.png');background-position:-239px -30px}.rwd-view3 a#rwd-share-digg, .rwd-view6 a#rwd-share-digg{background:url('../../images/share0.png');background-position:-273px 0}.rwd-view3 a#rwd-share-digg:hover, .rwd-view6 a#rwd-share-digg:hover{background:url('../../images/share0.png');background-position:-273px -30px}.rwd-view3 a#rwd-share-vk, .rwd-view6 a#rwd-share-vk{background:url('../../images/share0.png');background-position:-308px 0}.rwd-view3 a#rwd-share-vk:hover, .rwd-view6 a#rwd-share-vk:hover{background:url('../../images/share0.png');background-position:-308px -30px}.rwd-view3 a#rwd-share-yummly, .rwd-view6 a#rwd-share-yummly{background:url('../../images/share0.png');background-position:-344px 0}.rwd-view3 a#rwd-share-yummly:hover, .rwd-view6 a#rwd-share-yummly:hover{background:url('../../images/share0.png');background-position:-344px -30px}.rwd-view5 a#rwd-share-facebook{background:url('../../images/share1.png');background-position:0 0}.rwd-view5 a#rwd-share-twitter{background:url('../../images/share1.png');background-position:-35px 0}.rwd-view5 a#rwd-share-googleplus{background:url('../../images/share1.png');background-position:-68px 0}.rwd-view5 a#rwd-share-pinterest{background:url('../../images/share1.png');background-position:-100px 0}.rwd-view5 a#rwd-share-linkedin{background:url('../../images/share1.png');background-position:-133px 0}.rwd-view5 a#rwd-share-tumblr{background:url('../../images/share1.png');background-position:-165px 0}.rwd-view5 a#rwd-share-reddit{background:url('../../images/share1.png');background-position:-197px 0}.rwd-view5 a#rwd-share-buffer{background:url('../../images/share1.png');background-position:-231px 0}.rwd-view5 a#rwd-share-digg{background:url('../../images/share1.png');background-position:-263px 0}.rwd-view5 a#rwd-share-vk{background:url('../../images/share1.png');background-position:-294px 0}.rwd-view5 a#rwd-share-yummly{background:url('../../images/share1.png');background-position:-329px 0}

This is an extract from that stylesheet, and it is parsed as a single rule with two declarations!!

@rviscomi
Copy link
Collaborator

rviscomi commented Nov 3, 2020

Yeah I agree it seems like a Rework bug. Pasting the pretty-printed version of the CSS seems to be WAI. So making the system colors case-sensitive seems to help. We can also add heuristic checks for this in our JS, eg if (value.length > 100) return;.

@LeaVerou
Copy link
Owner Author

LeaVerou commented Nov 3, 2020

I think a better heuristic might be to remove all strings and url() calls, and if the remainder contains a semicolon, ditch the value. What do you think?

Btw if we're going the heuristic route, it may be better to just special case Background, since the other colors don't also correspond to properties. Or just get rid of Background altogether: even cased "Background", I'd wager it's more likely to be a parsing error than actual usage of that system color.

@rviscomi
Copy link
Collaborator

rviscomi commented Nov 3, 2020

IMO the updated results should be reliable enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅ Has algorithm (1/3) An implementable algorithm for how to measure this stat has been described in the issue ✅ Has JS (2/3) JS has been written to calculate this stat ✅ Has SQL (3/3) BigQuery SQL has been written to calculate this stat. proposed stat Proposed statistic to study Section: Color
Projects
None yet
Development

No branches or pull requests

3 participants