Skip to the content

Hata旗

Load a native country or region flag, choose supported framing and keep each drawing’s source, author and licence.

Hata (旗) is Japanese for a flag. About the name

Contents

Reference

Codes, URLs and SVG helpers

import { … } from "@johnmorrisdotca/hata";

3.5 kB minified and gzipped, with everything it imports (measured with esbuild)

Exports

NameKindWhat it is
aspectOffunctionThe aspect ratio of a flag, width over height, read from its SVG's viewBox: 1.5 for Japan's 2:3, 2 for Canada's 1:2, 1.9 for the United States' 10:19.
FittypeHow a flag sits in a frame of another shape.
FLAG_CODESconstantEvery code with a flag in this version, in order: the countries by ISO 3166-1 alpha-2 code ("AD" to "ZW", and "XK" for Kosovo), then the first-level subdivisions of 10 countries by ISO 3166-2 code ("AT-1", "AU-NSW", "CA-AB", "DE-BY", "JP-01", "US-AK").
flagCodefunctionThe code of a flag, from a code written loosely: either case, with spaces around it, and an underscore for the hyphen ("jp", " Jp-13 ", "us_tx").
FlagCodetypeA code with a flag, as Kuni writes it: "JP", "JP-13", "CA-ON", "US-TX".
flagUrlfunctionThe address of a flag's SVG file, for an <img src> or a CSS url(): on the jsDelivr CDN by default, or in a folder of your own.
FlagUrlOptionstypeWhere flagUrl finds the SVG files: a folder holding <code>.svg.
framefunctionA flag framed in another shape without stretching it: at its own aspect ratio, at 4:3, square, or in a circle.
FrameOptionstypeHow to frame a flag: its shape, how it fits, and a label for assistive technology.
isFlagCodefunctionTrue for one of the codes with a flag, written exactly as Kuni writes it: "JP", "JP-13", "CA-ON", "US-TX".
ShapetypeThe shapes a flag can be framed in.
toDataUrifunctionA flag's SVG as a data: URI, ready for an <img src>, a CSS background-image: url(…) or a canvas.
VERSIONconstantThe package's version, the same as package.json's.

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hata 1.6.0.