
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
react-native-stylekit
Advanced tools
一个用于快速构建界面的样式工具库
npm i react-native-stylekit --save
import React from 'react'
import { View } from 'react-native'
import stylekit from 'react-native-stylekit'
const SK = stylekit({ borderColor: '#eee' })
export default () =>
<View style={[SK.p1, SK.m1]}></View>
默认的 borderStyle 为 solid
,默认的 borderColor 为 #D9D9D9
,默认的 borderRadius 为 5px
下面的对象默认都有 borderStyle
和 borderColor
的样式
b0: { borderWidth: 0 },
bh: { borderWidth: 0.5, borderColor, borderStyle },
b1: { borderWidth: 1, borderColor, borderStyle },
bt0: { borderTopWidth: 0 },
bth: { borderTopWidth: 0.5, borderColor, borderStyle },
bt1: { borderTopWidth: 1, borderColor, borderStyle },
br0: { borderRightWidth: 0 },
brh: { borderRightWidth: 0.5, borderColor, borderStyle },
br1: { borderRightWidth: 1, borderColor, borderStyle },
bb0: { borderBottomWidth: 0 },
bbh: { borderBottomWidth: 0.5, borderColor, borderStyle },
bb1: { borderBottomWidth: 1, borderColor, borderStyle },
bl0: { borderLeftWidth: 0 },
blh: { borderLeftWidth: 0.5, borderColor, borderStyle },
bl1: { borderLeftWidth: 1, borderColor, borderStyle },
提供文字颜色、边框颜色支持的颜色
const $primary = '#337ab7'
const $success = '#5cb85c'
const $info = '#5bc0de'
const $warning = '#f0ad4e'
const $danger = '#d9534f'
const $white = '#fff'
const $silver = '#F4F4F4'
const $lightgrey = '#ececec'
const $grey = '#ccc'
const $midgrey = '#777'
const $darkgrey = '#444'
const $black = '#222'
const $trueblack = '#000'
文字颜色、背景颜色、边框颜色,分别使用 colorXxx
、bgXxx
、borderXxx
(eg. colorSuccess、bgWhite、borderBlack)
提供
textXxx
作为colorXxx
的别名
额外提供如下颜色对象
c0: { color: #000 },
c1: { color: #111 },
c2: { color: #222 },
c3: { color: #333 },
c4: { color: #444 },
c5: { color: #555 },
c6: { color: #666 },
c7: { color: #777 },
c8: { color: #888 },
c9: { color: #999 },
ca: { color: #aaa },
cb: { color: #bbb },
cc: { color: #ccc },
cd: { color: #ddd },
ce: { color: #eee },
cf: { color: #fff },
column: { flexDirection: 'column', flexWrap: 'nowrap' },
row: { flexDirection: 'row', flexWrap: 'wrap' },
center: { alignItems: 'center', justifyContent: 'center' },
topLeft: { alignItems: 'flex-start', justifyContent: 'flex-start' },
bottomRight: { alignItems: 'flex-end', justifyContent: 'flex-end' },
// row 和 column 定位不同,所以要分开写
columnTopCenter: { alignItems: 'center', justifyContent: 'flex-start' },
columnTopRight: { alignItems: 'flex-end', justifyContent: 'flex-start' },
columnCenterLeft: { alignItems: 'flex-start', justifyContent: 'center' },
columnCenterRight: { alignItems: 'flex-end', justifyContent: 'center' },
columnBottomLeft: { alignItems: 'flex-start', justifyContent: 'flex-end' },
columnBottomCenter: { alignItems: 'center', justifyContent: 'flex-end' },
rowTopCenter: { alignItems: 'flex-start', justifyContent: 'center' },
rowTopRight: { alignItems: 'flex-start', justifyContent: 'flex-end' },
rowCenterLeft: { alignItems: 'center', justifyContent: 'flex-start' },
rowCenterRight: { alignItems: 'center', justifyContent: 'flex-end' },
rowBottomLeft: { alignItems: 'flex-end', justifyContent: 'flex-start' },
rowBottomCenter: { alignItems: 'flex-end', justifyContent: 'center' },
spaceAround: { justifyContent: 'space-around' },
spaceBetween: { justifyContent: 'space-between' },
alignStart: { alignSelf: 'flex-start' },
alignCenter: { alignSelf: 'center' },
alignEnd: { alignSelf: 'flex-end' },
alignStretch: { alignSelf: 'stretch' },
flex1: { flex: 1 },
flex2: { flex: 2 },
flex3: { flex: 3 },
flex4: { flex: 4 },
flex5: { flex: 5 },
textCenter: { textAlign: 'center' },
textLeft: { textAlign: 'left' },
textRight: { textAlign: 'right' },
tc
、tl
、tr
分别作为textCenter
、textLeft
、textRight
的别名
fs12: { fontSize: 12 },
fs13: { fontSize: 13 },
fs14: { fontSize: 14 },
fs15: { fontSize: 15 },
fs16: { fontSize: 16 },
...
fs35: { fontSize: 35 },
fs36: { fontSize: 36 },
lh12: { lineHeight: 12 },
lh13: { lineHeight: 13 },
lh14: { lineHeight: 14 },
lh15: { lineHeight: 15 },
lh16: { lineHeight: 16 },
...
lh71: { lineHeight: 71 },
lh72: { lineHeight: 72 },
italic: { fontStyle: 'italic' },
tracked: { letterSpacing: 4 },
noTextDecoration: { textDecorationLine: 'none' },
underline: { textDecorationLine: 'underline' },
lineThrough: { textDecorationLine: 'line-through' },
thin: { fontWeight: 200 },
regular: { fontWeight: 400 },
bold: { fontWeight: 700 },
overflowHidden: { overflow: 'hidden' },
overflowVisible: { overflow: 'visible' },
ofh,ofv 作为 overflowHidden,overflowVisible 的别名
relative: { position: 'relative' },
absolute: { position: 'absolute' },
top: { top: 0 },
right: { right: 0 },
bottom: { bottom: 0 },
left: { left: 0 },
imgCover: { resizeMode: 'cover' },
imgContain: { resizeMode: 'contain' },
imgStretch: { resizeMode: 'stretch' },
提供内补和外补,以 10
为粒度
p0 { padding: 0 },
p5 { padding: 5 },
p10 { padding: 10 },
...
p50 { padding: 50 },
/*
pt => paddingTop
pr => paddingRight
pb => paddingBottom
pl => paddingLeft
*/
pt0 { paddingTop: 0 },
pt5 { paddingTop: 5 },
pt10 { paddingTop: 10 },
...
pt50 { paddingTop: 50 },
/*
ptb => paddingTop & paddingBottom
plr => paddingRight & paddingLeft
*/
ptb0 { paddingTop: 0, paddingBottom: 0 },
ptb5 { paddingTop: 5, paddingBottom: 5 },
ptb10 { paddingTop: 10, paddingBottom: 10 },
...
ptb5 { paddingTop: 50, paddingBottom: 50 },
外补同补风格一致,对象前缀为 m
FAQs
a stylekit for react native
The npm package react-native-stylekit receives a total of 157 weekly downloads. As such, react-native-stylekit popularity was classified as not popular.
We found that react-native-stylekit 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.