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

babel-plugin-transform-yoga-style-spacing

v1.0.0

Published

Transform spacing properties such as `marginVertical` into their separate properties for DOM support

Downloads

3

Readme

babel-plugin-transform-yoga-style-spacing

Work in progress. This is probably broken for many things and I'm certain it doesn't work with the emotion css prop preset. Also TypeScript understandably doesn't like these properties it doesn't know about. I'm looking into that and will test out some other cases but consider this experimental.

The style system in React Native (powered by Yoga) adds four critical properties to traditional CSS:

  • marginHorizontal
  • marginVertical
  • paddingHorizontal
  • paddingVertical

These provide shorthand for left/right and top/bottom.

This Babel transform plugin adds support for these properties by rewriting them as their component rules. For example:

Before:

<div style={{ marginVertical: 16 }} />

After:

<div style={{ marginTop: 16, marginBottom: 16 }} />

Installation

NPM:

npm install --dev babel-plugin-transform-yoga-style-spacing

Yarn:

yarn add --dev babel-plugin-transform-yoga-style-spacing

Then add to your babel config (more about babel configuration):

{
  "plugins": [
    // 'my-other-babel-plugin'
    "babel-plugin-transform-yoga-style-spacing"
    // ...
  ]
}

Caveats

  • doesn't currently work with the emotion css prop, probably because of plugin execution ordering
  • TypeScript doesn't recognize the new properties
  • It only works for ObjectExpressions and properties set by Identitiers. That is: const styles = { marginVertical: 12 } works. styles['marginVertical']: 12; does not. const marginVerticalKey = 'marginVertical'; const styles= { [marginVerticalKey]: 12 }; does not.
  • It duplicates by source whatever is on the right hand side of the property assignment. These should not be A) Expensive B) Cause side effects C) Non-deterministic