npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

posthtml-pseudo

v0.6.14

Published

Adds pseudo class names to elements.

Downloads

15

Readme

posthtml-pseudo

Build Coverage Greenkeeper badge super awesome

A PostHTML plugin to add pseudo classes to elements within <body>, eg :first-child/:last-child.

Before:

<html>
    <body>
        <div>one</div>
        <div>two</div>
        <div>three</div>
    </body>
</html>

After:

<html>
    <body>
        <div class=":first-child">one</div>
        <div>two</div>
        <div class=":last-child">three</div>
    </body>
</html>

:point_right: Check out postcss-pseudo-classes for the other side of the equation.

:pencil: Note on supported classes: Pseudo classes dependent on input values (:valid, :invalid, ...), browser history (:visted, :link, ...), interaction (:hover, :focus:), parameters (:nth-child(), :lang(), ...), page url (:target) or require JS (:indeterminate), have been excluded. See support list.

Options

Options config has two properties — include and exclude — to define which psuedo class names to add, and which tags to add them to. Both include.classNames and exclude.classNames can be:

  • a string of a class name group
  • a string of a class name (/^:\S+/, from those in the all group)
  • an array of class name groups and/or class names

Example Options Config

This config adds all supported pseudo class names to all appropriate elements using their default class names.

let config = {
    include : {
        classNames : "all" // all group
    }
};

Here's something more complex, adding only two class names but only to elements that aren't div, table or form.

let config = {
    include : {
        classNames : [ ":first-child", ":last-child" ]
    },
    exclude : {
        tags : [
            "div", "table", "form"
        ]
    }
};

And here's an unrealistic and irresponsible config showing more options.

let config = {
    include : {
        classNames : [
            "all", // include the "all" group using default class names
            { ":first-child" : "fc" }, // custom class name
            { "form" : (className) => className.replace(":", "") } // remove ":" from default classname
        ],
        tags : [
            "div",
            "p",
            "span"
        ]
    },
    exclude : {
        classNames : [
            "onlyChild",
            ":root",
            ":read-only"
        ],
        tags : [
            "div"
        ]
    }
}

Class Name Groups

{
    all : [
        ":default",
        ":disabled",
        ":empty",
        ":enabled",
        ":first-child"
        ":first-of-type",
        ":last-child",
        ":last-of-type",
        ":only-of-type",
        ":only-child",
        ":optional",
        ":read-only",
        ":read-write",
        ":required",
        ":root"
    ],
    firstLast : [
        ":first-child",
        ":first-child-of-type",
        ":last-child",
        ":last-child-of-type"
    ],
    firstLastOnly : [
        ":first-child",
        ":last-child"
    ],
    form : [
        ":default",
        ":disabled",
        ":enabled",
        ":optional",
        ":required",
        ":read-only",
        ":read-write"
    ],
    onlyChild : [
        ":only-child",
        ":only-child-of-type"
    ],
    readWrite : [
        ":read-only",
        ":read-write"
    ]
}

Pseudo Class Names

List of supported and unsupported pseudo class names. Checkboxes track implementation status.

  • ~~:active~~
  • ~~:any~~
  • ~~:checked~~
  • [X] :default
  • ~~:dir()~~ *
  • [X] :disabled
  • [X] :empty
  • [X] :enabled
  • [X] :first
  • [X] :first-child
  • [X] :first-of-type
  • ~~:fullscreen~~
  • ~~:focus~~
  • ~~:hover~~
  • ~~:indeterminate~~
  • ~~:in-range~~
  • ~~:invalid~~
  • ~~:lang()~~ *
  • [X] :last-child
  • [X] :last-of-type
  • ~~:left~~
  • ~~:link~~
  • ~~:not()~~ *
  • ~~:nth-child()~~ *
  • ~~:nth-last-child()~~ *
  • ~~:nth-last-of-type()~~ *
  • ~~:nth-of-type()~~ *
  • [X] :only-child
  • [X] :only-of-type
  • [X] :optional
  • ~~:out-of-range~~
  • [X] :read-only
  • [X] :read-write
  • [X] :required
  • ~~:right~~
  • [X] :root
  • ~~:scope~~
  • ~~:target~~
  • ~~:valid~~
  • ~~:visited~~

* Hope to add these, but require some thinking due to input parameters.