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

ds-variables-converter

v1.0.4

Published

get Econ vars from DS

Downloads

1

Readme

How to Install:

Install globally on your machine:

npm i ds-variables-converter -g

What is it for

This is a cli-tool to aid in front end development to convert over from plain css values to design system values.

Basically the designs that we receive are often given in pixels and without Economist Design System variables for other css elements.

This package will make it easy to quickly convert these over with little to no trouble.

Currently this package is in beta but will be improved upon if there is a need for it in the organisation.

How to use

The run command for this package in the cli is:

formatDoc

If you need help:

formatDoc --help

Flags

To use this cli-tool you will need to provide the format falg -f. There are several predefined values you can provide:

['fontSize', 'coloursVars', 'fontFamily', 'toRem', 'toPx', 'all']

  • -f all will do all the variables plus convert px to rem

  • -f fontsize will replace px or rem values to the ds variable (this is an exact matcher - will be improved to closest ds variable eventually, e.g. 16px/1rem will match convert to var( --ds-type-scale-0) and 18px//1.125rem will convert to var( --ds-type-scale-1) BUT 17px/0.625rem will not convert to anything, see design system docs)

  • -f coloursVars will convert hex values to ds vars. e.g #E3120B -> var(--ds-color-economist-red)

  • -f fontFamily will convert font families. E.g. Milo TE -> var(--ds-type-system-serif)

  • -f toPX will convert rem to px

  • -f toRem will convert px to rem

Paths/Files

When using the tool, you basically need to give it a path to the file on your machine. It can either be the full path or a relative path to the file.

Or you can cd into the directory where the styles file you desire to convert is and just provide the file name with its extension.

The -p flag and path/file name is necessary:

-p <yourFilePath>

e.g:

Full path: -p /Users/someone/Documents/PersonalEconProj/cli-tool-v1/my-first-cli/this-component.ts

A relative path:

-p my-first-cli/this-component.ts

if you cd into the folder:

-p this-component.ts

Example full commands

To convert an entire file:

formatDoc -p episode.styles.ts -f all

Convert to rem:

formatDoc -p episode.styles.ts -f toRem

Convert the fontFamilies only:

formatDoc -p episode.styles.ts -f fontFamily

Removing it from your local machine

As it is a beta. To remove easily from your local machine:

npm uninstall -g ds-variables-converter

and check it is no longer there:

npm list -g --depth=0