Files
tv-control/tv/src/types.ts
space eb4e7ea26a
All checks were successful
Build App / build (push) Successful in 7m10s
feat: implement background color and night mode settings in the TV control app
2026-03-01 17:53:41 +01:00

123 lines
3.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export interface TextState {
showing: boolean;
title: string;
}
export interface NightModeSettings {
/** Whether night mode scheduling is active */
enabled: boolean;
/** Start of night window, "HH:MM" 24-hour */
start_time: string;
/** End of night window (exclusive), "HH:MM" 24-hour */
end_time: string;
/** Text shown on image rotator cards during night mode */
message: string;
/** When true, hide background image/colour and use near-black */
dim_background: boolean;
}
export interface SettingsState {
/** Landscape background image URL. Empty string = no background. */
background_url: string;
/** CSS colour string for the TV background. Default "#000000". */
background_color: string;
night_mode: NightModeSettings;
}
export interface ImagePopupState {
showing: boolean;
image_url: string;
caption: string;
}
/** Grid layout: 1-based col/row, 4-column × 4-row grid */
export interface CardLayout {
grid_col: number; // 14
grid_row: number; // 14
col_span: number; // 14
row_span: number; // 14
}
// ─── custom_json ───────────────────────────────────────────────────────────────
export interface DisplayOptions {
font_size: number;
text_color: string;
}
export interface DataCardConfig {
url: string;
refresh_interval: number;
display_options: DisplayOptions;
take?: string;
additional_headers?: Record<string, string>;
}
export interface CustomJsonCard {
id: string;
type: "custom_json";
name: string;
config: DataCardConfig;
layout?: CardLayout;
}
// ─── static_text ──────────────────────────────────────────────────────────────
export interface StaticTextConfig {
text: string;
font_size: number;
text_color: string;
}
export interface StaticTextCard {
id: string;
type: "static_text";
name: string;
config: StaticTextConfig;
layout?: CardLayout;
}
// ─── clock ────────────────────────────────────────────────────────────────────
export interface ClockConfig {
/** "time" = live clock, "timer" = countdown to target_iso */
mode: "time" | "timer";
/** IANA timezone string, e.g. "Europe/Berlin" */
timezone?: string;
/** ISO-8601 target datetime for mode="timer", e.g. "2026-12-31T23:59:59" */
target_iso?: string;
font_size: number;
text_color: string;
show_seconds?: boolean;
}
export interface ClockCard {
id: string;
type: "clock";
name: string;
config: ClockConfig;
layout?: CardLayout;
}
// ─── image_rotator ────────────────────────────────────────────────────────────
export interface ImageRotatorConfig {
/** List of public image URLs to cycle through */
images: string[];
/** Seconds between transitions */
interval: number;
fit: "cover" | "contain";
}
export interface ImageRotatorCard {
id: string;
type: "image_rotator";
name: string;
config: ImageRotatorConfig;
layout?: CardLayout;
}
// ─── Union ────────────────────────────────────────────────────────────────────
export type DataCard = CustomJsonCard | StaticTextCard | ClockCard | ImageRotatorCard;