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-vars-2-ts

v0.0.9

Published

Generate typescript interfaces and constants from .css/.scss/.sass

Downloads

6

Readme

css-vars-2-ts

license npm latest package

Generate typescript interfaces and constants from .css/.scss/.sass

Installation

For the best CLI, we recommend installing css-vars-2-ts globally via npm or yarn:

npm

npm install -g css-vars-2-ts

yarn

yarn global add css-vars-2-ts

or

yarn add css-vars-2-ts -D

Usage

Input

./vars.css

body[data-theme='light'] {
  --colors-background: #fff;
  --colors-primary: #17a2b8;
  --colors-secondary: #798892;
  --colors-success: #43a047;
  --colors-info: #846eab;
  --colors-warning: #ffc247;
  --colors-danger: #f55d5d;
  --colors-dark: #3c484f;
  --colors-inverse: #495057;
  --colors-gray: #d6dee5;
  --colors-light: #f8f9fa;
  --colors-default: #e9ecef;
  --colors-primary-light: #dee4ee;
  --colors-success-light: #ecfaec;
  --colors-info-light: #f2fafa;
  --colors-warning-light: #fdf7e6;
  --colors-danger-light: #fff2ef;
  --colors-body-bg: #f8f9fa;
  --colors-white: #fff;
  --colors-gray-light: #f8f9fa;
  --colors-border-color: #c4c4c4;
  --colors-green-light: #00c853;
  --colors-disabled: #f3f3f3;
  --colors-textInfoBg: #f8cbd0;
  --colors-textInfoBorder: #a6a1a4;
  --colors-lineHeader: #7d7d7d;
  --lightness: 0.8;

  --spacing-gutter-vertical: 2.4rem;
  --spacing-gutter-horizontal: 2.4rem;
  --spacing-header-spacing-small: 0.5rem;
  --spacing-header-spacing-medium: 1rem;
  --spacing-header-spacing-large: 2rem;
}

body[data-theme='dark'] {
  --colors-background: #fff;
  --colors-primary: #17a2b8;
  --colors-secondary: #798892;
  --colors-success: #43a047;
  --colors-info: #846eab;
  --colors-warning: #ffc247;
  --colors-danger: #f55d5d;
  --colors-dark: #3c484f;
  --colors-inverse: #495057;
  --colors-gray: #d6dee5;
  --colors-light: #f8f9fa;
  --colors-default: #e9ecef;
  --colors-primary-light: #dee4ee;
  --colors-success-light: #ecfaec;
  --colors-info-light: #f2fafa;
  --colors-warning-light: #fdf7e6;
  --colors-danger-light: #fff2ef;
  --colors-body-bg: #f8f9fa;
  --colors-white: #fff;
  --colors-gray-light: #f8f9fa;
  --colors-border-color: #c4c4c4;
  --colors-green-light: #00c853;
  --colors-disabled: #f3f3f3;
  --colors-textInfoBg: #f8cbd0;
  --colors-textInfoBorder: #a6a1a4;
  --colors-lineHeader: #7d7d7d;
  --lightness: 0.2;

  --spacing-gutter-vertical: 2.4rem;
  --spacing-gutter-horizontal: 2.4rem;
  --spacing-header-spacing-small: 0.5rem;
  --spacing-header-spacing-medium: 1rem;
  --spacing-header-spacing-large: 2rem;
}

Command

css-vars-2-ts vars.css

Output

./vars-const.ts

