Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-flag-icon-css

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-flag-icon-css

React SVG country flags component

  • 1.0.13
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.9K
decreased by-12.99%
Maintainers
1
Weekly downloads
 
Created
Source

A simple React SVG country flags component: it works with React Css Modules (default) or standard Css.

NPM version Build Status Greenkeeper badge dependencies Status devDependencies Status peerDependencies Status

codecov Coverage Status

Installation

React Flag Icon Css is distributed as an npm package.

We recommend installing and managing npm packages with yarn:

$ yarn add react-flag-icon-css

otherwise with npm:

$ npm install --save react-flag-icon-css

Prerequisites

We recommend using the Webpack 2 module bundler and ecosystem to assemble your app.

You will need to install and configure a few commonly used packages for Webpack (see the Webpack 2 example project):

$ yarn add -D babel-loader css-loader file-loader style-loader extract-text-webpack-plugin

otherwise with npm:

$ npm install --save-dev ...

Basic usage

Import the factory from react-flag-icon-css, it accepts the React module as the first argument and creates the FlagIcon component. This approach ensures that FlagIcon uses your app's React instance, avoiding issues such as two versions of React being loaded at the same time.

import React from 'react'
import ReactDOM from 'react-dom'
import FlagIconFactory from 'react-flag-icon-css'

const FlagIcon = FlagIconFactory(React)
// If you are not using css modules, write the following:
// const FlagIcon = FlagIconFactory(React, { useCssModules: false })

const App = (props = {}) =>
  <div>
    <FlagIcon code={props.code} size={props.size} />
  </div>

const rootEL = document.body.querySelector('#app')

const appProps = { code: 'it', size: '3x' }
ReactDOM.render(<App {...appProps} />, rootEL)

A Webpack 2 example project is available.

:flags: FlagIcon props

PropTypeFlow TypeDefaultDescriptionSupported values
code *StringFlagIconCodeTypeISO 3166-1-alpha-2 codeThe list is here
sizeStringFlagIconSizeTypelg, 2x, 3x, 4x, 5x
flipStringFlagIconFlipTypehorizontal, vertical
rotateNumberFlagIconRotateType30, 60, 90, 180, 270
squaredBooleanfalse
ComponentStringspane.g span, div
ChildrenStringReact$Element<*>React elemente.g <Something />

Remember to always build FlagIcon with its factory.

:factory: FlagIconFactory

ArgumentTypeFlow TypeDescriptionSupported values
React *ModuleReactModuleYour app's React instanceVersions in peerDependencies
optionsObjectFlagIconOptionsType

Development

Runtime type checking: in development mode (process.env.NODE_ENV !== 'production'), when using unsupported props or prop values, you are warned at runtime by Failed prop type errors in the browser console. Feature powered by prop-types.

Static type checking: if you use Facebook's flow in your app (otherwise you can skip this section, unless you want to submit a PR), it should automatically pick up this package's definitions from the .js.flow files that are distributed with it, checking your code accordingly when you run yarn flow. Using the latest Flow version or the version in ./package.json is recommended. We also recommend using a Flow-aware editor such as Nuclide for Atom.

Contributing

Contributions are welcome:

  • :pencil2: Write code: use a topic branch, follow the AngularJS commit style guidelines and check that yarn prepublish (build, test, type checking, linting ...) returns zero errors before opening a PR. If you want to make major modifications to the code, please open an issue to discuss them first.

  • :bug: Report a bug: first, search all issues. If nothing turns up, open a new issue and be as specific as possible, so that we can reproduce your setup and find out if it is a bug or a configuration issue.

  • :triangular_ruler: Propose a feature: first, search all issues. If nothing turns up, open a new issue and describe what the proposed feature should do, why you think it is important and an example use case.

Thanks! :blue_heart:

Find this module useful?

:star: Starring it lets you keep track of this project and helps more people discover it.

Source of the flags

This project uses the great SVG country flags from flag-icon-css.

License

This project is licensed under the terms of the MIT license.

Keywords

FAQs

Package last updated on 26 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc