Skip to content

improve some tamagui setup #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 0 additions & 4 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
process.env.TAMAGUI_TARGET = "native"; // Don't forget to specify your TAMAGUI_TARGET here
const path = require("path");
const myBabel = require("@gluestack-style/babel-plugin-styled-resolver");

Expand Down Expand Up @@ -26,9 +25,6 @@ module.exports = function (api) {
],
[
"transform-inline-environment-variables",
{
include: "TAMAGUI_TARGET",
},
],
"nativewind/babel",
],
Expand Down
33 changes: 16 additions & 17 deletions cases/change-variants/Tamagui.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
import { styled } from "tamagui";
import React, { useMemo } from "react";
import { View, Text } from "react-native";
import { COUNT } from "../../utils";
import React from 'react'
import { styled, View } from 'tamagui'
import { COUNT } from '../../utils'

const Box = styled(View, {
bc: "$yellow5Light",
p: "$2",
m: "$1",
bg: '$yellow5Light',
p: '$2',
m: '$1',
variants: {
variant: {
solid: {
bc: "$red5Light",
p: "$2",
bc: '$red5Light',
p: '$2',
},
outlined: {
borderWidth: "$1",
borderColor: "$red5Light",
bc: "transparent",
borderWidth: '$1',
borderColor: '$red5Light',
bc: 'transparent',
},
},
},
});
})

const Tamagui = ({ toggleVariant }: { toggleVariant?: boolean }) => {
return (
<>
{new Array(COUNT).fill(0).map((_, k) => (
<Box key={k} variant={toggleVariant ? "outlined" : "solid"} />
<Box key={k} variant={toggleVariant ? 'outlined' : 'solid'} />
))}
</>
);
};
)
}

export default Tamagui;
export default Tamagui
57 changes: 28 additions & 29 deletions cases/complex-styling/Tamagui.tsx
Original file line number Diff line number Diff line change
@@ -1,53 +1,52 @@
import { styled } from "tamagui";
import React from "react";
import { COUNT } from "../../utils";
import { Pressable } from "react-native";
import { styled, View } from 'tamagui'
import React from 'react'
import { COUNT } from '../../utils'

const Button = styled(Pressable, {
bc: "$yellow5Light",
p: "$2",
m: "$1",
const Button = styled(View, {
bc: '$yellow5Light',
p: '$2',
m: '$1',
hoverStyle: {
bc: "$yellow6Light",
bc: '$yellow6Light',
},
pressStyle: {
bc: "$yellow7Light",
bc: '$yellow7Light',
},
focusStyle: {
bc: "$yellow8Light",
bc: '$yellow8Light',
},
variants: {
variant: {
solid: {
bc: "$red5Light",
p: "$2",
bc: '$red5Light',
p: '$2',
hoverStyle: {
bc: "$red6Light",
bc: '$red6Light',
},
pressStyle: {
bc: "$red7Light",
bc: '$red7Light',
},
focusStyle: {
bc: "$red8Light",
bc: '$red8Light',
},
},
outlined: {
borderWidth: "$1",
borderColor: "$red5Light",
bc: "transparent",
borderWidth: '$1',
borderColor: '$red5Light',
bc: 'transparent',
hoverStyle: {
bc: "$red6Light",
bc: '$red6Light',
},
pressStyle: {
bc: "$red7Light",
bc: '$red7Light',
},
focusStyle: {
bc: "$red8Light",
bc: '$red8Light',
},
},
},
},
});
})

const Tamagui = () => {
return (
Expand All @@ -57,18 +56,18 @@ const Tamagui = () => {
key={k}
variant="solid"
hoverStyle={{
bc: "$purple6Light",
bc: '$purple6Light',
}}
pressStyle={{
bc: "$purple7Light",
bc: '$purple7Light',
}}
focusStyle={{
bc: "$purple8Light",
bc: '$purple8Light',
}}
/>
))}
</>
);
};
)
}

export default Tamagui;
export default Tamagui
22 changes: 11 additions & 11 deletions cases/screens/Tamagui.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TamaguiProvider, XStack, YStack, Image, Text } from "tamagui";
import { ScrollView } from "react-native";
import { data } from "../../data";
import config from "../../tamagui.config";
import { TamaguiProvider, XStack, YStack, Image, Text } from 'tamagui'
import { ScrollView } from 'react-native'
import { data } from '../../data'
import config from '../../tamagui.config'