export const themes = {
  light: {
    colors: {
      background: 'var(--colors-background)',
      primary: 'var(--colors-primary)',
      secondary: 'var(--colors-secondary)',
      success: 'var(--colors-success)',
      info: 'var(--colors-info)',
      warning: 'var(--colors-warning)',
      danger: 'var(--colors-danger)',
      dark: 'var(--colors-dark)',
      inverse: 'var(--colors-inverse)',
      gray: 'var(--colors-gray)',
      light: 'var(--colors-light)',
      default: 'var(--colors-default)',
      primaryLight: 'var(--colors-primary-light)',
      successLight: 'var(--colors-success-light)',
      infoLight: 'var(--colors-info-light)',
      warningLight: 'var(--colors-warning-light)',
      dangerLight: 'var(--colors-danger-light)',
      bodyBg: 'var(--colors-body-bg)',
      white: 'var(--colors-white)',
      grayLight: 'var(--colors-gray-light)',
      borderColor: 'var(--colors-border-color)',
      greenLight: 'var(--colors-green-light)',
      disabled: 'var(--colors-disabled)',
      textInfoBg: 'var(--colors-textInfoBg)',
      textInfoBorder: 'var(--colors-textInfoBorder)',
      lineHeader: 'var(--colors-lineHeader)',
    },
    lightness: 'var(--lightness)',
    spacing: {
      gutterVertical: 'var(--spacing-gutter-vertical)',
      gutterHorizontal: 'var(--spacing-gutter-horizontal)',
      headerSpacingSmall: 'var(--spacing-header-spacing-small)',
      headerSpacingMedium: 'var(--spacing-header-spacing-medium)',
      headerSpacingLarge: 'var(--spacing-header-spacing-large)',
    },
  },
  dark: {
    colors: {
      background: 'var(--colors-background)',
      primary: 'var(--colors-primary)',
      secondary: 'var(--colors-secondary)',
      success: 'var(--colors-success)',
      info: 'var(--colors-info)',
      warning: 'var(--colors-warning)',
      danger: 'var(--colors-danger)',
      dark: 'var(--colors-dark)',
      inverse: 'var(--colors-inverse)',
      gray: 'var(--colors-gray)',
      light: 'var(--colors-light)',
      default: 'var(--colors-default)',
      primaryLight: 'var(--colors-primary-light)',
      successLight: 'var(--colors-success-light)',
      infoLight: 'var(--colors-info-light)',
      warningLight: 'var(--colors-warning-light)',
      dangerLight: 'var(--colors-danger-light)',
      bodyBg: 'var(--colors-body-bg)',
      white: 'var(--colors-white)',
      grayLight: 'var(--colors-gray-light)',
      borderColor: 'var(--colors-border-color)',
      greenLight: 'var(--colors-green-light)',
      disabled: 'var(--colors-disabled)',
      textInfoBg: 'var(--colors-textInfoBg)',
      textInfoBorder: 'var(--colors-textInfoBorder)',
      lineHeader: 'var(--colors-lineHeader)',
    },
    lightness: 'var(--lightness)',
    spacing: {
      gutterVertical: 'var(--spacing-gutter-vertical)',
      gutterHorizontal: 'var(--spacing-gutter-horizontal)',
      headerSpacingSmall: 'var(--spacing-header-spacing-small)',
      headerSpacingMedium: 'var(--spacing-header-spacing-medium)',
      headerSpacingLarge: 'var(--spacing-header-spacing-large)',
    },
  },
};

./vars-model.ts

export interface Themes {
  light: Light;
  dark: Light;
}

export interface Light {
  colors: Colors;
  lightness: string;
  spacing: Spacing;
}

export interface Spacing {
  gutterVertical: string;
  gutterHorizontal: string;
  headerSpacingSmall: string;
  headerSpacingMedium: string;
  headerSpacingLarge: string;
}

export interface Colors {
  background: string;
  primary: string;
  secondary: string;
  success: string;
  info: string;
  warning: string;
  danger: string;
  dark: string;
  inverse: string;
  gray: string;
  light: string;
  default: string;
  primaryLight: string;
  successLight: string;
  infoLight: string;
  warningLight: string;
  dangerLight: string;
  bodyBg: string;
  white: string;
  grayLight: string;
  borderColor: string;
  greenLight: string;
  disabled: string;
  textInfoBg: string;
  textInfoBorder: string;
  lineHeader: string;
}

Options

target

A directory where the generated files are placed.

Type: string

Default: ./

modelTarget

A directory where the generated model file is placed.

Type: string

Default: ./ or same as target

targetName

A file name for constant.

Type: string

Default: {css-file-name}-const.ts

targetModelName

A file name for interfaces.

Type: string

Default: {css-file-name}-model.ts

help

Show all available args.

Type: boolean

Default: false

License

The package is Open Source Software released under the MIT licensed.

This library was generated with Nx.