Skip to content

Commit 04af4c6

Browse files
committed
feat: rename prop atRule to natievMapping
1 parent 81d3fdb commit 04af4c6

3 files changed

Lines changed: 29 additions & 29 deletions

File tree

src/__tests__/compiler/@prop.test.tsx renamed to src/__tests__/compiler/@nativeMapping.test.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import {
77
testID,
88
} from "react-native-css/jest";
99

10-
test("@prop target (nested @media)", () => {
10+
test("@nativeMapping target (nested @media)", () => {
1111
const compiled = registerCSS(`
1212
.my-class {
13-
@prop test;
13+
@nativeMapping test;
1414
@media all {
1515
color: #00f;
1616
}
@@ -43,10 +43,10 @@ test("@prop target (nested @media)", () => {
4343
});
4444
});
4545

46-
test("@prop target (nested @media and nested declarations)", () => {
46+
test("@nativeMapping target (nested @media and nested declarations)", () => {
4747
const compiled = registerCSS(`
4848
.my-class {
49-
@prop test;
49+
@nativeMapping test;
5050
@media all {
5151
& {
5252
color: #00f;
@@ -81,14 +81,14 @@ test("@prop target (nested @media and nested declarations)", () => {
8181
});
8282
});
8383

84-
test("@prop target unparsed", () => {
84+
test("@nativeMapping target unparsed", () => {
8585
const compiled = registerCSS(`
8686
:root {
8787
--color-black: #000;
8888
}
8989
9090
.my-class {
91-
@prop test;
91+
@nativeMapping test;
9292
color: var(--color-black);
9393
}
9494
`);
@@ -119,12 +119,12 @@ test("@prop target unparsed", () => {
119119
});
120120
});
121121

122-
test("@prop value: target", () => {
122+
test("@nativeMapping value: target", () => {
123123
const compiled = registerCSS(`
124124
.my-class {
125125
color: red;
126126
background-color: blue;
127-
@prop background-color: myBackgroundColor;
127+
@nativeMapping background-color: myBackgroundColor;
128128
}
129129
`);
130130

@@ -161,12 +161,12 @@ test("@prop value: target", () => {
161161
});
162162
});
163163

164-
test("@prop value: nested target", () => {
164+
test("@nativeMapping value: nested target", () => {
165165
const compiled = compile(`
166166
.test {
167167
color: red;
168168
background-color: blue;
169-
@prop background-color: myBackgroundColor.nested;
169+
@nativeMapping background-color: myBackgroundColor.nested;
170170
}
171171
`);
172172

@@ -191,12 +191,12 @@ test("@prop value: nested target", () => {
191191
});
192192
});
193193

194-
test("@prop value: wildcard target", () => {
194+
test("@nativeMapping value: wildcard target", () => {
195195
const compiled = compile(`
196196
.test {
197197
color: red;
198198
background-color: blue;
199-
@prop background-color: &.myBackgroundColor;
199+
@nativeMapping background-color: &.myBackgroundColor;
200200
}
201201
`);
202202

@@ -221,12 +221,12 @@ test("@prop value: wildcard target", () => {
221221
});
222222
});
223223

224-
test("@prop value: wildcard nested target", () => {
224+
test("@nativeMapping value: wildcard nested target", () => {
225225
const compiled = registerCSS(`
226226
.my-class {
227227
color: red;
228228
background-color: blue;
229-
@prop background-color: &.myBackgroundColor.test;
229+
@nativeMapping background-color: &.myBackgroundColor.test;
230230
}
231231
`);
232232

@@ -261,12 +261,12 @@ test("@prop value: wildcard nested target", () => {
261261
});
262262
});
263263

264-
test("@prop multiple", () => {
264+
test("@nativeMapping multiple", () => {
265265
const compiled = compileWithAutoDebug(`
266266
.test {
267267
color: red;
268268
background-color: oklab(40.1% 0.1143 0.045);
269-
@prop {
269+
@nativeMapping {
270270
background-color: &.myBackgroundColor;
271271
color: &.myColor;
272272
}
@@ -294,10 +294,10 @@ test("@prop multiple", () => {
294294
});
295295
});
296296

297-
test("@prop dot notation shorthand", () => {
297+
test("@nativeMapping dot notation shorthand", () => {
298298
const compiled = registerCSS(`
299299
.my-class {
300-
@prop test.nested;
300+
@nativeMapping test.nested;
301301
@media all {
302302
color: red;
303303
}
@@ -332,10 +332,10 @@ test("@prop dot notation shorthand", () => {
332332
});
333333
});
334334

335-
test("@prop dot notation, escaped", () => {
335+
test("@nativeMapping dot notation, escaped", () => {
336336
const compiled = registerCSS(`
337337
.my-class {
338-
@prop test\\.nested;
338+
@nativeMapping test\\.nested;
339339
@media all {
340340
color: red;
341341
}

‎src/compiler/atRules.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ export function maybeMutateReactNativeOptions(
4747
}
4848

4949
/***********************************************
50-
* @prop *
50+
* @nativeMapping *
5151
***********************************************/
5252

53-
function isPropAtRule(rule: Rule | PropAtRule): rule is PropAtRule {
54-
return rule.type === "unknown" && rule.value.name === "prop";
53+
function isNativeMappingAtRule(rule: Rule | PropAtRule): rule is PropAtRule {
54+
return rule.type === "unknown" && rule.value.name === "nativeMapping";
5555
}
5656

5757
export function parsePropAtRule(rules?: (Rule | PropAtRule)[]) {
@@ -71,14 +71,14 @@ export function parsePropAtRule(rules?: (Rule | PropAtRule)[]) {
7171
if (!rules) return mapping;
7272

7373
for (const rule of rules) {
74-
if (!isPropAtRule(rule)) continue;
74+
if (!isNativeMappingAtRule(rule)) continue;
7575

7676
if (rule.value.prelude.length > 0) {
7777
const prelude = rule.value.prelude.filter((item) => {
7878
return item.value.type !== "white-space";
7979
});
8080

81-
propAtRuleBlock(prelude, mapping);
81+
nativeMappingAtRuleBlock(prelude, mapping);
8282
} else if (rule.value.block) {
8383
// Remove all whitespace tokens
8484
const blocks = rule.value.block.filter((item) => {
@@ -91,23 +91,23 @@ export function parsePropAtRule(rules?: (Rule | PropAtRule)[]) {
9191
});
9292

9393
for (const block of blockRules) {
94-
propAtRuleBlock(block, mapping);
94+
nativeMappingAtRuleBlock(block, mapping);
9595
}
9696
}
9797
}
9898

9999
return mapping;
100100
}
101101

102-
function propAtRuleBlock(
102+
function nativeMappingAtRuleBlock(
103103
token: Extract<TokenOrValue, { type: "token" }>[],
104104
mapping: StyleRuleMapping = {},
105105
): StyleRuleMapping {
106106
let [from, to] = splitByDelimiter(token, (item) => {
107107
return item.value.type === "colon";
108108
});
109109

110-
// @props <to>; (has no from value)
110+
// @nativeMapping <to>; (has no from value)
111111
if (!to) {
112112
to = from;
113113
from = [

‎src/compiler/stylesheet.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class StylesheetBuilder {
5656
private ruleTemplate: StyleRule = {
5757
s: [],
5858
},
59-
// Any default mapping should be included in the @prop parsing
59+
// Any default mapping should be included in the @nativeMapping parsing
6060
private mapping: StyleRuleMapping = {},
6161
public descriptorProperty?: string,
6262
private shared: {

0 commit comments

Comments
 (0)