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

brazil-mentioned

v1.1.5

Published

A simple interactive svg Brazil map web component

Downloads

13

Readme

Brazil mentioned npm version

A simple (but effective!) web component brazil map SVG with strokes and paths delimiting it's states. This web component is agnostic to any web js framework.

brazil-mentioned

This is Brazil


Installation

You can either install using a js package manager of your choice or use the official CDN distribution

via npm

npm i brazil-mentioned

via yarn

yarn add brazil-mentioned

via CDN

CDN link via jsDelivr

UMD:

https://cdn.jsdelivr.net/npm/brazil-mentioned/dist/brazil-mentioned.umd.min.js

ES:

https://cdn.jsdelivr.net/npm/brazil-mentioned/dist/brazil-mentioned.es.min.js

NOTE: The nature of this package is to provide an agnostic web component to work with any other framework and even vanilla js, plus html + css projects, and due to this the lit library is imported within the CDN bundle and this can cause bugs if you use another version of lit in your project, the recommended way to use this package in a other lit project is via package manager because they can deduplicate libs and handle this scenario better than a CDN. Otherwise ignore this note if you don't plan to use lit in your project alongside this package.

Basic Usage

To use the component in your project, first you need to reference the bundle of the lib in your index.html file or the one you wanna use it.

<!-- CDN -->
<script type="module" src="https://cdn.jsdelivr.net/npm/brazil-mentioned/dist/brazil-mentioned.umd.min.js"></script>

<!-- Node modules package -->
<script type="module" src="path-to-your/node_modules/brazil-mentioned/dist/brazil-mentioned.umd.min.js"></script>

Then just put the just put the brazil-component selector in a html page and Voilà! You're done.

<brazil-component id="webrazil"></brazil-component>

Properties

  • hidden-states: boolean - Determine whether or not the states acronyms will be displayed
  • static: boolean - Determine whether or not the map will react to mouse events

To use custom properties, these booleans for example, just insert like a html property in the selector and by default it will be treated like a truthy value internally by lit.

<brazil-component id="webrazil" hidden-states static></brazil-component>

Events

By default, if no static state is applied, a few mouse events occur naturally like the hover over the states strokes and paths in the internal svg, and a custom event is dispatched when some path is clicked.

  • onStateSelected: CustomEvent<string> - Dispatch the selected state on the SVG as a custom event. The value is the state acronym string(like SP).
<brazil-component id="webrazil" hidden-states static></brazil-component>

<!-- Adding a event listener to the custom element -->
<script>
    const element = document.querySelector('#webrazil');

    element.addEventListener('onStateSelected', (event) => {
        const { detail: state } = event;

        console.log(state) // RJ;
    });
</script>

Custom styles

This table shows the correlation variables related to the Brazilian style in your application, both in the light and dark versions. Default colors are used when there are no specific replacements for the dark colors scheme. The dark palette is used when the system has a preferred dark option and to make sure the component serve this two palettes, the variables listed below exists with the --dark suffix so that you can customize the two palettes in your way and style

| Variable | Description | Default (Light) | Default (Dark) | |----------------------------------|--------------------------------------|----------------|---------------| | --brazil-bg-color | Background color of the map | #ccc | #424242 | | --brazil-bg-hover-color | Hover color of the states | #424242 | #fff | | --brazil-stroke-color | Stroke colors that delimits the states | #424242 | #fff | | --brazil-stroke-hover-color | Hover color of the stroke when the state is hovered | #fff | #424242 | | --brazil-acronym-color | Brazil states acronym color | #424242 | #fff | | --brazil-acronym-hover-color | Brazil states hover acronym color | #fff | #424242 | | --brazil-acronym-font-family | Font family of the brazil states acronym | Tahoma, Arial, sans-serif | Tahoma, Arial, sans-serif |