Code Monkey home page Code Monkey logo

react-native-skeleton-placeholder's Introduction

SkeletonPlaceholder

SkeletonPlaceholder is a React Native library to easily create an amazing loading effect with FlexBox.
Android and iOS

Changes

I (nicolaslazzos) improved this library so you can pass custom components as children and also the skeletons adapts to layout changes, including screen rotation. See the example in the Usage section.

Installation

Note: This package requires the dependency @react-native-masked-view/masked-view.

Step #1

Using yarn:

yarn add @react-native-masked-view/masked-view

Using npm:

npm install @react-native-masked-view/masked-view --save

If you are running a react-native version below 0.60:

react-native link @react-native-masked-view/masked-view

Otherwise:

cd ios
pod install

  

Step #2

Using yarn:

yarn add nicolaslazzos/react-native-skeleton-placeholder

Using npm:

npm install git+https://github.com/nicolaslazzos/react-native-skeleton-placeholder --save

Usage

import React from "react";
import { View } from "react-native";
import { SkeletonContainer, Skeleton } from "react-native-skeleton-placeholder";

const App = () => {
  return (
    <SkeletonContainer>
      <View style={{ flexDirection: "row", alignContent: "center", padding: 16 }}>
        <Skeleton style={{ height: 70, width: 70, borderRadius: 6 }} />
        <View style={{ flex: 1, justifyContent: "center", marginLeft: 16 }}>
          <Skeleton style={{ height: 16, width: "50%", borderRadius: 6, marginBottom: 10 }} />
          <Skeleton style={{ height: 16, width: "30%", borderRadius: 6, marginBottom: 10 }} />
          <Skeleton style={{ height: 16, width: "70%", borderRadius: 6 }} />
        </View>
      </View>
    </SkeletonContainer>
  );
};

Also you can do things like this, that wasn't possible with the original library.

import React from "react";
import { View } from "react-native";
import { SkeletonContainer, Skeleton } from "react-native-skeleton-placeholder";

const App = () => {
  return (
    <SkeletonContainer>
      <ListItem />
      <ListItem />
    </SkeletonContainer>
  );
};

const ListItem = () => {
  return (
    <View style={{ flexDirection: "row", alignContent: "center", padding: 16 }}>
      <Skeleton style={{ height: 70, width: 70, borderRadius: 6 }} />
      <View style={{ flex: 1, justifyContent: "center", marginLeft: 16 }}>
        <Skeleton style={{ height: 16, width: "50%", borderRadius: 6, marginBottom: 10 }} />
        <Skeleton style={{ height: 16, width: "30%", borderRadius: 6, marginBottom: 10 }} />
        <Skeleton style={{ height: 16, width: "70%", borderRadius: 6 }} />
      </View>
    </View>
  );
};

Properties

SkeletonContainer

Prop Description Type Default
backgroundColor Determines the color of placeholder string #E1E9EE
highlightColor Determines the highlight color of placeholder string #F2F8FC
speed Determines the animation speed in milliseconds number 800

Skeleton

Prop Description Type Default
any Any view props was accepted any

Contributing

You are welcome to contribute!

License

MIT

react-native-skeleton-placeholder's People

Contributors

chramos avatar nicolaslazzos avatar mrousavy avatar drom4x avatar dependabot[bot] avatar sallar 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.