1.1.0 • Published 2 years ago

iso-3166-1-flags-sprite-generator v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

ISO-3166-1 Flags Generator

Generate a css sprite for iso-3166-1 country flags

GitHub release Build Status codecov Codacy Badge

Install

You can install via npm or yarn.

npm

npm install --save iso-3166-1-flags-sprite-generator

yarn

yarn add iso-3166-1-flags-sprite-generator

Documentation

This documentation is written in TypeScript, however this library works fine in vanilla JavaScript too.

Usage

import createFlagSprite from 'iso-3166-1-flags-sprite-generator';

async function myFn(): Promise<void> {
  await createFlagSprite('assets/img', 'styles');
}

Options

Options can be provided to the method as the third argument

import createFlagSprite from 'iso-3166-1-flags-sprite-generator';

async function myFn(): Promise<void> {
  await createFlagSprite('assets/img', 'styles', { width: 120, center: false });
}

Available options

OptionTypedescriptionDefault value
centerbooleanWhether to center the flag horizontallytrue
classPrefixstringPrefix for css classesflag
cssFileNamestringName for the generated css fileflags
demobooleanWhether to create a demo filetrue
demoDestinationstringDestination for the demo html file. Will have no affect if demo is set to falseflags-demo
dimensionsClassesbooleanWhether to add dimensions classesfalse
dimensionsSuffixstringSuffix for dimensions classesdims
lowecaseAlpha2booleanWhether to set the alpha2 code in the css classnames to lowercasefalse
spriteFileNamestringName for the generated sprite png fileflag-sprite
spriteUrlstringBackground url for the sprite (excluding the file name)same as provided sprite destination
widthnumberMaximum width of the flags. Note, all flags will be the same height but not necessarily the same width60
silentbooleanWhether to suppress loggingfalse