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

mottem-sheet

v1.1.3

Published

<img alt="logo" src="./src/assets/logo.webp" width="500px">

Downloads

84

Readme

mottem-sheet Documentation

mottem-sheet is a bottom-sheet React.js component designed to help developers effortlessly integrate a bottom sheet component into their applications in mobile view. This document aims to provide clear and simple instructions for using mottem-sheet in your projects.

Demo - Sandbox

Online Demo: Click Here to see demo

Sandbox: Here is the sandbox link to check the package Demo

Overview

mottem-sheet is a versatile React.js component developed using TypeScript, ensuring comprehensive support for both React TypeScript and React JavaScript applications. This component offers two distinct modes to cater to various development needs: Header Mode and Free Mode.

Installation

Before using mottem-sheet, you need to install it in your project. You can do this using npm or yarn:

npm install mottem-sheet
# or
yarn add mottem-sheet

Header Mode

Header Mode allows developers to add content at the top of their applications without specifying the height or phase. This mode automatically positions your content as the first phase, eliminating the need for manual height adjustments.

Usage in Header Mode

Here's how you can use mottem-sheet in Header Mode:

import { BottomSheet, Sheet, SheetHead, SheetBody, DragAreaEl } from "mottem-sheet";


<BottomSheet isOpen={isOpen} setIsOpen={setOpen}>
  <Sheet
    middlePhases={middlePhases}
    initPhaseActiveIndex={0}
  >
    <SheetHead>
      <DragAreaEl />
      <h1 style={{ margin: 0 }}>Header content</h1>
    </SheetHead>
    <SheetBody>
      <p>Body Content Here</p>
    </SheetBody>
  </Sheet>
</BottomSheet>

For a complete example, refer to the HeadMode.tsx file in the example folder within the source code.

Free Mode

In Free Mode, you define the stopping points of the bottom sheet using phases. This mode offers more control over the bottom sheet's behavior.

Defining a Phase

A phase is an object with value and an optional scrollable property:

{
  value: number;
  scrollable?: boolean;
}
  • value: A percentage indicating how much of the screen height the bottom sheet should cover.
  • scrollable: If set to true, the body content becomes scrollable. By default, it's false.

Example of Phases

const middlePhases = [
  {
    value: 20,
    scrollable: false,
  },
  {
    value: 60,
    scrollable: true,
  },
];

Usage in Free Mode

To use Free Mode, remove the <SheetHead /> component from the Header Mode example:

import { BottomSheet, Sheet, SheetBody, DragAreaEl } from "mottem-sheet";

<BottomSheet isOpen={isOpen} setIsOpen={setOpen}>
  <Sheet
    middlePhases={middlePhases}
    initPhaseActiveIndex={0}
  >
    <SheetBody>
      <DragAreaEl />
      <p>Body Content Here</p>
    </SheetBody>
  </Sheet>
</BottomSheet>

Component Properties

BottomSheet Component Props

  • isOpen: A boolean indicating if the bottom sheet is open or closed.
  • setIsOpen: A function to update the isOpen state.

Sheet Component Props

  • isOpen: Optional boolean to control the visibility of the sheet.
  • setIsOpen: Optional function to update the visibility state.
  • phaseActiveIndex: a number indicates index of active phase state. setPhaseActiveIndex: a function to update active phase index state.
  • initWithNoAnimation: Optional boolean to initialize the sheet without animation.
  • middlePhases: An array of phases to control the sheet's behavior.
  • onActiveIndexChange: Optional function triggered when the active index changes.
  • phaseThreshold: Safe space keep the phase as where it is, default is 60px.
  • headerStyle: css inline-style that applies on header.
  • bodyStyle: css inline-style that applies on body.
  • headerClassName: css class that applies on header.
  • bodyClassName: css class that applies on body.