react-native-overall-style
v1.0.2
Published
React Native için wp/hp ve width/375 tabanlı responsive/size yardımcıları.
Maintainers
Readme
react-native-overall-style
React Native için basit boyut yardımcıları:
wp(%): genişlik yüzdesihp(%): yükseklik yüzdesiresponsiveFontSize(size): size * (screenWidth / 375)isTablet(): ekran boyutuna göre tablet kontrolü
Kurulum
npm i react-native-overall-style
# veya
yarn add react-native-overall-styleKullanım
import { wp, hp, responsiveFontSize, fontSize, fontType, fontSizes, setFontConfig, isTablet } from 'react-native-overall-style';
const styles = {
container: {
paddingHorizontal: wp(4), // ekran genişliğinin %4'ü
paddingVertical: hp(2), // ekran yüksekliğinin %2'si
},
title: {
fontSize: fontSize(18), // responsiveFontSize alias
...fontType('semiBold'),
},
};
if (isTablet()) {
// tablet için alternatif stil/yerleşim uygulanabilir
}
// Özel font aileleri tanımlama (opsiyonel)
setFontConfig({
regular: 'Inter-Regular',
medium: 'Inter-Medium',
semiBold: 'Inter-SemiBold',
bold: 'Inter-Bold',
});
// Hazır ölçekler
const caption = fontSizes.xs;
const body = fontSizes.md;
const heading = fontSizes.xl;API
wp(percentage: number): numberhp(percentage: number): numberresponsiveFontSize(size: number): numberfontSize(size: number): number(alias)isTablet(): booleansetFontConfig(config: Partial<Record<FontTypeName, string>>): voidfontType(type: FontTypeName): { fontFamily?, fontWeight?, fontStyle? }fontSizes: { xs, sm, md, lg, xl, xxl }
TypeScript
Paket, index.d.ts ile tip deklarasyonları içerir. Ek konfigürasyon gerektirmez.
Gereksinimler
react-native >= 0.71react >= 18
