nandorojo / dripsy

🍷 Responsive, unstyled UI primitives for React Native + Web.
https://dripsy.xyz
MIT License
1.99k stars 77 forks source link

`sizes` not working properly on mobile native #191

Closed rafaelrinaldi closed 2 years ago

rafaelrinaldi commented 2 years ago

I am trying to use sizes to specify the height of a Pressable. It works fine on the browser, but I can't seem to make it work for mobile native other than inlining the value itself.

// theme.ts
export const theme = makeTheme({
  /* ... */
  sizes: {
    $0: 0,
    $1: 4,
    $2: 8,
    $3: 12,
    $4: 16,
    $5: 20,
    $6: 24,
    $7: 32,
    $8: 40,
  }
  /* ... */
})
// Button.tsx
const Button = ({ children, variant = 'primary' }) => (
    <Pressable
      sx={{
          variant: `buttons.${variant}`,
          justifyContent: 'center',
          backgroundColor: 'red',
          height: '$8'
       }}>
        {children}
</Pressable>
)

Browser output:

Untitled

iOS Simulator error:

Untitled

Am I doing something wrong?

nandorojo commented 2 years ago

yeah something is probably wrong here. can you try making sx a function of your theme and log it?

rafaelrinaldi commented 2 years ago

@nandorojo I am not sure I understand. Do you want me to share the whole theme definition?

nandorojo commented 2 years ago

Do this:

<Pressable
  sx={(theme) => {
    console.log(theme.sizes)

    return { height: theme.sizes.$8 }
  }}
/>

To make sure that the theme is getting picked up correctly.

nandorojo commented 2 years ago

any luck?