Skip to content

Commit

Permalink
chore: migrate from react-native-dotenv to babel-plugin-dotenv-import
Browse files Browse the repository at this point in the history
* Update change-guideline-sizes.md

* Update import

* Rename react-native-dotenv.js to @env.js

* Update mock
  • Loading branch information
meowcorp authored Dec 22, 2020
1 parent f8dea54 commit 5e5ded5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions __tests__/scaling-utils.extend.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
jest.mock('react-native');
jest.mock('react-native-dotenv');
jest.mock('@env');
import { scale, verticalScale, moderateScale, moderateVerticalScale } from '../extend';

describe('scaling-utils when guideline sizes are set using react-native-dotenv', () => {
Expand Down Expand Up @@ -32,4 +32,4 @@ describe('scaling-utils when guideline sizes are set using react-native-dotenv',
expect(Math.floor(moderateVerticalScale(100, 0.9))).toBe(100);
expect(Math.floor(moderateVerticalScale(100, 2))).toBe(100);
});
});
});
4 changes: 2 additions & 2 deletions examples/change-guideline-sizes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
In the ever-changing mobile devices world, screen sizes change a lot.
This lib uses 350dp x 680dp as guideline sizes, but if you (or your designer) prefer using different sizes it's possible.

To do so, first, you'd need to setup [react-native-dotenv](https://github.com/zetachang/react-native-dotenv).
To do so, first, you'd need to setup [babel-plugin-dotenv-import](https://github.com/tusbar/babel-plugin-dotenv-import).
After setting it up and creating `.env` file, add the following env params to it:
```env
SIZE_MATTERS_BASE_WIDTH=<custom-width>
Expand All @@ -12,4 +12,4 @@ SIZE_MATTERS_BASE_HEIGHT=<custom-height>
Next and final step, you should change all your imports to `react-native-size-matters/extend`, for instance:
```javascript
import { ScaledSheet, moderateScale } from 'react-native-size-matters/extend';
```
```
4 changes: 2 additions & 2 deletions lib/extend/scaling-utils.extend.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Dimensions } from 'react-native';
import { SIZE_MATTERS_BASE_WIDTH, SIZE_MATTERS_BASE_HEIGHT } from 'react-native-dotenv';
import { SIZE_MATTERS_BASE_WIDTH, SIZE_MATTERS_BASE_HEIGHT } from '@env';

const { width, height } = Dimensions.get('window');
const [shortDimension, longDimension] = width < height ? [width, height] : [height, width];
Expand All @@ -16,4 +16,4 @@ export const moderateVerticalScale = (size, factor = 0.5) => size + (verticalSca
export const s = scale;
export const vs = verticalScale;
export const ms = moderateScale;
export const mvs = moderateVerticalScale;
export const mvs = moderateVerticalScale;

0 comments on commit 5e5ded5

Please sign in to comment.