|
1 | | -import { isStyleDescriptorArray } from "react-native-css/utilities"; |
2 | | - |
3 | | -import type { StyleFunctionResolver } from "../resolve"; |
4 | | -import { shorthandHandler } from "../shorthands/_handler"; |
5 | | - |
6 | | -export const blur: StyleFunctionResolver = (resolveValue, value) => { |
7 | | - const args = resolveValue(value[2]); |
8 | | - return { |
9 | | - blur: (Array.isArray(args) ? args[0] : args) as unknown, |
10 | | - }; |
11 | | -}; |
12 | | - |
13 | | -export const brightness: StyleFunctionResolver = (resolveValue, value) => { |
14 | | - const args = resolveValue(value[2]); |
15 | | - return { |
16 | | - brightness: (Array.isArray(args) ? args[0] : args) as unknown, |
17 | | - }; |
18 | | -}; |
19 | | - |
20 | | -export const contrast: StyleFunctionResolver = (resolveValue, value) => { |
21 | | - const args = resolveValue(value[2]); |
22 | | - return { |
23 | | - contrast: (Array.isArray(args) ? args[0] : args) as unknown, |
24 | | - }; |
25 | | -}; |
26 | | - |
27 | | -export const grayscale: StyleFunctionResolver = (resolveValue, value) => { |
28 | | - const args = resolveValue(value[2]); |
29 | | - return { |
30 | | - grayscale: (Array.isArray(args) ? args[0] : args) as unknown, |
31 | | - }; |
32 | | -}; |
33 | | - |
34 | | -export const hueRotate: StyleFunctionResolver = (resolveValue, value) => { |
35 | | - const args = resolveValue(value[2]); |
36 | | - return { |
37 | | - hueRotate: (Array.isArray(args) ? args[0] : args) as unknown, |
38 | | - }; |
39 | | -}; |
40 | | - |
41 | | -export const invert: StyleFunctionResolver = (resolveValue, value) => { |
42 | | - const args = resolveValue(value[2]); |
43 | | - return { |
44 | | - invert: (Array.isArray(args) ? args[0] : args) as unknown, |
45 | | - }; |
46 | | -}; |
47 | | - |
48 | | -export const sepia: StyleFunctionResolver = (resolveValue, value) => { |
49 | | - const args = resolveValue(value[2]); |
50 | | - return { |
51 | | - sepia: (Array.isArray(args) ? args[0] : args) as unknown, |
52 | | - }; |
53 | | -}; |
54 | | - |
55 | | -export const saturate: StyleFunctionResolver = (resolveValue, value) => { |
56 | | - const args = resolveValue(value[2]); |
57 | | - return { |
58 | | - saturate: (Array.isArray(args) ? args[0] : args) as unknown, |
59 | | - }; |
60 | | -}; |
61 | | - |
62 | | -export const opacity: StyleFunctionResolver = (resolveValue, value) => { |
63 | | - const args = resolveValue(value[2]); |
64 | | - return { |
65 | | - hueRotate: (Array.isArray(args) ? args[0] : args) as unknown, |
66 | | - }; |
67 | | -}; |
68 | | - |
69 | | -const color = ["color", "string"] as const; |
70 | | -const offsetX = ["offsetX", "number"] as const; |
71 | | -const offsetY = ["offsetY", "number"] as const; |
72 | | -const blurRadius = ["blurRadius", "number"] as const; |
73 | | - |
74 | | -const handler = shorthandHandler( |
75 | | - [ |
76 | | - [offsetX, offsetY, blurRadius, color], |
77 | | - [color, offsetX, offsetY], |
78 | | - [color, offsetX, offsetY, blurRadius], |
79 | | - [offsetX, offsetY, color], |
80 | | - [offsetX, offsetY, blurRadius, color], |
81 | | - ], |
82 | | - [], |
83 | | - "object", |
84 | | -); |
85 | | - |
86 | | -export const dropShadow: StyleFunctionResolver = ( |
87 | | - resolveValue, |
88 | | - func, |
89 | | - get, |
90 | | - options, |
91 | | -) => { |
92 | | - const args = resolveValue(func[2]); |
93 | | - |
94 | | - return isStyleDescriptorArray(args) |
95 | | - ? { |
96 | | - dropShadow: handler(resolveValue, args, get, options), |
97 | | - } |
98 | | - : undefined; |
99 | | -}; |
| 1 | +import { isStyleDescriptorArray } from "react-native-css/utilities"; |
| 2 | + |
| 3 | +import type { StyleFunctionResolver } from "../resolve"; |
| 4 | +import { shorthandHandler } from "../shorthands/_handler"; |
| 5 | + |
| 6 | +export const blur: StyleFunctionResolver = (resolveValue, value) => { |
| 7 | + const args = resolveValue(value[2]); |
| 8 | + return { |
| 9 | + blur: (Array.isArray(args) ? args[0] : args) as unknown, |
| 10 | + }; |
| 11 | +}; |
| 12 | + |
| 13 | +export const brightness: StyleFunctionResolver = (resolveValue, value) => { |
| 14 | + const args = resolveValue(value[2]); |
| 15 | + return { |
| 16 | + brightness: (Array.isArray(args) ? args[0] : args) as unknown, |
| 17 | + }; |
| 18 | +}; |
| 19 | + |
| 20 | +export const contrast: StyleFunctionResolver = (resolveValue, value) => { |
| 21 | + const args = resolveValue(value[2]); |
| 22 | + return { |
| 23 | + contrast: (Array.isArray(args) ? args[0] : args) as unknown, |
| 24 | + }; |
| 25 | +}; |
| 26 | + |
| 27 | +export const grayscale: StyleFunctionResolver = (resolveValue, value) => { |
| 28 | + const args = resolveValue(value[2]); |
| 29 | + return { |
| 30 | + grayscale: (Array.isArray(args) ? args[0] : args) as unknown, |
| 31 | + }; |
| 32 | +}; |
| 33 | + |
| 34 | +export const hueRotate: StyleFunctionResolver = (resolveValue, value) => { |
| 35 | + const args = resolveValue(value[2]); |
| 36 | + return { |
| 37 | + hueRotate: (Array.isArray(args) ? args[0] : args) as unknown, |
| 38 | + }; |
| 39 | +}; |
| 40 | + |
| 41 | +export const invert: StyleFunctionResolver = (resolveValue, value) => { |
| 42 | + const args = resolveValue(value[2]); |
| 43 | + return { |
| 44 | + invert: (Array.isArray(args) ? args[0] : args) as unknown, |
| 45 | + }; |
| 46 | +}; |
| 47 | + |
| 48 | +export const sepia: StyleFunctionResolver = (resolveValue, value) => { |
| 49 | + const args = resolveValue(value[2]); |
| 50 | + return { |
| 51 | + sepia: (Array.isArray(args) ? args[0] : args) as unknown, |
| 52 | + }; |
| 53 | +}; |
| 54 | + |
| 55 | +export const saturate: StyleFunctionResolver = (resolveValue, value) => { |
| 56 | + const args = resolveValue(value[2]); |
| 57 | + return { |
| 58 | + saturate: (Array.isArray(args) ? args[0] : args) as unknown, |
| 59 | + }; |
| 60 | +}; |
| 61 | + |
| 62 | +export const opacity: StyleFunctionResolver = (resolveValue, value) => { |
| 63 | + const args = resolveValue(value[2]); |
| 64 | + return { |
| 65 | + opacity: (Array.isArray(args) ? args[0] : args) as unknown, |
| 66 | + }; |
| 67 | +}; |
| 68 | + |
| 69 | +const color = ["color", "color"] as const; |
| 70 | +const offsetX = ["offsetX", "number"] as const; |
| 71 | +const offsetY = ["offsetY", "number"] as const; |
| 72 | +const standardDeviation = ["standardDeviation", "number"] as const; |
| 73 | + |
| 74 | +const handler = shorthandHandler( |
| 75 | + [ |
| 76 | + [offsetX, offsetY, standardDeviation, color], |
| 77 | + [color, offsetX, offsetY], |
| 78 | + [color, offsetX, offsetY, standardDeviation], |
| 79 | + [offsetX, offsetY, color], |
| 80 | + [offsetX, offsetY, standardDeviation, color], |
| 81 | + ], |
| 82 | + [], |
| 83 | + "object", |
| 84 | +); |
| 85 | + |
| 86 | +export const dropShadow: StyleFunctionResolver = ( |
| 87 | + resolveValue, |
| 88 | + func, |
| 89 | + get, |
| 90 | + options, |
| 91 | +) => { |
| 92 | + const args = resolveValue(func[2]); |
| 93 | + |
| 94 | + return isStyleDescriptorArray(args) |
| 95 | + ? { |
| 96 | + dropShadow: handler(resolveValue, args, get, options), |
| 97 | + } |
| 98 | + : undefined; |
| 99 | +}; |
0 commit comments