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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
"react-test-renderer": "^19.1.0",
"release-it": "^19.0.4",
"tailwindcss": "^4.1.12",
"tailwindcss-safe-area": "^1.1.0",
"typescript": "^5.9.2",
"typescript-eslint": "^8.40.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/vendor/tailwind/_tailwind.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export async function render(
css += `@import "tailwindcss/preflight.css" layer(base);\n`;
}

css += `@import "tailwindcss/utilities.css" layer(utilities) source(none);\n`;
css += `@import "tailwindcss/utilities.css" layer(utilities) source(none);\n@import "tailwindcss-safe-area";`;
}

css += sourceInline
Expand Down
357 changes: 357 additions & 0 deletions src/__tests__/vendor/tailwind/safe-area.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,357 @@
import type { ViewProps } from "react-native";

import { SafeAreaProvider } from "react-native-css/components/react-native-safe-area-context";
import { type Metrics } from "react-native-safe-area-context";

import { renderCurrentTest } from "./_tailwind";

const initialMetrics: Metrics = {
insets: {
top: 10,
bottom: 10,
left: 10,
right: 10,
},
frame: {
x: 0,
y: 0,
height: 100,
width: 100,
},
};

function Wrapper({ children }: ViewProps) {
return (
<SafeAreaProvider initialMetrics={initialMetrics}>
{children}
</SafeAreaProvider>
);
}

test("m-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
marginBottom: 10,
marginLeft: 10,
marginRight: 10,
marginTop: 10,
},
},
});
});

test("mx-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
marginLeft: 10,
marginRight: 10,
},
},
});
});
test("my-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
marginBottom: 10,
marginTop: 10,
},
},
});
});
test("ms-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
marginInlineStart: 10,
},
},
});
});
test("me-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
marginInlineEnd: 10,
},
},
});
});
test("mt-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
marginTop: 10,
},
},
});
});
test("mr-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
marginRight: 10,
},
},
});
});
test("mb-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
marginBottom: 10,
},
},
});
});

test("ml-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
marginLeft: 10,
},
},
});
});

test("p-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
paddingBottom: 10,
paddingLeft: 10,
paddingRight: 10,
paddingTop: 10,
},
},
});
});

test("px-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
paddingLeft: 10,
paddingRight: 10,
},
},
});
});
test("py-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
paddingBottom: 10,
paddingTop: 10,
},
},
});
});
test("ps-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
paddingInlineStart: 10,
},
},
});
});
test("pe-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
paddingInlineEnd: 10,
},
},
});
});
test("pt-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
paddingTop: 10,
},
},
});
});
test("pr-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
paddingRight: 10,
},
},
});
});
test("pb-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
paddingBottom: 10,
},
},
});
});
test("pl-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
paddingLeft: 10,
},
},
});
});

test("min-h-screen-safe", async () => {
// calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)));
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
minHeight: 1314,
},
},
});
});

test("max-h-screen-safe", async () => {
// calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)));
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
maxHeight: 1314,
},
},
});
});

test("h-screen-safe", async () => {
// calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)));
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
height: 1314,
},
},
});
});

test("inset-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
bottom: 10,
left: 10,
right: 10,
top: 10,
},
},
});
});
test("inset-x-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
left: 10,
right: 10,
},
},
});
});
test("inset-y-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
bottom: 10,
top: 10,
},
},
});
});
test("start-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
insetInlineStart: 10,
},
},
});
});
test("end-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
insetInlineEnd: 10,
},
},
});
});
test("top-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
top: 10,
},
},
});
});
test("right-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
right: 10,
},
},
});
});
test("bottom-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
bottom: 10,
},
},
});
});
test("left-safe", async () => {
expect(await renderCurrentTest({ wrapper: Wrapper })).toStrictEqual({
props: {
style: {
left: 10,
},
},
});
});

test("pb-safe-offset-4", async () => {
// calc(env(safe-area-inset-right) + 2rem);
expect(
await renderCurrentTest({
wrapper: Wrapper,
}),
).toStrictEqual({
props: {
style: {
paddingBottom: 24, // 10 + 14
},
},
});
});

test("pb-safe-or-20", async () => {
// --spacing: 3.5
// max(env(safe-area-inset-bottom), calc(var(--spacing) * 20));
expect(
await renderCurrentTest({
wrapper: Wrapper,
}),
).toStrictEqual({
props: {
style: {
paddingBottom: 70,
},
},
});
});
Loading
Loading