Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/__tests__/native/logical-padding.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { render, screen } from "@testing-library/react-native";
import { TextInput } from "react-native-css/components/TextInput";
import { registerCSS, testID } from "react-native-css/jest";

// Android's TextInput keeps its theme padding unless it sees padding,
// paddingVertical/paddingHorizontal or a physical side, so a one-value
// padding-block/padding-inline must not reach it as paddingBlock/paddingInline.
describe.each([
["folded", {}],
["kept", { inlineVariables: false }],
] as const)("variables %s", (_, options) => {
test.each([
["padding-block: 8px", { paddingVertical: 8 }],
["padding-inline: 16px", { paddingHorizontal: 16 }],
["--s: 6px; padding-block: var(--s)", { paddingVertical: 6 }],
["--s: 6px; padding-inline: calc(var(--s) * 2)", { paddingHorizontal: 12 }],
["padding-block: 1px 2px", { paddingBlockStart: 1, paddingBlockEnd: 2 }],
])("%s", (body, expected) => {
registerCSS(`.a { ${body} }`, options);
render(<TextInput testID={testID} className="a" />);
expect(screen.getByTestId(testID).props.style).toStrictEqual(expected);
});
});
4 changes: 2 additions & 2 deletions src/__tests__/vendor/tailwind/@apply.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ test("@apply", async () => {
borderRadius: 7,
color: "#fff",
fontWeight: 600,
paddingBlock: 7,
paddingInline: 14,
paddingVertical: 7,
paddingHorizontal: 14,
boxShadow: [
{
offsetX: 0,
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/vendor/tailwind/spacing.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ describe("Spacing - Padding", () => {
});
test("px-0", async () => {
expect(await renderCurrentTest()).toStrictEqual({
props: { style: { paddingInline: 0 } },
props: { style: { paddingHorizontal: 0 } },
});
});
test("py-0", async () => {
expect(await renderCurrentTest()).toStrictEqual({
props: { style: { paddingBlock: 0 } },
props: { style: { paddingVertical: 0 } },
});
});
test("pt-0", async () => {
Expand Down
9 changes: 7 additions & 2 deletions src/compiler/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ const propertyRename: Record<string, string> = {
"border-block-start-width": "border-top-width",
"border-block-end-width": "border-bottom-width",
"font-variant-caps": "font-variant",
// React Native maps paddingBlock/paddingInline to the same Yoga edges as
// paddingVertical/paddingHorizontal, but Android's TextInput only sees the
// latter and otherwise keeps its theme padding
"padding-block": "padding-vertical",
"padding-inline": "padding-horizontal",
};

// React Native only supports a uniform borderStyle, so per-side border
Expand Down Expand Up @@ -702,7 +707,7 @@ function parsePaddingBlock(
{ value }: DeclarationType<"padding-block">,
builder: StylesheetBuilder,
) {
builder.addShorthand("padding-block", {
builder.addShorthand("padding-vertical", {
"padding-block-start": parseLengthPercentageOrAuto(
value.blockStart,
builder,
Expand All @@ -715,7 +720,7 @@ function parsePaddingInline(
{ value }: DeclarationType<"padding-inline">,
builder: StylesheetBuilder,
) {
builder.addShorthand("padding-inline", {
builder.addShorthand("padding-horizontal", {
"padding-inline-start": parseLengthPercentageOrAuto(
value.inlineStart,
builder,
Expand Down
Loading