Skip to content

Commit

Permalink
fix: stop babel appending platform to TailwindProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
marklawlor committed May 23, 2022
1 parent 5edef66 commit fc8fdc8
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 31 deletions.
2 changes: 1 addition & 1 deletion __tests__/visitor/allow-modules-with-content/output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { MotiText } from "moti";
import { TestComponent } from "./test";
export function Test() {
return (
<TailwindProvider platform="native">
<TailwindProvider>
<StyledComponent className="font-bold" component={Text}>
Hello world!
</StyledComponent>
Expand Down
2 changes: 1 addition & 1 deletion __tests__/visitor/allow-modules/output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TailwindProvider } from "tailwindcss-react-native";
import { MotiText } from "moti";
export function Test() {
return (
<TailwindProvider platform="native">
<TailwindProvider>
<StyledComponent className="container" component={View}>
<StyledComponent className="font-bold" component={Text}>
Hello world!
Expand Down
2 changes: 1 addition & 1 deletion __tests__/visitor/basic-tw/output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Text, View } from "react-native";
import { TailwindProvider } from "tailwindcss-react-native";
export function Test() {
return (
<TailwindProvider platform="native">
<TailwindProvider>
<StyledComponent tw="container" component={View}>
<StyledComponent tw="font-bold" component={Text}>
Hello world!
Expand Down
2 changes: 1 addition & 1 deletion __tests__/visitor/basic/output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Text, View } from "react-native";
import { TailwindProvider } from "tailwindcss-react-native";
export function Test() {
return (
<TailwindProvider platform="native">
<TailwindProvider>
<StyledComponent className="container" component={View}>
<StyledComponent className="font-bold" component={Text}>
Hello world!
Expand Down
2 changes: 1 addition & 1 deletion __tests__/visitor/className-expression/output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function Test({ isBold, isUnderline }) {
if (isBold) classNames.push("font-bold");
if (isUnderline) classNames.push("underline");
return (
<TailwindProvider platform="native">
<TailwindProvider>
<StyledComponent className={classNames.join(" ")} component={Text}>
Hello world!
</StyledComponent>
Expand Down
2 changes: 1 addition & 1 deletion __tests__/visitor/empty-className/output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Text } from "react-native";
import { TailwindProvider } from "tailwindcss-react-native";
export function Test() {
return (
<TailwindProvider platform="native">
<TailwindProvider>
<StyledComponent className="" component={Text}>
Hello world!
</StyledComponent>
Expand Down
2 changes: 1 addition & 1 deletion __tests__/visitor/existing-style/output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { StyleSheet, Text } from "react-native";
import { TailwindProvider } from "tailwindcss-react-native";
export function Test() {
return (
<TailwindProvider platform="native">
<TailwindProvider>
<StyledComponent
className="font-bold"
style={styles.test}
Expand Down
18 changes: 0 additions & 18 deletions src/babel/transforms/append-platform-attribute.ts

This file was deleted.

7 changes: 1 addition & 6 deletions src/babel/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { getImportBlockedComponents } from "./utils/get-import-blocked-component
import { someAttributes } from "./utils/has-attribute";

import { toStyledComponent } from "./transforms/to-component";
import { appendPlatformAttribute } from "./transforms/append-platform-attribute";

import {
AllowPathOptions,
Expand Down Expand Up @@ -53,15 +52,11 @@ export const visitor: Visitor<VisitorState> = {
);
},
JSXElement(path, state) {
const { platform, blockList, canTransform } = state;
const { blockList, canTransform } = state;
const name = getJSXElementName(path.node.openingElement);

state.hasProvider ||= name === "TailwindProvider";

if (name === "TailwindProvider" && canTransform) {
appendPlatformAttribute(path, platform);
}

if (blockList.has(name) || name[0] !== name[0].toUpperCase()) {
return;
}
Expand Down

0 comments on commit fc8fdc8

Please sign in to comment.