リファレンス
コード・URL・SVGの道具
import { … } from "@johnmorrisdotca/hata";
最小化と gzip 圧縮をしたサイズは 3.5 kB(読み込むものをすべて含み、esbuild で計測)
リファレンスの説明と例は英語です。見出しと目次は日本語です。
エクスポート
| 名前 | 種類 | 概要 |
|---|---|---|
aspectOf | 関数 | The 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. |
Fit | 型 | How a flag sits in a frame of another shape. |
FLAG_CODES | 定数 | Every 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"). |
flagCode | 関数 | The 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"). |
FlagCode | 型 | A code with a flag, as Kuni writes it: "JP", "JP-13", "CA-ON", "US-TX". |
flagUrl | 関数 | The 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. |
FlagUrlOptions | 型 | Where flagUrl finds the SVG files: a folder holding <code>.svg. |
frame | 関数 | A flag framed in another shape without stretching it: at its own aspect ratio, at 4:3, square, or in a circle. |
FrameOptions | 型 | How to frame a flag: its shape, how it fits, and a label for assistive technology. |
isFlagCode | 関数 | True for one of the codes with a flag, written exactly as Kuni writes it: "JP", "JP-13", "CA-ON", "US-TX". |
Shape | 型 | The shapes a flag can be framed in. |
toDataUri | 関数 | A flag's SVG as a data: URI, ready for an <img src>, a CSS background-image: url(…) or a canvas. |
VERSION | 定数 | The package's version, the same as package.json's. |
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。