shadowgiver
shadowgiver is a utility for react native and react native web to make shadows consistent across platforms. It takes in the most primitive object, an Android elevation, and turns it into a box shadow, and iOS shadow, and an elevation. Will only return the minimal number of keys.
Usage:
install
yarn add shadowgiver
or
npm install shadowgiver
; StyleSheet;
This project was bootstrapped with TSDX.
Want to see under the hood? Heres the shadowgiver function:
{ const shadowOffset = width: 0 height: 05 * elevation ; const shadowOpacity = 03; const shadowRadius = 08 * elevation; const shadowColor = color || 'black'; return Platform;}
There's also a way to JUST output what's needed for web. Just instead import from shadowgiver/web
!
Package Development
Below is a list of commands you will probably find useful.
npm start
or yarn start
Runs the project in development/watch mode. Your project will be rebuilt upon changes. TSDX has a special logger for you convenience. Error messages are pretty printed and formatted for compatibility VS Code's Problems tab.
Your library will be rebuilt if you make edits.
npm run build
or yarn build
Bundles the package to the dist
folder.
The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).
MIT License