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

@munkacsimark/react-flag

v0.1.0

Published

Simple flag component for React which uses svg or emojis, based on ISO-3166.

Downloads

7

Readme

React Flag

This package is based on ISO-3166 country codes, contains 245 flags. It comes with minimum styling for easier use in your project. Flags are in svg format but you can use them with emojis as well.

Installation

npm install @munkacsimark/react-flag --save

Usage

import Flag from '@munkacsimark/react-flag'

Properties

| Key | Value | Required | Default | Format | | ------------ | ------- | -------- | ------- | ------------------------------------------------------------------------------- | | alpha2 | String | false* | - | ISO 3166-1 alpha-2 | | alpha3 | String | false* | - | ISO 3166-1 alpha-2 | | numeric | String | false* | - | ISO 3166-1 numeric | | tld | String | false* | - | Country code TLD | | size | String | false | 'sm' | 'xs', 'sm', 'lg', 'xl' | | useEmoji | Boolean | false | false | - | | disableLabel | Boolean | false | false | - |

* For identifying the country one of the following properties needs to be defined: alpha2, alpha3, numeric, tld. The order of property precedence is the same.

alpha2 and alpha3 should be upper-case letters (e.g. 'US'), numeric codes as string (e.g '840') and tlds starting with a period (e.g. '.us').

There are predefined sizes of container width: 'xs'=18px, 'sm'=24px, 'lg'=36px and 'xl'=48px. Each is using 1.5 ratio for calculating height of container (e.g height of 'sm'=24/1.5=16px).

You can use useEmoji property for using only emojis in accessible way. This feature is based on a11y-react-emoji. disableLabel property makes sense only for emojis, it disables aria-label and sets aria-hidden to true.

Examples

Simple usage

<Flag alpha2={'US'} />

Usage with emojis

<Flag alpha2={'US'} useEmoji />

Styling

CSS Modules

Since it uses inline styles for now, you need to define width and height with !important.

.flag {
	width: 100px !important;
	height: 50px !important;
	border: 1px solid black;
}
<Flag alpha2={'US'} className={style.flag} />

Inline styles

<Flag alpha2={'US'} style={{ width: '100px' }} />

Examples

You can set styles of child img tag as following:

.flag img {
	object-fit: cover !important;
}

For making circle flags, use styles like below. Note that, you can align images with object-position rule.

.flag {
	width: 62px !important;
	height: 62px !important;
	border-radius: 50%;
}
.flag img {
	object-fit: cover !important;
	object-position: -10px center;
}

When you are using emojis with useEmoji property, you can set the size simply with:

.flag {
	font-size: 64px;
}