-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathsupports.ts
More file actions
28 lines (25 loc) · 974 Bytes
/
supports.ts
File metadata and controls
28 lines (25 loc) · 974 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
import type { SupportsCondition } from "lightningcss";
export function supportsConditionValid(condition: SupportsCondition): boolean {
if (condition.type === "and") {
return condition.value.every((condition) => {
return supportsConditionValid(condition);
});
} else if (condition.type === "or") {
return condition.value.some((condition) => {
return supportsConditionValid(condition);
});
} else if (condition.type === "not") {
return !supportsConditionValid(condition.value);
} else if (condition.type === "declaration") {
return Boolean(
declarations[condition.propertyId.property]?.includes(condition.value),
);
}
return false;
}
const declarations: Record<string, string[]> = {
// We don't actually support this, but its needed for Tailwind CSS
"-moz-orient": ["inline"],
// Special text used by TailwindCSS. We should probably change this to all color-mix
"color": ["color-mix(in lab, red, red)"],
};