Socket
Book a DemoInstallSign in
Socket

@ds-pack/theme-to-css-vars

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ds-pack/theme-to-css-vars

_Note: looking for a better package name, if you have ideas see [#1](https://github.com/ds-pack/theme-to-css-vars/issues/1)_

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

@ds-pack/theme-to-css-vars

Note: looking for a better package name, if you have ideas see #1

A utility package for transforming a css-in-js theme object from raw values to CSS custom properties (CSS variables).

Installation:

yarn add @ds-pack/theme-to-css-vars

Usage:

import themeToCSSVars from '@ds-pack/theme-to-css-vars'

let baseTheme = {
  colors: {
    blue: ['cadetblue', 'steelblue', 'cornflowerblue'],
    get primary() {
      return this.blue[2]
    },
  },
}

let cssVariables = themeToCSSVars(baseTheme)

// cssVariables ===
//   [
//     ['--colors-blue-0', 'cadetblue' ],
//     ['--colors-blue-1', 'steelblue' ],
//     ['--colors-blue-2', 'cornflowerblue' ],
//   ]

The utility function will return an array of tuples representing the CSS Variables for the theme.

Tools:

  • Typescript
  • Babel
  • Jest

FAQs

Package last updated on 16 Jan 2021

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