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

@qiuz/react-image-map

v1.1.8

Published

A percent react image map compnent -

Downloads

2,383

Readme

ImageMap

GitHub Workflow Status npm

A percent react image map compnent

简体中文

Installation

$ yarn add @qiuz/react-image-map
# or
$ npm install @qiuz/react-image-map

Get mapArea

open http://blog.qiuz.site/q/react-image-map/

and select yourself img

you can add ?imgSrc=${url} like:

http://blog.qiuz.site/q/react-image-map/?imgSrc=http://5b0988e595225.cdn.sohucs.com/images/20170920/2a178d11bc8b4178a387398b5658e105.jpeg

imgSrc is img url

page

Usage

import { ImageMap } from '@qiuz/react-image-map';

Props

ImageMapProps(extend React.ImgHTMLAttributes)

| Name | Type | Default | | :----------- | :---------------------------------------- | :------ | | className | String | '' | | src | String | '' | | onClick | () => void | noop | | onMapClick | (area: Area, index: number) => void | noop | | map | Area[] | [] |

Area(extend React.SpanHTMLAttributes)

| Name | Type | Default | | :----------- | :-------------------------------------------- | :------ | | left | String | 0 | | top | String | 0 | | width | String | 0 | | height | string | 0 | | style | React.CSSProperties | {} | | render | (area: Area, index: number) => React.ReactNode| null |

CHANGELOG

  • access all React.Img props, including events and attributes(like onMounse events and img alt attr.)
  • image map can use render to custom your ReactNode(2021.4.9)
  • use inline style for fix nextjs global css import issue(2022.4.16)

Example

online example

const img = 'https://images.app.goo.gl/STr3xKQMbdjLketR7';

const mapArea: Area[] = [
  {
    left: '0%',
    top: '6%',
    height: '12%',
    width: '33%',
    style: { background: 'rgba(255, 0, 0, 0.5)' },
    onMouseOver: () => console.log('map onMouseOver')
  },
  {
    width: '33%',
    height: '12%',
    left: '0%',
    top: '36.37931034482759%',
    style: { background: 'rgba(255, 0, 0, 0.5)' },
    render: (area: any, index: number) => (
      <span
				style={{
					display: 'flex',
					alignItems: 'center',
					justifyContent: 'center',
          background: 'rgba(255, 255, 0, 0.5)'
        }}
      >
        can render map node
      </span>
    ),
    onMouseOver: () => console.log('map onMouseOver')
  }
];

const onMapClick = (area, index) => {
	const tip = `click map${index + 1}`;
	console.log(tip, area);
	alert(tip);
}

<ImageMap
	className="usage-map"
	src={img}
	map={mapArea}
	onMapClick={onMapClick}
/>

// in hooks
const ImageMapComponent = React.useMemo(() => <ImageMap className="usage-map" src={img} map={mapArea} onMapClick={onMapClick} />, [mapArea, img]);

return (
	...

	{ImageMapComponent}

	...
)