GithubHelp home page GithubHelp logo

avatarchik / react-native-neomorph-shadows Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tokkozhin/react-native-neomorph-shadows

0.0 1.0 0.0 30.08 MB

Shadows and neumorphism/neomorphism for iOS & Android (like iOS).

License: MIT License

JavaScript 100.00%

react-native-neomorph-shadows's Introduction

npm npm github Supports Android and iOS

react-native-neomorph-shadows

Shadows and neumorphism/neomorphism for iOS & Android (like iOS).

See example folder

Shadows Demo Neomorph Demo Neomorph Blur Demo More Demo

Installation

IMPORTANT: this library, starting from v1.0.0, no longer supports expo because React Native Art library was recently deprecated from expo.

Step 1

Run the command below to install the plugin.

npm i react-native-neomorph-shadows

Step 2

You need to install React Native Art in your project.

npm install @react-native-community/art --save

With autolinking (react-native 0.60+)

cd ios && pod install && cd ..

Pre 0.60

react-native link @react-native-community/art

Great! Let's start to use it.

Usage

There are three components: Shadow, Neomorph & NeomorphBlur. Prop style supports most of the view/layout styles.

IMPORTANT: Components dont't support Flex.

If you want flex and auto sizing of Shadow or Neomorph components, use ShadowFlex/NeomorphFlex experimental components, but be careful, these components reduce performance by double rerender. If you know exactly what size(width, height props) it should be, use Shadow/Neomorph components.

Shadow / ShadowFlex

Outer shadow demo Inner shadow demo

import { Shadow } from 'react-native-neomorph-shadows';

...

<Shadow
  inner // <- enable inner shadow
  useArt // <- set this prop to use non-native shadow on ios
  style={{
    shadowOffset: {width: 10, height: 10},
    shadowOpacity: 1,
    shadowColor: "grey",
    shadowRadius: 10,
    borderRadius: 20,
    backgroundColor: 'white',
    width: 100,
    height: 100,
    // ...include most of View/Layout styles
  }}
>
  ...
</Shadow>

Neomorph / NeomorphFlex

Opacity of two shadows automaticly changing and depends of backgroundColor brightness.

Outer neomorph shadow demo Inner neomorph shadow demo

import { Neomorph } from 'react-native-neomorph-shadows';

...

<Neomorph
  inner // <- enable shadow inside of neomorph
  swapShadows // <- change zIndex of each shadow color
  style={{
    shadowRadius: 10,
    borderRadius: 25,
    backgroundColor: '#DDDDDD',
    width: 150,
    height: 150,
  }}
>
  ...
</Neomorph>

Nested Neomorph

Nested neomorph shadow demo

<Neomorph
  style={{
    shadowRadius: 3,
    borderRadius: 100,
    backgroundColor: '#DDDDDD',
    width: 200,
    height: 200,
    justifyContent: 'center',
    alignItems: 'center',
  }}
>
  <Neomorph
    inner
    style={{
      shadowRadius: 7,
      borderRadius: 90,
      backgroundColor: '#F19F9F',
      width: 180,
      height: 180,
      justifyContent: 'center',
      alignItems: 'center',
    }}
  >
    <Neomorph
      style={{
        shadowRadius: 7,
        borderRadius: 50,
        backgroundColor: '#DDDDDD',
        width: 100,
        height: 100,
      }}
    />
  </Neomorph>
</Neomorph>

Custom shadow colors of Neomorph

Custom neomorph shadow demo

<Neomorph
  darkShadowColor="#FF3333" // <- set this
  lightShadowColor="#3344FF" // <- this
  style={{
    shadowOpacity: 0.3, // <- and this or yours opacity
    shadowRadius: 15,
    borderRadius: 50,
    backgroundColor: '#ECF0F3',
    width: 200,
    height: 200,
  }}
/>

Neomorph Blur

Custom neomorph shadow demo

import { NeomorphBlur } from 'react-native-neomorph-shadows';

<NeomorphBlur
  style={{
    shadowRadius: 12,
    borderRadius: 70,
    backgroundColor: '#ECF0F3',
    width: 140,
    height: 140,
  }}
/>;

Animation

import { Animated } from 'react-native';
import { Shadow, Neomorph, NeomorphBlur } from 'react-native-neomorph-shadows';

const AnimatedShadow = Animated.createAnimatedComponent(Shadow);
const AnimatedNeomorph = Animated.createAnimatedComponent(Neomorph);
const AnimatedNeomorphBlur = Animated.createAnimatedComponent(NeomorphBlur);

...

<AnimatedShadow />
<AnimatedNeomorph />
<AnimatedNeomorphBlur />

Props

Shadow/ShadowFlex props

Prop Type Default Description
style object undefined Like View/Layout style prop with a few difference. Flex not available. width & height is required. (None of this is about the ShadowFlex)
useArt bool false If true, the component will use drawable shadow on both platform (iOS, Android)
inner bool false If true, a shadow will be inside of component
children node undefined

Neomorph/NeomorphFlex props

Prop Type Default Description
style object undefined Like View/Layout style prop with a few difference. Flex not available. width & height is required. (None of this is about the NeomorphFlex)
swapShadows bool false If true, the value of zIndex property both shadows will swap
inner bool false If true, shadows will be inside of component
darkShadowColor string 'black' Dark shadow color
lightShadowColor string 'white' Light shadow color
children node undefined

react-native-neomorph-shadows's People

Contributors

erickmaeda avatar gfpacheco avatar kennethnym avatar leo-techfox avatar pedrobergamini avatar tokkozhin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.