Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

theminator

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

theminator

Enhance your theme objects.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Theminator

Enhance your theme objects.

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, value: 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, value: 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.

FAQs

Package last updated on 11 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc