1.0.4 โ€ข Published 3 years ago

@dotmind/rn-shadow-generator v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Menu

๐Ÿš€ Roadmap

  • Android full compatibility (shadowOffset support)

๐Ÿ” Preview

preview

๐Ÿ’ป Installation

yarn add @dotmind/rn-shadow-generator

or

npm i @dotmind/rn-shadow-generator --save

๐Ÿ‘ทโ€โ™‚๏ธ How it's work

ShadowView usage

import { ShadowView } from '@dotmind/rn-shadow-generator';

const BasicComponent = () =>ย {
  return (
    <ShadowView>
      <Text>My Shadow View</Text>
    </ShadowView>
  );
}

const MyCustomComponent = () =>ย {
  return (
    <ShadowView level={4} shadowColor={'#000'} direction={'bottom'}>
      <Text>My Shadow View</Text>
    </ShadowView>
  );
}
propsdescriptionrequireddefault value
levelIncrease shadow dimensionsfalse4
shadowColorChange shadowColor style attributefalse#000
directionChange shadow directionfalsebottom

generateShadow usage

Returns a full shadow object depending on OS (iOS or Android).

import { generateShadow } from '@dotmind/rn-shadow-generator';

const BasicComponent = () =>ย {
  return (
    <View style={{ ...generateShadow() }}>
      <Text>My Shadow View</Text>
    </View>
  );
}

const MyCustomComponent = () =>ย {
  return (
    <View style={{ ...generateShadow({ level: 4, shadowColor: '#000', direction: 'bottom' }) }}>
      <Text>My Shadow View</Text>
    </View>
  );
}
attributesdescriptionrequireddefault value
levelIncrease shadow dimensionsfalse4
shadowColorChange shadowColor style attributefalse#000
directionChange shadow directionfalsebottom

Object returned

{
  ...Platform.select({
    ios: {
      shadowColor,
      shadowOffset,
      shadowOpacity,
      shadowRadius,
    },
    android: {
      shadowColor,
      elevation: level,
    },
  }),
}

๐Ÿงช Example app

To see full app integration example please refer to here.

โš ๏ธ To run the app please run here yarn build that the @dotmind/rn-shadow-generator npm package be able to link itselfs.

โšก๏ธ Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

๐Ÿ” License

MIT