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

@vocweb/svg-map

v0.1.11

Published

_A set of Vue.js components to display an interactive SVG map._

Downloads

4

Readme

svg-map

A set of Vue.js components to display an interactive SVG map.

Installation

npm

# Install package
npm install --save @vocweb/svg-map 

# Install SVG map 
npm install --save @svg-country-maps/japan
npm install --save @svg-country-maps/vietnam

yarn

# Install package
yarn add @vocweb/svg-map 

# Install SVG map 
yarn @svg-maps/japan

Usage

Demo

  • Svg map: demo/components/map/Link.vue
  • Checkbox map: demo/components/map/Checkbox.vue
  • Link map: demo/components/map/Link.vue
  • Radio map: demo/components/map/Radio.vue
  • Tooltip map: demo/components/map/Tooltip.vue

:earth_africa: Simple SVG Map

This is the base component to display an SVG map.

In a SFC (Single File Component):

  • Import SvgMap component from @vocweb/svg-map
  • Import the map you want
  • Optionally, import @vocweb/svg-map/dist/index.css if you want to apply the default styles
<template>
	<svg-map :map="Japan" />
</template>

<script>
import { SvgMap } from "@vocweb/svg-map";
import Japan from "@svg-maps/japan";

export default {
	name: "MyMap",
	components: {
		SvgMap
	},
	data() {
		return {
			Japan
		};
	}
};
</script>

<style src="@vocweb/svg-map/dist/index.css"></style>

Props

| Prop | Type | Default | Description | | -------------------- | ---------------- | ------------ | ---------------------------------------------------------------------------------------------------------------- | | map | Object | required | Describe SVG map to display. See maps section for more details. | | location-class | String|Function | null | CSS class of each <path>. The function parameters are the location object and the location index. | | location-tabindex | String|Function | null | Tabindex each <path>. The function parameters are the location object and the location index. | | location-role | String | null | ARIA role of each <path>. | | is-location-selected | Function | null | Executed to determine if a location is selected. This property is used to set the aria-checked HTML attribute. |

Note: other HTML attributes (e.g. style, title, data-*...) can be added to and customized for each <path> modifying the map object.

Events

All the listeners (click, keypress...) are applied to each location.

Slots

There are 2 named slots:

  • before which is before the locations
  • after which is after the locations

:ballot_box_with_check: Checkbox SVG Map

This is an implementation of SvgMap that behaves like a group of checkboxes.
It is based on this WAI-ARIA example to support keyboard navigation and be accessible.

  • Import CheckboxSvgMap component from @vocweb/svg-map
  • Import the map you want
  • Optionally, import @vocweb/svg-map/dist/index.css if you want to apply the default styles
<template>
	<checkbox-svg-map v-model="selectedLocations" :map="Japan" />
</template>

<script>
import { CheckboxSvgMap } from "@vocweb/svg-map";
import Japan from "@svg-maps/japan";

export default {
	name: "MyCheckboxMap",
	components: {
		CheckboxSvgMap
	},
	data() {
		return {
			Japan,
			selectedLocations: []
		};
	}
};
</script>

<style src="@vocweb/svg-map/dist/index.css"></style>

Props

| Prop | Type | Default | Description | | -------------- | ---------------- | ------------ | --------------------------------------------------------------------------------------------------- | | map | Object | required | Describe SVG map to display. See maps section for more details. | | value | String[] | [] | List of ids of selected locations. Used for v-model. | | location-class | String|Function | null | CSS class of each <path>. The function parameters are the location object and the location index. |

Note: other HTML attributes (e.g. style, title, data-*...) can be added to and customized for each <path> modifying the map object.

Events

Like for SvgMap all the listeners (click, keypress...) are applied to each location.

| Event | Output | Description | | ------ | -------- | ------------------------------------------------------------------------------------- | | change | String[] | Emits the new list of ids when a location is selected/unselected. Used for v-model. |

Slots

Like in SvgMap there are 2 named slots:

  • before which is before the locations
  • after which is after the locations

Note: inserting focusable elements may break the checkboxes' behaviour.

:radio_button: Radio SVG Map

This is an implementation of SvgMap that behaves like a group of radio buttons.
It is based on this WAI-ARIA example to support keyboard navigation and be accessible.

  • Import RadioSvgMap component from ``@vocweb/svg-map`
  • Import the map you want
  • Optionally, import @vocweb/svg-map/dist/index.css if you want to apply the default styles
<template>
	<radio-svg-map v-model="selectedLocation" :map="Japan" />
</template>

<script>
import { RadioSvgMap } from "@vocweb/svg-map";
import Japan from "@svg-maps/japan";

export default {
	name: "MyRadioMap",
	components: {
		RadioSvgMap
	},
	data() {
		return {
			Japan,
			selectedLocation: null
		};
	}
};
</script>

<style src="@vocweb/svg-map/dist/index.css"></style>

Props

| Prop | Type | Default | Description | | -------------- | ---------------- | ------------ | --------------------------------------------------------------------------------------------------- | | map | Object | required | Describe SVG map to display. See maps section for more details. | | value | String | null | Id of selected location. Used for v-model. | | location-class | String|Function | null | CSS class of each <path>. The function parameters are the location object and the location index. |

Note: other HTML attributes (e.g. style, title, data-*...) can be added to and customized for each <path> modifying the map object.

Events

Like for SvgMap all the listeners (click, keypress...) are applied to each location.

| Event | Output | Description | | ------ | ------ | ----------------------------------------------------------------- | | change | String | Emits the new id when a location is selected. Used for v-model. |

Slots

Like in SvgMap there are 2 named slots:

  • before which is before the locations
  • after which is after the locations

Note: inserting focusable elements may break the radio buttons' behaviour.

Maps

Existing maps

All the existing maps are in an independant svg-maps project because they may be useful for other components/projects.

Custom maps

You can modify existing maps or create your own.

Modify a map

  1. Import the map to modify
  2. Create a new object from this map
  3. Pass this new object as map prop of the component
<template>
	<svg-map :map="customJapan" />
</template>

<script>
import { SvgMap } from "@vocweb/svg-map";
import Japan from "@svg-maps/japan";

export default {
	name: "MyMap",
	components: {
		SvgMap
	},
	data() {
		return {
			customJapan: {
				...Japan,
				label: "Custom map label",
				locations: Japan.locations.map(location => {
					// Modify each location to customize/add attributes of <path>
				})
			}
		};
	}
};
</script>

It is recommended to not modify the SVG properties (viewBox, path), because it may break the map's display.

License

MIT