-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:platformbuilders/helpers
- Loading branch information
Showing
21 changed files
with
394 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
import 'styled-components'; | ||
|
||
declare module 'styled-components' { | ||
export interface DefaultTheme { | ||
white: string; | ||
} | ||
} | ||
|
||
export * from './web'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { renderHook } from '@testing-library/react-hooks'; | ||
import { useSpacingsWithSafeArea } from '../useSpacingsWithSafeArea'; | ||
|
||
jest.mock('react', () => ({ | ||
...jest.requireActual('react'), | ||
useContext: () => ({ | ||
spacing: { | ||
lg: 24, | ||
sm: 8, | ||
}, | ||
}), | ||
})); | ||
|
||
jest.mock('react-native-safe-area-context', () => { | ||
const { | ||
default: mockSafeAreaContext, | ||
} = require('react-native-safe-area-context/jest/mock'); | ||
return mockSafeAreaContext; | ||
}); | ||
|
||
describe('useSpacingsWithSafeArea', () => { | ||
test("should return spacing lg value when don't have safe area value", async () => { | ||
const { result } = renderHook(() => useSpacingsWithSafeArea()); | ||
|
||
expect(result.current.topSpacing).toBe(24); | ||
expect(result.current.bottomSpacing).toBe(24); | ||
}); | ||
|
||
test('should return spacing sm value when pass sm as parameter', async () => { | ||
const { result } = renderHook(() => useSpacingsWithSafeArea('sm')); | ||
|
||
expect(result.current.topSpacing).toBe(8); | ||
expect(result.current.bottomSpacing).toBe(8); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { useContext, useEffect, useState } from 'react'; | ||
import { useSafeAreaInsets } from 'react-native-safe-area-context'; | ||
import { ThemeContext } from 'styled-components/native'; | ||
import { FluidTheme } from '@platformbuilders/theme-toolkit'; | ||
|
||
export type SpacingValue = | ||
| 'min' | ||
| 'xxs' | ||
| 'xs' | ||
| 'sm' | ||
| 'md' | ||
| 'lg' | ||
| 'xl' | ||
| 'xxl' | ||
| 'max'; | ||
|
||
export const useSpacingsWithSafeArea = (customSpacing: SpacingValue = 'lg') => { | ||
const { bottom, top } = useSafeAreaInsets(); | ||
const themeContext: unknown = useContext(ThemeContext); | ||
const [spacings, setSpacings] = useState({ | ||
topSpacing: 0, | ||
bottomSpacing: 0, | ||
}); | ||
const themeFluid = themeContext as FluidTheme; | ||
const spacingFluid = themeFluid.spacing[customSpacing]; | ||
|
||
useEffect(() => { | ||
setSpacings({ | ||
topSpacing: top + spacingFluid, | ||
bottomSpacing: bottom + spacingFluid, | ||
}); | ||
}, [bottom, top]); | ||
|
||
return { | ||
topSpacing: spacings.topSpacing, | ||
bottomSpacing: spacings.bottomSpacing, | ||
}; | ||
}; |
2 changes: 1 addition & 1 deletion
2
src/__tests__/addMaskToCardNumber.spec.ts → ...red/__tests__/addMaskToCardNumber.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/base64.spec.ts → src/shared/__tests__/base64.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/currencyParser.spec.ts → src/shared/__tests__/currencyParser.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/currencyToNumber.spec.ts → ...shared/__tests__/currencyToNumber.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/formatCardNumber.spec.ts → ...shared/__tests__/formatCardNumber.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/formatToMonogram.spec.ts → ...shared/__tests__/formatToMonogram.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/formatToPhone.spec.ts → src/shared/__tests__/formatToPhone.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/parseToThousands.spec.ts → ...shared/__tests__/parseToThousands.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/removeWhiteSpaces.spec.ts → ...hared/__tests__/removeWhiteSpaces.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/sanitizer.spec.ts → src/shared/__tests__/sanitizer.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/toOnlyNumbers.spec.ts → src/shared/__tests__/toOnlyNumbers.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.