Skip to content

Commit

Permalink
chore: source index.tsx=> index.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
kdn0325 committed Mar 9, 2024
1 parent 24b12a6 commit 7110026
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"main": "lib/commonjs/index.js",
"module": "lib/module/index.js",
"types": "lib/typescript/src/index.d.ts",
"react-native": "src/index.tsx",
"source": "src/index.tsx",
"react-native": "src/index.ts",
"source": "src/index.ts",
"files": [
"src",
"lib",
Expand Down
51 changes: 51 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Dimensions } from 'react-native';

const { width, height } = Dimensions.get('window');

const isSmall = width <= 375;

const guidelineBaseWidth = () => {
if (isSmall) {
return 330;
}
return 350;
};

const guidelineBaseHeight = () => {
if (isSmall) {
return 550;
} else if (width > 410) {
return 620;
}
return 680;
};

const percentBaseWidth = (val: number) => {
return width * (val / 100);
};

const percentBaseHeight = (val: number) => {
return height * (val / 100);
};

const guidelineBaseFonts = () => {
if (width > 410) {
return 430;
}
return 400;
};

const horizontalScale = (size: number) => (width / guidelineBaseWidth()) * size;

const verticalScale = (size: number) => (height / guidelineBaseHeight()) * size;

const fontSizeScale = (size: number) =>
Math.round((size * width) / guidelineBaseFonts());

export {
horizontalScale,
verticalScale,
fontSizeScale,
percentBaseWidth,
percentBaseHeight,
};

0 comments on commit 7110026

Please sign in to comment.