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

magic-panel

v1.0.14

Published

React library developed with TailwindCSS to simplify the implementation of modals and drawers

Downloads

40

Readme

Documentation for MagicPanel Library

Overview

MagicPanel is a React component library designed for creating dynamic and interactive panels. It supports both modal and drawer styles and provides a variety of customization options for enhanced user experience.

• Its usage is intuitive and highly customizable.

• With MagicPanel, you can easily switch between modal and drawer using just a boolean, without compromising the layout.

• The library is perfect for creating responsive and adaptable interfaces with ease.

• Ideal for scenarios where a modal is preferred on the desktop version, while a bottom-up sliding drawer is used on the mobile version.


Installation

Install the MagicPanel library via npm:

npm install magic-panel
import { magicPanelPlugin } from 'magic-panel/plugin';

module.exports = {
  content: ["./src/**/*.{html,js}"],
  theme: {
    extend: {},
  },
  plugins: [magicPanelPlugin()] //  add this
//  Now you have access to the group: variant in Tailwind CSS.

<MagicPanel.Close className="close:bg-emerald-400" />

Styling

MagicPanel uses a combination of CSS classes for styling. Make sure to include the CSS file in your project:

import "magic-panel/style.css";

Usage

Here is a basic example of how to use the MagicPanel component:

import React, { useState } from "react";
import "magic-panel/style.css"
import { MagicPanel } from "magic-panel";

const App = () => {
  const [isOpen, setIsOpen] = useState(false);

  const handleToggle = () => {
    setIsOpen(!isOpen);
  };

  return (
    <div>
      <button onClick={handleToggle}>Toggle Panel</button>
      <MagicPanel
        open={isOpen}
        onChange={setIsOpen}
        drawer={true}
        placement="right"
      >
        <MagicPanel.Header>Header Content</MagicPanel.Header>
        <MagicPanel.Content>
          <p>Your content goes here...</p>
        </MagicPanel.Content>
        <MagicPanel.Close onClose={() => setIsOpen(false)} />
      </MagicPanel>
    </div>
  );
};

export default App;

Components

MagicPanel

The main component for creating a panel. It supports both modal and drawer styles.

Props:

  • header: ReactNode - Content for the panel header.
  • content: ReactNode - Content for the panel body.
  • children: ReactNode - Children components inside the panel.
  • open: boolean - Whether the panel is open or closed.
  • onChange: (isOpen: boolean) => void - Callback function triggered when the panel state changes.
  • destroyOnClose: boolean - Whether to destroy the panel content when closed.
  • width: number - Width of the panel.
  • height: number | string - Height of the panel.
  • className: string - Additional class names for customization.
  • drawer: boolean - Whether the panel should be a drawer.
  • placement: "top" | "bottom" | "left" | "right" - Position of the drawer.

Example:

<MagicPanel open={true} drawer={true} placement="right">
  <MagicPanel.Header>Header Content</MagicPanel.Header>
  <MagicPanel.ContentScroll>
    <p>Your content goes here...</p>
  </MagicPanel.ContentScroll>
  <MagicPanel.Close onClose={() => setIsOpen(false)} />
</MagicPanel>

ContentScroll

A component to enable scrolling within the panel content.

Props:

  • children: ReactNode - Children components inside the content scroll area.
  • className: string - Additional class names for customization.

Example:

<ContentScroll>
  <p>Your scrollable content goes here...</p>
</ContentScroll>

Advanced Usage

Drawer Positioning

MagicPanel supports various drawer positions. Set the placement prop to define the position:

  • "top"
  • "bottom"
  • "left"
  • "right"

Example:

<MagicPanel open={true} drawer={true} placement="left">
  <MagicPanel.Header>Header Content</MagicPanel.Header>
  <MagicPanel.Content>
    <p>Your content goes here...</p>
  </MagicPanel.Content>
  <MagicPanel.Close>Close</MagicPanel.Close>
</MagicPanel>

Handling Mobile Devices

MagicPanel includes optimizations for mobile devices. It automatically adjusts the overflow behavior based on the user's device.

License

MagicPanel is licensed under the MIT License.

Support

For bug reports and feature requests, please visit the issues page.

Homepage

Visit the official site for more information and documentation.