iso-3166-1-flags-sprite-generator
Version:
iso-3166-1 country flags css sprite generator
77 lines (56 loc) • 4.28 kB
Markdown
Generate a css sprite for iso-3166-1 country flags
[](https://github.com/bameyrick/iso-3166-1-flags-sprite-generator/releases)
[](https://travis-ci.com/github/bameyrick/iso-3166-1-flags-sprite-generator)
[](https://codecov.io/gh/bameyrick/iso-3166-1-flags-sprite-generator)
[](https://www.codacy.com/manual/bameyrick/iso-3166-1-flags-sprite-generator)
- [ISO-3166-1 Flags Generator](
- [Install](
- [npm](
- [yarn](
- [Documentation](
- [Usage](
- [Options](
- [Available options](
You can install via npm or yarn.
```bash
npm install --save iso-3166-1-flags-sprite-generator
```
```bash
yarn add iso-3166-1-flags-sprite-generator
```
This documentation is written in TypeScript, however this library works fine in vanilla JavaScript too.
```typescript
import createFlagSprite from 'iso-3166-1-flags-sprite-generator';
async function myFn(): Promise<void> {
await createFlagSprite('assets/img', 'styles');
}
```
Options can be provided to the method as the third argument
```typescript
import createFlagSprite from 'iso-3166-1-flags-sprite-generator';
async function myFn(): Promise<void> {
await createFlagSprite('assets/img', 'styles', { width: 120, center: false });
}
```
| 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 |