npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-skeleton-simpler

v1.0.5

Published

A simple and fully customizable React Native component that implements a skeleton-like loader

Downloads

117

Readme

React Native Skeleton Simpler

React Native Skeleton Simpler, a simple yet fully customizable component made to achieve loading animation in a Skeleton-style. Works in both iOS and Android.

Installation

npm install react-native-skeleton-simpler

or

yarn add react-native-skeleton-simpler

Usage

  1. Import react-native-skeleton-content:
import {SkeletonSimpler} from 'react-native-skeleton-simpler';
  1. Once you create the SkeletonSimpler, you have three options:
  • Custom Layout : You provide a prop layout to the component specifying the size of the bones (see the Examples section below). Below is an example with a custom layout.

  • Custom Layout : You provide a prop SkeletonComponent recommended for complex layouts.

  • Child Layout (in Development): The component will figure out the layout of its bones with the dimensions of its direct children. :construction:

export default function Placeholder() {
  return (
    <SkeletonSimpler
      containerStyle={{ flex: 1, width: 300 }}
      isLoading={true}
      layout={[
        { width: 220, height: 20, marginBottom: 6 },
        {  width: 180, height: 20, marginBottom: 6 }
      ]}
    >
      <Text>Your content</Text>
      <Text>Other content</Text>
    </SkeletonSimpler>
  );
}
  1. Then simply sync the prop isLoading to your state to show/hide the SkeletonSimpler when the assets/data are available to the user.
export default function Placeholder () {
  const [loading, setLoading] = useState(true);
  return (
    <SkeletonSimpler
       containerStyle={{flex: 1, width: 300}}
        isLoading={isLoading}>
        {...otherProps}
    />
  )
}

Props

| Name | Type | Default | Description | | ------------------ | ---------------- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------- | | isLoading | bool | required | Shows the Skeleton bones when true | | layout | array of objects | [] | A custom layout for the Skeleton bones | | duration | number | 1000 ms | Duration of one cycle of animation | | containerStyle | object | flex: 1 | The style applied to the View containing the bones | SkeletonComponent | React.JSX.Element| not required | Custom Componente of skeleton, recommended for complex layouts. | theme | string (light or dark) | light | Theme of SkeletonSimpler and SkeletonItem | animatedConfig | object of Animated.TimingAnimationConfig | {toValue: 1, duration: 1000, seNativeDriver: false, delay: 800} | Configs of Animated.timing

Examples

1 - Customizing the layout of the bones (layout prop) :

export default function Placeholder () {
  return (
    <SkeletonContent
        layout={[
        // long line
        { width: 220, height: 20, marginBottom: 6 },
        // short line
        { width: 180, height: 20, marginBottom: 6 },
        ...
        ]}
        isLoading={true}>
        ...
    />
  )
}

2 - Customizing the layout with props SkeletonComponent :

2.1 import SkeletonSimpler and SkeletonItem

import {SkeletonSimpler, SkeletonItem} from 'react-native-skeleton-simpler';

2.2 Create your custom SKeleton component using SkeletonItem

const SkeletonComponent = () => (

      <View style={{ flexDirection: 'row',
                    alignItems: 'center',
                    marginTop: 10,
                    justifyContent: 'space-between',
                }}>
                <View>
                    <SkeletonItem
                        style={[
                            styles.common,
                            {
                                width: 150,
                                height: 15,
                                borderRadius: 10,
                                marginTop: 10,
                            },
                        ]}
                    />
                    <SkeletonItem
                        style={[
                            styles.common,
                            {
                                width: 200,
                                height: 15,
                                borderRadius: 10,
                                marginTop: 10,
                            },
                        ]}
                    />
                </View>
                <View
                    style={{
                        flexDirection: 'row',
                        alignItems: 'center',
                    }}>
                    <SkeletonItem
                        style={[
                            styles.circle,
                            {marginLeft: 10, width: 40, height: 40},
                        ]}
                    />
                </View>
            </View>
) 

2.3 Pass your custom component in SkeletonComponent prop

    
  export const SkeletonSimplerExample = () => {
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    setTimeout(() => setLoading(false), 3000);
  }, []);

  return (
    <SkeletonSimpler loading={loading} SkeletonComponent={SkeletonLoader}>
      <View>
        <Text>Your children</Text>
      </View>
    </SkeletonSimpler>
  );
};

You can find this complete example here