Skip to content
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

Type the size prop according to the available sizes #442

Closed
thunfisch987 opened this issue Jul 24, 2023 · 5 comments · Fixed by #692
Closed

Type the size prop according to the available sizes #442

thunfisch987 opened this issue Jul 24, 2023 · 5 comments · Fixed by #692
Labels
enhancement New feature or request

Comments

@thunfisch987
Copy link

thunfisch987 commented Jul 24, 2023

Is your feature request related to a problem? Please describe.

It's not a problem per se but it would be nice to get autocomplete on the size prop.

Describe the solution you'd like

type all size props to the available sizes:
size: "3xs" | "xs" | "md" | "lg" aaand so on

Describe alternatives you've considered

I don't know if the solution above works, because i don't know if you can set your own sizes (did not find anything in the docs).
In that case you'd probably have to read in the tailwind.config.ts 🤔

Additional context

@thunfisch987 thunfisch987 added the enhancement New feature or request label Jul 24, 2023
@thunfisch987
Copy link
Author

i'm willing to make a PR to set it for every component, but i don't know if the sizes are customizable

Copy link
Member

benjamincanac commented Jul 26, 2023

The size and all the other props depends on your app.config.ts:

However, you can override the app.config.ts entirely and make your own sizes.

Maybe it would work to type it with something like this?

  size: {
      type: String as PropType<typeof appConfig.ui.button.size>,
      default: () => appConfig.ui.button.default.size,
      validator (value: string) {
        return Object.keys(appConfig.ui.button.size).includes(value)
      }
    }

@thunfisch987
Copy link
Author

i wanted to test it out locally so i forked and cloned it, but couldn't test it / run it because i need the Token 🤔
am i doing something wrong?

Copy link
Member

You can run the docs and the playground in dev mode, you just can't generate the docs.

@ItMaga
Copy link

ItMaga commented Aug 2, 2023

I think if import appConfig from '#build/app.config' is typed, it should work, won't it?

  size: {
      type: String as PropType<keyof typeof appConfig.ui.button.size>,
      default: () => appConfig.ui.button.default.size,
      validator (value: string) {
        return Object.keys(appConfig.ui.button.size).includes(value)
      }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants