本文へ移動

Hata旗

国や地域の旗を読み込み、対応する表示の形を選び、絵ごとの資料・作者・ライセンスを保てます。

「旗(はた)」は、旗を表す日本語です。 名前について(英語)

目次

リファレンス

コード・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.

ソースを見るGitHub で編集@johnmorrisdotca/hata 1.6.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。