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

edc-popover-react

v2.0.1

Published

The React edc popover to display the contextual help

Downloads

1

Readme

edc-popover-react

Build Status npm version

This is a react implementation of edc popover displaying the contextual help

This project is meant to be used with easy doc contents (aka edc).

edc is a simple yet powerful tool for agile-like documentation management.

Learn more at https://www.easydoccontents.com.

Dependencies

The required dependencies are:

How to use

Import

You can import this module with npm by running:

npm install edc-popover-react --save

Or with yarn:

yarn add edc-popover-react

Setup

To work properly, this module needs a basic configuration, you must implement your own configuration by using a high-level Component PopoverProvider like the example below:

import { PopoverProvider } from 'edc-popover-react'
import { EdcHelp } from 'edc-popover-react'
...

<PopoverProvider
        pluginId='myedchelp'
        docPath='/doc'
        helpPath='/help'
        i18nPath='/doc/i18n'
      >
    ...
   <EdcHelp .../>
    ...
   <EdcHelp .../>
    ...
</PopoverProvider>

Props to specify for the PopoverProvider (see PopoverConfig) : | Prop | Type | Description | |---|---|---| | pluginId | string | The identifier of the target plugin documentation export | | helpPath | string | The path to edc-help-viewer for opening the documentation. It needs to be the same as the base href parameter used by the viewer. See here for more information.| | docPath | string | The path to exported documentation | | i18nPath | string | The path to translation json files |

Optional prop that can be overridden : | Method | Return type | Description | Default value | |---|---|---|---| | icon | EdcIconData | The icon (see Icons) | far fa-question-circle | | lang | string | The default language | en | | options | IPopoverOptions | Global popover options | see PopoverOptions | | failBehavior | FailBehavior | The popover's behavior when an error occurs (see Behavior) | { popover: 'FRIENDLY_MSG', icon: 'SHOWN' } |

You can also reuse your provider to make your app more flexible (but not recommended) :

render(){
  return (
  ...
  <PopoverProvider
          pluginId='myedchelp'
          docPath='/doc'
          helpPath='/help'
          i18nPath='/doc/i18n'
        >
    ...
    <EdcHelp .../>
    ...
    <EdcHelp .../>
    ...
  </PopoverProvider>
  ...
  <PopoverProvider
          pluginId='myedchelp'
          docPath='/doc'
          helpPath='/help'
          i18nPath='/doc/i18n'
          icon='far corst'
        >
    ...
    <EdcHelp .../>
    ...
  </PopoverProvider>
  ...
  )
}

Usage

The main component is EdcHelp, you can use the component as follows:

import { EdcHelp } from 'edc-popover-react'

...
<EdcHelp mainKey='myKey' subKey='mySubKey'/>
...

All EdcHelp props that override the Provider are in the EdcHelp scope and completely isolated from other EdcHelps.

Props to specify for the EdcHelp (see EdcHelpProps): | Prop | Type | Description | |---|---|---| | mainKey | string | The main key of the contextual help | | subKey | string | The sub key of the contextual help |

Optional prop that can be overridden : | Method | Return type | Description | Default value | |---|---|---|---| | pluginId | string | A custom pluginId | undefined (keeps the pluginId from the provider) | | lang | string | A language | undefined (keeps the language from the provider) | | icon | EdcIconData | An icon (see Icons) | undefined (keeps the icon from the provider) | | options | IPopoverOptions | Global popover options | see PopoverOptions |

:warning: All EdcHelp components must be surrounded by your configured provider (see Setup)

Customization

Fail behavior

You can customize the popover's behavior when an error occurs with the FailBehavior object.

There are separate behaviors for the help icon, and the popover itself. For the help icon when an error occurs:

  • SHOWN The help icon is shown as usual
  • DISABLED The help icon is greyed out
  • HIDDEN The help icon is completely hidden (but stays in DOM to avoid breaking the UI)
  • ERROR The help icon is replaced by an exclamation point (fas fa-exclamation-circle)

For the popover when an error occurs:

  • ERROR_SHOWN An error message is shown in the popover
  • FRIENDLY_MSG A friendly and translated message is shown in the popover
  • NO_POPOVER No popover appears when the help icon is triggered

By default, the icon is SHOWN and the popover is set to FRIENDLY_MSG.

:warning: In case of a missing provider error or a wrong global configuration, an error is always shown !

Icons

The popover icons support 2 formats:

  • A CSS class (Font Awesome, Glyphicon, ...) using a <i />
  • An image which will have the same size as the text (height: 1em;) (PNG, JPG, SVG, ...) using a <img />

You can choose with the type prop:

  • class: The content must represent the CSS class
  • url: The content must represent the image's URL

If a string is provided to an EdcIconData, it will be interpreted as a CSS class by default.

CSS

Global

When dark-mode is enabled, the CSS class edc-on-dark is applied on the help icon.

So you can override this classes by CSS select the component as below sections and .edc-on-dark

(see EdcHelp.scss)

Popover

You can customize the popover's design as described in edc-popover-utils

Help icon

Each behavior (see Fail behavior) can be customized as below:

| Behavior | CSS selector | |---|---| | SHOWN | .edc-help-icon | | DISABLED | .edc-help-icon-disabled | | HIDDEN | .edc-help-icon-hidden | | ERROR | .edc-help-icon-error |

(You can see the default values here)

Tests

Unit

edc-popover-react uses Jest and Enzyme for unit testing, you can test it by running:

npm test

or

yarn test

UI components

edc-popover-react uses Storybook for isolated UI components and features testing, you can test it by running:

npm run storybook

or

yarn run storybook