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

Add generic to ColorModifiers type #3636

Merged
merged 1 commit into from
Jan 16, 2022
Merged

Conversation

OrestHk
Copy link
Contributor

@OrestHk OrestHk commented Jan 16, 2022

Proposed Changes

  • Add generic to ColorModifiers type

ATM ColorModifiers type will always resolve to string because of | string.
This PR will allow to pass custom union to ColorModifiers when defining new colors in a project using buefy / bulma, which will make the type more strict and representative of the colors used in your project.
As the default type of the generic is string, it will not break existing configurations.

Usage

type ProjectColors = ColorModifiers<'is-very-danger' | 'is-secondary'>
// Will resolve to 'is-white' | 'is-black' | 'is-light' | 'is-dark' | 'is-primary' | 'is-info' | 'is-success' | 'is-warning' | 'is-danger' | 'is-very-danger' | 'is-secondary'

Not sure if it's the right way to go, or is it better to create a .d.ts file directly in your project and overwritting this type as needed ?

@jtommy jtommy merged commit e147d3e into buefy:dev Jan 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants