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

@native-elements/funky

v1.3.2

Published

Your class-based utility

Downloads

50

Readme

Funky

The definitive tool to create your own class-less utility-first css.

Getting started

Funky is a CLI tool, you can install it globally or you can run it when you need it by using npx.

yarn add @native-elements/funky

If you prefer to use it with npx and without installing, skip to the usage section

Usage

You can now run the funky command in your terminal to generate the utility css file based on the default configuration.

funky --out path/to/utilities.css

You can use also use npx to run the CLI as-a-service:

npx @native-elements/funky --out path/to/utilities.css

How it works

Funky takes a configuration object and use it to generate class-less css utilities by using custom properties. By using the following configuration:

module.exports = {
  minify: false, // Default true
  outputPath: 'utilities.css',
  breakpoints: {
    sm: '48em',
    md: '60em',
    lg: '100em',
  },
  utilities: {
    m: {
      // 'responsive' || 'standard'
      type: 'standard',
      // Optional. Generate a variant for each status
      states: ['hover'],
      // CSS property name
      property: 'margin',
    },
  },
};

Funky takes that and generates the following CSS:

→ 📄utilities.css

[style*='--m:'] {
  margin: var(--m);
}
[style*='--m-hover:']:hover {
  margin: var(--m-hover);
}

If we set the type to be responsive instead of standard, we'll get this:

→ 📄utilities.css

[style*='--m:'] {
  margin: var(--m);
}

[style*='--m-hover:']:hover {
  margin: var(--m-hover);
}

@media (width >= 48em) {
  [style*='--m-sm:'] {
    margin: var(--m-sm);
  }
  [style*='--m-hover-sm:']:hover {
    margin: var(--m-hover-sm);
  }
}

@media (width >= 60em) {
  [style*='--m-md:'] {
    margin: var(--m-md);
  }
  [style*='--m-hover-md:']:hover {
    margin: var(--m-hover-md);
  }
}

@media (width >= 100em) {
  [style*='--margin-lg:'] {
    margin: var(--margin-lg);
  }
  [style*='--margin-hover-lg:']:hover {
    margin: var(--margin-hover-lg);
  }
}

Configuration

The CLI will use a default configuration when you don't provide yours but you can fully customize Funky by creating a file at the root of your project called funky.config.js.

Note that the default configuration is full logical properties oriented. So if you have to support obsolete softares, you have to provide your own configuration

New configuration

You may don't need all the utilities that are generated with the default configuration, so if you want to create a new set of utilities from scratch, export a new object from the configuration file, following this schema:

module.exports = {
  minify: false,
  outputPath: 'path/to/utilities.css'
  breakpoints: {
    xlg: '120em',
  },
  utilities: {
    res: {
      type: 'responsive',
      property: 'resize',
    },
  },
};

The above configuration will generate only the specified utilities and breakpoints, dropping everything else that comes from the default configuration:

[style*='--res:'] {
  resize: var(--res);
}

@media (width >= 120em) {
  [style*='--res-xlg:'] {
    resize: var(--res-xlg);
  }
}

Extending the default configuration

If you are ok with the default configuration but you need to add more utilities, you can extend the built-in config by importing it and exporting a new object from your funky.config.js:

const {breakpoints, utilities} = require('@native-elements/funky/config.js');

module.exports = {
  breakpoints: {
    ...breakpoints,
    xlg: '120em',
  },
  utilities: {
    ...utilities,
    res: {
      type: 'responsive',
      property: 'resize',
    },
  },
};

By this way the CLI will merge the default configurations with ones provided by your configuration file.