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

@pmwcs/drawer

v1.1.0

Published

PMWCS drawer component

Downloads

8

Readme

Drawers

A navigation drawer slides in from the left and contains the navigation destinations for your app.

Permanent

These are drawers that are permanently fixed inside of a view.

<Drawer>
  <DrawerHeader>
    <DrawerTitle>DrawerHeader</DrawerTitle>
    <DrawerSubtitle>Subtitle</DrawerSubtitle>
  </DrawerHeader>
  <DrawerContent>
    <List>
      <ListItem>Cookies</ListItem>
      <ListItem>Pizza</ListItem>
      <ListItem>Icecream</ListItem>
    </List>
  </DrawerContent>
</Drawer>

Dismissible

These are drawers that can be toggled to an open or closed state inside of a view, but still takes up viewable space when closed.

function Example() {
  const [open, setOpen] = React.useState(false);

  return (
    <>
      <div style={{ overflow: 'hidden', position: 'relative' }}>
        <Drawer dismissible open={open}>
          <DrawerHeader>
            <DrawerTitle>DrawerHeader</DrawerTitle>
            <DrawerSubtitle>Subtitle</DrawerSubtitle>
          </DrawerHeader>
          <DrawerContent>
            <List>
              <ListItem>Cookies</ListItem>
              <ListItem>Pizza</ListItem>
              <ListItem>Icecream</ListItem>
            </List>
          </DrawerContent>
        </Drawer>

        {/* Optional DrawerAppContent */}
        <DrawerAppContent
          style={{ minHeight: '15rem', padding: '1rem' }}
        >
          DrawerAppContent is an optional component that will resize
          content when the dismissible drawer is open and closed. It
          must be placed directly after the Drawer component.
        </DrawerAppContent>
      </div>

      <div style={{ textAlign: 'center' }}>
        <Button onClick={() => setOpen(!open)} raised>
          Toggle Dismissible
        </Button>
      </div>
    </>
  );
}

Modal

These are drawers that can be temporarily displayed fixed on the side of the entire viewport.

function Example() {
  const [open, setOpen] = React.useState(false);

  return (
    <>
      <Drawer modal open={open} onClose={() => setOpen(false)}>
        <DrawerHeader>
          <DrawerTitle>DrawerHeader</DrawerTitle>
          <DrawerSubtitle>Subtitle</DrawerSubtitle>
        </DrawerHeader>
        <DrawerContent>
          <List>
            <ListItem>Cookies</ListItem>
            <ListItem>Pizza</ListItem>
            <ListItem>Icecream</ListItem>
          </List>
        </DrawerContent>
      </Drawer>

      <Button onClick={() => setOpen(!open)} raised>
        Toggle Modal
      </Button>
    </>
  );
}

Right Side Drawers

material-components-web doesn't directly support right hand drawers, but it respects the dir attribute on DOM elements. This simple hack will allow you to get drawers that appear from the right hand side of your app. As an aside, the dir attribute can be used to invert many other behaviors where the element is anchored on the left.

function Example() {
  const [open, setOpen] = React.useState(false);

  return (
    <>
      {/** Make the drawer appear right-to-left */}
      <Drawer
        dir="rtl"
        modal
        open={open}
        onClose={() => setOpen(false)}
      >
        {/** Set the content back to left-to-right */}
        <DrawerHeader dir="ltr">
          <DrawerTitle>Right Drawer</DrawerTitle>
          <DrawerSubtitle>Subtitle</DrawerSubtitle>
        </DrawerHeader>

        <DrawerContent dir="ltr">
          <List>
            <ListItem>Cookies</ListItem>
            <ListItem>Pizza</ListItem>
            <ListItem>Icecream</ListItem>
          </List>
        </DrawerContent>
      </Drawer>

      <Button onClick={() => setOpen(!open)} raised>
        Toggle Right Drawer
      </Button>
    </>
  );
}

Drawer

A Drawer component.

Props

| Name | Type | Description | |------|------|-------------| | dismissible | undefined \| false \| true | Makes a dismissible drawer. | | foundationRef | React.Ref<MDCModalDrawerFoundation \| MDCDismissibleDrawerFoundation> | Advanced: A reference to the MDCFoundation. | | modal | undefined \| false \| true | Makes a modal / temporary drawer. | | onClose | undefined \| (evt: DrawerOnOpenEventT) => void | Callback that fires when the Drawer is closed. | | onOpen | undefined \| (evt: DrawerOnCloseEventT) => void | Callback that fires when the Drawer is opened. | | open | undefined \| false \| true | Opens or closes the Drawer. |

DrawerHeader

An optional header for the Drawer.

DrawerTitle

An title for the DrawerHeader.

DrawerSubtitle

A subtitle for the DrawerHeader.

DrawerContent

Content for Drawers.

DrawerAppContent

For the Dismissible variant only. Sibling element that is resized when the drawer opens/closes.