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

ui-kit-converter

v0.1.0

Published

Convert your legacy components to shiny UI-Kit.

Downloads

7

Readme

ui-kit-converter

Install

yarn global add ui-kit-converter

or if npm is your package manager

npm install --global ui-kit-converter

Description

The only purpose of this converter is to convert 'legacy' components to UI-Kit. It makes use of both inline styles and external stylesheets (if provided).

The converter does its best to transform as many components as possible, yet it supports limited set of cases. Although, the code styling is preserved, you may still need to make code-style changes (i.e. sort imports etc.)

Styled components should be isolated, so if you have styles with declarations that rely on presence of given node or style siblings, you must adjust them.

Unsafe changes are not applied in most cases, but this does not mean the converter won't break your code.

import * as React from 'react';
import cn from 'classnames';

export const MyComponent: React.FunctionComponent<IMyComponent> = ({ onClick, ...props }) => {
  return (
    <div {...props} className="pin-l relative" style={{ display: 'block', backgroundColor: 'blue', userSelect: 'none' }}>
      <a style={{ fontSize: '20px' }} href="www.example.com">example.com</a>
      <span className="flex" style={{ alignItems: 'center' }}>I am aligned!</span>
      <button className={cn('cursor-move absolute pin-l border-b')}>I support classnames too!</button>
    </div>
  );
};

is transformed to

/* @jsx jsx */
import { jsx } from "@emotion/core";

import { Box, Link, Flex, Button } from "@stoplight/ui-kit";
import * as React from 'react';
import cn from 'classnames';

export const MyComponent: React.FunctionComponent<IMyComponent> = ({ onClick, ...props }) => {
  return (
    <Box
      position="relative"
      left={0}
      backgroundColor="blue"
      display="block"
      {...props}
      className="pin-l relative"
      style={{
        userSelect: 'none'
      }}>
      <Link fontSize="20px" href="www.example.com">example.com</Link>
      <Flex as="span" alignItems="center" className="flex">I am aligned!</Flex>
      <Button
        borderBottomWidth="1px"
        cursor="move"
        position="absolute"
        left={0}
        className={cn('cursor-move absolute pin-l border-b')}>I support classnames too!</Button>
    </Box>
  );
};

Pretty neat, huh?

For more examples go to tests/fixtures.

Requirements

  • Node >= 10

Usage

to-ui-kit src/

or if you want to include styles from external stylesheet(s)

to-ui-kit --stylesheet https://cdn.jsdelivr.net/npm/tailwindcss/dist/tailwind.min.css -- src/

You can also provide custom plugins to the parser to handle non-standard syntax. To do so, just pass --parser.plugins typescript asyncGenerators.

A full list of available plugins is here

LICENSE

MIT