
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
mrn-pxtrans
Advanced tools
痛点:我们在编写 RN 引用时,通常会使用 750 设计稿;而 RN 默认单位是 px,因此我们需要频繁的转换
本工具的目的即解决设计稿转换问题
已支持 Typescript
初始化之后,任意 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>
)
FAQs
将 750 设计稿的尺寸,自动转成实际像素,(开发时,可直接按 750 尺寸写样式)
The npm package mrn-pxtrans receives a total of 7 weekly downloads. As such, mrn-pxtrans popularity was classified as not popular.
We found that mrn-pxtrans demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.