本文へ移動

Koyomi Calendars暦

カレンダーのページをSVGで描きます。1日を18種類のアイコンで、1か月をポスターや卓上カレンダーで、そして日めくりも使えます。

「暦」(こよみ) は、カレンダーのことです。 名前について(英語)

目次

リファレンス · カレンダーアイコン

CalendarIconOptions型

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

What calendarIcon takes: the date, the design and the look of one calendar page.

Only month and day are required.

インポート

import type { CalendarIconOptions } from "@johnmorrisdotca/koyomi-calendars";

定義

interface CalendarIconOptions {
    month: number;
    day: number;
    year?: number;
    theme?: CalendarTheme;
    locale?: string;
    scheme?: "light" | "dark";
    size?: number;
    weekend?: "split";
    holidays?: Readonly<Record<string, string | {
        readonly en?: string;
        readonly ja?: string;
    }>>;
    mark?: string;
    columns?: boolean;
    japanese?: boolean | {
        readonly holidays?: boolean;
        readonly oldDate?: boolean;
        readonly rokuyo?: boolean;
    };
    moon?: boolean;
    housing?: CalendarHousing;
    housingColour?: string;
    rings?: boolean | number;
    turn?: number;
    preset?: CalendarPreset;
}

メンバー

名前型説明
monthnumber

Month 1–12.

daynumber

Day of the month 1–31.

year (省略可)number | undefined

Four-digit year. Names the weekday (and a small year) where a theme draws them; omit it to leave both off.

theme (省略可)"pins" | "loops" | "shadow" | "heavy" | "cartoon" | "flip" | "stack" | "line" | "curl" | "soft" | "desk" | "thin" | "frame" | "badge" | "sun" | "roll" | "plain" | "squircle" | undefined
locale (省略可)string | undefined

en (the default) or any locale Intl accepts.

scheme (省略可)"light" | "dark" | undefined
size (省略可)number | undefined

Width in CSS pixels. Height follows the theme's shape. Default 96.

weekend (省略可)"split" | undefined

"split" draws a Saturday and the Sunday after it on one page, cut by a diagonal (themes sun and roll, and only when a year is given and the day is a Saturday or a Sunday). Any other day keeps its own page.

holidays (省略可)Readonly<Record<string, string | { readonly en?: string; readonly ja?: string; }>> | undefined

Holiday names for the side columns, by date ("2027-01-01") or by day of every year ("01-01"): one string, or one per language. The library knows none itself; a date with no name leaves its cell empty.

mark (省略可)string | undefined

SVG shapes that replace the sun's red disc: drawn in a box from -100,-100 to 100,100 centred behind the day. Your own markup, written as given: no scripts, styles, event attributes or foreign objects.

columns (省略可)boolean | undefined

The side columns of sun and roll (weekday, month, holiday). Default true.

japanese (省略可)boolean | { readonly holidays?: boolean; readonly oldDate?: boolean; readonly rokuyo?: boolean; } | undefined

What the side columns add from the Japanese calendar, computed (src/japaneseCalendar.ts), never looked up: holidays the day's public holiday (国民の祝日, 2000 to 2099; a name in holidays above wins), oldDate the old calendar date (旧暦, 1900 to 2100) and rokuyo the day of the six-day cycle (六曜). true is all three; a cell the method cannot settle is left empty. Off by default, so a page drawn without it is as before. A weekend page shows the holiday only.

moon (省略可)boolean | undefined

The moon phase on plain, drawn when a year is given. Default true.

housing (省略可)"square" | "circle" | undefined

"circle" sets the icon on a coloured disc. Default "square": the icon alone.

housingColour (省略可)string | undefined

The disc's colour, any CSS colour. A soft blue (a deep one in dark) by default.

rings (省略可)number | boolean | undefined

Spiral rings across the top of the page, on the themes that have no binding of their own (badge, frame, sun, roll, plain, squircle); the others ignore it. true fits the page; a number sets how many (0–24). Default off.

turn (省略可)number | undefined

A slight turn of the whole icon, in degrees, clockwise when positive (older macOS icons stood a little askew). −45 to 45. Default 0.

preset (省略可)"flat" | "disc" | "ringed" | "tilted" | "disc-ringed" | undefined

A named set of the three options above (CALENDAR_PRESETS). An option you give yourself wins over it.

例

import { calendarIcon, type CalendarIconOptions } from "@johnmorrisdotca/koyomi-calendars";

const options: CalendarIconOptions = { month: 7, day: 17, year: 2026, theme: "badge", scheme: "light" };
console.log(calendarIcon(options).length > 100);
true

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

ソースを見るGitHub で編集@johnmorrisdotca/koyomi-calendars 0.3.0 のソースから作成しました。

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