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

rn-pxtrans

v0.0.13

Published

将 750 设计稿的尺寸,自动转成实际像素,(开发时,可直接按 750 尺寸写样式)

Downloads

16

Readme

解决什么痛点:

痛点:我们在编写 RN 引用时,通常会使用 750 设计稿;而 RN 默认单位是 px,因此我们需要频繁的转换

本工具的目的即解决设计稿转换问题

开始使用

已支持 Typescript

create 方法将实现自动转换 (无需额外配置)

初始化之后,任意 create 里的尺寸数据,自动按照 750 设计稿算

使用 rn-pxtrans 里的 create 替代原有的 StyleSheet.create

内联样式需手动加入

非 create 创建的样式,比如直接在 jsx 直接写的 style,还是需要转换

import { styleTrans } from 'rn-pxtrans'

const Home = () => <View style={styleTrans({ height: 100, width: 100 })}>...</View> 

在内联样式中,也可以只对某个值进行转化,如

import { pxTrans } from 'rn-pxtrans'

const Home = () => <View style={{ height: pxTrans(100), width: 100 }}>...</View> 

如何排除不转换的尺寸

在有些时候,整体需要转换,但个别的属性我们希望使用原始的 px,此时,只需用 noTrans 包裹个别的尺寸即可

import { noTrans, create } from 'rn-pxtrans'
create({
  height: 100,
  width: 100,
  borderRadius: noTrans(2) // 依旧保留 2px
})

同样,在内联里,类似使用

import { styleTrans, noTrans } from 'rn-pxtrans'

const Home = () => (
  <View style={styleTrans({ height: 100, width: 100, borderRadius: noTrans(2) })}>...</View>
)