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

w-popover

v2.1.4

Published

React Popover component

Downloads

219

Readme

Features

  1. Based on React hooks
  2. Small size, zero 3rd-party library dependencies.

Usage

import React, { useState } from 'react';
import { Popover, Tooltip } from 'w-popover';

export default function App() {
  const [visible, setVisible] = useState(false);

  return (
    <div>
      <p>
        <Popover
          placement="bottom-right"
          visible={visible}
          onClose={() => setVisible(false)}
          closeOnClickOutside
          content="This is ReactNode content."
        >
          <button onClick={() => setVisible(true)}>Anchor to trigger Popover to showup</button>
        </Popover>
      </p>

      <p>
        <Tooltip content="This is a tooltip." placement="right">
          <button>mouse over me</button>
        </Tooltip>
      </p>
    </div>
  );
}

Props Definition

type Props = {
  /** Popover display position. default: bottom */
  placement?: Placement,
  /** Trigger element,If a component been used please specify the the forwardRef to inner DOM element */
  children: React.ReactElement,
  /** Content to show */
  content?: React.ReactNode,
  /** Whether to show the popover */
  visible?: boolean,
  /** Visibility change callback */
  onVisibleChange?: (visible: boolean) => void,
  /** Whether to show arrow */
  arrow?: boolean,
  /** Whether to show close button on upper right of the popover. */
  closable?: boolean,
  /** Popover container style to apply */
  style?: React.CSSProperties,
  /** Trigger to unmount the popover */
  onClose?: () => void,
  /** Popover container css classname to apply */
  className?: string,
  /** Whether to show a mask layer below the popover.  */
  mask?: boolean,
  /** Mask style if mask is enabled. */
  maskStyle?: React.CSSProperties,
  /** Mask css className if mask is enabled. */
  maskClass?: string,
  /** Manually set a left,top offset to popover
   * type Offset = { x?: number; y?: number }; */
  offset?: Offset,
  /**
   * Whether to close the Popover when click outside area.
   * @default true
   * */
  closeOnClickOutside?: boolean,
  /**
   *  Whether to close the Popover when click mask area.
   * @default true
   * */
  closeOnMaskClick?: boolean,
  /**
   *  Whether to enable entrance transition effect.
   * @default true
   *  */
  transition?: boolean,
  /**
   *  Transition duration time. default: 220 ms
   */
  transitionDuration?: number,
  /**
   *  transitionTimingFunction. default: ease-in-out
   */
  transitionTimingFunction?: string,
};

export type SinglePlacement = 'top' | 'bottom' | 'left' | 'right';

export type Placement =
  | 'top'
  | 'left'
  | 'bottom'
  | 'right'
  | 'top-left'
  | 'top-right'
  | 'bottom-left'
  | 'bottom-right'
  | 'left-top'
  | 'left-bottom'
  | 'right-top'
  | 'right-bottom'
  | SinglePlacement;