add more variations for a spectrum button web component in our component that extends the spectrum button #3108
-
We are trying to create a button web component extending the spectrum button. However we want 1 more button variant apart from the one provided by the api ie export declare type Button Variants = 'accent' | 'primary' | 'secondary' | 'negative' | Button Statics | DeprecatedButtonVariants; One easy way could be add another attribute for that type but we want to use the original api as is as far as possible. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Monkey patching that types would be pretty involved, I'm not sure it would be worth it. Doing this is JS would be relatively straight forward, but that's not likely a good idea for something that is broadly used. In specific, One path that's not "supported" and could run into issues across future releases would be to realize that In the end, all of the possibilities here take you out of expected consumption of the code that is surfaced. and will likely run afoul of supported APIs at some unannounced point in the future, so again, I'd say it wasn't worth the effort. |
Beta Was this translation helpful? Give feedback.
-
thanks @Westbrook for the prompt reply. Really appreciate it. |
Beta Was this translation helpful? Give feedback.
Monkey patching that types would be pretty involved, I'm not sure it would be worth it. Doing this is JS would be relatively straight forward, but that's not likely a good idea for something that is broadly used. In specific,
variant
holds a lot of logic while we continue to support deprecated variant, so beyond the basics of extending a type (which doesn't align to how class extension is meant to work), you'd need to reference back to thesuper
or slice off functionality to achieve this. Again, I'm not sure it would be worth it.One path that's not "supported" and could run into issues across future releases would be to realize that
Button
itself has very little code: https://github.com/…