Fixed #1027 - Knob: Allow a label function for greater flexibility #5569
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
Though #1027 is closed, I had a use case for more flexible labeling and decided to see if I could make this happen. My use case is that I am using the
Knob
component to show progress toward a goal; the data is kept in minutes, but the display should format it to show hours and minutes. There's no way to do that with a template string, so I hope that this PR gets accepted soon.Approach
To be honest, this PR isn't doing much that isn't already implemented in https://github.com/kramer99/vue-knob-control/blob/master/src/KnobControl.vue. I retained the ability to pass a template string for backward compatibility. I also specifically checked to make sure that reactivity still works when a function was passed, since that was the original reason to reject #1027.
I also added tests for both a string template and passing a function. Those tests pass, but it looks like
InputNumber
has a couple of failing tests (which were failing before I started work on this - I didn't want to delve into fixing those because it seemed irrelevant to this PR).I also modified the docs, though the doc structure is a bit confusing and there are no contributing docs or other instructions I could find, so I apologize in advance if I've missed something. Happy to make any changes needed or take any feedback.
Thank you for your hard work! I've been enjoying using PrimeVue to power my app TrackBear.