UNPKG

custom-card-helpers

Version:

Set of helpful functions and types for Custom Card creators

34 lines (27 loc) 772 B
import { HASSDomEvent, fireEvent } from "./fire-event"; /** * Broadcast haptic feedback requests */ // Allowed types are from iOS HIG. // https://developer.apple.com/design/human-interface-guidelines/ios/user-interaction/feedback/#haptics // Implementors on platforms other than iOS should attempt to match the patterns (shown in HIG) as closely as possible. export type HapticType = | "success" | "warning" | "failure" | "light" | "medium" | "heavy" | "selection"; declare global { // for fire event interface HASSDomEvents { haptic: HapticType; } interface GlobalEventHandlersEventMap { haptic: HASSDomEvent<HapticType>; } } export const forwardHaptic = (hapticType: HapticType) => { fireEvent(window, "haptic", hapticType); };