1.1.0 • Published 3 years ago
iso-3166-1-flags-sprite-generator v1.1.0
ISO-3166-1 Flags Generator
Generate a css sprite for iso-3166-1 country flags
Install
You can install via npm or yarn.
npm
npm install --save iso-3166-1-flags-sprite-generatoryarn
yarn add iso-3166-1-flags-sprite-generatorDocumentation
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
| Option | Type | description | Default value |
|---|---|---|---|
| center | boolean | Whether to center the flag horizontally | true |
| classPrefix | string | Prefix for css classes | flag |
| cssFileName | string | Name for the generated css file | flags |
| demo | boolean | Whether to create a demo file | true |
| demoDestination | string | Destination for the demo html file. Will have no affect if demo is set to false | flags-demo |
| dimensionsClasses | boolean | Whether to add dimensions classes | false |
| dimensionsSuffix | string | Suffix for dimensions classes | dims |
| lowecaseAlpha2 | boolean | Whether to set the alpha2 code in the css classnames to lowercase | false |
| spriteFileName | string | Name for the generated sprite png file | flag-sprite |
| spriteUrl | string | Background url for the sprite (excluding the file name) | same as provided sprite destination |
| width | number | Maximum width of the flags. Note, all flags will be the same height but not necessarily the same width | 60 |
| silent | boolean | Whether to suppress logging | false |