本文へ移動

Hata旗

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

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

目次

リファレンス · ページが自分で登録する旗

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.

インポート

import type { CustomFlagRecord } from "@johnmorrisdotca/hata/custom";

定義

interface CustomFlagRecord {
    id: string;
    name: {
        en: string;
        ja?: string;
    };
    svg: string;
    group?: string;
}

メンバー

名前型説明
idstring

custom: and a slug: lower-case letters, digits and hyphens, up to 48 characters.

name{ en: string; ja?: string; }

The name for a caption or a screen reader; the Japanese one may be left out (the English is used).

svgstring

The SVG text: allowed elements and attributes only (see registerFlags), with a viewBox and no width or height.

group (省略可)string | undefined

What it is listed under; "custom" when left out.

例

import type { CustomFlagRecord } from "@johnmorrisdotca/hata/custom";

const club: CustomFlagRecord = {
  id: "custom:harbour-fc",
  name: { en: "Harbour FC", ja: "ハーバーFC" },
  group: "Clubs",
  svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 3 2"><path fill="#036" d="M0 0h3v2H0z"/></svg>',
};
console.log(club.id);
custom:harbour-fc

出力(このページを作ったときに実行した結果)

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

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