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

css-utilities-generator

v1.4.5

Published

TypeScript utility package that simplifies working with CSS properties by providing shorthand notations for common CSS class names. Ideal for developers who want to streamline their CSS styling process, this package helps you translate short, intuitive cl

Downloads

288

Readme

🎨 css-utilities-generator NPM

Preview

TypeScript utility package that generates a utilities.css file on demand with shorthand class names for common CSS properties. By using intuitive notations like d-f (display: flex) as values for className attributes inside your jsx, this package streamlines your styling process, making your main CSS structure cleaner, reusable and more maintainable while ensuring consistent, efficient application of styles across your project.

Installation & Setup (Auto)

First, run create-css-utilities auto executable, installing css-utilities-generator, dependencies and configuration files into your project:

# Automatic installation executable:
> npx create-css-utilities

Run the following command to start generatic css utilities:

# Run the following command (generates css utilities on save):
> npm run utils

Now import the generated css file to the project root file, start watching for changes in your root directory and automatically regenerate the CSS utilities.

Example

  <main className="ml-50 mr-50">
    <header className="d-f h-64px ai-c jc-sb pos-sticky top-0 z-5">
      <h1 className="w-fc">
        Site Title
      </h1>
      <nav className="w-300px">
        <ul className="d-f jc-sb">
          <li>
            <a href="#">Home</a>
          </li>
          <li>
            <a href="#">About</a>
          </li>
          <li>
            <a href="#">Contact</a>
          </li>
        </ul>
      </nav>
    </header>
    <section className="d-f fd-co ai-c jc-c h-80">
      <h1 className="fs-40 fw-700">
        Welcome!
      </h1>
      <p className="mt-2rem fs-12 o-70 fw-2">
        Some filler text
      </p>
    </section>
  </main>

some-file.tsx

.ml-50 { margin-left: 50px; }
.mr-50 { margin-right: 50px; }
.d-f { display: flex; }
.h-64px { height: 64px; }
.ai-c { align-items: center; }
.jc-sb { justify-content: space-between; }
.pos-sticky { position: sticky; }
.z-5 { z-index: 5; }
.w-fc { width: fit-content; }
.w-300px { width: 300px; }
.fd-co { flex-direction: column; }
.jc-c { justify-content: center; }
.h-80 { height: 80%; }
.fs-40 { font-size: 40px; }
.fw-700 { font-weight: 700; }
.mt-2rem { margin-top: 2rem; }
.fs-12 { font-size: 12px; }
.o-70 { opacity: 70%; }
.fw-2 { font-weight: 2; }

utilities.css

Configuration File (Defaults)

{
    "onlyDictionary": true, /* Matching only dictionary or extension properties, Defaults to false */
    "acceptAnyKey": false,
    "acceptAnyValue": true,
    "units": "rem", /* Defines unit for those css properties with numeric values or others, Defaults to "px" */
    "extendKeys": /* Extend default dictionary abbreviations */ 
    {
        "fs": {"name": "font-size", "valueExtension": "vw"}, /* Would match for fs className */
        "fi": {"name": "filter", "valueExtension": ""} /* Would match for fs className */
    },
    "writeTo": "./styles/utilities.css", /* Where to write generated css file, Defaults to "./styles/utilities.css" */
    "readFrom": "./", /* Where to parse - interpret files from, Defaults to "./" */
    "extensions": ["tsx", "ts", "js", "jsx"] /* Read className attributes from files with extensions in Array */
    "exclude": ["node_modules", ".git"] /* Exclude directories from having files parsed, traversed ...  */
}

/cuconfig.json

Usage

Example of jsx elements with above configuration set, variables usage and their respective generated classes at utilities.css

<div className="d-f ml-40">
    <h1 className="fs-2 c--brand-primary">
        Hello World!
...

/src/some-file.tsx

...
.d-f {display: flex}
.ml-40 {margin-left: 40rem}
.fs-2 {font-size: 2vw}
.c--brand-primary {color: var(--brand-primary)}
...

src/styles/utilities.css

Contributions

This project encourages contributions and suggestions.