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

mapnj

v0.2.1

Published

A script to add interactivity (such as click events) to SVG-based illustration maps

Downloads

79

Readme

MapNJ

MapNJ Screenshot

Official Web Site

A script to add interactivity to SVG-based illustration maps

  • Manipulates SVG illustrations
  • Manages the selection and deselection states of SVG illustration parts
  • Separates design and code roles in production
  • Customizes SVG illustration fill and line colors based on context
  • Allows for the addition of related parts involved in operations

Check out the demo to see it in action.

Super simple demo

Paste the following into an html file and check it in your browser. Your SVG elements will manage the state.

<div id="your-mapnj">
  <svg
    width="600"
    height="400"
    viewBox="0 0 600 400"
    fill="none"
    xmlns="http://www.w3.org/2000/svg"
  >
    <circle id="mapnj-area-blue" cx="204" cy="200" r="40" fill="blue" />
    <circle id="mapnj-area-yellow" cx="300" cy="200" r="40" fill="yellow" />
    <circle id="mapnj-area-red" cx="396" cy="200" r="40" fill="red" />
  </svg>
</div>
<script src="https://cdn.jsdelivr.net/npm/mapnj@latest/dist/MapNJ.min.js"></script>
<script>
  const mapnj = new MapNJ('#your-mapnj');
</script>

Usage

Installation

Using NPM

To use MapNJ with NPM, run the following command:

$ npm install mapnj

Using CDN

You can also include MapNJ directly in your HTML file using a CDN. Add the following script tag to your HTML:

<script src="https://cdn.jsdelivr.net/npm/mapnj@latest/dist/MapNJ.min.js"></script>

Direct Script Usage

For the latest releases, please visit the GitHub Releases page.

Design Source Setup

MapNJ requires both JavaScript and SVG (design source) preparation. We recommend using Adobe Illustrator or Figma for creating design sources, as they can output layer names as id attributes or data-name attributes. For more details, please refer to the Design Source Setup section on the official website.

Code Preparation

<div id="your-mapnj">
  <svg>
    <defs>
      <style></style>
    </defs>

    <!-- mapping to basic nodes -->
    <path id="mapnj-area-xxx" d="" />
    <path id="mapnj-label-xxx" d="" />

    <!-- mapping to group nodes -->
    <g id="mapnj-area-xxx"><path d="" /><path d="" /></g>
    <g id="mapnj-label-xxx"><path d="" /><path d="" /></g>
  <svg>
</div>
// via Node Module

import MapNJ from 'mapnj';

const mapnj = new MapNJ('#your-mapnj');

API Documentation

For detailed API documentation, please visit the Advanced Usage section on the official website.

License

This project is licensed under the MIT License. See the LICENSE file in the project root for full license information.

Changelog

[0.2.1] - 2024-09-13

Documentation

  • Add Super simple demo in README.

Refactored

  • Adjusting how main class methods are defined.
  • Streamlined State Management.

Test

  • Add ResetSelector test file.

[0.2.0] - 2024-08-16

Changed

  • Use - instead of _ in mapnj part naming conventions

[0.1.0] - 2024-07-25

Added

  • Initial Release