Closed fortezhuo closed 3 years ago
React Native doesn't use REM, only fixed numbers. That's why. You could use Dripsy's remToPixels function to wrap any usage of rem.
I have convert manually from rem to only fixed number.
sizes: {
"0": 0,
"1": 4,
"2": 8,
"3": 12,
"4": 16,
"5": 20,
"6": 24,
"8": 32,
"10": 40,
"12": 48,
"16": 64,
"20": 80,
"24": 96,
"32": 128,
"40": 160,
"48": 192,
"56": 224,
"64": 256,
px: 1,
xs: 320,
sm: 384,
md: 448,
lg: 512,
xl: 576,
"2xl": 672,
"3xl": 768,
"4xl": 896,
"5xl": 1024,
"6xl": 1152,
"1/2": "50%",
"1/3": "33.333333%",
"2/3": "66.666667%",
"1/4": "25%",
"2/4": "50%",
"3/4": "75%",
"1/5": "20%",
"2/5": "40%",
"3/5": "60%",
"4/5": "80%",
"1/6": "16.666667%",
"2/6": "33.333333%",
"3/6": "50%",
"4/6": "66.666667%",
"5/6": "83.333333%",
"1/12": "8.333333%",
"2/12": "16.666667%",
"3/12": "25%",
"4/12": "33.333333%",
"5/12": "41.666667%",
"6/12": "50%",
"7/12": "58.333333%",
"8/12": "66.666667%",
"9/12": "75%",
"10/12": "83.333333%",
"11/12": "91.666667%",
"full": "100%",
screenHeight: "100vh",
screenWidth: "100vw",
},
....
input: {
default: {
bg: "white",
flexDirection: "row",
borderColor: "gray.4",
borderWidth: "1",
width: "full",
height: "10",
borderRadius: "lg",
},
disabled: {
bg: "gray.5",
flexDirection: "row",
borderColor: "gray.4",
borderWidth: "1",
width: "full",
height: "10",
minHeight: "10",
borderRadius: "lg",
},
text: {
mx: "3",
flex: 1,
},
placeholder: {},
},
And it cause problem on web. I have create component with themeKey: input,and defaultVariant:"default", and the height on web will be rendered 160px
And how I make {width:"full"} or {borderRadius:"full"} works on react native ?
And how I make {width:"full"} or {borderRadius:"full"} works on react native ?
I think both of these should work out of the box. For borderRadius have you converted the "9999px"
of full to just the number 9999
?
@cmaycumber
Here part of theme.ts
radii: {
none: 0,
sm: 2,
default: 4,
md: 6,
lg: 8,
full: 9999,
},
...
view: {
avatar: {
alignSelf: "center",
borderRadius: "full",
p: "2",
},
},
And I create component
const RNAvatar = createThemedComponent(View, {
themeKey: "view",
defaultVariant: "avatar",
})
And an error occurs caused by borderRadius "full"
@fortezhuo The theme does look right to be. Is the root of the app wrapped with the DripsyProvider
with the theme being passed?
I'm currently using borderRadius: "full"
the same way you are in my application. I might be able to try to reproduce what you are doing with the avatar variant.
It's easier if you share an expo snack
Sorry.. I have tried to create the repo testing.. and it's working.. I will close this issue.. Thanks
I try to create theme from https://theme-ui.com/presets/tailwind and remove some themeKeys that can't be applied to React Native
While I compile to Web, it's working properly.. But while I tried to compile for iOS, an error occurs due to dripsy can't convert rem to px.
So I try to convert manually rem to px, and I still have found another error like below image