1interface Interactive<T> {
2 default: T,
3 hover?: T,
4 clicked?: T,
5 disabled?: T,
6}
7
8export function interactive<T>(base: T, modifications: Partial<Interactive<T>>): Interactive<T> {
9 const interactiveObj: Interactive<T> = {
10 default: base,
11 };
12
13 if (modifications.hover !== undefined) {
14 interactiveObj.hover = { ...base, ...modifications.hover };
15 }
16
17 if (modifications.clicked !== undefined) {
18 interactiveObj.clicked = { ...base, ...modifications.clicked };
19 }
20
21 if (modifications.disabled !== undefined) {
22 interactiveObj.disabled = { ...base, ...modifications.disabled };
23 }
24
25 return interactiveObj;
26}