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

inherit-classname

v1.1.0

Published

A babel plugin that can prefix the class name of a parent element to the class name of a child element

Downloads

4

Readme

inherit-classname

A babel plugin that can prefix the class name of a parent element to the class name of a child element

简介

一个 babel 插件,通过给元素设置特定的属性,可以把这些属性拼接到类名中,其中子元素的类名会把父元素的类名作为前缀

简单来说,看下面的例子就懂了

转换前

function App() {
  return (
    <div inherit-class="feedback">
      <div inherit-class="head">
        <div inherit-class="title"></div>
        <div inherit-class="avatar"></div>
      </div>
      <div inherit-class="body">
        <div inherit-class="charts">
          <div inherit-class="line"></div>
          <div inherit-class="pie"></div>
        </div>
        <div inherit-class="table">
          <div inherit-class="thead"></div>
          <div inherit-class="tbody"></div>
        </div>
        <div inherit-class="area3" />
      </div>
      <div inherit-class="cl1 cl2" className="cl3" />
      {[].map(() => <div inherit-class="map"/>)}
    </div>
  );
}

=>

转换后的 html

function App() {
  return (
    <div className="feedback">
      <div className="feedback-head">
        <div className="feedback-head-title"></div>
        <div className="feedback-head-avatar"></div>
      </div>
      <div className="feedback-body">
        <div className="feedback-body-charts">
          <div className="feedback-body-charts-line"></div>
          <div className="feedback-body-charts-pie"></div>
        </div>
        <div className="feedback-body-table">
          <div className="feedback-body-table-thead"></div>
          <div className="feedback-body-table-tbody"></div>
        </div>
        <div className="feedback-area3" />
      </div>
      <div inherit-class="feedback-cl1 feedback-cl2 cl3" />
      {[].map(() => <div inherit-class="feedback-map"/>)}
    </div>
  );
}

代码片段辅助工具

在写代码时敲这个“inherit-class”属性是不是非常烦?别问我怎么知道烦的...

可以通过 vscode 的代码片段工具来快速生成

  1. 打开用户代码片段设置
  2. 点击添加新片段,随便一个名字
  3. 把下面这段 json 复制进去,就可以快乐的敲了
{
  "InheritClass": {
    "scope": "javascriptreact,typescriptreact",
    "prefix": "inh",
    "body": ["inherit-class=\"$1\""],
    "description": "添加集成类名"
  }
}

alt