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

@lg-tools/codemods

v0.1.0

Published

Codemods for LeafyGreen UI

Downloads

121

Readme

Codemods

npm (scoped)

Installation

Yarn

yarn add @lg-tools/codemods

NPM

npm install @lg-tools/codemods

Usage

yarn lg codemod <codemod-name> <path> [...options]

Arguments

codemod

name of codemod, see available codemods below.

path

files or directory to transform

Options

-i or --ignore

Glob patterns to ignore

yarn lg codemod <codemod-name> <path> --ignore **/node_modules/** **/.next/**

-d or --dry

Dry run (no changes to files are made)

yarn lg codemod <codemod-name> <path> --dry

-p or --print

Print transformed files to stdout and changes are also made to files

yarn lg codemod <codemod-name> <path> --print

-f or --force

Bypass Git safety checks and forcibly run codemods.

yarn lg codemod <codemod-name> <path> --force

--packages

Restrict the codemod to certain packages

yarn lg codemod <codemod-name> <path> --packages @leafygreen-ui/popover @leafygreen-ui/select

Codemods

popover-v12

This codemod can be used to get started in refactoring LG components dependent on v12+ of @leafygreen-ui/popover.

By default, the codemod will apply for all below listed packages. Use the --packages flag to filter for a subset of these.

This codemod does the following:

  1. Adds an explicit usePortal={true} declaration if left undefined and consolidates the usePortal and renderMode props into a single renderMode prop for components in the following packages:
  • @leafygreen-ui/combobox
  • @leafygreen-ui/menu
  • @leafygreen-ui/popover
  • @leafygreen-ui/select
  • @leafygreen-ui/split-button
  • @leafygreen-ui/tooltip
  1. Removes popoverZIndex, portalClassName, portalContainer, portalRef, scrollContainer, and usePortal props from the following components:
  • @leafygreen-ui/info-sprinkle
  • @leafygreen-ui/inline-definition
  • @leafygreen-ui/number-input
  1. Removes popoverZIndex, portalClassName, portalContainer, portalRef, and scrollContainer props from the following components:
  • @leafygreen-ui/date-picker
  • @leafygreen-ui/guide-cue
  1. Removes popoverZIndex, portalClassName, portalContainer, scrollContainer, and usePortal props from Code component in the @leafygreen-ui/code package

  2. Removes portalClassName, portalContainer, portalRef, scrollContainer, and usePortal props from SearchInput component in the @leafygreen-ui/search-input package

  3. Removes shouldTooltipUsePortal prop from Copyable component in the @leafygreen-ui/copyable package

  4. Replaces justify="fit" prop value with justify="middle" for components in the following packages:

  • @leafygreen-ui/date-picker
  • @leafygreen-ui/info-sprinkle
  • @leafygreen-ui/inline-definition
  • @leafygreen-ui/menu
  • @leafygreen-ui/popover
  • @leafygreen-ui/tooltip
yarn lg codemod popover-v12 <path> --packages @leafygreen-ui/combobox @leafygreen-ui/code @leafygreen-ui/info-sprinkle @leafygreen-ui/copyable

Before:

import LeafyGreenCode from '@leafygreen-ui/code';
import { Combobox as LGCombobox } from '@leafygreen-ui/combobox';
import { DatePicker } from '@leafygreen-ui/date-picker';
import { InfoSprinkle } from '@leafygreen-ui/info-sprinkle';
import { Menu } from '@leafygreen-ui/menu';
import Copyable from '@leafygreen-ui/copyable';
import Tooltip from '@leafygreen-ui/tooltip';

<LGCombobox />
<LGCombobox usePortal={true} />
<LGCombobox usePortal={false} />

<LeafyGreenCode portalClassName="portal-class" portalRef={ref} usePortal />
<InfoSprinkle popoverZIndex={9999} usePortal={false} />

<DatePicker portalContainer={containerRef} scrollContainer={containerRef} />
<Menu portalClassName="portal-class" usePortal />

<Copyable shouldTooltipUsePortal />
<Copyable shouldTooltipUsePortal={true} />
<Copyable shouldTooltipUsePortal={false} />

<Menu justify="fit" renderMode="top-layer" />
<Tooltip justify="fit" renderMode="top-layer" />

After:

import LeafyGreenCode from '@leafygreen-ui/code';
import { Combobox as LGCombobox } from '@leafygreen-ui/combobox';
import { DatePicker } from '@leafygreen-ui/date-picker';
import { InfoSprinkle } from '@leafygreen-ui/info-sprinkle';
import { Menu } from '@leafygreen-ui/menu';
import Copyable from '@leafygreen-ui/copyable';

<LGCombobox renderMode="portal" />
<LGCombobox renderMode="portal" />
<LGCombobox renderMode="inline" />

<LeafyGreenCode />
<InfoSprinkle />

<DatePicker portalContainer={containerRef} scrollContainer={containerRef} />
<Menu portalClassName="portal-class" usePortal />

<Copyable />
<Copyable />
<Copyable />

<Menu justify="middle" renderMode="top-layer" />
<Tooltip justify="middle" renderMode="top-layer" />