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

Flags a page registers itself

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

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

Exports

NameKindWhat it is
CUSTOM_GROUPconstantThe group a flag is listed under when its record names none.
customAspectfunctionA custom flag's width over its height, from its viewBox, for keeping a box before it is drawn.
customCreditLinefunctionWhose 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.
customFlagfunctionA 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.
CustomFlagInfotypeA registered flag as a list shows it: the id, the names, the group, the width over the height and the source it came from.
CustomFlagRecordtypeOne 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.
CustomFlagSourcetypeA 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.
customGroupsfunctionThe 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.
customIdfunctionA custom flag's id, from one written loosely (either case, spaces around it) and registered: "custom:harbour-fc".
customNamefunctionA custom flag's name, in English or Japanese (any tag that starts ja); the English where no Japanese was given.
enableFlagsfunctionSwitches a registered set off or on without forgetting it: while off, its flags are not found, listed or credited.
FlagsRegisteredtypeWhat 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.
isCustomIdfunctionTrue 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).
listCustomFlagsfunctionThe 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_FLAGSconstantThe most custom flags a page may hold at once, over all its sets.
registerFlagsfunctionRegisters 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.
removeFlagsfunctionTakes a registered set out: its flags are no longer found, listed or drawn, and its id can be registered again.
searchCustomFlagsfunctionFinds 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.

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