The chart page is now one page: board and inspector beside the nine-body table, house themes, dasha strip and summary, with four deep-reading tabs below (time, strength, yogas, chart book). Clicking a body or house draws its rulership and aspect lines and fills the inspector. Shadbala, yogas and the birth tithi come from the natal packet; ashtakavarga and house strength are a new lazy layer; the transit layer takes any date. The chat's natal panel carries the same board, opens by default, and is a bottom sheet on phones. Logged two engine bugs found on the way (BUG-1462 sunrise, BUG-1463 /api/shadbala); neither is fixed here. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014Ad9rqAB8pXXvyzh7f4X8v
78 lines
2.3 KiB
TypeScript
78 lines
2.3 KiB
TypeScript
/**
|
|
* Desktop chat natal panel. localStorage, same reason as the sidebar width:
|
|
* `/` is static, so a cookie read on the server would drop that.
|
|
* It starts open until the reader closes it (issue #114 Q8 A); the phone
|
|
* opens the same board as a bottom sheet, which never writes `open`.
|
|
*/
|
|
|
|
export const CHAT_CHART_OPEN_STORAGE_KEY = "chat_chart_panel_open";
|
|
export const CHAT_CHART_WIDTH_STORAGE_KEY = "chat_chart_panel_width";
|
|
// The panel carries the whole clickable board, inspector and 九曜 table now.
|
|
export const CHAT_CHART_WIDTH_MIN = 320;
|
|
export const CHAT_CHART_WIDTH_MAX = 760;
|
|
export const CHAT_CHART_WIDTH_DEFAULT = 440;
|
|
|
|
export type ChatChartStorage = Pick<Storage, "getItem" | "setItem">;
|
|
|
|
export function chatChartStorage(): ChatChartStorage | null {
|
|
try {
|
|
if (typeof localStorage === "undefined") return null;
|
|
return localStorage;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
export function clampChatChartWidth(width: number): number {
|
|
if (!Number.isFinite(width)) return CHAT_CHART_WIDTH_DEFAULT;
|
|
return Math.min(CHAT_CHART_WIDTH_MAX, Math.max(CHAT_CHART_WIDTH_MIN, Math.round(width)));
|
|
}
|
|
|
|
export function readStoredChatChartOpen(
|
|
storage: ChatChartStorage | null = chatChartStorage(),
|
|
): boolean {
|
|
if (storage === null) return true;
|
|
try {
|
|
return storage.getItem(CHAT_CHART_OPEN_STORAGE_KEY) !== "0";
|
|
} catch {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
export function readStoredChatChartWidth(
|
|
storage: ChatChartStorage | null = chatChartStorage(),
|
|
): number {
|
|
if (storage === null) return CHAT_CHART_WIDTH_DEFAULT;
|
|
try {
|
|
const raw = storage.getItem(CHAT_CHART_WIDTH_STORAGE_KEY);
|
|
if (raw === null || raw === "") return CHAT_CHART_WIDTH_DEFAULT;
|
|
return clampChatChartWidth(Number(raw));
|
|
} catch {
|
|
return CHAT_CHART_WIDTH_DEFAULT;
|
|
}
|
|
}
|
|
|
|
export function writeStoredChatChartOpen(
|
|
open: boolean,
|
|
storage: ChatChartStorage | null = chatChartStorage(),
|
|
): void {
|
|
if (storage === null) return;
|
|
try {
|
|
storage.setItem(CHAT_CHART_OPEN_STORAGE_KEY, open ? "1" : "0");
|
|
} catch {
|
|
/* private mode */
|
|
}
|
|
}
|
|
|
|
export function writeStoredChatChartWidth(
|
|
width: number,
|
|
storage: ChatChartStorage | null = chatChartStorage(),
|
|
): void {
|
|
if (storage === null) return;
|
|
try {
|
|
storage.setItem(CHAT_CHART_WIDTH_STORAGE_KEY, String(clampChatChartWidth(width)));
|
|
} catch {
|
|
/* private mode */
|
|
}
|
|
}
|