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

hallvardlh-react-native-drawer

v1.0.3

Published

A customizable side drawer component for React Native. The drawer has no boilerplate, just functionality. It's animated, and can be dismissed by outside click, user swipe or function call.

Downloads

5

Readme

react-native-side-drawer

A customizable side drawer component for React Native. The drawer has no boilerplate, just functionality. It's animated, and can be dismissed by outside click, user swipe or function call.

npm version

Table of Contents

Installation

npm install hallvardlh-react-native-drawer

Usage

Basic component with a drawer using default settings.

import { View, Text, TouchableOpacity } from 'react-native';
import { useRef } from 'react';
import { Drawer } from 'hallvardlh-react-native-drawer';

export default function MyComponent() {
    const drawerRef1 = useRef(null);
    return (
        <View>
            <TouchableOpacity onPress={() => drawerRef1.current?.openDrawer()}>
                <Text>Open Drawer 1</Text>
            </TouchableOpacity>

            <Drawer ref={drawerRef1}>
                <TouchableOpacity onPress={() => drawerRef1.current?.closeDrawer()}>
                    <Text>Close drawer</Text>
                </TouchableOpacity>
                <Text>Drawer 1 content</Text>
            </Drawer>
        </View>
    );
}

Props

| Prop | Type | Default | Description | ------------ | -------------- | ------------- | - | children | ReactNode | null | The content of the drawer. | onStateChange | function| - | Callback function that gets triggered when the drawer state changes. It receives a boolean (isOpen) indicating the drawer's state. | | side | string | 'right' | The side to which the drawer will be aligned, which side it will come from. Accepts: 'left' or 'right'. | width | string | '85%' | Specifies the width of the drawer. Accepts strings ending in either 'px' or '%'. Percentage values represent percentage of the screen's width. | maxWidth | string | '500px' | Specifies the maxium width of the drawer. This is inteded to avoid ridiculously long drawers on wider screens. Accepts strings ending in either 'px' or '%'. Value can also be 'none' to remove maxWidth. | containerStyle | StyleProp | null | Allows setting custom styles on the view that containing the children. | backgroundColor | string | 'white' | The background color of the view containing children. Accepts any CSS color value as a string.

ScrollView

Warning: The default ScrollViews and FlatLists from React Native cannot be used within the drawer.

The ScrollView and FlatList from React Native Gesture Handler must be used instead. This is due to default ScrollViews not working properly within gesture handlers on Android.

Simply import the ScrollView as such:

import { ScrollView } from "react-native-gesture-handler";

Or in case ScrollView is already being used within the file:

import { ScrollView as DrawerScrollView } from "react-native-gesture-handler";

These ScrollViews and FlatLists are used just like default.

Callbacks

onStateChange

The Drawer component has one callback, onStateChange, which returns a boolean upon completing an opening or closing animation.

Usage example:

<Drawer 
    onStateChange={(isOpen) => {
        if (isOpen) {
            console.log('Drawer opened!');
        } else {
            console.log('Drawer closed!');
        }
    }}
>

Contribution

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

License

MIT