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

theminator

v0.2.3

Published

Theminator enhances the properties of your theme object with useful methods to help you more easily create derived values.

Downloads

3

Readme

Theminator

Theminator replaces the colors and dimensions (e.g. #123456 or 12rem) in your theme with objects containing useful methods that you can use to create derived values, like a darkened version of the background color or a multiplied border width for a hover effect.

Installation

yarn add theminator

or

npm i theminator

Quick start

1. Import Theminator.

import decorate from 'theminator';

2. Create your theme object.

A theme object needs to have at least a colors key and a dimensions key at the top level. Feel free to nest values as deep as you want, the only requirement is that primitive values need to be parseable as a color value or a dimension value respectively. The rest of the top level keys are ignored and can contain anything.

const theme = {
  colors: {
    button: {
      primary: '#123456',
      secondary: '#654321',
    },
  },
  dimensions: {
    borderWidth: '1px',
    circle: {
      borderRadius: '50%',
    },
  },
  extra: 'I am ignored.',
};

3. Decorate it using Theminator. If you want, you can export it right away.

export default decorate(theme);

4. Profit.

// ...
import theme from '../theme';

const color = theme.colors.button.primary;
const borderWidth = theme.dimensions.borderWidth;

// ...

<button
  className={css`
    background: ${color.css()};
    border-color: ${color.darken(2).css()};
    border-width: ${borderWidth.value * 2} ${borderWidth.unit};
  `}
>
  ...
</button>;

Documentation

decorate(theme) (default export)

Parameters

theme: an object containing a colors and a dimensions key.

Return value

An enhanced object of the same shape. Color values are wrapped with chroma-js. Dimension values are replaced with an object of the shape { css: string, number: number, unit: string }. If a value is not valid, the function throws.

decorateColors(colors)

Parameters

colors: an object containing color values. Values can be nested as deep as you want but they need to be valid.

Return value

An enhanced object of the same shape. Values are wrapped with chroma-js. Called internally by decorate().

decorateDimensions(dimensions)

Parameters

dimensions: an object containing dimension values. Values can be nested as deep as you want but they need to be valid.

Return value

An enhanced object of the same shape. Values are replaced with an object of the shape { css: string, number: number, unit: string }. Called internally by decorate().

Development

Below is a list of commands you will probably find useful.

npm start or yarn start

Runs the project in development/watch mode.

npm run build or yarn build

Bundles the package to the dist folder.

npm test or yarn test

Runs the test watcher (Jest) in an interactive mode.