Skip to content

Commit

Permalink
feat: Shopify#187 add gap property
Browse files Browse the repository at this point in the history
  • Loading branch information
mlecoq committed Jan 15, 2023
1 parent a7326ec commit 39f47eb
Show file tree
Hide file tree
Showing 8 changed files with 2,141 additions and 2,187 deletions.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@
"devDependencies": {
"@shopify/eslint-plugin": "^37.0.0",
"@types/jest": "^25.0.0",
"@types/react": "^16.9.2",
"@types/react-native": "^0.60.10",
"@types/react": "^18.0.24",
"@types/react-native": "^0.71.0",
"@types/react-test-renderer": "^16.9.0",
"babel-jest": "^25.5.0",
"babel-jest": "^29.2.1",
"eslint": "^7.14.0",
"husky": "^4.2.3",
"jest": "^25.5.0",
"jest": "^29.2.1",
"prettier": "^1.18.2",
"react": "^17.0.2",
"react-native": "0.66.3",
"react": "18.2.0",
"react-native": "0.71.0",
"react-test-renderer": "^17.0.2",
"ts-jest": "^25.5.0",
"typescript": "~3.7.5"
"typescript": "4.8.4"
},
"peerDependencies": {
"react": ">=16.8.0",
"react-native": ">=0.59.0"
"react": ">=18.2.0",
"react-native": ">=0.71.0"
},
"files": [
"dist/*"
Expand Down
6 changes: 1 addition & 5 deletions src/hooks/useDimensions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ export const DimensionsProvider = ({children}: {children: React.ReactNode}) => {
useEffect(() => {
const subscription = Dimensions.addEventListener('change', onChange) as any;

return () =>
// Using removeEventListener is deprecated in react-native > 0.65 and will throw warning. Use .remove() if available.
subscription && subscription.remove
? subscription.remove()
: Dimensions.removeEventListener('change', onChange);
return () => subscription.remove();
}, []);

return (
Expand Down
4 changes: 3 additions & 1 deletion src/hooks/useRestyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ const filterRestyleProps = <
return {
cleanProps,
restyleProps: {...restyleProps, [key]: props[key]},
serializedRestyleProps: `${serializedRestyleProps}${key}:${props[key]};`,
serializedRestyleProps: `${serializedRestyleProps}${String(key)}:${
props[key]
};`,
};
} else {
return {
Expand Down
4 changes: 3 additions & 1 deletion src/responsiveHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ export const getResponsiveValue = <
if (transform) return transform({value: val, theme, themeKey});
if (isThemeKey(theme, themeKey)) {
if (val && theme[themeKey][val as string] === undefined)
throw new Error(`Value '${val}' does not exist in theme['${themeKey}']`);
throw new Error(
`Value '${val}' does not exist in theme['${String(themeKey)}']`,
);

return val ? theme[themeKey][val as string] : val;
}
Expand Down
6 changes: 6 additions & 0 deletions src/restyleFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const spacingProperties = {
paddingVertical: true,
paddingStart: true,
paddingEnd: true,
columnGap: true,
rowGap: true,
gap: true,
};

const spacingPropertiesShorthand = {
Expand All @@ -44,6 +47,9 @@ const spacingPropertiesShorthand = {
py: 'paddingVertical',
ps: 'paddingStart',
pe: 'paddingEnd',
g: 'gap',
rG: 'rowGap',
cG: 'columnGap',
};

const typographyProperties = {
Expand Down
3 changes: 2 additions & 1 deletion src/typeHelpers.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const getKeys = <T>(object: T) => Object.keys(object) as (keyof T)[];
export const getKeys = <T extends Record<string, any>>(object: T) =>
Object.keys(object) as (keyof T)[];
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface Dimensions {
}

export interface RestyleFunctionContainer<
TProps extends Record<string, unknown>,
TProps extends Record<string, any>,
Theme extends BaseTheme = BaseTheme,
P extends keyof TProps = keyof TProps,
K extends keyof Theme | undefined = keyof Theme | undefined
Expand Down
Loading

0 comments on commit 39f47eb

Please sign in to comment.