RollerOptions型
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Everything a tray can be told when it is mounted. All of it is optional.
インポート
import type { RollerOptions } from "@johnmorrisdotca/korokoro";
定義
type RollerOptions = {
locale?: string;
strings?: Partial<RollerStrings>;
storage?: StorageLike | null;
storageKey?: string;
spec?: Partial<RollSpec>;
query?: string;
shareBase?: string;
cloth?: Cloth;
onePip?: "red" | "black";
theme?: Record<`--kk-${string}`, string>;
wide?: boolean;
onRoll?: (roll: Roll) => void;
animationMs?: number;
sound?: boolean;
playSound?: PlaySound;
hold?: boolean;
placeholder?: boolean;
keyboard?: boolean;
diceWar?: boolean;
languageChooser?: boolean;
size?: RollerSize;
};
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
locale (省略可) | string | undefined | For numbers and times, and for which built-in words to use: "ja…" is Japanese, anything else English. |
strings (省略可) | Partial<RollerStrings> | undefined | Words to use instead of the built-in ones. |
storage (省略可) | StorageLike | null | undefined | Where the history is kept. Defaults to localStorage; pass null to keep nothing. |
storageKey (省略可) | string | undefined | The key the history is kept under. Defaults to "korokoro.history". |
spec (省略可) | Partial<RollSpec> | undefined | The dice showing when the tray opens. |
query (省略可) | string | undefined | A query string that may hold a shared roll or a seed. Defaults to the page's own. |
shareBase (省略可) | string | undefined | The address a shared link points at. Defaults to the page's own, without its query. |
cloth (省略可) | "green" | "blue" | "red" | "black" | "wood" | undefined | The cloth the felt is laid in: "green" (unless said), "blue", "red", "black" or "wood", the family's five. |
onePip (省略可) | "red" | "black" | undefined | The colour of a d6's one pip, on the felt and in the history: |
theme (省略可) | Record<`--kk-${string}`, string> | undefined | CSS variables for the tray, such as |
wide (省略可) | boolean | undefined | Tray and panels side by side on a wide screen. |
onRoll (省略可) | ((roll: Roll) => void) | undefined | Called once each roll has landed. |
animationMs (省略可) | number | undefined | Length of the tumble, in milliseconds, from the throw to the last die landing. Reduced motion always skips it. |
sound (省略可) | boolean | undefined | Whether the tray has a sound at all. Left out or true, it has a mute button, and starts with the sound on unless the device asks for reduced motion or somebody muted it here before. False, it is silent and has no button. |
playSound (省略可) | PlaySound | undefined | A sound of your own for each throw, in place of the recorded dice. It is called only while the tray is not muted. |
hold (省略可) | boolean | undefined | Whether a die on the felt can be tapped to hold it while the rest are rolled again. Left out or true, plain dice can be held once they have been rolled. False, a tap anywhere on the felt rolls, a die included. |
placeholder (省略可) | boolean | undefined | Whether the dice the tray opens with are only a suggestion. Left out or true, they are: the first die button tapped replaces them with one of that die, so one tap gives a d20, and every tap after that adds. False, the opening dice are the user's own roll and the first tap adds to them. A roll that arrives by a shared link is always the user's. |
keyboard (省略可) | boolean | undefined | Whether Space rolls from anywhere on the page. Left out or true, it does, unless something that takes typing has the focus. False, the page keeps its Space (to scroll, say) and the tray rolls from the keyboard only when the focus is inside it: for a tray that is one thing among many on a page. |
diceWar (省略可) | boolean | undefined | Whether Dice War is among the games: a table of the person at the tray and computers, played with the tray's own dice
( |
languageChooser (省略可) | boolean | undefined | Whether the tray offers its own small choice of language, English or 日本語, remembered on the device. Off unless asked for, so the tray stays as plain as it was. |
size (省略可) | RollerSize | undefined | How much of the tray is drawn, for a tray put into a small space on somebody's page. "small" is the felt and the result and nothing else: the dice are the ones it was given. "medium" adds the choice of dice and the bonus. "large", and left out, is everything: the history, the stats and the odds too. |
例
import type { RollerOptions } from "@johnmorrisdotca/korokoro";
const value: RollerOptions = { spec: { count: 2, sides: 6 }, storage: null, sound: false };
console.log(value.spec?.count);2出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。