LeaVerou / css-almanac

Repo for planning & voting on which stats to study
https://projects.verou.me/mavoice/?repo=leaverou/css-almanac&labels=proposed%20stat
34 stars 3 forks source link

direction CSS property usage #38

Open catalinred opened 4 years ago

catalinred commented 4 years ago

I'm interested to find out how many devs use a different direction in CSS compared to the dir attribute from the markup?

My guess is that the CSS direction property is often used for UX things like star rating or similar and has nothing to do with the actual direction of the text in the document.

LeaVerou commented 4 years ago

I don’t think this is feasible to do without custom metrics since we don’t have access to the DOM and it would be too expensive to parse the HTML via DOMParser, but we could still measure how frequently dir is used and on what selectors. @rviscomi correct me if I’m wrong?

LeaVerou commented 4 years ago

@catalinred Do you think we should still pursue this by measuring dir usage or should we axe it?

catalinred commented 4 years ago

If we can measure both ‘dir’ attr from the markup and ‘direction’ property from the CSS, and depending of the resulted numbers, then we could draw some interesting conclusions here.

But if this is too cumbersome and expensive, sure, we can skip it :)

rviscomi commented 4 years ago

@Tiggerito added a dir custom metric for the Markup chapter, so this should be possible.

LeaVerou commented 4 years ago

So we just measure usage of each dir value?

Tiggerito commented 4 years ago

Here's an example of the output for dirs:

    "dirs": {
        "html_dir": "ltr",
        "body_nodes_dir": {
            "values": {
                "ltr": 1
            },
            "total": 1
        }
    },

So you can report on the values people use for the html dir attribute as well as how often it gets used within the body.

LeaVerou commented 4 years ago

One complication is that we don't really know what CSS selectors match. We can guess in certain cases (e.g. html or :root, but we don't know what e.g. .foo is. I could:

Thoughts?

catalinred commented 4 years ago

measure dir values broken down into 3 categories: a) obviously , b) obviously , c) any other selector lumped together

I'd say this breakdown can be helpful.