本文へ移動

Hata旗

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

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

目次

リファレンス

ページが自分で登録する旗

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

最小化と gzip 圧縮をしたサイズは 6.9 kB(読み込むものをすべて含み、esbuild で計測)

リファレンスの説明と例は英語です。見出しと目次は日本語です。

エクスポート

名前種類概要
CUSTOM_GROUP定数The group a flag is listed under when its record names none.
customAspect関数A custom flag's width over its height, from its viewBox, for keeping a box before it is drawn.
customCreditLine関数Whose flags are on a page, as one line: each set that is on and holds a flag, with its credit and its licence beside it (and "non-commercial" or "share-alike" where the set says so), in English or Japanese.
customFlag関数A registered custom flag's SVG, the checked and rewritten one, with a viewBox and no width or height, like a country's: frame() and toDataUri() from the main entry take it.
CustomFlagInfo型A registered flag as a list shows it: the id, the names, the group, the width over the height and the source it came from.
CustomFlagRecord型One custom flag a page gives: its id (custom: and a slug), its name, its SVG and, if it likes, a group to be listed under.
CustomFlagSource型A set of flags handed in by a page: a records source of the family's data door, whose info says whose they are (id, names, credit, licence, page, day) and whose records() gives the flags.
customGroups関数The groups of the flags registered and on, in the order each first appears, with the ids in each: for a picker that shows custom flags beside the built-in ones.
customId関数A custom flag's id, from one written loosely (either case, spaces around it) and registered: "custom:harbour-fc".
customName関数A custom flag's name, in English or Japanese (any tag that starts ja); the English where no Japanese was given.
enableFlags関数Switches a registered set off or on without forgetting it: while off, its flags are not found, listed or credited.
FlagsRegistered型What registering a set did: the flags added, the records left out with the reason each was (never drawn), and a way to take the set out again.
isCustomId関数True for a string written as a custom flag's id, custom: and a slug; it says nothing of whether such a flag is registered (customFlag does).
listCustomFlags関数The flags registered and on, in the order they were added, each as { id, name, group, aspect, source }; only one group's with group.
MAX_CUSTOM_FLAGS定数The most custom flags a page may hold at once, over all its sets.
registerFlags関数Registers a set of flags a page brings: the source is checked at once (a TypeError for an empty credit, no licence, a bad id, a set id already registered, or a source that is not a records source), its records are read once, and each record is checked on its own.
removeFlags関数Takes a registered set out: its flags are no longer found, listed or drawn, and its id can be registered again.
searchCustomFlags関数Finds registered flags by a word: in the id's slug, the names (English and Japanese) and the group, ignoring case; the best first (exact, then a start, then anywhere), then in the order added.

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

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