-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathroot.ts
More file actions
31 lines (24 loc) · 867 Bytes
/
root.ts
File metadata and controls
31 lines (24 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import type { StyleDescriptor, VariableValue } from "react-native-css/compiler";
import { testMediaQuery } from "./conditions/media-query";
import { family, observable, type Observable } from "./reactivity";
const rootVariableFamily = () => {
return family<string, Observable<StyleDescriptor, VariableValue[]>>(() => {
const obs = observable<StyleDescriptor, VariableValue[]>(
(read, variableValue) => {
if (!variableValue) return undefined;
for (const [value, mediaQuery] of variableValue) {
if (!mediaQuery) {
return value;
}
if (testMediaQuery(mediaQuery, read)) {
return value;
}
}
return undefined;
},
);
return obs;
});
};
export const rootVariables = rootVariableFamily();
export const universalVariables = rootVariableFamily();