export function Provider({ children, ...props }) {
return (
Expand All @@ -13,11 +13,11 @@ export function Provider({ children, ...props }) {
>
{children}
</TamaguiProvider>
);
)
}

export const ListItem = (item) => {
const { name, thumbnail, label1, label2, label3 } = item.item.values;
const { name, thumbnail, label1, label2, label3 } = item.item.values

return (
<XStack
Expand Down Expand Up @@ -67,8 +67,8 @@ export const ListItem = (item) => {
{/* <Icon /> */}
</YStack>
</XStack>
);
};
)
}

function Label({ text }) {
return (
Expand All @@ -86,7 +86,7 @@ function Label({ text }) {
{text}
</Text>
</XStack>
);
)
}

export const Tamagui = () => {
Expand All @@ -98,5 +98,5 @@ export const Tamagui = () => {
))}
</Provider>
</ScrollView>
);
};
)
}
21 changes: 10 additions & 11 deletions cases/simple-component/Tamagui.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { styled } from "tamagui";
import React from "react";
import { View } from "react-native";
import { COUNT } from "../../utils";
import { styled, View } from 'tamagui'
import React from 'react'
import { COUNT } from '../../utils'

const Box = styled(View, {
bc: "$yellow5Light",
p: "$2",
m: "$1",
});
bc: '$yellow5Light',
p: '$2',
m: '$1',
})

const Tamagui = () => {
return (
Expand All @@ -16,7 +15,7 @@ const Tamagui = () => {
<Box key={k} />
))}
</>
);
};
)
}

export default Tamagui;
export default Tamagui
22 changes: 7 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start-native": "GLUESTACK_STYLE_TARGET=native TAMAGUI_TARGET=native expo start -c",
"start-native-release-mode": "GLUESTACK_STYLE_TARGET=native TAMAGUI_TARGET=native expo start --no-dev --minify",
"start-native": "GLUESTACK_STYLE_TARGET=native TAMAGUI_OPTIMIZE_NATIVE_VIEWS=1 expo start -c",
"start-native-release-mode": "GLUESTACK_STYLE_TARGET=native TAMAGUI_OPTIMIZE_NATIVE_VIEWS=1 expo start --no-dev --minify",
"start-web": "GLUESTACK_STYLE_TARGET=web TAMAGUI_TARGET=web expo start -c",
"android": "GLUESTACK_STYLE_TARGET=native TAMAGUI_TARGET=native yarn expo run:android",
"ios": "GLUESTACK_STYLE_TARGET=native TAMAGUI_TARGET=native yarn expo run:ios",
"android": "GLUESTACK_STYLE_TARGET=native TAMAGUI_OPTIMIZE_NATIVE_VIEWS=1 yarn expo run:android",
"ios": "GLUESTACK_STYLE_TARGET=native TAMAGUI_OPTIMIZE_NATIVE_VIEWS=1 yarn expo run:ios",
"web": "GLUESTACK_STYLE_TARGET=web TAMAGUI_TARGET=web expo start --web"
},
"dependencies": {
Expand All @@ -20,15 +20,8 @@
"@react-navigation/native": "^6.1.7",
"@react-navigation/native-stack": "^6.9.13",
"@shopify/restyle": "2.4.2",
"@tamagui/animations-react-native": "1.47.3",
"@tamagui/config": "1.47.3",
"@tamagui/core": "^1.74.15",
"@tamagui/font-inter": "1.47.3",
"@tamagui/helpers": "^1.74.15",
"@tamagui/react-native-media-driver": "1.47.3",
"@tamagui/shorthands": "1.47.3",
"@tamagui/theme-base": "1.47.3",
"@tamagui/themes": "1.47.3",
"@tamagui/config": "1.74.21",
"tamagui": "1.74.21",
"@types/react": "18.2.17",
"babel-plugin-transform-inline-environment-variables": "0.4.4",
"dripsy": "4.3.3",
Expand All @@ -48,13 +41,12 @@
"react-native-web": "0.19.7",
"react-native-zephyr": "1.1.2",
"styled-components": "^6.0.7",
"tamagui": "^1.74.15",
"twrnc": "^3.6.3"
},
"devDependencies": {
"@babel/core": "7.22.9",
"@gluestack-style/babel-plugin-styled-resolver": "^0.2.6-alpha.0",
"@tamagui/babel-plugin": "1.47.3",
"@tamagui/babel-plugin": "1.74.21",
"@types/react-native": "0.72.2",
"react-native": "0.72.3",
"react-native-web": "0.19.7",
Expand Down
Loading