Skip to content

Instantly share code, notes, and snippets.

@pedroraft
Last active January 29, 2020 16:14
Show Gist options
  • Save pedroraft/57949f98a6fed6dc27991b803110c368 to your computer and use it in GitHub Desktop.
Save pedroraft/57949f98a6fed6dc27991b803110c368 to your computer and use it in GitHub Desktop.
React native shadow defaults
import { ShadowStyleIOS } from 'react-native';
export default (
depth?: 'min' | 'default' | 'max',
color?: string,
): {
elevation: number;
} & ShadowStyleIOS => {
switch (depth) {
case 'min':
return {
shadowColor: color || '#000',
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.23,
shadowRadius: 2.62,
elevation: 4,
};
case 'max':
return {
shadowColor: color || '#000',
shadowOffset: {
width: 0,
height: 8,
},
shadowOpacity: 0.44,
shadowRadius: 10.32,
elevation: 16,
};
default:
return {
shadowColor: color || '#000',
shadowOffset: {
width: 0,
height: 4,
},
shadowOpacity: 0.3,
shadowRadius: 4.65,
elevation: 8,
};
}
};
{
"name": "react-native-shadow-util",
"version": "0.0.1"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment