gluestack / gluestack-ui

React & React Native Components & Patterns (copy-paste components & patterns crafted with Tailwind CSS (NativeWind))
https://gluestack.io/
MIT License
2.36k stars 114 forks source link

Custom theme token types not registering #1302

Open milesingrams opened 11 months ago

milesingrams commented 11 months ago

Description

When changing theme tokens types stay with original theme

CodeSandbox/Snack link

No response

Steps to reproduce

  1. Eject config
  2. Change the tokens in the config to be something different than default
  tokens: {
     ...all other tokens,
    space: {
      '4xs': 2,
      '3xs': 4,
      '2xs': 6,
      xs: 8,
      sm: 12,
      md: 16,
      lg: 20,
      xl: 24,
      '2xl': 32,
      '3xl': 40,
    },
}
  1. Use the theme overrides described in docs/ejected theme
type Config = typeof gluestackUIConfig; // Assuming `config` is defined elsewhere

type Components = typeof componentsConfig;

export type { UIConfig, UIComponents } from '@gluestack-ui/themed';

export interface IConfig {}
export interface IComponents {}

declare module '@gluestack-ui/themed' {
  interface UIConfig extends Omit<Config, keyof IConfig>, IConfig {}
  interface UIComponents extends Omit<Components, keyof IComponents>, IComponents {}
}
  1. Pass the config to GluestackUIProvider

  2. Types will throw errors when you try to use new tokens in components. Seems to only recognize old tokens

Screen Shot 2023-10-17 at 11 47 02 PM Screen Shot 2023-10-17 at 11 47 42 PM

gluestack-ui Version

1.0.6

Platform

Other Platform

No response

Additional Information

No response

Viraj-10 commented 11 months ago

Hey @milesingrams, Thanks for reporting this issue. we will have a look. mean while can you please confirm if it is just typing that is not coming or tokens are not getting resolved as well.

milesingrams commented 11 months ago

The tokens still work as far as I can tell. I think the declare module '@gluestack-ui/themed' part isn't overriding the base types

milesingrams commented 11 months ago

So after looking into it more looks like overriding using declare module '@gluestack-style/react' works. Maybe the ejected config should use that instead of declare module '@gluestack-ui/themed'

milesingrams commented 11 months ago

I am still seeing a type issue with the ':transition' property which I believe might be unrelated but should be fixed:

Screen Shot 2023-10-18 at 11 35 00 AM

Looks like it expects opacity to be number type but in the context of the :transition property it has a different structure

milesingrams commented 11 months ago

Same with duration on the :transition prop

Screen Shot 2023-10-18 at 11 41 49 AM
Viraj-10 commented 11 months ago

Hey @milesingrams, Thanks for reporting this issue. We will have a look.

lhguerra commented 3 months ago

Was any progress made on this?